don't attempt to clip layers anymore using glScissor
this seems to hurt performance on some GPU. this change
might negatively affect performance on other GPUs though, but
probably in less time-sensitive cases. If this becomes a
problem it might become necessary to pre-clip the geometry
(so that we don't have to use glScissor).
This improves the rotation animation quite a bit.
Change-Id: I5dbe1286f7ad858ef2c1e1ad9a07ee3f26c0b1f3
diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp
index 416fc93..694ecde 100644
--- a/services/surfaceflinger/LayerBase.cpp
+++ b/services/surfaceflinger/LayerBase.cpp
@@ -231,7 +231,9 @@
const uint32_t hw_h = hw.getHeight();
uint32_t w = s.w;
- uint32_t h = s.h;
+ uint32_t h = s.h;
+
+ mNumVertices = 4;
tr.transform(mVertices[0], 0, 0);
tr.transform(mVertices[1], 0, h);
tr.transform(mVertices[2], w, h);
@@ -268,27 +270,6 @@
const Transform& planeTransform, Region& outDirtyRegion) {
}
-void LayerBase::drawRegion(const Region& reg) const
-{
- Region::const_iterator it = reg.begin();
- Region::const_iterator const end = reg.end();
- if (it != end) {
- Rect r;
- const DisplayHardware& hw(graphicPlane(0).displayHardware());
- const int32_t fbWidth = hw.getWidth();
- const int32_t fbHeight = hw.getHeight();
- const GLshort vertices[][2] = { { 0, 0 }, { fbWidth, 0 },
- { fbWidth, fbHeight }, { 0, fbHeight } };
- glVertexPointer(2, GL_SHORT, 0, vertices);
- while (it != end) {
- const Rect& r = *it++;
- const GLint sy = fbHeight - (r.top + r.height());
- glScissor(r.left, sy, r.width(), r.height());
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- }
- }
-}
-
void LayerBase::setGeometry(hwc_layer_t* hwcl)
{
hwcl->compositionType = HWC_FRAMEBUFFER;
@@ -345,9 +326,6 @@
void LayerBase::draw(const Region& clip) const
{
- // reset GL state
- glEnable(GL_SCISSOR_TEST);
-
onDraw(clip);
}
@@ -371,16 +349,8 @@
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
- Region::const_iterator it = clip.begin();
- Region::const_iterator const end = clip.end();
- glEnable(GL_SCISSOR_TEST);
glVertexPointer(2, GL_FLOAT, 0, mVertices);
- while (it != end) {
- const Rect& r = *it++;
- const GLint sy = fbHeight - (r.top + r.height());
- glScissor(r.left, sy, r.width(), r.height());
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- }
+ glDrawArrays(GL_TRIANGLE_FAN, 0, mNumVertices);
}
void LayerBase::clearWithOpenGL(const Region& clip) const
@@ -434,15 +404,8 @@
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, mVertices);
glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
+ glDrawArrays(GL_TRIANGLE_FAN, 0, mNumVertices);
- Region::const_iterator it = clip.begin();
- Region::const_iterator const end = clip.end();
- while (it != end) {
- const Rect& r = *it++;
- const GLint sy = fbHeight - (r.top + r.height());
- glScissor(r.left, sy, r.width(), r.height());
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- }
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_BLEND);
}