I have an app that used SurfaceView to draw dynamic 2D graphs. It worked ok 
but transformations 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 not accelerated (the view 
is) does not display initially but if I touch the 
screen onSurfaceTextureUpdated (currently with no code inside) is called 
and it displays???

protected void RenderCanvas(){
    //mCanvas = null;
    Canvas c = null;
    //synchronized (mCanvas) {
        //mCanvas = null;
        try {
            c = mChartView.lockCanvas(null);
             if (!c.isHardwareAccelerated()) {
                   Log.w("GVIEW", "A TextureView or a subclass can only be "
                             + "used with hardware acceleration enabled.");
               }
            synchronized (mCanvas) {
                c.drawBitmap(buffBitmap, 0, 0, null);

            }
        } finally {
            // do this in a finally so that if an exception is thrown
            // during the above, we don't leave the Surface in an
            // inconsistent state
            if (c != null) {
                mChartView.unlockCanvasAndPost(c);
                //mSurfaceHolder.updateTexImage();
            }
        }
}

I implement the SurfaceTextureListener within my TextureView and all of the 
program flow seems fine a real surface is handed to the plotting thread by

@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);

mChart.Redraw(true) 

}

This void finishes with the RenderCanvas() above.

Redrawing the view also doesn't work unless i again touch the screen.

Cannot I not use TextureView like this? 

Does it have to be openGl content stream?

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