In Thread "SurfaceFlinger" of android 4.3
01-02 00:00:42.549: D/zzgratest(275): #00  pc 00029924  /system/lib/libsurfaceflinger.so (android::FramebufferSurface::onFrameAvailable()+23)
01-02 00:00:42.549: D/zzgratest(275): #01  pc 0001f1c4  /system/lib/libgui.so (android::BufferQueue::ProxyConsumerListener::onFrameAvailable()+15)
01-02 00:00:42.549: D/zzgratest(275): #02  pc 0001f0bc  /system/lib/libgui.so (android::BufferQueue::queueBuffer(int, android::IGraphicBufferProducer::QueueBufferInput const&, android::IGraphicBufferProducer::QueueBufferOutput*)+851)
01-02 00:00:42.549: D/zzgratest(275): #03  pc 000277dc  /system/lib/libgui.so (android::Surface::queueBuffer(ANativeWindowBuffer*, int)+223)
01-02 00:00:42.549: D/zzgratest(275): #04  pc 0002644a  /system/lib/libgui.so (android::Surface::hook_queueBuffer(ANativeWindow*, ANativeWindowBuffer*, int)+7)
01-02 00:00:42.549: D/zzgratest(275): #05  pc 00003478  /system/vendor/lib/egl/eglsubAndroid.so (SwapBuffers+312)
01-02 00:00:42.549: D/zzgratest(275): #06  pc 00012b0c  /system/vendor/lib/egl/libEGL_adreno.so (qeglDrvAPI_eglSwapBuffers+1544)
01-02 00:00:42.549: D/zzgratest(275): #07  pc 00006c20  /system/vendor/lib/egl/libEGL_adreno.so (eglSwapBuffers+16)
01-02 00:00:42.549: D/zzgratest(275): #08  pc 0000fb1a  /system/lib/libEGL.so (eglSwapBuffers+277)
01-02 00:00:42.549: D/zzgratest(275): #09  pc 0001d8c4  /system/lib/libsurfaceflinger.so (android::DisplayDevice::swapBuffers(android::HWComposer&) const+131)
01-02 00:00:42.549: D/zzgratest(275): #10  pc 0002334e  /system/lib/libsurfaceflinger.so (android::SurfaceFlinger::doDisplayComposition(android::sp const&, android::Region const&)+121)
01-02 00:00:42.549: D/zzgratest(275): #11  pc 00025884  /system/lib/libsurfaceflinger.so (android::SurfaceFlinger::doComposition()+95)
01-02 00:00:42.549: D/zzgratest(275): #12  pc 00025ae0  /system/lib/libsurfaceflinger.so (android::SurfaceFlinger::handleMessageRefresh()+47)
01-02 00:00:42.549: D/zzgratest(275): #13  pc 00026874  /system/lib/libsurfaceflinger.so (android::SurfaceFlinger::onMessageReceived(int)+63)
01-02 00:00:42.549: D/zzgratest(275): #14  pc 000150ea  /system/lib/libutils.so (android::Looper::pollInner(int)+381)
01-02 00:00:42.549: D/zzgratest(275): #15  pc 000151ec  /system/lib/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+91)
01-02 00:00:42.549: D/zzgratest(275): #16  pc 00021cd8  /system/lib/libsurfaceflinger.so (android::MessageQueue::waitMessage()+35)
01-02 00:00:42.549: D/zzgratest(275): #17  pc 00022a68  /system/lib/libsurfaceflinger.so (android::SurfaceFlinger::threadLoop()+1)
01-02 00:00:42.549: D/zzgratest(275): #18  pc 00011a8a  /system/lib/libutils.so (android::Thread::_threadLoop(void*)+213)
01-02 00:00:42.549: D/zzgratest(275): #19  pc 0001157e  /system/lib/libutils.so
01-02 00:00:42.549: D/zzgratest(275): #20  pc 0000cba0  /system/lib/libc.so (__thread_entry+72)
01-02 00:00:42.549: D/zzgratest(275): #21  pc 0000cd1c  /system/lib/libc.so (pthread_create+208)

SurfaceFlinger::doComposition()
-->doDisplayComposition()
//DisplayDevicce::PARTIAL_UPDATES NOTE
-->-->doComposeSurface()
-->-->-->HWComposer::hasGlesComposition()
//by check disp.hasFbComp
-->-->-->-->LayerBase::draw()
-->-->-->-->-->Layer::onDraw()
-->-->-->-->-->-->drawWithOpenGL()
-->-->-->HWComposer::hasHwcComposition()
//by check disp.hasOvComp

