Defer layer rendering to avoid stalls
Bug #7326824
When a layer is taken out of the cache and initialized it gets cleared
to prepare it for future rendering. This triggers the following sequence
of operations:
glBindFramebuffer(layer.fbo)
attach texture storage to FBO
glClear()
glBindFramebuffer(defaultFbo)
The clear forces a resolve on tilers which stalls the CPU for a little
while, thus producing jank during animations. This change moves the
clear to the next frame when we know we will have to execute a resolve
anyway.
Change-Id: Ic1939c25df20ed65a4c48dc81ee549b2cd8b6ec3
diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h
index 448e3da..e1f6a70 100644
--- a/libs/hwui/Layer.h
+++ b/libs/hwui/Layer.h
@@ -162,6 +162,14 @@
this->cacheable = cacheable;
}
+ inline bool isDirty() {
+ return dirty;
+ }
+
+ inline void setDirty(bool dirty) {
+ this->dirty = dirty;
+ }
+
inline bool isTextureLayer() {
return textureLayer;
}
@@ -287,6 +295,12 @@
bool textureLayer;
/**
+ * When set to true, this layer is dirty and should be cleared
+ * before any rendering occurs.
+ */
+ bool dirty;
+
+ /**
* Indicates the render target.
*/
GLenum renderTarget;