/*****************************************************************************                      I.MX6 Surfaceflinger 机制* 说明:*     最近需要去分析一下Surfaceflinger工作机制,记录一下相关的文档和主要的* 处理函数。**                                          2016-9-14 深圳 南山平山村 曾剑锋***************************************************************************/一、参考文档:1. Android SurfaceFlinger服务启动过程源码分析http://blog.csdn.net/yangwen123/article/details/118909412. Android 开关机动画显示源码分析http://blog.csdn.net/yangwen123/article/details/116807593. 深入学习EGL http://blog.sina.com.cn/s/blog_602f87700100p1e7.html4. Android hwcomposer模块接口http://blog.sina.com.cn/s/blog_7213e0310102wmc0.html5. Android VSync信号产生过程源码分析http://blog.csdn.net/yangwen123/article/details/169699076. android HAL浅探http://www.cnblogs.com/mr-nop/archive/2013/02/27/2935131.html7. Android: 显示系统模块加载以及调用流程http://blog.csdn.net/hongzg1982/article/details/49681705

二、cat frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp......status_t SurfaceFlinger::readyToRun(){ALOGI(  "SurfaceFlinger's main thread ready to run. ""Initializing graphics H/W...");// initialize EGL for the default displaymEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);eglInitialize(mEGLDisplay, NULL, NULL);// Initialize the H/W composer object.  There may or may not be an// actual hardware composer underneath.mHwc = new HWComposer(this,*static_cast<HWComposer::EventHandler *>(this));// initialize the config and contextEGLint format = mHwc->getVisualID();mEGLConfig  = selectEGLConfig(mEGLDisplay, format);mEGLContext = createGLContext(mEGLDisplay, mEGLConfig);LOG_ALWAYS_FATAL_IF(mEGLContext == EGL_NO_CONTEXT,"couldn't create EGLContext");// initialize our non-virtual displaysfor (size_t i=0 ; i<DisplayDevice::NUM_DISPLAY_TYPES ; i++) {DisplayDevice::DisplayType type((DisplayDevice::DisplayType)i);mDefaultDisplays[i] = new BBinder();wp<IBinder> token = mDefaultDisplays[i];// set-up the displays that are already connectedif (mHwc->isConnected(i) || type==DisplayDevice::DISPLAY_PRIMARY) {// All non-virtual displays are currently considered secure.bool isSecure = true;bool isSecure = true;mCurrentState.displays.add(token, DisplayDeviceState(type));sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc, i);sp<SurfaceTextureClient> stc = new SurfaceTextureClient(static_cast< sp<ISurfaceTexture> >(fbs->getBufferQueue()));sp<DisplayDevice> hw = new DisplayDevice(this,type, isSecure, token, stc, fbs, mEGLConfig);if (i > DisplayDevice::DISPLAY_PRIMARY) {// FIXME: currently we don't get blank/unblank requests// for displays other than the main display, so we always// assume a connected display is unblanked.ALOGD("marking display %d as acquired/unblanked", i);hw->acquireScreen();}mDisplays.add(token, hw);}}//  we need a GL context current in a few places, when initializing//  OpenGL ES (see below), or creating a layer,//  or when a texture is (asynchronously) destroyed, and for that//  we need a valid surface, so it's convenient to use the main display//  for that.sp<const DisplayDevice> hw(getDefaultDisplayDevice());//  initialize OpenGL ES
        DisplayDevice::makeCurrent(mEGLDisplay, hw, mEGLContext);initializeGL(mEGLDisplay);// start the EventThreadmEventThread = new EventThread(this);mEventQueue.setEventThread(mEventThread);// initialize our drawing statemDrawingState = mCurrentState;// We're now ready to accept clients...
        mReadyToRunBarrier.open();// set initial conditions (e.g. unblank default device)
        initializeDisplays();// start boot animation
        startBootAnim();return NO_ERROR;}......三、cat frameworks/native/services/surfaceflinger/DisplayHardware/HWComposer.cpp......// Load and prepare the hardware composer module.  Sets mHwc.void HWComposer::loadHwcModule(){hw_module_t const* module;if (hw_get_module(HWC_HARDWARE_MODULE_ID, &module) != 0) {ALOGE("%s module not found", HWC_HARDWARE_MODULE_ID);return;}int err = hwc_open_1(module, &mHwc);if (err) {ALOGE("%s device failed to initialize (%s)",HWC_HARDWARE_COMPOSER, strerror(-err));return;}if (!hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_0) ||hwcHeaderVersion(mHwc) < MIN_HWC_HEADER_VERSION ||hwcHeaderVersion(mHwc) > HWC_HEADER_VERSION) {ALOGE("%s device version %#x unsupported, will not be used",HWC_HARDWARE_COMPOSER, mHwc->common.version);hwc_close_1(mHwc);mHwc = NULL;return;}}......四、cat hardware/imx/mx6/hwcomposer/hwcomposer.cppstatic int hwc_device_open(const struct hw_module_t* module, const char* name,struct hw_device_t** device){printf("fsl hwc_device_open().\n");int status = -EINVAL;if (!strcmp(name, HWC_HARDWARE_COMPOSER)) {struct hwc_context_t *dev;dev = (hwc_context_t*)malloc(sizeof(*dev));/* initialize our state here */// memset(dev, 0, sizeof(*dev));/* initialize the procs */dev->device.common.tag = HARDWARE_DEVICE_TAG;dev->device.common.module = const_cast<hw_module_t*>(module);dev->device.common.close = hwc_device_close;dev->device.prepare = hwc_prepare;dev->device.set = hwc_set;dev->device.common.version = HWC_DEVICE_API_VERSION_1_1;dev->device.registerProcs = hwc_registerProcs;dev->device.eventControl = hwc_eventControl;dev->device.query = hwc_query;dev->device.blank = hwc_blank;dev->device.getDisplayConfigs = hwc_getDisplayConfigs;dev->device.getDisplayAttributes = hwc_getDisplayAttributes;/* our private state goes below here */dev->m_vsync_thread = new VSyncThread(dev);dev->m_vsync_thread = new VSyncThread(dev);dev->m_uevent_thread = new UeventThread(dev);hwc_get_display_info(dev);hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &dev->m_gralloc_module);struct private_module_t *priv_m = (struct private_module_t *)dev->m_gralloc_module;for(int dispid=0; dispid<HWC_NUM_DISPLAY_TYPES; dispid++) {if(dev->mDispInfo[dispid].connected && dev->m_gralloc_module != NULL) {int fbid = dev->mDispInfo[dispid].fb_num;char fbname[HWC_STRING_LENGTH];memset(fbname, 0, sizeof(fbname));sprintf(fbname, "fb%d", fbid);ALOGI("hwcomposer: open framebuffer %s", fbname);dev->mFbDev[dispid] = (framebuffer_device_t*)fbid;dev->m_gralloc_module->methods->open(dev->m_gralloc_module, fbname,(struct hw_device_t**)&dev->mFbDev[dispid]);}}const hw_module_t *hwc_module;if(hw_get_module(HWC_VIV_HARDWARE_MODULE_ID,(const hw_module_t**)&hwc_module) < 0) {ALOGE("Error! hw_get_module viv_hwc failed");goto nor_exit;}if(hwc_open_1(hwc_module, &(dev->m_viv_hwc)) != 0) {ALOGE("Error! viv_hwc open failed");goto nor_exit;}nor_exit:*device = &dev->device.common;ALOGI("%s,%d", __FUNCTION__, __LINE__);return 0;err_exit:if(dev){free(dev);}/****************************************/}return status;}