-->-->DisplayDevice->swapBuffers(getHwComposer()) // ** in doDisplayComposition
-->-->-->eglSwapBuffers()@libEGL.so  // ** Swap buffers in EGLSurface, holding BufferQueue(USAGE_HW_FB) with consumer FrameBufferSurface. 
-->-->-->-->eglSwapBuffers()@libEGL_adreno.so
-->-->-->-->-->qeglDrvAPI_eglSwapBuffers()@libEGL_adreno.so
-->-->-->-->-->-->SwapBuffers()@eglsubAndroid.so
-->-->-->-->-->-->-->Surface::hook_queueBuffer()
-->-->-->-->-->-->-->-->Surface::queueBuffer()
-->-->-->-->-->-->-->-->-->BufferQueue::queueBuffer()
-->-->-->-->-->-->-->-->-->-->BufferQueue::ProxyConsumerListener::onFrameAvailable()
-->-->-->-->-->-->-->-->-->-->-->FramebufferSurface::onFrameAvailable()
-->-->-->-->-->-->-->-->-->-->-->-->HWComposer::fbPost()
-->-->-->-->-->-->-->-->-->-->-->-->-->framebuffer_device_t::(*post)() = fb_post()
-->-->-->-->-->-->-->-->-->-->-->-->-->-->ioctl(m->framebuffer->fd, FBIOPUT_VSCREENINFO, &m->info) // ** the framebuffer is swapped.

in DisplayDevice::readyToRun, Surface instance will be registered as egl's window surface. Surface includes FramebufferSurface's BufferQueue(USAGE_HW_FB|USAGE_HW_COMPOSER) and inherits from ANativeWindow. in Surface, ANativeWindow's hook function should be called by egl!!! Thus Surface's and its BufferQueue's queuebuffer()s will be called. Then BufferQueue's and its comsumer FramebufferSurface's onframeavailable will be called.

-->DisplayDevice::flip()
-->-->eglSetSwapRectangleANDROID() ************** I think should be 'set' the region.. 

-->-->-->-->DisplayDevice::onSwapBuffersCompleted() // ** callbacked by eglSwpaBuufers
-->-->-->-->-->Signal the Fence

-->postFramebuffer()
-->-->HWComposer::commit()
-->-->-->mHwc->set()  that is hwc_set
-->-->-->-->MDPComp::draw()
-->-->-->-->-->MDPCompSplit::draw()
-->-->-->-->-->-->Overlay::queueBuffer
-->-->-->-->-->-->-->GenericPipe::queueBuffer()
-->-->-->-->-->-->-->-->MdpData::queueBuffer()
-->-->-->-->-->-->-->-->-->MdpData::play()
-->-->-->-->-->-->-->-->-->-->mdp_wrapper::play()
-->-->-->-->-->-->-->-->-->-->-->ioctl(MSMFB_OVERLAY_PLAY) // **start the layerMixer to composite, overlay the HWC_OVERLAY layer to framebuffer.
-->-->-->-->Overlay::displayCommit()
-->-->-->-->->Overlay::displayCommit()
-->-->-->-->->-->mdp_wrapper::displayCommit()
-->-->-->-->->-->-->ioctl(MSMFB_DISPLAY_COMMIT) // ** start DMA, transfer layerMixer output to DSI controller

FramebufferSurface no longer speaks directly to the FB HAL.  Now
everything goes through HWComposer (which may or may not be
connected to a hardware composer).

120// Overrides ConsumerBase: onFrameAvailable(), does not call base class impl.
121void FramebufferSurface: onFrameAvailable() {
122    sp buf;
123    sp acquireFence;
124    status_t err = nextBuffer(buf, acquireFence);
125    if (err != NO_ERROR) {
126        ALOGE("error latching nnext FramebufferSurface buffer: %s (%d)",
127                strerror(-err), err);
128        return;
129    }
130    err = mHwc.fbPost(mDisplayType, acquireFence, buf);
131    if (err != NO_ERROR) {
132        ALOGE("error posting framebuffer: %d", err);
133    }
134}

757int HWComposer::fbPost(int32_t id,
758        const sp& acquireFence, const sp& buffer) {
759    if (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
760        return setFramebufferTarget(id, acquireFence, buffer);
761    } else {
762        acquireFence->waitForever("HWComposer::fbPost");
763        return mFbDev->post(mFbDev, buffer->handle);  // ** fb_post
764    }
765}

