Better backend for hardware layers.
With this new backend, a hardware layer is only recreated when
its associated view is udpated. This offers fast composition
in GL and fast update of the layer in GL as well.
Change-Id: I97c43a612f5955c6bf1c192c8ca4af10fdf1d076
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 99bb6f0..aefefe4 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -178,7 +178,7 @@
#endif
}
-void OpenGLRenderer::acquireContext() {
+void OpenGLRenderer::interrupt() {
if (mCaches.currentProgram) {
if (mCaches.currentProgram->isInUse()) {
mCaches.currentProgram->remove();
@@ -188,7 +188,11 @@
mCaches.unbindMeshBuffer();
}
-void OpenGLRenderer::releaseContext() {
+void OpenGLRenderer::acquireContext() {
+ interrupt();
+}
+
+void OpenGLRenderer::resume() {
glViewport(0, 0, mSnapshot->viewport.getWidth(), mSnapshot->viewport.getHeight());
glEnable(GL_SCISSOR_TEST);
@@ -205,6 +209,10 @@
glBlendEquation(GL_FUNC_ADD);
}
+void OpenGLRenderer::releaseContext() {
+ resume();
+}
+
///////////////////////////////////////////////////////////////////////////////
// State management
///////////////////////////////////////////////////////////////////////////////
@@ -1477,6 +1485,30 @@
finishDrawTexture();
}
+void OpenGLRenderer::drawLayer(int texture, float left, float top, float right, float bottom,
+ float u, float v, SkPaint* paint) {
+ if (quickReject(left, top, right, bottom)) {
+ return;
+ }
+
+ glActiveTexture(gTextureUnits[0]);
+ if (!texture) return;
+
+ mCaches.unbindMeshBuffer();
+ resetDrawTextureTexCoords(0.0f, v, u, 0.0f);
+
+ int alpha;
+ SkXfermode::Mode mode;
+ getAlphaAndMode(paint, &alpha, &mode);
+
+ // TODO: Should get the blend info from the caller
+ drawTextureMesh(left, top, right, bottom, texture, alpha / 255.0f, mode, true,
+ &mMeshVertices[0].position[0], &mMeshVertices[0].texture[0],
+ GL_TRIANGLE_STRIP, gMeshCount);
+
+ resetDrawTextureTexCoords(0.0f, 0.0f, 1.0f, 1.0f);
+}
+
///////////////////////////////////////////////////////////////////////////////
// Shaders
///////////////////////////////////////////////////////////////////////////////