I.MX6 Surfaceflinger 机制相关推荐

  1. Android系统Surface机制的SurfaceFlinger服务的线程模型分析

    在前面两篇文章中,我们分析了SurfaceFlinger服务的启动过程以及SurfaceFlinger服务初始化硬件帧缓冲区的过程.从这两个过程可以知道,SurfaceFlinger服务在启动的过程中 ...

  2. Android系统Surface机制的SurfaceFlinger服务渲染应用程序UI的过程分析

    出自:http://blog.csdn.net/luoshengyang/article/details/8079456 在前面的一系列文章中,我们学习了Android应用程序与SurfaceFlin ...

  3. Android系统Surface机制的SurfaceFlinger服务的启动过程分析

    在前面一篇文章中,我们简要介绍了Android系统Surface机制中的SurfaceFlinger服务.SurfaceFlinger服务是在System进程中启动的,并且负责统一管理设备的帧缓冲区. ...

  4. Android系统Surface机制的SurfaceFlinger服务对帧缓冲区(Frame Buffer)的管理分析

    在前文中,我们分析了SurfaceFlinger服务的启动过程.SurfaceFlinger服务在启动的过程中,会对系统的硬件帧缓冲区进行初始化.由于系统的硬件帧缓冲区一般只有一个,并且不是谁都可以随 ...

  5. Android系统Surface机制的SurfaceFlinger服务简要介绍和学习计划

    前面我们从Android应用程序与SurfaceFlinger服务的关系出发,从侧面简单学习了SurfaceFlinger服务.有了这些预备知识之后,我们就可以从正面来分析SurfaceFlinger ...

  6. Android 渲染机制——SurfaceFlinger

    SurfaceFlinger Android 图形架构使用了生产者--消费者模型.Surface 表示缓冲队列中的生产方,图像流最常见的消耗方是 SurfaceFlinger,该系统服务接收来自于多个 ...

  7. Android SurfaceFlinger中Fence机制--个人理解整理

    1 Fence 是什么? Fence中文是栅栏/围墙的意思,理解成分界/界限的东西.android中的一个资源锁机制.(i.e. a kind of memory barrier) 下面链接是engl ...

  8. Android刷新机制-View绘制原理

    Android刷新机制-View绘制原理 Android刷新机制-SurfaceFlinger原理 Android刷新机制-Choreographer原理 一.概述 本文将从startActivity ...

  9. Android应用程序与SurfaceFlinger服务的关系概述和学习计划

    文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/7846923 SurfaceFlinger服务负 ...

