Loading libs/hwui/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -266,6 +266,7 @@ LOCAL_SRC_FILES += \ tests/unit/BakedOpDispatcherTests.cpp \ tests/unit/BakedOpRendererTests.cpp \ tests/unit/BakedOpStateTests.cpp \ tests/unit/CanvasContextTests.cpp \ tests/unit/CanvasStateTests.cpp \ tests/unit/ClipAreaTests.cpp \ tests/unit/DamageAccumulatorTests.cpp \ Loading libs/hwui/renderthread/CanvasContext.cpp +30 −16 Original line number Diff line number Diff line Loading @@ -97,6 +97,31 @@ void CanvasContext::destroyLayer(RenderNode* node) { } } void CanvasContext::invokeFunctor(const RenderThread& thread, Functor* functor) { ATRACE_CALL(); auto renderType = Properties::getRenderPipelineType(); switch (renderType) { case RenderPipelineType::OpenGL: OpenGLPipeline::invokeFunctor(thread, functor); break; default: LOG_ALWAYS_FATAL("canvas context type %d not supported", (int32_t) renderType); break; } } void CanvasContext::prepareToDraw(const RenderThread& thread, Bitmap* bitmap) { auto renderType = Properties::getRenderPipelineType(); switch (renderType) { case RenderPipelineType::OpenGL: OpenGLPipeline::prepareToDraw(thread, bitmap); break; default: LOG_ALWAYS_FATAL("canvas context type %d not supported", (int32_t) renderType); break; } } CanvasContext::CanvasContext(RenderThread& thread, bool translucent, RenderNode* rootRenderNode, IContextFactory* contextFactory, std::unique_ptr<IRenderPipeline> renderPipeline) Loading Loading @@ -425,8 +450,11 @@ void CanvasContext::draw() { GpuMemoryTracker::onFrameCompleted(); #ifdef BUGREPORT_FONT_CACHE_USAGE auto renderType = Properties::getRenderPipelineType(); if (RenderPipelineType::OpenGL == renderType) { Caches& caches = Caches::getInstance(); caches.fontRenderer.getFontRenderer().historyTracker().frameCompleted(); } #endif } Loading Loading @@ -456,16 +484,6 @@ void CanvasContext::prepareAndDraw(RenderNode* node) { } } void CanvasContext::invokeFunctor(RenderThread& thread, Functor* functor) { ATRACE_CALL(); DrawGlInfo::Mode mode = DrawGlInfo::kModeProcessNoContext; if (thread.eglManager().hasEglContext()) { mode = DrawGlInfo::kModeProcess; } thread.renderState().invokeFunctor(functor, mode, nullptr); } void CanvasContext::markLayerInUse(RenderNode* node) { if (mPrefetchedLayers.erase(node)) { node->decStrong(nullptr); Loading Loading @@ -520,10 +538,6 @@ void CanvasContext::destroyHardwareResources(TreeObserver* observer) { for (const sp<RenderNode>& node : mRenderNodes) { node->destroyHardwareResources(observer); } Caches& caches = Caches::getInstance(); // Make sure to release all the textures we were owning as there won't // be another draw caches.textureCache.resetMarkInUse(this); mRenderPipeline->onDestroyHardwareResources(); } } Loading libs/hwui/renderthread/CanvasContext.h +4 −2 Original line number Diff line number Diff line Loading @@ -85,6 +85,10 @@ public: */ static void destroyLayer(RenderNode* node); static void invokeFunctor(const RenderThread& thread, Functor* functor); static void prepareToDraw(const RenderThread& thread, Bitmap* bitmap); /* * If Properties::isSkiaEnabled() is true then this will return the Skia * grContext associated with the current RenderPipeline. Loading Loading @@ -121,8 +125,6 @@ public: void destroyHardwareResources(TreeObserver* observer); static void trimMemory(RenderThread& thread, int level); static void invokeFunctor(RenderThread& thread, Functor* functor); DeferredLayerUpdater* createTextureLayer(); void stopDrawing(); Loading libs/hwui/renderthread/OpenGLPipeline.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -165,6 +165,10 @@ bool OpenGLPipeline::isContextReady() { } void OpenGLPipeline::onDestroyHardwareResources() { Caches& caches = Caches::getInstance(); // Make sure to release all the textures we were owning as there won't // be another draw caches.textureCache.resetMarkInUse(this); mRenderThread.renderState().flush(Caches::FlushMode::Layers); } Loading Loading @@ -225,6 +229,21 @@ void OpenGLPipeline::destroyLayer(RenderNode* node) { } } void OpenGLPipeline::prepareToDraw(const RenderThread& thread, Bitmap* bitmap) { if (Caches::hasInstance() && thread.eglManager().hasEglContext()) { ATRACE_NAME("Bitmap#prepareToDraw task"); Caches::getInstance().textureCache.prefetch(bitmap); } } void OpenGLPipeline::invokeFunctor(const RenderThread& thread, Functor* functor) { DrawGlInfo::Mode mode = DrawGlInfo::kModeProcessNoContext; if (thread.eglManager().hasEglContext()) { mode = DrawGlInfo::kModeProcess; } thread.renderState().invokeFunctor(functor, mode, nullptr); } } /* namespace renderthread */ } /* namespace uirenderer */ } /* namespace android */ libs/hwui/renderthread/OpenGLPipeline.h +2 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,8 @@ public: bool createOrUpdateLayer(RenderNode* node, const DamageAccumulator& damageAccumulator) override; static void destroyLayer(RenderNode* node); static void prepareToDraw(const RenderThread& thread, Bitmap* bitmap); static void invokeFunctor(const RenderThread& thread, Functor* functor); private: EglManager& mEglManager; Loading Loading
libs/hwui/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -266,6 +266,7 @@ LOCAL_SRC_FILES += \ tests/unit/BakedOpDispatcherTests.cpp \ tests/unit/BakedOpRendererTests.cpp \ tests/unit/BakedOpStateTests.cpp \ tests/unit/CanvasContextTests.cpp \ tests/unit/CanvasStateTests.cpp \ tests/unit/ClipAreaTests.cpp \ tests/unit/DamageAccumulatorTests.cpp \ Loading
libs/hwui/renderthread/CanvasContext.cpp +30 −16 Original line number Diff line number Diff line Loading @@ -97,6 +97,31 @@ void CanvasContext::destroyLayer(RenderNode* node) { } } void CanvasContext::invokeFunctor(const RenderThread& thread, Functor* functor) { ATRACE_CALL(); auto renderType = Properties::getRenderPipelineType(); switch (renderType) { case RenderPipelineType::OpenGL: OpenGLPipeline::invokeFunctor(thread, functor); break; default: LOG_ALWAYS_FATAL("canvas context type %d not supported", (int32_t) renderType); break; } } void CanvasContext::prepareToDraw(const RenderThread& thread, Bitmap* bitmap) { auto renderType = Properties::getRenderPipelineType(); switch (renderType) { case RenderPipelineType::OpenGL: OpenGLPipeline::prepareToDraw(thread, bitmap); break; default: LOG_ALWAYS_FATAL("canvas context type %d not supported", (int32_t) renderType); break; } } CanvasContext::CanvasContext(RenderThread& thread, bool translucent, RenderNode* rootRenderNode, IContextFactory* contextFactory, std::unique_ptr<IRenderPipeline> renderPipeline) Loading Loading @@ -425,8 +450,11 @@ void CanvasContext::draw() { GpuMemoryTracker::onFrameCompleted(); #ifdef BUGREPORT_FONT_CACHE_USAGE auto renderType = Properties::getRenderPipelineType(); if (RenderPipelineType::OpenGL == renderType) { Caches& caches = Caches::getInstance(); caches.fontRenderer.getFontRenderer().historyTracker().frameCompleted(); } #endif } Loading Loading @@ -456,16 +484,6 @@ void CanvasContext::prepareAndDraw(RenderNode* node) { } } void CanvasContext::invokeFunctor(RenderThread& thread, Functor* functor) { ATRACE_CALL(); DrawGlInfo::Mode mode = DrawGlInfo::kModeProcessNoContext; if (thread.eglManager().hasEglContext()) { mode = DrawGlInfo::kModeProcess; } thread.renderState().invokeFunctor(functor, mode, nullptr); } void CanvasContext::markLayerInUse(RenderNode* node) { if (mPrefetchedLayers.erase(node)) { node->decStrong(nullptr); Loading Loading @@ -520,10 +538,6 @@ void CanvasContext::destroyHardwareResources(TreeObserver* observer) { for (const sp<RenderNode>& node : mRenderNodes) { node->destroyHardwareResources(observer); } Caches& caches = Caches::getInstance(); // Make sure to release all the textures we were owning as there won't // be another draw caches.textureCache.resetMarkInUse(this); mRenderPipeline->onDestroyHardwareResources(); } } Loading
libs/hwui/renderthread/CanvasContext.h +4 −2 Original line number Diff line number Diff line Loading @@ -85,6 +85,10 @@ public: */ static void destroyLayer(RenderNode* node); static void invokeFunctor(const RenderThread& thread, Functor* functor); static void prepareToDraw(const RenderThread& thread, Bitmap* bitmap); /* * If Properties::isSkiaEnabled() is true then this will return the Skia * grContext associated with the current RenderPipeline. Loading Loading @@ -121,8 +125,6 @@ public: void destroyHardwareResources(TreeObserver* observer); static void trimMemory(RenderThread& thread, int level); static void invokeFunctor(RenderThread& thread, Functor* functor); DeferredLayerUpdater* createTextureLayer(); void stopDrawing(); Loading
libs/hwui/renderthread/OpenGLPipeline.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -165,6 +165,10 @@ bool OpenGLPipeline::isContextReady() { } void OpenGLPipeline::onDestroyHardwareResources() { Caches& caches = Caches::getInstance(); // Make sure to release all the textures we were owning as there won't // be another draw caches.textureCache.resetMarkInUse(this); mRenderThread.renderState().flush(Caches::FlushMode::Layers); } Loading Loading @@ -225,6 +229,21 @@ void OpenGLPipeline::destroyLayer(RenderNode* node) { } } void OpenGLPipeline::prepareToDraw(const RenderThread& thread, Bitmap* bitmap) { if (Caches::hasInstance() && thread.eglManager().hasEglContext()) { ATRACE_NAME("Bitmap#prepareToDraw task"); Caches::getInstance().textureCache.prefetch(bitmap); } } void OpenGLPipeline::invokeFunctor(const RenderThread& thread, Functor* functor) { DrawGlInfo::Mode mode = DrawGlInfo::kModeProcessNoContext; if (thread.eglManager().hasEglContext()) { mode = DrawGlInfo::kModeProcess; } thread.renderState().invokeFunctor(functor, mode, nullptr); } } /* namespace renderthread */ } /* namespace uirenderer */ } /* namespace android */
libs/hwui/renderthread/OpenGLPipeline.h +2 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,8 @@ public: bool createOrUpdateLayer(RenderNode* node, const DamageAccumulator& damageAccumulator) override; static void destroyLayer(RenderNode* node); static void prepareToDraw(const RenderThread& thread, Bitmap* bitmap); static void invokeFunctor(const RenderThread& thread, Functor* functor); private: EglManager& mEglManager; Loading