Revert "Revert "[SurfaceFlinger] Add GPU protected content support.""
This reverts commit 78fb96f3f8b40cba6b9e2cb2b0c332a45798b522.
Reason for revert: Revert the revert with Fix.
BUG: 35315015
Test: Test with a hacked patch.
Test: Watch Youtube movie, verifed by force GPU composition.
Change-Id: Ic738b5f873dbff322473d4f999074dc35c8813c7
diff --git a/libs/renderengine/gl/ProgramCache.h b/libs/renderengine/gl/ProgramCache.h
index 653aaf0..400ad74 100644
--- a/libs/renderengine/gl/ProgramCache.h
+++ b/libs/renderengine/gl/ProgramCache.h
@@ -20,6 +20,7 @@
#include <memory>
#include <unordered_map>
+#include <EGL/egl.h>
#include <GLES2/gl2.h>
#include <renderengine/private/Description.h>
#include <utils/Singleton.h>
@@ -178,13 +179,13 @@
~ProgramCache() = default;
// Generate shaders to populate the cache
- void primeCache(bool useColorManagement);
+ void primeCache(const EGLContext context, bool useColorManagement);
- size_t getSize() const { return mCache.size(); }
+ size_t getSize(const EGLContext context) { return mCaches[context].size(); }
// useProgram lookup a suitable program in the cache or generates one
// if none can be found.
- void useProgram(const Description& description);
+ void useProgram(const EGLContext context, const Description& description);
private:
// compute a cache Key from a Description
@@ -206,7 +207,8 @@
// Key/Value map used for caching Programs. Currently the cache
// is never shrunk (and the GL program objects are never deleted).
- std::unordered_map<Key, std::unique_ptr<Program>, Key::Hash> mCache;
+ std::unordered_map<EGLContext, std::unordered_map<Key, std::unique_ptr<Program>, Key::Hash>>
+ mCaches;
};
} // namespace gl