Hi All:

I have tried this sample, it works great. But when I change 
lockCanvas(null) into lockCanvas(new Rect(x, y, x+20, y+20)), the example 
starts to flicker. 
It seems 'lockCanvas(Rect)' can not work well for TextureView or any other 
reasons?

I am using Motorola XOOM with android 4.0.3. 
Thanks for any help! 

在 2012年10月4日星期四UTC+8上午6时06分00秒,Romain Guy (Google)写道:
>
> Here is a fully working example of Canvas & TextureView: 
>
> http://pastebin.com/J4uDgrZ8 
>
> On Wed, Oct 3, 2012 at 3:01 PM, Romain Guy <[email protected]<javascript:>> 
> wrote: 
> > The problem is that you are calling updateTexImage() yourself. Do 
> > *not* do this. You are interfering with TextureView, preventing it 
> > from receiving the events that it uses to refresh the screen. 
> > 
> > On Tue, Oct 2, 2012 at 7:40 AM, Conrad Chapman 
> > <[email protected]<javascript:>> 
> wrote: 
> >> Also asked in StackOverflow here 
> >> 
> http://stackoverflow.com/questions/12688409/android-textureview-canvas-drawing-problems
>  
> >> 
> >> I have an app that used SurfaceView to draw dynamic 2D graphs. It 
> worked ok 
> >> but transormations etc as we know are not supported. So I went to 
> >> TextureView. My old code used another class/thread to do the drawing 
> via the 
> >> Surfaceholder.lockCanvas(); So I changed this to 
> TextureView.lockcanvas. 
> >> When this runs the canvas is not accelerated (the view is). It does not 
> >> display initially but if I touch the screen it displays??? The touch is 
> >> handled by the main activity. 
> >> 
> >> Obviously it works as it will display eventually but why doesn't it 
> display 
> >> immediately? 
> >> 
> >> The TextureView class implements SurfaceTextureListener as such below. 
> >> @Override 
> >> public void onSurfaceTextureAvailable(SurfaceTexture surface, int 
> width, 
> >> int height) { 
> >> // TODO Auto-generated method stub 
> >> isRunning = true; 
> >> mySurface = surface; 
> >> mChart.setTextureSurface(surface); 
> >> mChart.setSurfaceSize(width, height); 
> >> mPaint.setColor(ZOOM_BUTTONS_COLOR); 
> >> //mySurface.setOnFrameAvailableListener(frameready); 
> >> mChart.Redraw(true); 
> >> } 
> >> @Override 
> >> public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { 
> >> // TODO Auto-generated method stub 
> >> isRunning = false; 
> >> return false; 
> >> } 
> >> this block below also workswhen manipluating the view later on (pan and 
> >> zoom) 
> >>   public void Render(Bitmap buffmap){ 
> >> //mCanvas = null; 
> >>  post(new Runnable() { 
> >> public void run() { 
> >> invalidate(); 
> >> mySurface.updateTexImage(); 
> >> } 
> >> }); 
> >> 
> >> 
> >> The drawing from the worker thread/class is 
> >> protected void RenderCanvas(){ 
> >> //mCanvas = null; 
> >> Canvas c = null; 
> >> //synchronized (mCanvas) { 
> >> //mCanvas = null; 
> >> try { 
> >> c = mChartView.lockCanvas(null); 
> >> 
> >> synchronized (mCanvas) { 
> >> c.drawBitmap(buffBitmap, 0, 0, null); 
> >> 
> >> } 
> >> } finally { 
> >> if (c != null) { 
> >> mChartView.unlockCanvasAndPost(c); 
> >> } 
> >> } 
> >> mChartView.Render(null); 
> >> } 
> >> 
> >> Can I work like this? Non-GL content in a TextureView? 
> >> Please help desperate for an answer. 
> >> 
> >> -- 
> >> 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]<javascript:> 
> >> To unsubscribe from this group, send email to 
> >> [email protected] <javascript:> 
> >> For more options, visit this group at 
> >> http://groups.google.com/group/android-developers?hl=en 
> > 
> > 
> > 
> > -- 
> > Romain Guy 
> > Android framework engineer 
> > [email protected] <javascript:> 
>
>
>
> -- 
> Romain Guy 
> Android framework engineer 
> [email protected] <javascript:> 
>

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