summaryrefslogtreecommitdiff
path: root/libs/hwui/ShapeCache.h
diff options
context:
space:
mode:
author Romain Guy <romainguy@google.com> 2011-01-23 14:18:41 -0800
committer Romain Guy <romainguy@google.com> 2011-01-23 14:18:41 -0800
commitc1cd9ba335b293f11e1082447ef08e474710a05f (patch)
tree3f07bf1887e0cd5602c2f1e356e3efe92d7f766b /libs/hwui/ShapeCache.h
parentf6834478b379856d3e5de92ddce7de0e6ba9fa4a (diff)
Add support for ovals and stroked rectangles.
Change-Id: I1292e241386763c82e6622c8f7ed90b0f5b7bd4f
Diffstat (limited to 'libs/hwui/ShapeCache.h')
-rw-r--r--libs/hwui/ShapeCache.h80
1 files changed, 79 insertions, 1 deletions
diff --git a/libs/hwui/ShapeCache.h b/libs/hwui/ShapeCache.h
index c62793180838..a4aff9df117c 100644
--- a/libs/hwui/ShapeCache.h
+++ b/libs/hwui/ShapeCache.h
@@ -76,6 +76,7 @@ struct PathTexture: public Texture {
struct ShapeCacheEntry {
enum ShapeType {
kShapeNone,
+ kShapeRect,
kShapeRoundRect,
kShapeCircle,
kShapeOval,
@@ -216,6 +217,70 @@ private:
uint32_t mRadius;
}; // CircleShapeCacheEntry
+struct OvalShapeCacheEntry: public ShapeCacheEntry {
+ OvalShapeCacheEntry(float width, float height, SkPaint* paint):
+ ShapeCacheEntry(ShapeCacheEntry::kShapeOval, paint) {
+ mWidth = *(uint32_t*) &width;
+ mHeight = *(uint32_t*) &height;
+ }
+
+ OvalShapeCacheEntry(): ShapeCacheEntry() {
+ mWidth = mHeight = 0;
+ }
+
+ OvalShapeCacheEntry(const OvalShapeCacheEntry& entry):
+ ShapeCacheEntry(entry) {
+ mWidth = entry.mWidth;
+ mHeight = entry.mHeight;
+ }
+
+ bool lessThan(const ShapeCacheEntry& r) const {
+ const OvalShapeCacheEntry& rhs = (const OvalShapeCacheEntry&) r;
+ LTE_INT(mWidth) {
+ LTE_INT(mHeight) {
+ return false;
+ }
+ }
+ return false;
+ }
+
+private:
+ uint32_t mWidth;
+ uint32_t mHeight;
+}; // OvalShapeCacheEntry
+
+struct RectShapeCacheEntry: public ShapeCacheEntry {
+ RectShapeCacheEntry(float width, float height, SkPaint* paint):
+ ShapeCacheEntry(ShapeCacheEntry::kShapeRect, paint) {
+ mWidth = *(uint32_t*) &width;
+ mHeight = *(uint32_t*) &height;
+ }
+
+ RectShapeCacheEntry(): ShapeCacheEntry() {
+ mWidth = mHeight = 0;
+ }
+
+ RectShapeCacheEntry(const RectShapeCacheEntry& entry):
+ ShapeCacheEntry(entry) {
+ mWidth = entry.mWidth;
+ mHeight = entry.mHeight;
+ }
+
+ bool lessThan(const ShapeCacheEntry& r) const {
+ const RectShapeCacheEntry& rhs = (const RectShapeCacheEntry&) r;
+ LTE_INT(mWidth) {
+ LTE_INT(mHeight) {
+ return false;
+ }
+ }
+ return false;
+ }
+
+private:
+ uint32_t mWidth;
+ uint32_t mHeight;
+}; // RectShapeCacheEntry
+
/**
* A simple LRU shape cache. The cache has a maximum size expressed in bytes.
* Any texture added to the cache causing the cache to grow beyond the maximum
@@ -289,8 +354,21 @@ public:
CircleShapeCache();
PathTexture* getCircle(float radius, SkPaint* paint);
-}; // class RoundRectShapeCache
+}; // class CircleShapeCache
+
+class OvalShapeCache: public ShapeCache<OvalShapeCacheEntry> {
+public:
+ OvalShapeCache();
+
+ PathTexture* getOval(float width, float height, SkPaint* paint);
+}; // class OvalShapeCache
+
+class RectShapeCache: public ShapeCache<RectShapeCacheEntry> {
+public:
+ RectShapeCache();
+ PathTexture* getRect(float width, float height, SkPaint* paint);
+}; // class RectShapeCache
///////////////////////////////////////////////////////////////////////////////
// Constructors/destructor