惠普p1007打印机-防火墙排名
![skia](/uploads/image/0045.jpg)
2023年4月6日发(作者:3dmax2012中文版免费下载)
[074]RenderEngineType简介
前⾔
RenderEngine是⼀个静态库,主要作⽤于SurfaceFlinger进⾏clientlayer合成。
简单理解就是将clientbufferlayer合成到FramebufferSurface
frameworksnativelibsrenderengine
⼀、RenderEngineType
RenderEngineType是指RenderEngine的合成⽅式实现类型,⽬前有四种类型实现如下。
enumclassRenderEngineType{
GLES=1,//opengl
THREADED=2,//opengl异步线程
SKIA_GL=3,//skia
SKIA_GL_THREADED=4,//skia异步线程
};
同步异步
skiaSKIA_GLSKIA_GL_THREADED
openglGLESTHREADED
异步的意思会另起⼀个名叫RenderEngine的线程中处理合成任务。
同步的意思是会在SurfaceFlinger的主线程中处理合成任务
如图:异步处理合成任务的Trace。
⼆、RenderEngine初始化流程
基于最新的代码安卓代码
SurfaceFlingerinit的时候会构建RenderEngine,并且确认RenderEngineType
frameworks/native/services/surfaceflinger/
voidSurfaceFlinger::init(){
...
//GetaRenderEngineforthegivendisplay/config(can'tfail)
//TODO(b/77156734):WeneedtostopcastinganduseHALtypeswhenpossible.
//SendingmaxFrameBufferAcquiredBuffersasthecachesizeistightlytunedtosingle-display.
mCompositionEngine->setRenderEngine(renderengine::RenderEngine::create(
renderengine::RenderEngineCreationArgs::Builder()
.setPixelFormat(static_cast
.setImageCacheSize(maxFrameBufferAcquiredBuffers)
.setUseColorManagerment(useColorManagement)
.setEnableProtectedContext(enable_protected_contents(false))
.setPrecacheToneMapperShaderOnly(false)
.setSupportsBackgroundBlur(mSupportsBlur)
.setContextPriority(
useContextPriority
renderengine::RenderEngine::ContextPriority::REALTIME
:renderengine::RenderEngine::ContextPriority::MEDIUM)
.build()));//跳转到1.2
mMaxRenderTargetSize=
std::min(getRenderEngine().getMaxTextureSize(),getRenderEngine().getMaxViewportDims());
....
}
1.2RenderEngine
提供了setRenderEngineType的接⼝,默认缺省值是SKIA_GL_THREADED
frameworks/native/libs/renderengine/include/renderengine/RenderEngine.h
structRenderEngineCreationArgs::Builder{
...
Builder&setRenderEngineType(RenderEngine::RenderEngineTyperenderEngineType){
this->renderEngineType=renderEngineType;
return*this;
}
...
private:
//1meansRGBA_8888
intpixelFormat=1;
uint32_timageCacheSize=0;
booluseColorManagement=true;
boolenableProtectedContext=false;
boolprecacheToneMapperShaderOnly=false;
boolsupportsBackgroundBlur=false;
RenderEngine::ContextPrioritycontextPriority=RenderEngine::ContextPriority::MEDIUM;
RenderEngine::RenderEngineTyperenderEngineType=
RenderEngine::RenderEngineType::SKIA_GL_THREADED;//缺省值
};
}//namespacerenderengine
可以通过设置"d",改变RenderEngineType。
配置项:gles,threaded,skiagl,skiaglthread分别对应四种类型
frameworks/native/libs/renderengine/
#definePROPERTY_DEBUG_RENDERENGINE_BACKEND"d"
std::unique_ptr
//KeeptheabilitytooverridebyPROPERTIES:
charprop[PROPERTY_VALUE_MAX];
property_get(PROPERTY_DEBUG_RENDERENGINE_BACKEND,prop,"");
if(strcmp(prop,"gles")==0){
EngineType=RenderEngineType::GLES;
}
if(strcmp(prop,"threaded")==0){
EngineType=RenderEngineType::THREADED;
}
if(strcmp(prop,"skiagl")==0){
EngineType=RenderEngineType::SKIA_GL;
}
if(strcmp(prop,"skiaglthreaded")==0){
EngineType=RenderEngineType::SKIA_GL_THREADED;
}
switch(EngineType){
caseRenderEngineType::THREADED:
ALOGD("ThreadedRenderEnginewithGLESBackend");
returnrenderengine::threaded::RenderEngineThreaded::create(
[args](){returnandroid::renderengine::gl::GLESRenderEngine::create(args);},
EngineType);
caseRenderEngineType::SKIA_GL:
ALOGD("RenderEnginewithSkiaGLBackend");
returnrenderengine::skia::SkiaGLRenderEngine::create(args);
caseRenderEngineType::SKIA_GL_THREADED:{
ALOGD("ThreadedRenderEnginewithSkiaGLBackend");
returnrenderengine::threaded::RenderEngineThreaded::create(
[args](){
returnandroid::renderengine::skia::SkiaGLRenderEngine::create(args);
},
EngineType);
}
caseRenderEngineType::GLES:
default:
ALOGD("RenderEnginewithGLESBackend");
returnrenderengine::gl::GLESRenderEngine::create(args);
}
}
三、⼩结
androidS以后原⽣配置的是SKIA_GL_THREADED,⽬前窗⼝的blurs效果,只在skia实现上
opengl模式不⽀持blurs。
Somenewfeatures(indowblurs)areonlyimplementedinSkia
evicescanstill
turnitoffwithPROPERTY_DEBUG_RENDERENGINE_BACKEND.
细⼼你可能会发现前⾯SKIA_GL_THREADED的drawlayers中并没有发挥异步的作⽤。本质上还是会BlockSF的主线程。
⽬前我只发现REThreaded::unmapExternalTextureBuffer这个⽅法是异步处理了,相⽐SKIA_GL,有⼀定程度上的性能提升。
但是据说可能⼀些极限情况的下并发读写的问题,我相信后续android会不断的完善SKIA_GL_THREADED,后续可能就渐渐放弃GLES了。
更多推荐
skia
发布评论