summaryrefslogtreecommitdiff
path: root/libs/hwui/ShapeCache.cpp
diff options
context:
space:
mode:
author Romain Guy <romainguy@google.com> 2012-04-27 11:47:13 -0700
committer Romain Guy <romainguy@google.com> 2012-04-27 11:47:13 -0700
commitfdd6fc1beb5076a630c7066b8b1731995636c09f (patch)
tree8df0ddc48fda9ffb9015e3fb190e68ca806646d4 /libs/hwui/ShapeCache.cpp
parenta44a63ac5c29b2cc57df95ec495def8cdddd9c6f (diff)
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
Diffstat (limited to 'libs/hwui/ShapeCache.cpp')
-rw-r--r--libs/hwui/ShapeCache.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/libs/hwui/ShapeCache.cpp b/libs/hwui/ShapeCache.cpp
index 0d7cd9cb9a72..5a23235f7241 100644
--- a/libs/hwui/ShapeCache.cpp
+++ b/libs/hwui/ShapeCache.cpp
@@ -105,10 +105,29 @@ PathTexture* RectShapeCache::getRect(float width, float height, SkPaint* paint)
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;