am b9c932ba: Merge change 26925 into eclair

Merge commit 'b9c932ba1203b477abbb0695d8b7162f45b4e91e' into eclair-plus-aosp

* commit 'b9c932ba1203b477abbb0695d8b7162f45b4e91e':
  minor SurfaceFlinger code cleanup and remove unnecessary tests
This commit is contained in:
Mathias Agopian
2009-09-24 15:30:40 -07:00
committed by Android Git Automerger
5 changed files with 68 additions and 80 deletions

View File

@@ -160,7 +160,7 @@ void DisplayHardware::init(uint32_t dpy)
if (mNativeWindow->isUpdateOnDemand()) { if (mNativeWindow->isUpdateOnDemand()) {
mFlags |= UPDATE_ON_DEMAND; mFlags |= PARTIAL_UPDATES;
} }
if (eglGetConfigAttrib(display, config, EGL_CONFIG_CAVEAT, &dummy) == EGL_TRUE) { if (eglGetConfigAttrib(display, config, EGL_CONFIG_CAVEAT, &dummy) == EGL_TRUE) {
@@ -174,9 +174,9 @@ void DisplayHardware::init(uint32_t dpy)
surface = eglCreateWindowSurface(display, config, mNativeWindow.get(), NULL); surface = eglCreateWindowSurface(display, config, mNativeWindow.get(), NULL);
if (mFlags & UPDATE_ON_DEMAND) { if (mFlags & PARTIAL_UPDATES) {
// if we have update on demand, we definitely don't need to // if we have partial updates, we definitely don't need to
// preserve the backbuffer, which is usually costly. // preserve the backbuffer, which may be costly.
eglSurfaceAttrib(display, surface, eglSurfaceAttrib(display, surface,
EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED); EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED);
} }
@@ -199,9 +199,9 @@ void DisplayHardware::init(uint32_t dpy)
mFlags |= SWAP_RECTANGLE; mFlags |= SWAP_RECTANGLE;
} }
} }
// when we have the choice between UPDATE_ON_DEMAND and SWAP_RECTANGLE // when we have the choice between PARTIAL_UPDATES and SWAP_RECTANGLE
// choose UPDATE_ON_DEMAND, which is more efficient // choose PARTIAL_UPDATES, which should be more efficient
if (mFlags & UPDATE_ON_DEMAND) if (mFlags & PARTIAL_UPDATES)
mFlags &= ~SWAP_RECTANGLE; mFlags &= ~SWAP_RECTANGLE;
#endif #endif
@@ -317,7 +317,7 @@ void DisplayHardware::flip(const Region& dirty) const
} }
#endif #endif
if (mFlags & UPDATE_ON_DEMAND) { if (mFlags & PARTIAL_UPDATES) {
mNativeWindow->setUpdateRectangle(dirty.getBounds()); mNativeWindow->setUpdateRectangle(dirty.getBounds());
} }

View File

@@ -48,7 +48,7 @@ public:
NPOT_EXTENSION = 0x00000100, NPOT_EXTENSION = 0x00000100,
DRAW_TEXTURE_EXTENSION = 0x00000200, DRAW_TEXTURE_EXTENSION = 0x00000200,
BUFFER_PRESERVED = 0x00010000, BUFFER_PRESERVED = 0x00010000,
UPDATE_ON_DEMAND = 0x00020000, // video driver feature PARTIAL_UPDATES = 0x00020000, // video driver feature
SLOW_CONFIG = 0x00040000, // software SLOW_CONFIG = 0x00040000, // software
SWAP_RECTANGLE = 0x00080000, SWAP_RECTANGLE = 0x00080000,
}; };

View File

@@ -223,14 +223,12 @@ void Layer::onDraw(const Region& clip) const
mFrontBufferIndex : 0; mFrontBufferIndex : 0;
GLuint textureName = mTextures[index].name; GLuint textureName = mTextures[index].name;
if (UNLIKELY(textureName == -1LU)) { if (UNLIKELY(textureName == -1LU)) {
//LOGW("Layer %p doesn't have a texture", this);
// the texture has not been created yet, this Layer has // the texture has not been created yet, this Layer has
// in fact never been drawn into. this happens frequently with // in fact never been drawn into. this happens frequently with
// SurfaceView. // SurfaceView.
clearWithOpenGL(clip); clearWithOpenGL(clip);
return; return;
} }
drawWithOpenGL(clip, mTextures[index]); drawWithOpenGL(clip, mTextures[index]);
} }

View File

