From c1cd9ba335b293f11e1082447ef08e474710a05f Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Sun, 23 Jan 2011 14:18:41 -0800 Subject: Add support for ovals and stroked rectangles. Change-Id: I1292e241386763c82e6622c8f7ed90b0f5b7bd4f --- libs/hwui/ShapeCache.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'libs/hwui/ShapeCache.cpp') diff --git a/libs/hwui/ShapeCache.cpp b/libs/hwui/ShapeCache.cpp index b78eecba5215..da86075602bc 100644 --- a/libs/hwui/ShapeCache.cpp +++ b/libs/hwui/ShapeCache.cpp @@ -68,5 +68,51 @@ PathTexture* CircleShapeCache::getCircle(float radius, SkPaint* paint) { return texture; } +/////////////////////////////////////////////////////////////////////////////// +// Ovals +/////////////////////////////////////////////////////////////////////////////// + +OvalShapeCache::OvalShapeCache(): ShapeCache( + "oval", PROPERTY_SHAPE_CACHE_SIZE, DEFAULT_SHAPE_CACHE_SIZE) { +} + +PathTexture* OvalShapeCache::getOval(float width, float height, SkPaint* paint) { + OvalShapeCacheEntry entry(width, height, paint); + PathTexture* texture = get(entry); + + if (!texture) { + SkPath path; + SkRect r; + r.set(0.0f, 0.0f, width, height); + path.addOval(r, SkPath::kCW_Direction); + + texture = addTexture(entry, &path, paint); + } + + return texture; +} + +/////////////////////////////////////////////////////////////////////////////// +// Rects +/////////////////////////////////////////////////////////////////////////////// + +RectShapeCache::RectShapeCache(): ShapeCache( + "rect", PROPERTY_SHAPE_CACHE_SIZE, DEFAULT_SHAPE_CACHE_SIZE) { +} + +PathTexture* RectShapeCache::getRect(float width, float height, SkPaint* paint) { + RectShapeCacheEntry entry(width, height, paint); + PathTexture* texture = get(entry); + + if (!texture) { + SkPath path; + path.addRect(0.0f, 0.0f, width, height, SkPath::kCW_Direction); + + texture = addTexture(entry, &path, paint); + } + + return texture; +} + }; // namespace uirenderer }; // namespace android -- cgit v1.2.3-59-g8ed1b