Android TextureView画布绘图问题

时间:2012-10-02 10:13:09

标签: android 2d surfaceview

我有一个使用SurfaceView绘制动态2D图形的应用程序。它工作正常,但我们知道的转换等不受支持。所以我去了TextureView。我的旧代码使用另一个类/线程通过Surfaceholder.lockCanvas()进行绘图;所以我把它改成了TextureView.lockcanvas。当这运行时,未加速的画布(视图是)最初不会显示,但如果我触摸屏幕onSurfaceTextureUpdated(当前没有内部代码)被调用并显示???

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();
        }
    }

}

我在TextureView中实现了SurfaceTextureListener,并且所有的程序流似乎很好,真正的表面被传递到绘图线程

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

}

此void以上面的RenderCanvas()结束。

除非我再次触摸屏幕,否则重绘或使视图无效也不起作用。

我不能像这样使用TextureView吗?

是否必须是openGl内容流?

0 个答案:

没有答案