Improve RenderEngine's blur performance.

This CL uses new Skia APIs to skip the unnecessary glClear issued when
creating the temporary surfaces. On a Pixel 5 device this showed an
~6% improvement in total GPU time as well as a similar improvement on
the CPU time taken by Skia to isssue the calls to the GPU.

Test: perfetto traces
Bug: 176903027
Change-Id: If04b795ce44107670e9e752b10ab5470393e1e32
diff --git a/libs/renderengine/skia/SkiaGLRenderEngine.cpp b/libs/renderengine/skia/SkiaGLRenderEngine.cpp
index dc04f69..2ab3c6c 100644
--- a/libs/renderengine/skia/SkiaGLRenderEngine.cpp
+++ b/libs/renderengine/skia/SkiaGLRenderEngine.cpp
@@ -593,6 +593,7 @@
     // view is still on-screen. The clear region could be re-specified as a black color layer,
     // however.
     if (!display.clearRegion.isEmpty()) {
+        ATRACE_NAME("ClearRegion");
         size_t numRects = 0;
         Rect const* rects = display.clearRegion.getArray(&numRects);
         SkIRect skRects[numRects];
@@ -612,6 +613,7 @@
     }
 
     for (const auto& layer : layers) {
+        ATRACE_NAME("DrawLayer");
         canvas->save();
 
         if (mCapture->isCaptureRunning()) {
@@ -630,7 +632,7 @@
         const auto& bounds = layer->geometry.boundaries;
         const auto dest = getSkRect(bounds);
         const auto layerRect = canvas->getTotalMatrix().mapRect(dest);
-        std::unordered_map<uint32_t, sk_sp<SkSurface>> cachedBlurs;
+        std::unordered_map<uint32_t, sk_sp<SkImage>> cachedBlurs;
         if (mBlurFilter) {
             if (layer->backgroundBlurRadius > 0) {
                 ATRACE_NAME("BackgroundBlur");
@@ -882,17 +884,15 @@
 }
 
 void SkiaGLRenderEngine::drawBlurRegion(SkCanvas* canvas, const BlurRegion& effectRegion,
-                                        const SkRect& layerRect, sk_sp<SkSurface> blurredSurface) {
+                                        const SkRect& layerRect, sk_sp<SkImage> blurredImage) {
     ATRACE_CALL();
 
     SkPaint paint;
     paint.setAlpha(static_cast<int>(effectRegion.alpha * 255));
     const auto matrix = getBlurShaderTransform(canvas, layerRect);
-    paint.setShader(blurredSurface->makeImageSnapshot()->makeShader(
-            SkTileMode::kClamp,
-            SkTileMode::kClamp,
-            SkSamplingOptions({SkFilterMode::kLinear, SkMipmapMode::kNone}),
-            &matrix));
+    SkSamplingOptions linearSampling(SkFilterMode::kLinear, SkMipmapMode::kNone);
+    paint.setShader(blurredImage->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, linearSampling,
+                                             &matrix));
 
     auto rect = SkRect::MakeLTRB(effectRegion.left, effectRegion.top, effectRegion.right,
                                  effectRegion.bottom);