Update RenderEngine blur to snap an image of the full surface.

Snapping a subregion of a surface causes Skia's GPU surfaces to make
a copy of the pixels into a new buffer so that the dimensions of the
buffer match the requested size. By requesting a basic snapshot this
CL avoids any uncessary framebuffer copies.

Also refactor the code to start consolidating where blurs are used.

Test: tracing SysUI blurs
Bug: 176903027
Change-Id: I72a9e442e50bc6d945c601efca1fdd2ce7cdfcd1
diff --git a/libs/renderengine/tests/RenderEngineTest.cpp b/libs/renderengine/tests/RenderEngineTest.cpp
index 58afe6e..886c9da 100644
--- a/libs/renderengine/tests/RenderEngineTest.cpp
+++ b/libs/renderengine/tests/RenderEngineTest.cpp
@@ -950,15 +950,18 @@
     blurLayer.sourceDataspace = ui::Dataspace::V0_SRGB_LINEAR;
     blurLayer.geometry.boundaries = fullscreenRect().toFloatRect();
     blurLayer.backgroundBlurRadius = blurRadius;
+    SourceVariant::fillColor(blurLayer, 0.0f, 0.0f, 1.0f, this);
     blurLayer.alpha = 0;
     layers.push_back(&blurLayer);
 
     invokeDraw(settings, layers);
 
-    expectBufferColor(Rect(center - 1, center - 5, center, center + 5), 150, 150, 0, 255,
-                      50 /* tolerance */);
-    expectBufferColor(Rect(center, center - 5, center + 1, center + 5), 150, 150, 0, 255,
-                      50 /* tolerance */);
+    // solid color
+    expectBufferColor(Rect(0, 0, 1, 1), 255, 0, 0, 255, 0 /* tolerance */);
+
+    // blurred color (downsampling should result in the center color being close to 128)
+    expectBufferColor(Rect(center - 1, center - 5, center + 1, center + 5), 128, 128, 0, 255,
+                      10 /* tolerance */);
 }
 
 template <typename SourceVariant>