From 8b2f5267f16c295f12faab810527cd6311997e34 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Sun, 23 Jan 2011 16:15:02 -0800 Subject: Add support for arcs. Change-Id: I96c057ff4eb1b464b03f132da0b85333777bee4f --- libs/hwui/ShapeCache.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'libs/hwui/ShapeCache.cpp') diff --git a/libs/hwui/ShapeCache.cpp b/libs/hwui/ShapeCache.cpp index da86075602bc..0d7cd9cb9a72 100644 --- a/libs/hwui/ShapeCache.cpp +++ b/libs/hwui/ShapeCache.cpp @@ -114,5 +114,36 @@ PathTexture* RectShapeCache::getRect(float width, float height, SkPaint* paint) return texture; } +/////////////////////////////////////////////////////////////////////////////// +// Arcs +/////////////////////////////////////////////////////////////////////////////// + +ArcShapeCache::ArcShapeCache(): ShapeCache( + "arc", PROPERTY_SHAPE_CACHE_SIZE, DEFAULT_SHAPE_CACHE_SIZE) { +} + +PathTexture* ArcShapeCache::getArc(float width, float height, + float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) { + ArcShapeCacheEntry entry(width, height, startAngle, sweepAngle, useCenter, paint); + PathTexture* texture = get(entry); + + if (!texture) { + SkPath path; + SkRect r; + r.set(0.0f, 0.0f, width, height); + if (useCenter) { + path.moveTo(r.centerX(), r.centerY()); + } + path.arcTo(r, startAngle, sweepAngle, !useCenter); + if (useCenter) { + path.close(); + } + + texture = addTexture(entry, &path, paint); + } + + return texture; +} + }; // namespace uirenderer }; // namespace android -- cgit v1.2.3-59-g8ed1b