Cleanup implementation of hardware layers.
The new implementation relies on OpenGLRenderer's existing layer
code instead of duplicating it. The new code is much cleaner, with
simpler and better APIs and allows tracking of drawn regions inside
layers. Region tracking is not yet enabled but this will be done
in a future CL.
Change-Id: Ie826121a2227de8252c77b992a61218defea5143
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 9beb227..7f7deec 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -622,10 +622,12 @@
setupDraw();
setupDrawWithTexture();
setupDrawColor(alpha, alpha, alpha, alpha);
+ setupDrawColorFilter();
setupDrawBlending(layer->blend || layer->alpha < 255, layer->mode, false);
setupDrawProgram();
setupDrawDirtyRegionsDisabled();
setupDrawPureColorUniforms();
+ setupDrawColorFilterUniforms();
setupDrawTexture(layer->texture);
setupDrawModelViewTranslate(rect.left, rect.top, rect.right, rect.bottom);
setupDrawMesh(&mesh[0].position[0], &mesh[0].texture[0]);
@@ -1485,28 +1487,22 @@
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)) {
+void OpenGLRenderer::drawLayer(Layer* layer, float x, float y, SkPaint* paint) {
+ if (!layer || quickReject(x, y, x + layer->layer.getWidth(), y + layer->layer.getHeight())) {
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);
+ layer->alpha = alpha;
+ layer->mode = mode;
- resetDrawTextureTexCoords(0.0f, 0.0f, 1.0f, 1.0f);
+ const Rect r(x, y, x + layer->layer.getWidth(), y + layer->layer.getHeight());
+ composeLayerRect(layer, r);
}
///////////////////////////////////////////////////////////////////////////////