Texture and Surface

Texture
SurfaceTextureClient( ANativeWindow) .... SurfaceTexture...Server
1. SurfaceTexture Server and SurfaceTextureClient
Server, render the data ; client provide the data; they share a buffer.
client:surface
server:  ISurfaceTexture<-BnSurfaceTexture<-SurfaceTexture
ISurfaceTexture<-BnSurfaceTexture<-SurfaceTexture
ISurfaceTexture<-BpSurfaceTexture
(a surface must has a surfaceTexture)
2. SurfaceTextureClient member
a.sp< ISurfaceTexture> mSurfaceTexture, pointer to the server.  all call the server will use it as proxy.
b.sp< GraphicBuffer> mSlots[NUM_BUFFER_SLOTS]; //the buffer shared between client and server
server provider buffer, client get the pointer( maybe null, should request first) and fill it, server the use it to render.
3. SurfaceTextureClient function ()
SurfaceTextureClient::dequeueBuffer(android_native_buffer_t** buffer)
//client empty a buffer put to the parameter, also  get a new buffer id from server.  also request the buffer of the id if necessary.
4. SurfaceTexture's function
connect //it will be called from the client.
disconnect
queueBuffer
dequeueBuffer //dequeueBuffer gets the next buffer slot index for the client to use
requestBuffer // 
5. SurfaceTexture's membership

6. SurfaceTexture,  an implementation of SurfaceTexture.
connect //it can connect to many api. 
queueBuffer// in queueBufffer, "listener->onFrameAvailable()" will be called.
7.Surface , an implementation of  SurfaceTextureClient



Surface.java
<--->android_view_Surface.cpp
surface is a SurfaceTextureClient
1. construction
a.null 
b.SurfaceTexture Surface(SurfaceTexture surfaceTexture)
    image drawn to the surface may be  available to the SurfaceTexture, which can attach them to the OpenGL ES via  SurfaceTexture's updateTexImage.
    surfaceTexture, the surfaceTexture that is  updated by the surface.
c.Parcel 
d.SurfaceSession

2. Member
 private Canvas mCanvas;
int mSurfaceControl; //The mSurfaceControl will only be present for Surfaces used by the window server.?  the c's SurfaceControl pointer.

3. Function
void freezeDisplay(int display)
void unfreezeDisplay(int display)
Canvas lockCanvas(Rect dirty);//lock the rect, return the canvas to draw.
unlockCanvas(Canvas canvas); //unlock the canvas, but don't update
unlockCanvasAndPost(Canvas canvas); //unlock the canvas and update

 SurfaceView
1.SurfaceView.getHolder().getSurface() will return the surface.
2.SurfaceView's membership
a. Surface mSurface;
b.WindowManager.LayoutParams mLayout;
c.IWindowSession mSession;
d.MyWindow mWindow;
e.Rect mSurfaceFrame;
f.ReentrantLock mSurfaceLock;
g.SurfaceHolder mSurfaceHolder;surfaceCreated(mSurfaceHolder),surfaceChanged(mSurfaceHolder, mFormat, myWidth, myHeight),surfaceRedrawNeeded
all above will  be called in "updateWindow."



GLSurfaceView
1.A GLSurfaceView provides the following features:
a.Manages a surface,which is a special piece of memory that can be composited into the Android view system.
b.Manages an EGL display, which enables OpenGL to render into a surface.
c.Accepts a user-provided Renderer object that does the actual rendering.
d.Renders on a dedicated thread to decouple rendering performance from the UI thread.
e.Supports both on-demand and continuous rendering.

a.unlike a regular View, drawing is delegated to a separate Renderer object.
2.membership in GLSurfaceView
GLThread mGLThread; the render thread.
Renderer mRenderer; the render.
3.function in GLSurfaceView

flash to surfacetexture(java)
1.
flashwirtedata->SurfaceTextureClient.queueBuffer->SurfaceTexture.queueBuffer->listener.onFrameAvailable
for java: JNISurfaceTextureContext.onFrameAvailable->SurfaceTexture.java.postEventFromNative->mOnFrameAvailableListener.onFrameAvailable
for cpp: MediaListener.onFrameAvailable->View.postInvalid&FramerateCallbackProc
->handle to flash? (maybe WebView.drawGL)
->GLWebViewState.drawGL->BaseLayerAndroid.drawGL()
2.
how to use gl
a. generate a textureID.
b. generate a SurfaceTexture with the id
c.  generate a Surface with the SurfaceTexture



cpp
1.Surface.cpp
2.SurfaceTextureClient 
SurfaceTextureClient::queueBuffer(android_native_buffer_t* buffer) {mSurfaceTexture->queueBuffer}// get buffer from self and  put into server's buffer
SurfaceTextureClient::dequeueBuffer(android_native_buffer_t** buffer)// get the dequeue buffer id, 
3. 
SurfaceTextureClient:the class who has data to draw. The server must own a pointer of the client.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值