Saturday, August 6, 2011

[android-developers] Re: onDraw() causing "flicker" when drawing new images

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 <therevolti...@gmail.com> 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 <nikolatesl...@yahoo.com> 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 <jeffisagen...@gmail.com> 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 android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscribe@googlegroups.com
> > 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment