Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android OpenGL是否有用于drawbitmap性能的屏幕外功能_Android_Performance_Opengl Es_Android Camera_Android Mediarecorder - Fatal编程技术网

Android OpenGL是否有用于drawbitmap性能的屏幕外功能

Android OpenGL是否有用于drawbitmap性能的屏幕外功能,android,performance,opengl-es,android-camera,android-mediarecorder,Android,Performance,Opengl Es,Android Camera,Android Mediarecorder,我有一个Android应用程序(targetSdkVersion 28),它将两个TextureView(每个视图显示一个摄像头视图)组合成一个位图,然后使用drawbitmap到mediarecorder表面进行录制。这是从OnSurfaceTextureUpdate调用的。在最后一段视频中,这似乎将其限制在每秒8到10帧左右 有人知道OpenGL是否能以更高效的帧速率实现这一点,或者下面的代码是否能更高效 我尝试过在函数之外创建位图和画布,虽然效果稍好,但组合的位图会闪烁 class thS

我有一个Android应用程序(targetSdkVersion 28),它将两个TextureView(每个视图显示一个摄像头视图)组合成一个位图,然后使用drawbitmap到mediarecorder表面进行录制。这是从OnSurfaceTextureUpdate调用的。在最后一段视频中,这似乎将其限制在每秒8到10帧左右

有人知道OpenGL是否能以更高效的帧速率实现这一点,或者下面的代码是否能更高效

我尝试过在函数之外创建位图和画布,虽然效果稍好,但组合的位图会闪烁

class thScreenShot extends AsyncTask{

    @Override
    protected Object doInBackground(Object... params) {

        try {

            List<TextureView> tilingViews = getAllTextureViews(rootLayout);
            if (tilingViews.size() > 0) {
                final Bitmap bitmap = Bitmap.createBitmap(DISPLAY_WIDTH, DISPLAY_HEIGHT, Bitmap.Config.RGB_565);
                final Canvas canvas = new Canvas(bitmap);
                for (TextureView tilingTextureView : tilingViews) {
                    Bitmap bitmap1 = tilingTextureView.getBitmap(tilingTextureView.getWidth(), tilingTextureView.getHeight());
                    int[] location = new int[2];
                    tilingTextureView.getLocationInWindow(location);
                    Rect dest = new Rect(location[0], location[1], bitmap.getWidth(), bitmap.getHeight());
                    canvas.drawBitmap(bitmap1, dest, dest, null);
                }
                if (isRecording) {
                     if (surfaceS == null)
                     {
                          surfaceS = mMediaRecorder.getSurface();
                     }
                     synchronized (surfaceS) {
                          canvasS = surfaceS.lockHardwareCanvas();
                          canvasS.drawBitmap(bitmap, 0, 0, null);
                          surfaceS.unlockCanvasAndPost(canvasS);
                          FPSCount++;
                     }
                }
            }
            return null;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
}

public List<TextureView> getAllTextureViews(View view)
{
    List<TextureView> tilingViews = new ArrayList<TextureView>();
    if (view instanceof TextureView) {
        tilingViews.add((TextureView)view);
    }
    else if(view instanceof ViewGroup)
    {
        ViewGroup viewGroup = (ViewGroup)view;
        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            tilingViews.addAll(getAllTextureViews(viewGroup.getChildAt(i)));
        }
    }
    return tilingViews;
}
class-thScreenShot扩展异步任务{
@凌驾
受保护对象doInBackground(对象…参数){
试一试{
列表平铺视图=getAllTextureViews(rootLayout);
如果(平铺视图.size()>0){
最终位图=Bitmap.createBitmap(显示宽度、显示高度、Bitmap.Config.RGB_565);
最终画布=新画布(位图);
用于(纹理视图平铺纹理视图:平铺视图){
位图bitmap1=tilingTextureView.getBitmap(tilingTextureView.getWidth(),tilingTextureView.getHeight());
int[]位置=新int[2];
tilingTextureView.getLocationInWindow(位置);
Rect dest=new Rect(位置[0],位置[1],bitmap.getWidth(),bitmap.getHeight());
drawBitmap(位图1,dest,dest,null);
}
如果(isRecording){
如果(曲面==null)
{
surfaceS=mMediaRecorder.getSurface();
}
同步(曲面){
canvasS=surfaceS.lockHardwareCanvas();
drawBitmap(位图,0,0,null);
表面。解锁canvasandpost(canvas);
fpscont++;
}
}
}
返回null;
}
捕获(例外情况除外)
{
返回null;
}
}
}
公共列表getAllTextureViews(视图)
{
列表平铺视图=新建ArrayList();
如果(查看TextureView的实例){
添加((TextureView)视图);
}
else if(视图组的视图实例)
{
ViewGroup ViewGroup=(ViewGroup)视图;
对于(int i=0;i
我不确定您是否需要UI渲染到纹理或普通渲染到纹理,可能是其中之一。例如,您可以检查和


还记得经常检查

谢谢。我会查清楚的。干杯