diff options
Diffstat (limited to 'libs/hwui/ShapeCache.h')
| -rw-r--r-- | libs/hwui/ShapeCache.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/libs/hwui/ShapeCache.h b/libs/hwui/ShapeCache.h index a4aff9df117c..e53546605f13 100644 --- a/libs/hwui/ShapeCache.h +++ b/libs/hwui/ShapeCache.h @@ -281,6 +281,58 @@ private: uint32_t mHeight; }; // RectShapeCacheEntry +struct ArcShapeCacheEntry: public ShapeCacheEntry { + ArcShapeCacheEntry(float width, float height, float startAngle, float sweepAngle, + bool useCenter, SkPaint* paint): + ShapeCacheEntry(ShapeCacheEntry::kShapeArc, paint) { + mWidth = *(uint32_t*) &width; + mHeight = *(uint32_t*) &height; + mStartAngle = *(uint32_t*) &startAngle; + mSweepAngle = *(uint32_t*) &sweepAngle; + mUseCenter = useCenter ? 1 : 0; + } + + ArcShapeCacheEntry(): ShapeCacheEntry() { + mWidth = 0; + mHeight = 0; + mStartAngle = 0; + mSweepAngle = 0; + mUseCenter = 0; + } + + ArcShapeCacheEntry(const ArcShapeCacheEntry& entry): + ShapeCacheEntry(entry) { + mWidth = entry.mWidth; + mHeight = entry.mHeight; + mStartAngle = entry.mStartAngle; + mSweepAngle = entry.mSweepAngle; + mUseCenter = entry.mUseCenter; + } + + bool lessThan(const ShapeCacheEntry& r) const { + const ArcShapeCacheEntry& rhs = (const ArcShapeCacheEntry&) r; + LTE_INT(mWidth) { + LTE_INT(mHeight) { + LTE_INT(mStartAngle) { + LTE_INT(mSweepAngle) { + LTE_INT(mUseCenter) { + return false; + } + } + } + } + } + return false; + } + +private: + uint32_t mWidth; + uint32_t mHeight; + uint32_t mStartAngle; + uint32_t mSweepAngle; + uint32_t mUseCenter; +}; // ArcShapeCacheEntry + /** * 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 @@ -370,6 +422,14 @@ public: PathTexture* getRect(float width, float height, SkPaint* paint); }; // class RectShapeCache +class ArcShapeCache: public ShapeCache<ArcShapeCacheEntry> { +public: + ArcShapeCache(); + + PathTexture* getArc(float width, float height, float startAngle, float sweepAngle, + bool useCenter, SkPaint* paint); +}; // class ArcShapeCache + /////////////////////////////////////////////////////////////////////////////// // Constructors/destructor /////////////////////////////////////////////////////////////////////////////// |