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.
On Mon, Oct 1, 2012 at 2:53 AM, Ajit Vasudevan <[email protected]> wrote: > 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 > > On Saturday, September 29, 2012 2:47:45 PM UTC-7, Romain Guy (Google) wrote: >> >> 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. >> >> On Thu, Sep 27, 2012 at 2:19 PM, Ajit Vasudevan <[email protected]> wrote: >> > 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 received this message because you are subscribed to the Google >> > Groups "Android Developers" group. >> > To post to this group, send email to [email protected] >> > To unsubscribe from this group, send email to >> > [email protected] >> > For more options, visit this group at >> > http://groups.google.com/group/android-developers?hl=en >> >> >> >> -- >> Romain Guy >> Android framework engineer >> [email protected] > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- Romain Guy Android framework engineer [email protected] -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

