* commit 'cfe5dd01f29acbb7393ffa91bb4b2a8ad43414f2': Yet another fix for 9patch rendering. Bug #3362133
This commit is contained in:
@@ -154,7 +154,8 @@ void Patch::updateVertices(const float bitmapWidth, const float bitmapHeight,
|
|||||||
float y1 = 0.0f;
|
float y1 = 0.0f;
|
||||||
float v1 = 0.0f;
|
float v1 = 0.0f;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < mYCount; i++) {
|
uint32_t i = 0;
|
||||||
|
for ( ; i < mYCount; i++) {
|
||||||
float stepY = mYDivs[i];
|
float stepY = mYDivs[i];
|
||||||
|
|
||||||
float y2 = 0.0f;
|
float y2 = 0.0f;
|
||||||
@@ -166,7 +167,8 @@ void Patch::updateVertices(const float bitmapWidth, const float bitmapHeight,
|
|||||||
}
|
}
|
||||||
float v2 = fmax(0.0f, stepY - 0.5f) / bitmapHeight;
|
float v2 = fmax(0.0f, stepY - 0.5f) / bitmapHeight;
|
||||||
|
|
||||||
generateRow(vertex, y1, y2, v1, v2, stretchX, right - left, bitmapWidth, quadCount);
|
generateRow(vertex, y1, y2, v1, v2, stretchX, right - left,
|
||||||
|
bitmapWidth, quadCount, i & 1);
|
||||||
|
|
||||||
y1 = y2;
|
y1 = y2;
|
||||||
v1 = (stepY + 0.5f) / bitmapHeight;
|
v1 = (stepY + 0.5f) / bitmapHeight;
|
||||||
@@ -175,7 +177,7 @@ void Patch::updateVertices(const float bitmapWidth, const float bitmapHeight,
|
|||||||
}
|
}
|
||||||
|
|
||||||
generateRow(vertex, y1, bottom - top, v1, 1.0f, stretchX, right - left,
|
generateRow(vertex, y1, bottom - top, v1, 1.0f, stretchX, right - left,
|
||||||
bitmapWidth, quadCount);
|
bitmapWidth, quadCount, i & 1);
|
||||||
|
|
||||||
if (verticesCount > 0) {
|
if (verticesCount > 0) {
|
||||||
Caches::getInstance().bindMeshBuffer(meshBuffer);
|
Caches::getInstance().bindMeshBuffer(meshBuffer);
|
||||||
@@ -193,14 +195,15 @@ void Patch::updateVertices(const float bitmapWidth, const float bitmapHeight,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Patch::generateRow(TextureVertex*& vertex, float y1, float y2, float v1, float v2,
|
void Patch::generateRow(TextureVertex*& vertex, float y1, float y2, float v1, float v2,
|
||||||
float stretchX, float width, float bitmapWidth, uint32_t& quadCount) {
|
float stretchX, float width, float bitmapWidth, uint32_t& quadCount, bool isStretch) {
|
||||||
float previousStepX = 0.0f;
|
float previousStepX = 0.0f;
|
||||||
|
|
||||||
float x1 = 0.0f;
|
float x1 = 0.0f;
|
||||||
float u1 = 0.0f;
|
float u1 = 0.0f;
|
||||||
|
|
||||||
// Generate the row quad by quad
|
// Generate the row quad by quad
|
||||||
for (uint32_t i = 0; i < mXCount; i++) {
|
uint32_t i = 0;
|
||||||
|
for ( ; i < mXCount; i++) {
|
||||||
float stepX = mXDivs[i];
|
float stepX = mXDivs[i];
|
||||||
|
|
||||||
float x2 = 0.0f;
|
float x2 = 0.0f;
|
||||||
@@ -212,7 +215,7 @@ void Patch::generateRow(TextureVertex*& vertex, float y1, float y2, float v1, fl
|
|||||||
}
|
}
|
||||||
float u2 = fmax(0.0f, stepX - 0.5f) / bitmapWidth;
|
float u2 = fmax(0.0f, stepX - 0.5f) / bitmapWidth;
|
||||||
|
|
||||||
bool valid = generateQuad(vertex, x1, y1, x2, y2, u1, v1, u2, v2, quadCount);
|
generateQuad(vertex, x1, y1, x2, y2, u1, v1, u2, v2, quadCount, isStretch || (i & 1));
|
||||||
|
|
||||||
x1 = x2;
|
x1 = x2;
|
||||||
u1 = (stepX + 0.5f) / bitmapWidth;
|
u1 = (stepX + 0.5f) / bitmapWidth;
|
||||||
@@ -220,13 +223,13 @@ void Patch::generateRow(TextureVertex*& vertex, float y1, float y2, float v1, fl
|
|||||||
previousStepX = stepX;
|
previousStepX = stepX;
|
||||||
}
|
}
|
||||||
|
|
||||||
generateQuad(vertex, x1, y1, width, y2, u1, v1, 1.0f, v2, quadCount);
|
generateQuad(vertex, x1, y1, width, y2, u1, v1, 1.0f, v2, quadCount, isStretch || (i & 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Patch::generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, float y2,
|
void Patch::generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, float y2,
|
||||||
float u1, float v1, float u2, float v2, uint32_t& quadCount) {
|
float u1, float v1, float u2, float v2, uint32_t& quadCount, bool isStretch) {
|
||||||
const uint32_t oldQuadCount = quadCount;
|
const uint32_t oldQuadCount = quadCount;
|
||||||
const bool valid = x2 >= x1 && y2 >= y1;
|
const bool valid = isStretch || (x2 - x1 > 0.9999f && y2 - y1 > 0.9999f);
|
||||||
if (valid) {
|
if (valid) {
|
||||||
quadCount++;
|
quadCount++;
|
||||||
}
|
}
|
||||||
@@ -238,7 +241,7 @@ bool Patch::generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, f
|
|||||||
PATCH_LOGD(" left, top = %.2f, %.2f\t\tu1, v1 = %.2f, %.2f", x1, y1, u1, v1);
|
PATCH_LOGD(" left, top = %.2f, %.2f\t\tu1, v1 = %.2f, %.2f", x1, y1, u1, v1);
|
||||||
PATCH_LOGD(" right, bottom = %.2f, %.2f\t\tu2, v2 = %.2f, %.2f", x2, y2, u2, v2);
|
PATCH_LOGD(" right, bottom = %.2f, %.2f\t\tu2, v2 = %.2f, %.2f", x2, y2, u2, v2);
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if RENDER_LAYERS_AS_REGIONS
|
#if RENDER_LAYERS_AS_REGIONS
|
||||||
@@ -267,8 +270,6 @@ bool Patch::generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, f
|
|||||||
PATCH_LOGD(" left, top = %.2f, %.2f\t\tu1, v1 = %.2f, %.2f", x1, y1, u1, v1);
|
PATCH_LOGD(" left, top = %.2f, %.2f\t\tu1, v1 = %.2f, %.2f", x1, y1, u1, v1);
|
||||||
PATCH_LOGD(" right, bottom = %.2f, %.2f\t\tu2, v2 = %.2f, %.2f", x2, y2, u2, v2);
|
PATCH_LOGD(" right, bottom = %.2f, %.2f\t\tu2, v2 = %.2f, %.2f", x2, y2, u2, v2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // namespace uirenderer
|
}; // namespace uirenderer
|
||||||
|
|||||||
@@ -70,11 +70,11 @@ private:
|
|||||||
|
|
||||||
void generateRow(TextureVertex*& vertex, float y1, float y2,
|
void generateRow(TextureVertex*& vertex, float y1, float y2,
|
||||||
float v1, float v2, float stretchX, float width, float bitmapWidth,
|
float v1, float v2, float stretchX, float width, float bitmapWidth,
|
||||||
uint32_t& quadCount);
|
uint32_t& quadCount, bool isStretch);
|
||||||
bool generateQuad(TextureVertex*& vertex,
|
void generateQuad(TextureVertex*& vertex,
|
||||||
float x1, float y1, float x2, float y2,
|
float x1, float y1, float x2, float y2,
|
||||||
float u1, float v1, float u2, float v2,
|
float u1, float v1, float u2, float v2,
|
||||||
uint32_t& quadCount);
|
uint32_t& quadCount, bool isStretch);
|
||||||
}; // struct Patch
|
}; // struct Patch
|
||||||
|
|
||||||
}; // namespace uirenderer
|
}; // namespace uirenderer
|
||||||
|
|||||||
Reference in New Issue
Block a user