SkiaGLRE caching: monitor the caching of shaders

Bug: 178661709
Test: adb shell setprop debug.renderengine.backend skiagl
      adb shell stop && adb shell start
      adb shell dumpsys SurfaceFlinger

Add an implementation of PersistentCache that allows us to monitor
whether a shader was generated when we expected one to be. This can be
repurposed in the future (i.e. once we've generated all the shaders we
expect) to verify that we do *not* generate shaders after primeCache
finishes.

Add the number of recently cached shaders (i.e. since the last call, or
primeCache, if this is the first call) to the output of dumpsys.

Change-Id: I6f177b7ad78fef166d529e918447395629673f47
diff --git a/libs/renderengine/skia/Cache.cpp b/libs/renderengine/skia/Cache.cpp
index 4fdae74..f8dd7f5 100644
--- a/libs/renderengine/skia/Cache.cpp
+++ b/libs/renderengine/skia/Cache.cpp
@@ -55,6 +55,7 @@
     // generate the slower (more general case) version. If we also need a
     // slow version without color correction, we should use this matrix with
     // display.outputDataspace set to SRGB.
+    bool identity = true;
     for (const mat4 transform : { mat4(), mat4(0.728872f,   0.f,          0.f, 0.f,
                                                0.f,         0.727627f,    0.f, 0.f,
                                                0.f,         0.f,          1.f, 0.f,
@@ -62,6 +63,8 @@
         layer.geometry.positionTransform = transform;
         renderengine->drawLayers(display, layers, dstBuffer, false /* useFrameBufferCache*/,
                                  base::unique_fd(), nullptr);
+        renderengine->assertShadersCompiled(identity ? 1 : 2);
+        identity = false;
     }
 }
 
@@ -105,6 +108,7 @@
                     renderengine->drawLayers(display, layers, dstBuffer,
                                              false /* useFrameBufferCache*/, base::unique_fd(),
                                              nullptr);
+                    renderengine->assertShadersCompiled(1);
                 }
             }
         }