Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
TextureView & Canvas
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ajit Vasudevan  
View profile  
 More options Sep 27 2012, 5:19 pm
From: Ajit Vasudevan <vasu.a...@gmail.com>
Date: Thu, 27 Sep 2012 14:19:10 -0700 (PDT)
Local: Thurs, Sep 27 2012 5:19 pm
Subject: TextureView & Canvas

Hello,

I am currently working on an app that requires computations/rendering based
on a variety of user inputs. I have implemented the SurfaceView and things
work as expected.
But I started facing performance issues when I tried to put this inside a
horizontal scroll view. Obviously it is not intended to work this way - but
I tried anyway :)
Based on what I have read - it appears like I have to move to TextureView.
But i am unable to override the onDraw, and therefore cannot perform the
necessary drawing using the Canvas. This might be a trivial question - but
I wanted to know if we can use TextureView to draw primitives on the screen
using a Canvas? The only examples I have seen thus far show the use of
video/camera/openGL rendering on the TextureView.

Any help on this would be great.

Thanks much
-Ajit


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Romain Guy  
View profile  
 More options Sep 29 2012, 5:47 pm
From: Romain Guy <romain...@android.com>
Date: Sat, 29 Sep 2012 14:44:53 -0700
Local: Sat, Sep 29 2012 5:44 pm
Subject: Re: [android-developers] TextureView & Canvas
Hi,

If you were using SurfaceView's onDraw() method then you were not
getting any benefit. You have to use
lockCanvas()/unlockCanvasAndPost() and post on the underlying Surface.
TextureView works in a similar way: you can call
lockCanvas()/unlockCanvasAndPost().

However, it seems all you need is a View. It's easier to use and since
you are not using SurfaceView properly anyway it will do the same
thing.

--
Romain Guy
Android framework engineer
romain...@android.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ajit Vasudevan  
View profile  
 More options Oct 1 2012, 5:53 am
From: Ajit Vasudevan <vasu.a...@gmail.com>
Date: Mon, 1 Oct 2012 02:53:22 -0700 (PDT)
Local: Mon, Oct 1 2012 5:53 am
Subject: Re: [android-developers] TextureView & Canvas

Hi Romain,

Thanks for your response.

I was experiencing a very interesting behavior. I started using a custom
view inside a framelayout, and performed all the primitive operations and
called invalidate() to let the system call onDraw. It was choking. I even
tried to invalidate a rect, but it was just not fast enough - the 2nd view
that was requesting the underlying view to redraw certain primitives based
on the actions on the 2nd view was not responsive. I then started using the
SurfaceView to see if there is any benefit for the same operation - and
voila - it worked like a charm. This is why is used SurfaceView as a
substitute - there was an apparent performance benefit.

 That said, I'm going to take another look at my hierarchy, and all the
custom views (there are quite a few), to make sure there are no other
leaks. Like you said, I would rather use a View instead of SurfaceView.  
Thanks for your input though - it does answer the question that I can use a
canvas with TextureView if i follow the intended mode of use.

-Ajit


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Romain Guy  
View profile  
 More options Oct 1 2012, 12:17 pm
From: Romain Guy <romain...@android.com>
Date: Mon, 1 Oct 2012 09:14:38 -0700
Local: Mon, Oct 1 2012 12:14 pm
Subject: Re: [android-developers] TextureView & Canvas
There is an overhead associated to invalidate() but unless your
hierarchy is extremely complicated it shouldn't be such an issue. But
you're right: SurfaceView can be used to avoid calling invalidate()
but don't override it's onDraw() method. You usually create a new
thread that renders onto the surface.

--
Romain Guy
Android framework engineer
romain...@android.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Conrad Chapman  
View profile  
 More options Oct 3 2012, 5:34 am
From: Conrad Chapman <chapman.con...@gmail.com>
Date: Wed, 3 Oct 2012 02:34:58 -0700 (PDT)
Local: Wed, Oct 3 2012 5:34 am
Subject: Re: [android-developers] TextureView & Canvas

I have a similar problem but I was using SurfaceView properly as you
mention Romain Guy but changing my code over does not work. The problem and
code was posted here
http://stackoverflow.com/questions/12688409/android-textureview-canva...
The unlockandpostcanvas method does nothing. neither does
TextureView.invalidate or surface.updateTexImage(). Only tapping the screen
gets it to display??
Any ideas?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Conrad Chapman  
View profile  
 More options Oct 4 2012, 11:25 am
From: Conrad Chapman <chapman.con...@gmail.com>
Date: Thu, 4 Oct 2012 08:25:01 -0700 (PDT)
Local: Thurs, Oct 4 2012 11:25 am
Subject: Re: [android-developers] TextureView & Canvas

As it happens our friend Romain Guy did have some ideas
https://groups.google.com/forum/?fromgroups=#!topic/android-developer...

thank you


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ajit Vasudevan  
View profile  
 More options Oct 5 2012, 3:50 am
From: Ajit Vasudevan <vasu.a...@gmail.com>
Date: Fri, 5 Oct 2012 00:50:13 -0700 (PDT)
Local: Fri, Oct 5 2012 3:50 am
Subject: Re: [android-developers] TextureView & Canvas

awesome. Thanks Conrad & Romain.

@Romain : I fixed a rather expensive draw operation on the canvas in one of
my views (a custom listview actually - was performing a few primitive draws
in the onDraw method). I managed to define a Rect area to limit the bounds.
It opens up another question - but I will post it in a separate thread
because its not related to TextureView.  FYI - Once i fixed this , a simple
view (with invalidate() calls) worked like a charm - atleast thus far. I
will gauge the performance and see if introducing more drawing operations
causes it to choke.

Thanks
-Ajit


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions Older topic »