Work-around for a Skia rasterization bug
Bug #6411457
Skia does not generates the bottom right pixel of a rect when
drawing a rect as an SkPath into an alpha8 bitmap.
Change-Id: Ifb5286ae67745c9e44ee387b6d6ad607a9a2e6ce
diff --git a/libs/hwui/ShapeCache.cpp b/libs/hwui/ShapeCache.cpp
index 0d7cd9c..5a23235 100644
--- a/libs/hwui/ShapeCache.cpp
+++ b/libs/hwui/ShapeCache.cpp
@@ -105,10 +105,29 @@
PathTexture* texture = get(entry);
if (!texture) {
- SkPath path;
- path.addRect(0.0f, 0.0f, width, height, SkPath::kCW_Direction);
+ SkRect bounds;
+ bounds.set(0.0f, 0.0f, width, height);
- texture = addTexture(entry, &path, paint);
+ float left, top, offset;
+ uint32_t rectWidth, rectHeight;
+ computeBounds(bounds, paint, left, top, offset, rectWidth, rectHeight);
+
+ if (!checkTextureSize(rectWidth, rectHeight)) return NULL;
+
+ purgeCache(rectWidth, rectHeight);
+
+ SkBitmap bitmap;
+ initBitmap(bitmap, rectWidth, rectHeight);
+
+ SkPaint pathPaint(*paint);
+ initPaint(pathPaint);
+
+ SkCanvas canvas(bitmap);
+ canvas.translate(-left + offset, -top + offset);
+ canvas.drawRect(bounds, pathPaint);
+
+ texture = createTexture(0, 0, offset, rectWidth, rectHeight, 0);
+ addTexture(entry, &bitmap, texture);
}
return texture;