Fix 9patch rendering
Bug #3253396
Some quads were incorrectly assumed to be degenerate.
Change-Id: I9155699edc3424afe9d5a131886bb9966d46b109
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 @@
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 @@
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 @@
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::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++;
}