Only use the gainmap shader if we might need it
Skip using the gainmap shader when drawing to a bitmap
with a known SDR colorspace as it'll be a no-op in
rendering results since W=1.0, but it'll be very expensive
in runtime due to CPU evaluation of the SKSL shader.
Before:
createScaledBitmapWithGainmap_median (ns): 179,455,037
After:
createScaledBitmapWithGainmap_median (ns): 15,643,742
Bug: 311085927
Test: benchmark in CL
Change-Id: I3f2506a2bd86bbe29c6e0837d31e4a231a7c182a
diff --git a/libs/hwui/SkiaCanvas.h b/libs/hwui/SkiaCanvas.h
index ced0224..4bf1790 100644
--- a/libs/hwui/SkiaCanvas.h
+++ b/libs/hwui/SkiaCanvas.h
@@ -223,6 +223,8 @@
void drawPoints(const float* points, int count, const Paint& paint, SkCanvas::PointMode mode);
+ bool useGainmapShader(Bitmap& bitmap);
+
class Clip;
std::unique_ptr<SkCanvas> mCanvasOwned; // Might own a canvas we allocated.