I.MX6 Surfaceflinger 机制
/****************************************************************************
* I.MX6 Surfaceflinger 机制
* 说明:
* 最近需要去分析一下Surfaceflinger工作机制,记录一下相关的文档和主要的
* 处理函数。
*
* 2016-9-14 深圳 南山平山村 曾剑锋
***************************************************************************/ 一、参考文档:
. Android SurfaceFlinger服务启动过程源码分析
http://blog.csdn.net/yangwen123/article/details/11890941
. Android 开关机动画显示源码分析
http://blog.csdn.net/yangwen123/article/details/11680759
. 深入学习EGL
http://blog.sina.com.cn/s/blog_602f87700100p1e7.html
. Android hwcomposer模块接口
http://blog.sina.com.cn/s/blog_7213e0310102wmc0.html
. Android VSync信号产生过程源码分析
http://blog.csdn.net/yangwen123/article/details/16969907
. android HAL浅探
http://www.cnblogs.com/mr-nop/archive/2013/02/27/2935131.html
. 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 display
mEGLDisplay = 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 context
EGLint 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 displays
for (size_t i= ; 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 connected
if (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 EventThread
mEventThread = new EventThread(this);
mEventQueue.setEventThread(mEventThread); // initialize our drawing state
mDrawingState = 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) != ) {
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.cpp
static 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=; 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, , 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) < ) {
ALOGE("Error! hw_get_module viv_hwc failed");
goto nor_exit;
} if(hwc_open_1(hwc_module, &(dev->m_viv_hwc)) != ) {
ALOGE("Error! viv_hwc open failed");
goto nor_exit;
}
nor_exit: *device = &dev->device.common;
ALOGI("%s,%d", __FUNCTION__, __LINE__);
return ;
err_exit:
if(dev){
free(dev);
}
/****************************************/
}
return status;
}
I.MX6 Surfaceflinger 机制的更多相关文章
- Android系统Surface机制的SurfaceFlinger服务渲染应用程序UI的过程分析
参考:Android系统Surface机制的SurfaceFlinger服务渲染应用程序UI的过程分析 一句话概括一下Android应用程序显示的过程:Android应用程序调用SurfaceFlin ...
- [转]Android系统Surface机制的SurfaceFlinger服务简要介绍和学习计划
转自:Android系统Surface机制的SurfaceFlinger服务简要介绍和学习计划 前面我们从Android应用程序与SurfaceFlinger服务的关系出发,从侧面简单学习了Surfa ...
- Android系统Surface机制的SurfaceFlinger服务的线程模型分析
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/8062945 在前面两篇文章中,我们分析了Sur ...
- Android系统Surface机制的SurfaceFlinger服务对帧缓冲区(Frame Buffer)的管理分析
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/8046659 在前文中,我们分析了Surface ...
- Android系统Surface机制的SurfaceFlinger服务的启动过程分析
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/8022957 在前面一篇文章中,我们简要介绍了A ...
- Android系统Surface机制的SurfaceFlinger服务简要介绍和学习计划
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/8010977 前面我们从Android应用程序与 ...
- Surface机制(SurfaceFlinger服务)
Android系统Surface机制的SurfaceFlinger服务的线程模型分析http://blog.csdn.net/luoshengyang/article/details/8062945
- Android 12(S) 图形显示系统 - SurfaceFlinger的启动和消息队列处理机制(四)
1 前言 SurfaceFlinger作为Android图形显示系统处理逻辑的核心单元,我们有必要去了解其是如何启动,初始化及进行消息处理的.这篇文章我们就来简单分析SurfaceFlinger这个B ...
- 11.4 Android显示系统框架_APP与SurfaceFlinger内部机制分析
4.1 APP跟SurfaceFlinger之间的重要数据结构 一个应用程序有一个或者多个surface(一般只有一个),一个surface有一个或者多个buffer,这些buffer需要应用向sur ...
随机推荐
- android状态栏总结
针对状态栏的操作,只针对4.4kitKat(含)以上的机型,部分国产rom会失效,目前发现的有华为的EMUI Activity必须是noActionbar主题 本文基于StatusBarUtils略作 ...
- windows10系统下安装nginx的安装步骤
打开nginx的官网:http://nginx.org/,下载最新的稳定版本. 下载完成后,解压到你想要解压的文件路径中,我解压到了D盘中,并把文件名改为nginx:进入文件内,打开nginx.e ...
- [转] RabbitMQ介绍
转自: http://lynnkong.iteye.com/blog/1699684 1 什么是RabbitMQ? RabbitMQ是实现AMQP(高级消息队列协议)的消息中间件的一种,最初 ...
- Host Controller transport layer and AMPs
The logical Host Controller Interface does not consider multiplexing/routing over the Host Controlle ...
- py3中的文字编码
Python3 中字符的类型只有两种: str: 编码过的 unicode 文本字符 bytes: 编码前的字节序列
- Phpstorm 放大字体的快捷键是什么?
这个功能需要设置才能使用: 步骤:control+shift+A功能可以搜索对应功能 输入mouse 设置Change font size(Zoom) ...的按钮打开,然后就可以通过 ctrl+ ...
- http 错误代码一览表
http协议一些常见的状态码为: 1xx(临时响应) 表示临时响应并需要请求者继续执行操作的状态代码. 代码 说明 100 (继续) 请求者应当继续提出请求. 服务器返回此代码表示已收到请求的第一部分 ...
- MySQL优化之——日志
转载请注明出处:http://blog.csdn.net/l1028386804/article/details/46790451 MYSQL里的日志主要分为4类,使用这些日志文件.能够查看MYSQL ...
- 数据库如何让自增id重置
sql语句:truncate tablename; 会清空表的所有记录,并且使自增的id重置. 另外,navicat的截断表,就是这个功能. 它的清空表只会清空数据,不能使自增的id重置.
- 如何打造你的独特观点(一) ——形成“自己的想法”的基础课zz
信息过载的时代,能在各种KOL的声音中保持独立思考很不容易,能输出独特观点又进一层.不断练习我们独立思考的能力,有助于看清周围复杂的事物,也能让我们在日常生活中给人留下“有趣之人”的印象,提升人际交往 ...