最新文章

  1. android点击展开textview,《Android APP可能有的东西》之UI篇:展开TextView全文
  2. illegal base64 character 3a_双11华硕多款产品再送豪礼 高端硬件通吃最新3A大作
  3. postMan下使用xdebug
  4. 教你3个python「性能分析」工具,再也不用自己计算函数耗时了
  5. C3P0连接池问题,APPARENT DEADLOCK!!! Creating emergency..... [问题点数:20分,结帖人lovekong]...
  6. ip地址能够什么标识网络中的一台计算机,计算机网络第一学期期末考试模拟练习题(这套卷子上面也会有原题).pdf...
  7. vue.js 组件基础
  8. Python文件夹copy器(多进程版)学习笔记
  9. matlab电力系统建模与仿真实验,基于MATLAB的小型电力系统的建模与仿真.doc
  10. Excel 2016中的新增函数之SWITCH
  11. js实现一键复制到剪切板上_js实现各种复制到剪贴板的方法(分享)
  12. mumu模拟器命令安装apk
  13. 基于STM32C8T6的MLX90614-DCC红外无线测温系统
  14. Android 使用Calendar类获取系统时间
  15. 中石油大学22春季《大学英语(四)#》第一阶段在线作业
  16. 改进Zhang Suen细化算法的C#实现
  17. 数据结构-算法与算法描述
  18. 小能手英语口语学习笔记
  19. 第一周 周报
  20. iOS 中集成百度echarts3.0

热门文章

  1. Mysql笔记——DML
  2. 利用虚拟硬盘(把内存当作硬盘)来提高数据库的效率(目前只针对SQL Server 2000)可以提高很多...
  3. linux系统安装jdk及配置环境变量
  4. Js中数组去重的几种方法
  5. JMeter 保持sessionId
  6. Intellij IDEA设置忽略部分类编译错误
  7. EZ的间谍网络(codevs 4093)
  8. ADO之connection
  9. for(;;)和 while(1) 有什么区别吗?for()和while()的使用情景。
  10. window.open参数完全手册