diff options
| author | 2010-08-18 11:47:12 -0700 | |
|---|---|---|
| committer | 2010-08-18 11:47:12 -0700 | |
| commit | 2542d199745cdf3ec910b8e3e4cff5851ed24e9b (patch) | |
| tree | b0628a20db972e570e5781a957a2747dc3a3c16a /libs/hwui/OpenGLRenderer.cpp | |
| parent | a8031c68c8e7ac5b1edfff2b6d03e3b46ec38a9d (diff) | |
Layers were using an extra Snapshot causing extra clipping.
Bug #2919310
Change-Id: I72ccd44bba7a3f3db72f581aa96198b6226e4478
Diffstat (limited to 'libs/hwui/OpenGLRenderer.cpp')
| -rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 58 |
1 files changed, 23 insertions, 35 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 35e17bfb4a9e..01e5a2a0ac23 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -219,22 +219,16 @@ int OpenGLRenderer::save(int flags) { } void OpenGLRenderer::restore() { - if (mSaveCount > 1 && restoreSnapshot()) { - setScissorFromClip(); + if (mSaveCount > 1) { + restoreSnapshot(); } } void OpenGLRenderer::restoreToCount(int saveCount) { if (saveCount < 1) saveCount = 1; - bool restoreClip = false; - while (mSaveCount > saveCount) { - restoreClip |= restoreSnapshot(); - } - - if (restoreClip) { - setScissorFromClip(); + restoreSnapshot(); } } @@ -267,12 +261,11 @@ bool OpenGLRenderer::restoreSnapshot() { } mSnapshot = previous; - if (!skip) { - return restoreClip; - } else { - bool restorePreviousClip = restoreSnapshot(); - return restoreClip || restorePreviousClip; + if (restoreClip) { + setScissorFromClip(); } + + return restoreClip; } /////////////////////////////////////////////////////////////////////////////// @@ -339,21 +332,15 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top, snapshot->layer = layer; snapshot->fbo = layer->fbo; - // Creates a new snapshot to draw into the FBO - saveSnapshot(); - mSaveCount--; - - mSnapshot->skip = true; - mSnapshot->transform.loadTranslate(-left, -top, 0.0f); - mSnapshot->setClip(0.0f, 0.0f, right - left, bottom - top); - mSnapshot->viewport.set(0.0f, 0.0f, right - left, bottom - top); - mSnapshot->height = bottom - top; + snapshot->transform.loadTranslate(-left, -top, 0.0f); + snapshot->setClip(0.0f, 0.0f, right - left, bottom - top); + snapshot->viewport.set(0.0f, 0.0f, right - left, bottom - top); + snapshot->height = bottom - top; + snapshot->flags |= Snapshot::kFlagDirtyOrtho; + snapshot->orthoMatrix.load(mOrthoMatrix); setScissorFromClip(); - mSnapshot->flags = Snapshot::kFlagDirtyOrtho | Snapshot::kFlagClipSet; - mSnapshot->orthoMatrix.load(mOrthoMatrix); - // Change the ortho projection glViewport(0, 0, right - left, bottom - top); // Don't flip the FBO, it will get flipped when drawing back to the framebuffer @@ -594,6 +581,12 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, SkXfermode::Mode mode; getAlphaAndMode(paint, &alpha, &mode); + uint32_t color = paint->getColor(); + const GLfloat a = alpha / 255.0f; + const GLfloat r = a * ((color >> 16) & 0xFF) / 255.0f; + const GLfloat g = a * ((color >> 8) & 0xFF) / 255.0f; + const GLfloat b = a * ((color ) & 0xFF) / 255.0f; + mFontRenderer.setFont(paint, SkTypeface::UniqueID(paint->getTypeface()), paint->getTextSize()); if (mHasShadow) { glActiveTexture(gTextureUnits[0]); @@ -601,19 +594,13 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, count, mShadowRadius); const AutoTexture autoCleanup(shadow); - setupShadow(shadow, x, y, mode); + setupShadow(shadow, x, y, mode, a); // Draw the mesh glDrawArrays(GL_TRIANGLE_STRIP, 0, gMeshCount); glDisableVertexAttribArray(mCurrentProgram->getAttrib("texCoords")); } - uint32_t color = paint->getColor(); - const GLfloat a = alpha / 255.0f; - const GLfloat r = a * ((color >> 16) & 0xFF) / 255.0f; - const GLfloat g = a * ((color >> 8) & 0xFF) / 255.0f; - const GLfloat b = a * ((color ) & 0xFF) / 255.0f; - GLuint textureUnit = 0; glActiveTexture(gTextureUnits[textureUnit]); @@ -705,11 +692,12 @@ void OpenGLRenderer::setupShadow(float radius, float dx, float dy, int color) { /////////////////////////////////////////////////////////////////////////////// void OpenGLRenderer::setupShadow(const ShadowTexture* texture, float x, float y, - SkXfermode::Mode mode) { + SkXfermode::Mode mode, float alpha) { const float sx = x - texture->left + mShadowDx; const float sy = y - texture->top + mShadowDy; - const GLfloat a = ((mShadowColor >> 24) & 0xFF) / 255.0f; + const int shadowAlpha = ((mShadowColor >> 24) & 0xFF); + const GLfloat a = shadowAlpha < 255 ? shadowAlpha / 255.0f : alpha; const GLfloat r = a * ((mShadowColor >> 16) & 0xFF) / 255.0f; const GLfloat g = a * ((mShadowColor >> 8) & 0xFF) / 255.0f; const GLfloat b = a * ((mShadowColor ) & 0xFF) / 255.0f; |