diff options
author | Steve Kondik <shade@chemlab.org> | 2011-11-30 23:15:19 -0800 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2011-11-30 23:15:19 -0800 |
commit | f361ac6f137d1aa616203ac39453d36f1585cce1 (patch) | |
tree | 7a2ac8c197a15a335f51a07ecea80e8b504df91c /services | |
parent | 15581654f4376003d695be12898dea6e9942df47 (diff) | |
download | frameworks_base-f361ac6f137d1aa616203ac39453d36f1585cce1.zip frameworks_base-f361ac6f137d1aa616203ac39453d36f1585cce1.tar.gz frameworks_base-f361ac6f137d1aa616203ac39453d36f1585cce1.tar.bz2 |
Revert "frameworks/base: surfaceflinger: Use vertical quads for 90/270 orientation"
This reverts commit f7382855f1d3c5d9dbd3e5191f7336e47736ef04.
Diffstat (limited to 'services')
-rw-r--r-- | services/surfaceflinger/Layer.cpp | 5 | ||||
-rw-r--r-- | services/surfaceflinger/LayerBase.cpp | 331 | ||||
-rw-r--r-- | services/surfaceflinger/LayerBase.h | 3 |
3 files changed, 1 insertions, 338 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 29a983e..e311ee5 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -279,10 +279,7 @@ void Layer::onDraw(const Region& clip) const } #endif - if (mFlags & DisplayHardware::SLOW_CONFIG) - drawWithOpenGL(clip, tex); - else - drawWithOpenGLOptimized(clip, tex); + drawWithOpenGL(clip, tex); } bool Layer::needsFiltering() const diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp index e99130d..550030a 100644 --- a/services/surfaceflinger/LayerBase.cpp +++ b/services/surfaceflinger/LayerBase.cpp @@ -553,337 +553,6 @@ void LayerBase::drawWithOpenGL(const Region& clip, const Texture& texture) const glDisableClientState(GL_TEXTURE_COORD_ARRAY); } -void LayerBase::drawWithOpenGLOptimized(const Region& clip, const Texture& texture) const -{ - const DisplayHardware& hw(graphicPlane(0).displayHardware()); - const uint32_t fbHeight = hw.getHeight(); - const State& s(drawingState()); - - // bind our texture - TextureManager::activateTexture(texture, needsFiltering()); - uint32_t width = texture.width; - uint32_t height = texture.height; - - GLenum src = mPremultipliedAlpha ? GL_ONE : GL_SRC_ALPHA; - int renderEffect = mFlinger->getRenderEffect(); - int renderColorR = mFlinger->getRenderColorR(); - int renderColorG = mFlinger->getRenderColorG(); - int renderColorB = mFlinger->getRenderColorB(); - - bool noEffect = renderEffect == 0; - - if (UNLIKELY(s.alpha < 0xFF) && noEffect) { - const GLfloat alpha = s.alpha * (1.0f/255.0f); - if (mPremultipliedAlpha) { - glColor4f(alpha, alpha, alpha, alpha); - } else { - glColor4f(1, 1, 1, alpha); - } - glEnable(GL_BLEND); - glBlendFunc(src, GL_ONE_MINUS_SRC_ALPHA); - glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - } else if (noEffect) { - glColor4f(1, 1, 1, 1); - glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - if (needsBlending()) { - glEnable(GL_BLEND); - glBlendFunc(src, GL_ONE_MINUS_SRC_ALPHA); - } else { - glDisable(GL_BLEND); - } - } else { - // Apply a render effect, which is simple color masks for now. - GLenum env, src; - env = GL_MODULATE; - src = mPremultipliedAlpha ? GL_ONE : GL_SRC_ALPHA; - const GGLfixed alpha = (s.alpha << 16)/255; - switch (renderEffect) { - case RENDER_EFFECT_NIGHT: - glColor4x(alpha, alpha*0.6204, alpha*0.3018, alpha); - break; - case RENDER_EFFECT_TERMINAL: - glColor4x(0, alpha, 0, alpha); - break; - case RENDER_EFFECT_BLUE: - glColor4x(0, 0, alpha, alpha); - break; - case RENDER_EFFECT_AMBER: - glColor4x(alpha, alpha*0.75, 0, alpha); - break; - case RENDER_EFFECT_SALMON: - glColor4x(alpha, alpha*0.5, alpha*0.5, alpha); - break; - case RENDER_EFFECT_FUSCIA: - glColor4x(alpha, 0, alpha*0.5, alpha); - break; - case RENDER_EFFECT_N1_CALIBRATED_N: - glColor4x(alpha*renderColorR/1000, alpha*renderColorG/1000, alpha*renderColorB/1000, alpha); - break; - case RENDER_EFFECT_N1_CALIBRATED_R: - glColor4x(alpha*(renderColorR-50)/1000, alpha*renderColorG/1000, alpha*(renderColorB-30)/1000, alpha); - break; - case RENDER_EFFECT_N1_CALIBRATED_C: - glColor4x(alpha*renderColorR/1000, alpha*renderColorG/1000, alpha*(renderColorB+30)/1000, alpha); - break; - case RENDER_EFFECT_RED: - glColor4x(alpha, 0, 0, alpha); - break; - } - glEnable(GL_BLEND); - glBlendFunc(src, GL_ONE_MINUS_SRC_ALPHA); - glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, env); - } - - /* - * compute texture coordinates - * here, we handle NPOT, cropping and buffer transformations - */ - - GLfloat cl, ct, cr, cb; - if (!mBufferCrop.isEmpty()) { - // source is cropped - const GLfloat us = (texture.NPOTAdjust ? texture.wScale : 1.0f) / width; - const GLfloat vs = (texture.NPOTAdjust ? texture.hScale : 1.0f) / height; - cl = mBufferCrop.left * us; - ct = mBufferCrop.top * vs; - cr = mBufferCrop.right * us; - cb = mBufferCrop.bottom * vs; - } else { - cl = 0; - ct = 0; - cr = (texture.NPOTAdjust ? texture.wScale : 1.0f); - cb = (texture.NPOTAdjust ? texture.hScale : 1.0f); - } - - /* - * For the buffer transformation, we apply the rotation last. - * Since we're transforming the texture-coordinates, we need - * to apply the inverse of the buffer transformation: - * inverse( FLIP_V -> FLIP_H -> ROT_90 ) - * <=> inverse( ROT_90 * FLIP_H * FLIP_V ) - * = inverse(FLIP_V) * inverse(FLIP_H) * inverse(ROT_90) - * = FLIP_V * FLIP_H * ROT_270 - * <=> ROT_270 -> FLIP_H -> FLIP_V - * - * The rotation is performed first, in the texture coordinate space. - * - */ - - struct TexCoords { - GLfloat u; - GLfloat v; - }; - - enum { - // name of the corners in the texture map - LB = 0, // left-bottom - LT = 1, // left-top - RT = 2, // right-top - RB = 3 // right-bottom - }; - - // vertices in screen space - int vLT = LB; - int vLB = LT; - int vRB = RT; - int vRT = RB; - - // the texture's source is rotated - uint32_t transform = mBufferTransform; - if (transform & HAL_TRANSFORM_ROT_90) { - vLT = RB; - vLB = LB; - vRB = LT; - vRT = RT; - } - if (transform & HAL_TRANSFORM_FLIP_V) { - swap(vLT, vLB); - swap(vRT, vRB); - } - if (transform & HAL_TRANSFORM_FLIP_H) { - swap(vLT, vRT); - swap(vLB, vRB); - } - - TexCoords texCoords[4]; - texCoords[vLT].u = cl; - texCoords[vLT].v = ct; - texCoords[vLB].u = cl; - texCoords[vLB].v = cb; - texCoords[vRB].u = cr; - texCoords[vRB].v = cb; - texCoords[vRT].u = cr; - texCoords[vRT].v = ct; - - if (needsDithering()) { - glEnable(GL_DITHER); - } else { - glDisable(GL_DITHER); - } - - - /* - * We are using glDrawElements - * - setup variables for the same - */ - GLfloat *pvertices = (GLfloat*) mVertices; - GLfloat *ptexCoords = (GLfloat*) texCoords; - GLubyte indices[] = { LT, LB, RT, RB }; - int numElements = sizeof(indices); - GLubyte *pindices = indices; - - /* - * For Orientation 270/90 use vertical quads to draw - * width limit 16 - */ - - GLubyte *rotIndices = 0; - GLfloat *rotVertices = 0, *rotTexCoords = 0; - int tWidth = mTransformedBounds.right - mTransformedBounds.left; - if (((mOrientation == HAL_TRANSFORM_ROT_90) - || (mOrientation == HAL_TRANSFORM_ROT_270)) - && (tWidth > getQuadWidth()) && !transform) { - - /* - * We divide the texture in vertical quads - * The quads are of width 16 - */ - int quad_width = getQuadWidth(); - - int numQuads = tWidth / quad_width; - if (tWidth % quad_width) - numQuads++; - - numElements = (numQuads + 1) * 2; - /* - * new vertices and texcoords - */ - rotVertices = new GLfloat[numElements * 2]; - rotTexCoords = new GLfloat[numElements * 2]; - - /* - * Indices for GL_TRIANGLE_STRIP - */ - rotIndices = new GLubyte[numElements]; - for (int i = 0; i < numElements; i++) - rotIndices[i] = i; - - /* - * Calculate vertex/texture coords increments - * From left to right - */ - float vIncrement = (float) quad_width; - float tIncrement = 1.0f / (float) numQuads; - - /* - * 90 - (vLB, vLT, vRT, vRB) ==> (LT, RT, LB, RB) - * 270 - (vLB, vLT, vRT, vRB) ==> (RB, LB, RT, LT) - * texture increment is negative for 90 - */ - int vLB = LB; - int vLT = LT; - int vRB = RB; - int vRT = RT; - switch (mOrientation) { - case HAL_TRANSFORM_ROT_90: - { - tIncrement *= -1; - vLB = LT; - vLT = RT; - vRT = LB; - vRB = RB; - break; - } - case HAL_TRANSFORM_ROT_270: - { - vLB = RB; - vLT = LB; - vRT = RT; - vRB = LT; - break; - } - default: - LOGE("DrawWithOpenGL will fail"); - break; - } - - // leftmost vertices - rotVertices[0] = mVertices[vLB][0]; - rotVertices[1] = mVertices[vLB][1]; - rotVertices[2] = mVertices[vLT][0]; - rotVertices[3] = mVertices[vLT][1]; - - // texcoords corresponding to vertices - rotTexCoords[0] = texCoords[vLB].u; - rotTexCoords[1] = texCoords[vLB].v; - rotTexCoords[2] = texCoords[vLT].u; - rotTexCoords[3] = texCoords[vLT].v; - - int vertexIndex = 4; - // Even numbered vertices - for (int i = 0; i < (numQuads -1); i++) { - rotVertices[vertexIndex] = rotVertices[vertexIndex - 4] + vIncrement; - rotVertices[vertexIndex + 1] = rotVertices[vertexIndex - 4 + 1]; - - rotTexCoords[vertexIndex] = rotTexCoords[vertexIndex - 4]; - rotTexCoords[vertexIndex + 1] = rotTexCoords[vertexIndex + 1 - 4] + tIncrement; - vertexIndex += 4; - } - - /* - * last vertices/texcoords, (use RT/RB) - */ - rotVertices[vertexIndex] = mVertices[vRT][0]; - rotVertices[vertexIndex + 1] = mVertices[vRT][1]; - rotTexCoords[vertexIndex] = texCoords[vRT].u; - rotTexCoords[vertexIndex + 1] = texCoords[vRT].v; - - // odd numbered vertices - vertexIndex = 6; - for (int i = 0; i < (numQuads -1); i++) { - rotVertices[vertexIndex] = rotVertices[vertexIndex - 4] + vIncrement; - rotVertices[vertexIndex + 1] = rotVertices[vertexIndex - 4 + 1]; - - rotTexCoords[vertexIndex] = rotTexCoords[vertexIndex - 4]; - rotTexCoords[vertexIndex + 1] = rotTexCoords[vertexIndex + 1 - 4] + tIncrement; - vertexIndex += 4; - } - - /* - * last vertices/texcoords, (use RT/RB) - */ - rotVertices[vertexIndex] = mVertices[vRB][0]; - rotVertices[vertexIndex + 1] = mVertices[vRB][1]; - rotTexCoords[vertexIndex] = texCoords[vRB].u; - rotTexCoords[vertexIndex + 1] = texCoords[vRB].v; - - /* - * change vertex/texcoords/indices pointer - */ - pvertices = rotVertices; - ptexCoords = rotTexCoords; - pindices = rotIndices; - } - - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glVertexPointer(2, GL_FLOAT, 0, pvertices); - glTexCoordPointer(2, GL_FLOAT, 0, ptexCoords); - - 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()); - glDrawElements(GL_TRIANGLE_STRIP, numElements, GL_UNSIGNED_BYTE, pindices); - } - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - - delete[] rotVertices; - delete[] rotTexCoords; - delete[] rotIndices; -} - void LayerBase::setBufferCrop(const Rect& crop) { if (!crop.isEmpty()) { mBufferCrop = crop; diff --git a/services/surfaceflinger/LayerBase.h b/services/surfaceflinger/LayerBase.h index b43d26f..2e1d2ba 100644 --- a/services/surfaceflinger/LayerBase.h +++ b/services/surfaceflinger/LayerBase.h @@ -232,9 +232,6 @@ protected: GLclampf b, GLclampf alpha) const; void clearWithOpenGL(const Region& clip) const; void drawWithOpenGL(const Region& clip, const Texture& texture) const; - void drawWithOpenGLOptimized(const Region& clip, const Texture& texture) const; - enum { QUAD_WIDTH = 16 }; - int getQuadWidth() const { return QUAD_WIDTH; } // these must be called from the post/drawing thread void setBufferCrop(const Rect& crop); |