195void DisplayDevice::flip(const Region& dirty) const
196{
197    checkGLErrors();
198
199    EGLDisplay dpy = mDisplay;
200    EGLSurface surface = mSurface;
201
202#ifdef EGL_ANDROID_swap_rectangle
203    if (mFlags & SWAP_RECTANGLE) {
204        const Region newDirty(dirty.intersect(bounds()));
205        const Rect b(newDirty.getBounds());
206        eglSetSwapRectangleANDROID(dpy, surface, // *****
207                b.left, b.top, b.width(), b.height());
208    }
209#endif
210
211    mPageFlipCount++;
212}

Another ANativeWindow with same role of Class Surface(for USAGE_HW_FB) is FrameBufferNativeWindow used by QCom's "GL updater" thread.

GL updater will call this.
GL updater, call FrameBufferNativeWindow::queueBuffer ANativeWindow::dequeueBuffer in eglsubAndroid.so
Thread 3 (LWP 511):
#0 __ioctl () at bionic/libc/arch-arm/syscalls/__ioctl.S:10
#1 0x4028e070 in ioctl (fd=, request=17921) at bionic/libc/bionic/ioctl.c:41
#2 0x400eed38 in fb_post (dev=, buffer=0x4122ff80) at hardware/qcom/display/libgralloc/framebuffer.cpp:129
#3 0x4004ec5a in android::FramebufferNativeWindow::queueBuffer (window=0x4122f578, buffer=) at frameworks/native/libs/ui/FramebufferNativeWindow.cpp:304
#4 0x40423da4 in updater_thread (ptr=0x41230f10) at vendor/qcom/proprietary/gles/adreno200/egl14/src/linux/android/eglUpdaterAndroid.c:451
#5 0x40278eb4 in __thread_entry (func=0x40423c55 , arg=0x41230f10, tls=0x41041f00) at bionic/libc/bionic/pthread.c:218
#6 0x4027860c in pthread_create (thread_out=0x41230f58, attr=0x402a0154 , start_routine=0x40423c55 , arg=0x41230f10) at bionic/libc/bionic/pthread.c:357
#7 0x00000000 in ?? ()

FramebufferNativeWindow::queueBuffer
274int FramebufferNativeWindow::queueBuffer(ANativeWindow* window,
275        ANativeWindowBuffer* buffer, int fenceFd)
276{
277    FramebufferNativeWindow* self = getSelf(window);
278    Mutex::Autolock _l(self->mutex);
279    framebuffer_device_t* fb = self->fbDev;
280    buffer_handle_t handle = static_cast(buffer)->handle;
281
282    sp fence(new Fence(fenceFd));
283    fence->wait(Fence::TIMEOUT_NEVER);
284
285    const int index = self->mCurrentBufferIndex;
286    int res = fb->post(fb, handle);  // ** fb_post
287    self->front = static_cast(buffer);
288    self->mNumFreeBuffers++;
289    self->mCondition.broadcast();
290    return res;
291}

SurfaceTextureClient(USAGE_TEXTURE) is used by normal application layers with GPU used buffers.
#05 pc 00014a6b /system/lib/libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+34)
#06 pc 0001e337 /system/lib/libgui.so 
#07 pc 000217fb /system/lib/libgui.so (android::SurfaceTextureClient::dequeueBuffer(ANativeWindowBuffer**)+86)
#08 pc 000207a7 /system/lib/libgui.so (android::SurfaceTextureClient::hook_dequeueBuffer(ANativeWindow*, ANativeWindowBuffer**)+10)
#09 pc 00002705 /system/lib/egl/eglsubAndroid.so (oeglSwapBuffers something maybe)
#10 pc 000037dd /system/lib/egl/eglsubAndroid.so (eglSwapBuffers something maybe)
#11 pc 00010f90 /system/lib/egl/libEGL_adreno200.so (qeglDrvAPI_eglSwapBuffers+452)
#12 pc 000061bc /system/lib/egl/libEGL_adreno200.so (eglSwapBuffers+16)
#13 pc 0000c6a9 /system/lib/libEGL.so (eglSwapBuffers+164)

[Reference]
http://blog.chinaunix.net/uid-25871104-id-3925025.html

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. Android框架的深度分析1
  2. Android设置代理访问网络Proxy
  3. Android(安卓)中SQList用法详解(增删查改)
  4. Android和设计模式:建造者模式
  5. Android短视频中如何实现720P磨皮美颜录
  6. 范例解析:学习Android的IPC主板模式
  7. Android应用程序线程消息循环模型分析
  8. Android应用程序的Life Cycle
  9. 初涉Android
  10. 我是如何自学Android,资料分享(2015 版)