Refactoring of Program ownership/lifecycle, and WIP Glop rendering path
Change-Id: I2549032790bddbc048b0bccc224ed8f386b4517c
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index cef2c84..03b8283 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -72,9 +72,8 @@
ATRACE_NAME("Caches::init");
-
mRegionMesh = nullptr;
- currentProgram = nullptr;
+ mProgram = nullptr;
mFunctorsCount = 0;
@@ -200,7 +199,7 @@
fboCache.clear();
programCache.clear();
- currentProgram = nullptr;
+ setProgram(nullptr);
patchCache.clear();
@@ -213,6 +212,22 @@
mInitialized = false;
}
+void Caches::setProgram(const ProgramDescription& description) {
+ setProgram(programCache.get(description));
+}
+
+void Caches::setProgram(Program* program) {
+ if (!program || !program->isInUse()) {
+ if (mProgram) {
+ mProgram->remove();
+ }
+ if (program) {
+ program->use();
+ }
+ mProgram = program;
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////
// Debug
///////////////////////////////////////////////////////////////////////////////