summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author John Reck <jreck@google.com> 2023-08-23 17:08:37 -0400
committer John Reck <jreck@google.com> 2023-08-23 17:10:54 -0400
commitaa584a39771e64f6b5ffb4da6e50068b7afe3134 (patch)
tree65a0df6ef9a01824c6cb7d7014469f25131d6ab3
parentaf3eb24f8e68617e7a4686edd6201fea1b0fe59d (diff)
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
-rw-r--r--libs/hwui/effects/GainmapRenderer.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/libs/hwui/effects/GainmapRenderer.cpp b/libs/hwui/effects/GainmapRenderer.cpp
index db58b2bfa273..3ebf7d19202d 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<const SkImage>& image, const SkRect& src,