diff options
| -rw-r--r-- | libs/hwui/Patch.cpp | 33 | ||||
| -rw-r--r-- | tests/HwAccelerationTest/res/drawable-nodpi/appwidget_bg.9.png (renamed from tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg.9.png) | bin | 1694 -> 1694 bytes | |||
| -rw-r--r-- | tests/HwAccelerationTest/res/drawable-nodpi/appwidget_bg_focus.9.png (renamed from tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_focus.9.png) | bin | 1910 -> 1910 bytes | |||
| -rw-r--r-- | tests/HwAccelerationTest/res/drawable-nodpi/appwidget_bg_press.9.png (renamed from tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_press.9.png) | bin | 1908 -> 1908 bytes | |||
| -rw-r--r-- | tests/HwAccelerationTest/res/drawable-nodpi/green_gradient.9.png (renamed from tests/HwAccelerationTest/res/drawable-hdpi/green_gradient.9.png) | bin | 1239 -> 1239 bytes | |||
| -rw-r--r-- | tests/HwAccelerationTest/res/drawable-nodpi/patch.9.png (renamed from tests/HwAccelerationTest/res/drawable-hdpi/patch.9.png) | bin | 2863 -> 2863 bytes | |||
| -rw-r--r-- | tests/HwAccelerationTest/res/drawable-nodpi/patch2.9.png | bin | 0 -> 2825 bytes | |||
| -rw-r--r-- | tests/HwAccelerationTest/res/drawable-nodpi/widget_title_bg.9.png (renamed from tests/HwAccelerationTest/res/drawable-hdpi/widget_title_bg.9.png) | bin | 1429 -> 1429 bytes | |||
| -rw-r--r-- | tests/HwAccelerationTest/src/com/android/test/hwui/ThinPatchesActivity.java | 11 |
9 files changed, 29 insertions, 15 deletions
diff --git a/libs/hwui/Patch.cpp b/libs/hwui/Patch.cpp index f7dacaea1c3f..47a2c99dd60a 100644 --- a/libs/hwui/Patch.cpp +++ b/libs/hwui/Patch.cpp @@ -157,14 +157,17 @@ void Patch::updateVertices(const float bitmapWidth, const float bitmapHeight, for (uint32_t i = 0; i < mYCount; i++) { float stepY = mYDivs[i]; + const float segment = stepY - previousStepY; if (i & 1) { - const float segment = stepY - previousStepY; y2 = y1 + floorf(segment * stretchY + 0.5f); } else { - y2 = y1 + stepY - previousStepY; + y2 = y1 + segment; } - float v2 = fmax(0.0f, stepY - 0.5f) / bitmapHeight; + + float vOffset = y1 == y2 ? 0.0f : 0.5 - (0.5 * segment / (y2 - y1)); + float v2 = fmax(0.0f, stepY - vOffset) / bitmapHeight; + v1 += vOffset / bitmapHeight; if (stepY > 0.0f) { #if DEBUG_EXPLODE_PATCHES @@ -179,7 +182,7 @@ void Patch::updateVertices(const float bitmapWidth, const float bitmapHeight, } y1 = y2; - v1 = (stepY + 0.5f) / bitmapHeight; + v1 = stepY / bitmapHeight; previousStepY = stepY; } @@ -190,8 +193,7 @@ void Patch::updateVertices(const float bitmapWidth, const float bitmapHeight, y1 += mYCount * EXPLODE_GAP; y2 += mYCount * EXPLODE_GAP; #endif - generateRow(vertex, y1, y2, v1, 1.0f, stretchX, right - left, - bitmapWidth, quadCount); + generateRow(vertex, y1, y2, v1, 1.0f, stretchX, right - left, bitmapWidth, quadCount); } if (verticesCount > 0) { @@ -220,14 +222,17 @@ void Patch::generateRow(TextureVertex*& vertex, float y1, float y2, float v1, fl // Generate the row quad by quad for (uint32_t i = 0; i < mXCount; i++) { float stepX = mXDivs[i]; + const float segment = stepX - previousStepX; if (i & 1) { - const float segment = stepX - previousStepX; x2 = x1 + floorf(segment * stretchX + 0.5f); } else { - x2 = x1 + stepX - previousStepX; + x2 = x1 + segment; } - float u2 = fmax(0.0f, stepX - 0.5f) / bitmapWidth; + + float uOffset = x1 == x2 ? 0.0f : 0.5 - (0.5 * segment / (x2 - x1)); + float u2 = fmax(0.0f, stepX - uOffset) / bitmapWidth; + u1 += uOffset / bitmapWidth; if (stepX > 0.0f) { #if DEBUG_EXPLODE_PATCHES @@ -241,7 +246,7 @@ void Patch::generateRow(TextureVertex*& vertex, float y1, float y2, float v1, fl } x1 = x2; - u1 = (stepX + 0.5f) / bitmapWidth; + u1 = stepX / bitmapWidth; previousStepX = stepX; } @@ -265,8 +270,8 @@ void Patch::generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, f if ((mColorKey >> oldQuadCount) & 0x1) { #if DEBUG_PATCHES_EMPTY_VERTICES PATCH_LOGD(" quad %d (empty)", oldQuadCount); - 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(" left, top = %.2f, %.2f\t\tu1, v1 = %.4f, %.4f", x1, y1, u1, v1); + PATCH_LOGD(" right, bottom = %.2f, %.2f\t\tu2, v2 = %.4f, %.4f", x2, y2, u2, v2); #endif return; } @@ -294,8 +299,8 @@ void Patch::generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, f #if DEBUG_PATCHES_VERTICES PATCH_LOGD(" quad %d", oldQuadCount); - 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(" left, top = %.2f, %.2f\t\tu1, v1 = %.4f, %.4f", x1, y1, u1, v1); + PATCH_LOGD(" right, bottom = %.2f, %.2f\t\tu2, v2 = %.4f, %.4f", x2, y2, u2, v2); #endif } diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg.9.png b/tests/HwAccelerationTest/res/drawable-nodpi/appwidget_bg.9.png Binary files differindex 80491912d80b..80491912d80b 100644 --- a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg.9.png +++ b/tests/HwAccelerationTest/res/drawable-nodpi/appwidget_bg.9.png diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_focus.9.png b/tests/HwAccelerationTest/res/drawable-nodpi/appwidget_bg_focus.9.png Binary files differindex c81f67582110..c81f67582110 100644 --- a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_focus.9.png +++ b/tests/HwAccelerationTest/res/drawable-nodpi/appwidget_bg_focus.9.png diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_press.9.png b/tests/HwAccelerationTest/res/drawable-nodpi/appwidget_bg_press.9.png Binary files differindex d060b77556bb..d060b77556bb 100644 --- a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_press.9.png +++ b/tests/HwAccelerationTest/res/drawable-nodpi/appwidget_bg_press.9.png diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/green_gradient.9.png b/tests/HwAccelerationTest/res/drawable-nodpi/green_gradient.9.png Binary files differindex a535678ab531..a535678ab531 100644 --- a/tests/HwAccelerationTest/res/drawable-hdpi/green_gradient.9.png +++ b/tests/HwAccelerationTest/res/drawable-nodpi/green_gradient.9.png diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/patch.9.png b/tests/HwAccelerationTest/res/drawable-nodpi/patch.9.png Binary files differindex e3b3639e86f2..e3b3639e86f2 100644 --- a/tests/HwAccelerationTest/res/drawable-hdpi/patch.9.png +++ b/tests/HwAccelerationTest/res/drawable-nodpi/patch.9.png diff --git a/tests/HwAccelerationTest/res/drawable-nodpi/patch2.9.png b/tests/HwAccelerationTest/res/drawable-nodpi/patch2.9.png Binary files differnew file mode 100644 index 000000000000..f65a35592cd4 --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable-nodpi/patch2.9.png diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/widget_title_bg.9.png b/tests/HwAccelerationTest/res/drawable-nodpi/widget_title_bg.9.png Binary files differindex 79615c237ffe..79615c237ffe 100644 --- a/tests/HwAccelerationTest/res/drawable-hdpi/widget_title_bg.9.png +++ b/tests/HwAccelerationTest/res/drawable-nodpi/widget_title_bg.9.png diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ThinPatchesActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ThinPatchesActivity.java index cfad6daf0335..656f2b143654 100644 --- a/tests/HwAccelerationTest/src/com/android/test/hwui/ThinPatchesActivity.java +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ThinPatchesActivity.java @@ -44,7 +44,7 @@ public class ThinPatchesActivity extends Activity { } private class PatchView extends View { - private Drawable mPatch1, mPatch2; + private Drawable mPatch1, mPatch2, mPatch3; private Bitmap mTexture; public PatchView(Activity activity) { @@ -53,6 +53,7 @@ public class ThinPatchesActivity extends Activity { final Resources resources = activity.getResources(); mPatch1 = resources.getDrawable(R.drawable.patch); mPatch2 = resources.getDrawable(R.drawable.btn_toggle_on); + mPatch3 = resources.getDrawable(R.drawable.patch2); mTexture = Bitmap.createBitmap(4, 3, Bitmap.Config.ARGB_8888); mTexture.setPixel(0, 0, 0xffff0000); @@ -77,6 +78,14 @@ public class ThinPatchesActivity extends Activity { final int left = (getWidth() - width) / 2; final int top = (getHeight() - height) / 2; + canvas.save(); + canvas.translate(0.0f, -height * 2 - 20.0f); + + mPatch3.setBounds(left, top, left + height, top + width); + mPatch3.draw(canvas); + + canvas.restore(); + mPatch1.setBounds(left, top, left + width, top + height); mPatch1.draw(canvas); |