Problems drawing an Android TextureView canvas

I have an application that used SurfaceView to draw dynamic 2D graphics. It worked fine, but conversions, etc., as we know, are not supported. So I went to TextureView. My old code used a different class / thread to draw using Surfaceholder.lockCanvas (); So I changed this to TextureView.lockcanvas. When this is done, the canvas, not accelerated (view), is not displayed at first, but if I touch the onSurfaceTextureUpdated screen (currently without the code inside), it is called and displayed

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 a SurfaceTextureListener in my TextureView, and the whole program stream seems fine, the real surface is passed to the build stream

 @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 ends with the RenderCanvas () above.

Repeatedly changing or canceling the view also does not work unless I touch the screen again.

Can't I use a TextureView like this?

Should there be an openGl content stream?

+4
source share

Source: https://habr.com/ru/post/1437358/


All Articles