summaryrefslogtreecommitdiff
path: root/libs/hwui/ShapeCache.cpp
diff options
context:
space:
mode:
author Romain Guy <romainguy@google.com> 2011-01-23 16:15:02 -0800
committer Romain Guy <romainguy@google.com> 2011-01-23 16:15:02 -0800
commit8b2f5267f16c295f12faab810527cd6311997e34 (patch)
tree2f81ab177ebfadee474c44f3aa8e44cdc539665e /libs/hwui/ShapeCache.cpp
parentc1cd9ba335b293f11e1082447ef08e474710a05f (diff)
Add support for arcs.
Change-Id: I96c057ff4eb1b464b03f132da0b85333777bee4f
Diffstat (limited to 'libs/hwui/ShapeCache.cpp')
-rw-r--r--libs/hwui/ShapeCache.cpp31
1 files changed, 31 insertions, 0 deletions
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<ArcShapeCacheEntry>(
+ "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