@@ -363,15 +363,13 @@ void LayerBase::clearWithOpenGL(const Region& clip, GLclampx red,
Region::const_iterator it = clip.begin(); Region::const_iterator it = clip.begin();
Region::const_iterator const end = clip.end(); Region::const_iterator const end = clip.end();
if (it != end) { glEnable(GL_SCISSOR_TEST);
glEnable(GL_SCISSOR_TEST); glVertexPointer(2, GL_FIXED, 0, mVertices);
glVertexPointer(2, GL_FIXED, 0, mVertices); while (it != end) {
while (it != end) { const Rect& r = *it++;
const Rect& r = *it++; const GLint sy = fbHeight - (r.top + r.height());
const GLint sy = fbHeight - (r.top + r.height()); glScissor(r.left, sy, r.width(), r.height());
glScissor(r.left, sy, r.width(), r.height()); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
} }
} }
@@ -427,71 +425,63 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const
} }
} }
Region::const_iterator it = clip.begin();
Region::const_iterator const end = clip.end();
if (UNLIKELY(transformed() if (UNLIKELY(transformed()
|| !(mFlags & DisplayHardware::DRAW_TEXTURE_EXTENSION) )) || !(mFlags & DisplayHardware::DRAW_TEXTURE_EXTENSION) ))
{ {
//StopWatch watch("GL transformed"); //StopWatch watch("GL transformed");
Region::const_iterator it = clip.begin(); const GLfixed texCoords[4][2] = {
Region::const_iterator const end = clip.end(); { 0, 0 },
if (it != end) { { 0, 0x10000 },
const GLfixed texCoords[4][2] = { { 0x10000, 0x10000 },
{ 0, 0 }, { 0x10000, 0 }
{ 0, 0x10000 }, };
{ 0x10000, 0x10000 },
{ 0x10000, 0 }
};
glMatrixMode(GL_TEXTURE); glMatrixMode(GL_TEXTURE);
glLoadIdentity(); glLoadIdentity();
// the texture's source is rotated // the texture's source is rotated
if (texture.transform == HAL_TRANSFORM_ROT_90) { if (texture.transform == HAL_TRANSFORM_ROT_90) {
// TODO: handle the other orientations // TODO: handle the other orientations
glTranslatef(0, 1, 0); glTranslatef(0, 1, 0);
glRotatef(-90, 0, 0, 1); glRotatef(-90, 0, 0, 1);
}
if (!(mFlags & (DisplayHardware::NPOT_EXTENSION |
DisplayHardware::DIRECT_TEXTURE))) {
// find the smallest power-of-two that will accommodate our surface
GLuint tw = 1 << (31 - clz(width));
GLuint th = 1 << (31 - clz(height));
if (tw < width) tw <<= 1;
if (th < height) th <<= 1;
// this divide should be relatively fast because it's
// a power-of-two (optimized path in libgcc)
GLfloat ws = GLfloat(width) /tw;
GLfloat hs = GLfloat(height)/th;
glScalef(ws, hs, 1.0f);
}
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FIXED, 0, mVertices);
glTexCoordPointer(2, GL_FIXED, 0, texCoords);
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);
} }
if (!(mFlags & (DisplayHardware::NPOT_EXTENSION |
DisplayHardware::DIRECT_TEXTURE))) {
// find the smallest power-of-two that will accommodate our surface
GLuint tw = 1 << (31 - clz(width));
GLuint th = 1 << (31 - clz(height));
if (tw < width) tw <<= 1;
if (th < height) th <<= 1;
GLfloat ws = GLfloat(width) /tw;
GLfloat hs = GLfloat(height)/th;
glScalef(ws, hs, 1.0f);
}
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FIXED, 0, mVertices);
glTexCoordPointer(2, GL_FIXED, 0, texCoords);
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);
} else { } else {
Region::const_iterator it = clip.begin(); GLint crop[4] = { 0, height, width, -height };
Region::const_iterator const end = clip.end(); glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
if (it != end) { int x = tx();
GLint crop[4] = { 0, height, width, -height }; int y = ty();
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop); y = fbHeight - (y + height);
int x = tx(); while (it != end) {
int y = ty(); const Rect& r = *it++;
y = fbHeight - (y + height); const GLint sy = fbHeight - (r.top + r.height());
while (it != end) { glScissor(r.left, sy, r.width(), r.height());
const Rect& r = *it++; glDrawTexiOES(x, y, 0, width, height);
const GLint sy = fbHeight - (r.top + r.height());
glScissor(r.left, sy, r.width(), r.height());
glDrawTexiOES(x, y, 0, width, height);
}
} }
} }
} }

View File

@@ -859,10 +859,10 @@ void SurfaceFlinger::handleRepaint()
// is costly and usually involves copying the whole update back. // is costly and usually involves copying the whole update back.
} }
} else { } else {
if (flags & DisplayHardware::UPDATE_ON_DEMAND) { if (flags & DisplayHardware::PARTIAL_UPDATES) {
// We need to redraw the rectangle that will be updated // We need to redraw the rectangle that will be updated
// (pushed to the framebuffer). // (pushed to the framebuffer).
// This is needed because UPDATE_ON_DEMAND only takes one // This is needed because PARTIAL_UPDATES only takes one
// rectangle instead of a region (see DisplayHardware::flip()) // rectangle instead of a region (see DisplayHardware::flip())
mDirtyRegion.set(mInvalidRegion.bounds()); mDirtyRegion.set(mInvalidRegion.bounds());
} else { } else {
@@ -920,7 +920,7 @@ void SurfaceFlinger::debugFlashRegions()
if (!((flags & DisplayHardware::SWAP_RECTANGLE) || if (!((flags & DisplayHardware::SWAP_RECTANGLE) ||
(flags & DisplayHardware::BUFFER_PRESERVED))) { (flags & DisplayHardware::BUFFER_PRESERVED))) {
const Region repaint((flags & DisplayHardware::UPDATE_ON_DEMAND) ? const Region repaint((flags & DisplayHardware::PARTIAL_UPDATES) ?
mDirtyRegion.bounds() : hw.bounds()); mDirtyRegion.bounds() : hw.bounds());
composeSurfaces(repaint); composeSurfaces(repaint);
} }