diff options
author | Romain Guy <romainguy@google.com> | 2010-12-07 13:30:10 -0800 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2010-12-07 13:30:10 -0800 |
commit | 8ab4079ca27e36e5c584495bcd71b573598ac021 (patch) | |
tree | 80b5dca2e6ad9cf75a7215109575a9c2d927b278 /libs | |
parent | 3a3fa1be9ab8e11edc660ecb35ae21ae0b5c8cc2 (diff) | |
download | frameworks_base-8ab4079ca27e36e5c584495bcd71b573598ac021.zip frameworks_base-8ab4079ca27e36e5c584495bcd71b573598ac021.tar.gz frameworks_base-8ab4079ca27e36e5c584495bcd71b573598ac021.tar.bz2 |
Fix 9patch rendering
Bug #3253396
Some quads were incorrectly assumed to be degenerate.
Change-Id: I9155699edc3424afe9d5a131886bb9966d46b109
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/Patch.cpp | 8 | ||||
-rw-r--r-- | libs/hwui/Patch.h | 2 |
3 files changed, 6 insertions, 8 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index fc14777..1a89ca0 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -954,11 +954,11 @@ void OpenGLRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int mSnapshot->region && mesh->hasEmptyQuads) { const size_t count = mesh->quads.size(); for (size_t i = 0; i < count; i++) { - Rect bounds = mesh->quads.itemAt(i); + const Rect& bounds = mesh->quads.itemAt(i); if (pureTranslate) { const float x = (int) floorf(bounds.left + 0.5f); const float y = (int) floorf(bounds.top + 0.5f); - dirtyLayer(x, y, x + bounds.getWidth(), y + bounds.getBottom(), + dirtyLayer(x, y, x + bounds.getWidth(), y + bounds.getHeight(), *mSnapshot->transform); } else { dirtyLayer(bounds.left, bounds.top, bounds.right, bounds.bottom, diff --git a/libs/hwui/Patch.cpp b/libs/hwui/Patch.cpp index 17b1d86..e5cb67b 100644 --- a/libs/hwui/Patch.cpp +++ b/libs/hwui/Patch.cpp @@ -35,7 +35,7 @@ Patch::Patch(const uint32_t xCount, const uint32_t yCount, const int8_t emptyQua mXCount(xCount), mYCount(yCount), mEmptyQuads(emptyQuads) { // Initialized with the maximum number of vertices we will need // 2 triangles per patch, 3 vertices per triangle - const int maxVertices = ((xCount + 1) * (yCount + 1) - emptyQuads) * 2 * 3; + uint32_t maxVertices = ((xCount + 1) * (yCount + 1) - emptyQuads) * 2 * 3; mVertices = new TextureVertex[maxVertices]; mUploaded = false; @@ -160,7 +160,7 @@ void Patch::updateVertices(const float bitmapWidth, const float bitmapHeight, float y2 = 0.0f; if (i & 1) { const float segment = stepY - previousStepY; - y2 = y1 + segment * stretchY; + y2 = y1 + floorf(segment * stretchY + 0.5f); } else { y2 = y1 + stepY - previousStepY; } @@ -206,7 +206,7 @@ void Patch::generateRow(TextureVertex*& vertex, float y1, float y2, float v1, fl float x2 = 0.0f; if (i & 1) { const float segment = stepX - previousStepX; - x2 = x1 + segment * stretchX; + x2 = x1 + floorf(segment * stretchX + 0.5f); } else { x2 = x1 + stepX - previousStepX; } @@ -226,7 +226,7 @@ void Patch::generateRow(TextureVertex*& vertex, float y1, float y2, float v1, fl void Patch::generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, float y2, float u1, float v1, float u2, float v2, uint32_t& quadCount) { const uint32_t oldQuadCount = quadCount; - const bool valid = fabs(x2 - x1) > 0.9999f && fabs(y2 - y1) > 0.9999f; + const bool valid = x2 - x1 > 0.9999f && y2 - y1 > 0.9999f; if (valid) { quadCount++; } diff --git a/libs/hwui/Patch.h b/libs/hwui/Patch.h index 16ad86d..0f0ffa2 100644 --- a/libs/hwui/Patch.h +++ b/libs/hwui/Patch.h @@ -52,9 +52,7 @@ struct Patch { GLuint meshBuffer; uint32_t verticesCount; bool hasEmptyQuads; -#if RENDER_LAYERS_AS_REGIONS Vector<Rect> quads; -#endif private: TextureVertex* mVertices; |