diff options
Diffstat (limited to 'libs/hwui/renderthread/CanvasContext.cpp')
-rw-r--r-- | libs/hwui/renderthread/CanvasContext.cpp | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index 9c80ab304b80..a79bf359913b 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -186,7 +186,8 @@ void CanvasContext::setSurface(Surface* surface) { mNativeSurface = surface; - bool hasSurface = mRenderPipeline->setSurface(surface, mSwapBehavior); + ColorMode colorMode = mWideColorGamut ? ColorMode::WideColorGamut : ColorMode::Srgb; + bool hasSurface = mRenderPipeline->setSurface(surface, mSwapBehavior, colorMode); mFrameNumber = -1; @@ -241,6 +242,10 @@ void CanvasContext::setOpaque(bool opaque) { mOpaque = opaque; } +void CanvasContext::setWideGamut(bool wideGamut) { + mWideColorGamut = wideGamut; +} + bool CanvasContext::makeCurrent() { if (mStopped) return false; @@ -580,15 +585,37 @@ void CanvasContext::destroyHardwareResources() { } void CanvasContext::trimMemory(RenderThread& thread, int level) { - // No context means nothing to free - if (!thread.eglManager().hasEglContext()) return; - - ATRACE_CALL(); - if (level >= TRIM_MEMORY_COMPLETE) { - thread.renderState().flush(Caches::FlushMode::Full); - thread.eglManager().destroy(); - } else if (level >= TRIM_MEMORY_UI_HIDDEN) { - thread.renderState().flush(Caches::FlushMode::Moderate); + auto renderType = Properties::getRenderPipelineType(); + switch (renderType) { + case RenderPipelineType::OpenGL: { + // No context means nothing to free + if (!thread.eglManager().hasEglContext()) return; + ATRACE_CALL(); + if (level >= TRIM_MEMORY_COMPLETE) { + thread.renderState().flush(Caches::FlushMode::Full); + thread.eglManager().destroy(); + } else if (level >= TRIM_MEMORY_UI_HIDDEN) { + thread.renderState().flush(Caches::FlushMode::Moderate); + } + break; + } + case RenderPipelineType::SkiaGL: + case RenderPipelineType::SkiaVulkan: { + // No context means nothing to free + if (!thread.getGrContext()) return; + ATRACE_CALL(); + if (level >= TRIM_MEMORY_COMPLETE) { + thread.cacheManager().trimMemory(CacheManager::TrimMemoryMode::Complete); + thread.eglManager().destroy(); + thread.vulkanManager().destroy(); + } else if (level >= TRIM_MEMORY_UI_HIDDEN) { + thread.cacheManager().trimMemory(CacheManager::TrimMemoryMode::UiHidden); + } + break; + } + default: + LOG_ALWAYS_FATAL("canvas context type %d not supported", (int32_t) renderType); + break; } } |