The logic for onDraw in any given View should be to draw the entire
view every time it's called by the view hierarchy.

Are you calling invalidate with a dirty region on your view to
indicate only which portions of the view have changed from moment to
moment?  That should speed up rendering because Android will try to
optimize away any part of the drawing that lies outside the dirty
rect.  If you're allowing every pixel in view to update on every call
to onDraw, well, that can be expensive.

Doug

On Aug 6, 3:59 pm, Jeffrey <[email protected]> wrote:
> The problem isn't tearing, as the images shouldn't be drawn there yet
> anyway. I don't have my position calculations in a separate thread,
> should I? I have tried locking the array (though because of my limited
> knowledge I've gone about it probably the wrong way, by basically
> having a boolean that tells the draw cycle whether to read the data or
> not) but that didn't work, probably because of the poor quality of my
> attempt. I don't know too much about syncing threads and all that so
> I've been unable to figure this out on my own.
>
> On Aug 6, 12:19 pm, Miguel Morales <[email protected]> wrote:
>
>
>
>
>
>
>
> > Perhaps you can try adding a synchronized lock that protects your data 
> > array.
> > Lock it before going into onDraw() and unlock it when finished, and do
> > the same when calculating your array data.
> > Do you have a separate thread that calculates positions?
>
> > On Fri, Aug 5, 2011 at 6:23 PM, niko20 <[email protected]> wrote:
> > > Hm sounds like a refresh rate issue, with Surface view you probably
> > > can't sync to vertical refresh, so you get "tearing", where you see
> > > halfway animations for a second as the video buffer changes over to
> > > the next frame.
>
> > > -niko
>
> > > On Aug 5, 1:56 pm, Jeffrey <[email protected]> wrote:
> > >> I'm having an issue with drawing on my surface view. At one point I
> > >> was just replacing images with new ones in a grid, but the images
> > >> didn't all draw at the same time. I think that that may have had
> > >> something to do with modifying the array that it was using to
> > >> determine what to draw but I couldn't get it resolved even when
> > >> pausing the drawing. Now I have images that drop down and new ones
> > >> fall in (think slot machine reels) but the images will occasionally
> > >> flicker with what the new image is going to be before the old images
> > >> fall out.
>
> > >> Basically I guess I'm asking what is a good way to either pause the
> > >> onDraw command while I can edit my arrays and get them all in place or
> > >> what is a good way to sync my array modifications to not take place
> > >> during an onDraw cycle? Or is onDraw just bad at drawing images
> > >> simultaneously and I should be using OpenGL or something?
>
> > > --
> > > 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
>
> > --
> > ~ Jeremiah:9:23-24
> > Android 2D MMORPG:http://solrpg.com/, http://www.youtube.com/user/revoltingx

-- 
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

Reply via email to