Adding an image cache to be behind drawLayers.
This is intended to replace the shadow GLImage array in BufferQueueLayer, since
I think this is simpler, and I don't fully trust BufferLayerConsumer's locking
model so that we could safely hold a unique_ptr<GLImage> there while passing a
pointer to RenderEngine::drawLayers.
Also, putting RenderEngine behind a binderizable interface is a bit of
a stretch goal for profiling, so EGLImage operations will need to be
behind the interface.
Bug: 118461793
Change-Id: Ibde79abd722ecb48ddf1288bc27008e07e1dc0c4
Test: librenderengine_test
diff --git a/libs/renderengine/gl/GLESRenderEngine.h b/libs/renderengine/gl/GLESRenderEngine.h
index b596242..e094860 100644
--- a/libs/renderengine/gl/GLESRenderEngine.h
+++ b/libs/renderengine/gl/GLESRenderEngine.h
@@ -30,6 +30,7 @@
#include <GLES2/gl2.h>
#include <renderengine/RenderEngine.h>
#include <renderengine/private/Description.h>
+#include <unordered_map>
#define EGL_NO_CONFIG ((EGLConfig)0)
@@ -133,7 +134,10 @@
// Defines the viewport, and sets the projection matrix to the projection
// defined by the clip.
void setViewportAndProjection(Rect viewport, Rect clip);
- status_t bindExternalTextureBuffer(uint32_t texName, sp<GraphicBuffer> buffer, sp<Fence> fence);
+ status_t bindExternalTextureBuffer(uint32_t texName, sp<GraphicBuffer> buffer, sp<Fence> fence,
+ bool readCache, bool persistCache);
+ // Evicts stale images from the buffer cache.
+ void evictImages(const std::vector<LayerSettings>& layers);
// Computes the cropping window for the layer and sets up cropping
// coordinates for the mesh.
FloatRect setupLayerCropping(const LayerSettings& layer, Mesh& mesh);
@@ -179,6 +183,9 @@
// supports sRGB, DisplayP3 color spaces.
const bool mUseColorManagement = false;
+ // Cache of GL images that we'll store per GraphicBuffer ID
+ std::unordered_map<uint64_t, std::unique_ptr<Image>> mImageCache;
+
class FlushTracer {
public:
FlushTracer(GLESRenderEngine* engine);