From fadc20184ccb27fe15bb862e6e03fa6d05d41eac Mon Sep 17 00:00:00 2001 From: John Reck Date: Wed, 23 Aug 2023 17:08:37 -0400 Subject: Fix potential thread violation in applying gainmaps When deciding whether or not to apply the gainmap & if so by how much only use the CanvasContext ratio if we are on RenderThread. Bug: 293927383 Test: Good guess Change-Id: Ie49ae2718df09ab14019b354197d99538e8c6b04 --- libs/hwui/effects/GainmapRenderer.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libs/hwui/effects/GainmapRenderer.cpp b/libs/hwui/effects/GainmapRenderer.cpp index 613f52b32bea..651d526511ef 100644 --- a/libs/hwui/effects/GainmapRenderer.cpp +++ b/libs/hwui/effects/GainmapRenderer.cpp @@ -54,14 +54,13 @@ float getTargetHdrSdrRatio(const SkColorSpace* destColorspace) { return maxPQLux / GenericSdrWhiteNits; } else if (skcms_TransferFunction_isHLGish(&destTF)) { return maxHLGLux / GenericSdrWhiteNits; - } else { #ifdef __ANDROID__ + } else if (RenderThread::isCurrent()) { CanvasContext* context = CanvasContext::getActiveContext(); return context ? context->targetSdrHdrRatio() : 1.f; -#else - return 1.f; #endif } + return 1.f; } void DrawGainmapBitmap(SkCanvas* c, const sk_sp& image, const SkRect& src, -- cgit v1.2.3-59-g8ed1b