美文网首页
阅读 GlSurfaceView 源码 对 eglCreateW

阅读 GlSurfaceView 源码 对 eglCreateW

作者: xx_G | 来源:发表于2019-01-31 17:05 被阅读0次
Issue:为什么 GlSurfaceView 在 eglCreateWindowSurface() 时, 对于 Object 类型参数 native_window 直接传入 SurfaceHolder 对象?

其实通过观察EGL14的源码, 不难发现 Google 其实只需要SurfaceHolder里的Surface对象, 那又是为什么呢?

Surface 的源码注解是这么说的 Handle onto a raw buffer that is being managed by the screen compositor.(大意: 是屏幕管理器的句柄)

那么这个时候,我们就需要到 Khronos 官网 看一下EGL eglCreateWindowSurface()的方法说明(Android api 没做过多说明,too bad !!)

method: EGLSurface  eglCreateWindowSurface() ---> 说明:create a new EGL window 
param : Object  native_window ---> 说明:Specifies the native window.(指定本地窗口)

<而 EGLSurface 是屏幕画布的抽象>

所以native_window这个参数,我更愿意将它理解成 将屏幕画布EGLSurface的句柄赋值到native_window这个参数对象上,那赋值到参数对象上有什么用?
就可以直接在 Java层 使用Surface对象对屏幕进行操作了,只是GLSurfaceView一般通过 SurfaceHolder来处理

相关文章

网友评论

      本文标题:阅读 GlSurfaceView 源码 对 eglCreateW

      本文链接:https://www.haomeiwen.com/subject/msqlsqtx.html