SurfaceView或TextureView组合 [英] SurfaceView or TextureView combination

查看:546
本文介绍了SurfaceView或TextureView组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图应用实时效果在多个视图相机preVIEW和表演,我该怎么办?结果
(就像摄像机2 )(<一href=\"https://lh4.ggpht.com/2RVnMZoCuY9NUdRcPkXGx9mt0TgMOps_f1fdCaGPoDzloPXyTTF7HkqfBTgnGJEqOII=h310-rw\"相对=nofollow>快照)

I am trying to apply real-time effects to camera preview and show in multiple views, how can I do?
(just like the camera2) (snapshot)

我知道2的方法来显示在相机preivew实时效果,如果不涉及左侧滚动型。

I know 2 approaches to show real-time effects on camera preivew if no ScrollView involved on the left side.


  • 使用 GLSurfaceView 和<一个href=\"http://developer.android.com/reference/android/opengl/GLSurfaceView.html#setRenderer(android.opengl.GLSurfaceView.Renderer)\"相对=nofollow> setRenderer 。绑定的表面纹理外部GLES质感,并使用GLSL(OpenGL着色语言)应用效果。

  • 使用<一个href=\"http://web.mit.edu/majapw/MacData/afs/sipb/project/android/docs/reference/android/view/TextureView.html\"相对=nofollow> TextureView 。因为需要设置EGLContext / EGLSurface并做线程管理是比较复杂的。

  • Use GLSurfaceView and setRenderer. Bind SurfaceTexture as GLES external texture, and use GLSL(OpenGL Shading Language) to apply effects.
  • Use TextureView. It is more complex because need to setup EGLContext/EGLSurface and do thread management.

不过,我不知道如何使滚动型的实时效果覆盖项目组成GLES。

However, I don't know how to make ScrollView with real-time effect items overlay GLES composition.


  1. 我应该选择GLSurfaceView(性能)或TextureView(对于装置的柔性)来实现滚动型?哪一个是更好的解决方案,为什么?

  2. 是否可以共享多个视图中的一个东瀛背景/面?如果有,任何code段是指?

  1. Should I choose GLSurfaceView (for performance) or TextureView (for flexble) to implement the ScrollView? Which one is better solution and why?
  2. Is it possible to share one EGL context/surface among multiple views? If yes, any code snippets to refer to?

谷歌搜索和阅读漂亮图形架构文章和的 Grafika 项目,我仍然不知道......结果
也许我错过了什么重要的,剂量有人点我吗?先谢谢了。

After googling and reading nice Graphics architecture article and Grafika project, I still have no idea ...
Maybe I miss something important, dose someone point me out? Thanks in advance.

推荐答案

SurfaceView和滚动不顺利在一起,因为SurfaceView有两部分 - 产品表面和视图 - 和一个运动往往要落后其它的运动。视图是由应用程序呈现,但表面被SurfaceFlinger的合成,使窗口移动已获得通过窗口管理器通过。 TextureView不存在这个问题,但并引入一些额外的开销。

SurfaceView and scrolling don't go well together, because the SurfaceView has two parts -- the Surface and the View -- and movement of one tends to lag behind movement of the other. The View is rendered by the app, but the Surface is composited by SurfaceFlinger, so window movement has to get passed through the Window Manager. TextureView doesn't have this problem, but does introduce some additional overhead.

如果您希望它看起来滚动时好时,你可能会想一个TextureView。

If you want it to look good when scrolling, you'll probably want a TextureView.

有可能为多个EGL上下文共享数据,并且可以使用单一的EGL上下文来呈现多于一个表面上。 Grafika 既有的例子(显示+相机捕捉使用GLSurfaceView和共用EGL的背景下,连续拍摄使用SurfaceView和一个单一的EGL上下文;两种活性渲染到屏幕上的表面和一个离屏面)

It is possible for multiple EGL contexts to share data, and it is possible to use a single EGL context to render to more than one surface. Grafika has examples of both ("show + capture camera" uses GLSurfaceView and a shared EGL context, "continuous capture" uses SurfaceView and a single EGL context; both activities render to an on-screen surface and an off-screen surface).

所有硬件加速的浏览做好自己的EGL上下文管理,如果你正在渲染到SurfaceView或TextureView没有理由与那些乱七八糟。

All hardware-accelerated Views do their own EGL context management, and there's no reason to mess with that if you're rendering onto SurfaceView or TextureView.

如果你打算绘制实时直播相机preVIEW的多个版本,你会被渲染他们自己都在一个场景获得最佳的性能。渲染多个TextureViews效率会降低。根据您的UI选择,这可能意味着处理项目图纸和滚动你自己,而不是交给它关闭的ListView。 (最起码,你要确保你只活更新,实际上是在屏幕上的缩略图。)

If you're planning to draw multiple versions of the live camera preview in real time, you'll get the best performance by rendering them all yourself in a single scene. Rendering multiple TextureViews will be less efficient. Depending on your UI choices, this might mean handling the item drawing and scrolling yourself instead of handing it off to ListView. (At the very least, you'd want to ensure that you're only live-updating the thumbnails that are actually on screen.)

这篇关于SurfaceView或TextureView组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