diff options
author | 2013-01-22 13:34:01 +0000 | |
---|---|---|
committer | 2013-01-22 13:34:01 +0000 | |
commit | 46d3d39e65e0b3ea2ad7c91c176ccafb4df0fa24 (patch) | |
tree | 3ed0089389283fd2d9cfa8bea196b9363ee60a9d /include | |
parent | 9d5f99bc309a7d733e33a149bef295ae3c8b3ac1 (diff) |
Add GPU support for axis-aligned ovals:
- Add drawOval base function to SkDevice, and override in SkGpuDevice
- Move isSimilarityMatrix to SkMatrix (renamed to isSimilarity) and fixed up unit test
- Since both SkGpuDevice::drawOval() and GrContext::drawPath() can try to draw ovals, added GrContext::canDrawOval() and GrContext::internalDrawOval() to avoid duplicate code
- Hooked in axis-aligned oval fill shader
- Enabled GPU stroked circles
- Added stroked circle bench test
Review URL: https://codereview.appspot.com/7137050
git-svn-id: http://skia.googlecode.com/svn/trunk@7304 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkDevice.h | 2 | ||||
-rw-r--r-- | include/core/SkDrawFilter.h | 1 | ||||
-rw-r--r-- | include/core/SkMatrix.h | 5 | ||||
-rw-r--r-- | include/gpu/GrContext.h | 14 | ||||
-rw-r--r-- | include/gpu/SkGpuDevice.h | 2 |
5 files changed, 17 insertions, 7 deletions
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h index 33be2f672a..5c32f768a5 100644 --- a/include/core/SkDevice.h +++ b/include/core/SkDevice.h @@ -226,6 +226,8 @@ protected: const SkPoint[], const SkPaint& paint); virtual void drawRect(const SkDraw&, const SkRect& r, const SkPaint& paint); + virtual void drawOval(const SkDraw&, const SkRect& oval, + const SkPaint& paint); /** * If pathIsMutable, then the implementation is allowed to cast path to a * non-const pointer and modify it in place (as an optimization). Canvas diff --git a/include/core/SkDrawFilter.h b/include/core/SkDrawFilter.h index 3944257851..6a50ca7ac6 100644 --- a/include/core/SkDrawFilter.h +++ b/include/core/SkDrawFilter.h @@ -31,6 +31,7 @@ public: kLine_Type, kBitmap_Type, kRect_Type, + kOval_Type, kPath_Type, kText_Type, }; diff --git a/include/core/SkMatrix.h b/include/core/SkMatrix.h index f9b72d7aeb..87599d4cfb 100644 --- a/include/core/SkMatrix.h +++ b/include/core/SkMatrix.h @@ -85,6 +85,11 @@ public: kPerspective_Mask); } + /** Returns true if the matrix contains only translation, rotation or uniform scale + Returns false if other transformation types are included or is degenerate + */ + bool isSimilarity(SkScalar tol = SK_ScalarNearlyZero) const; + enum { kMScaleX, kMSkewX, diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index b1e9dd6193..399b372e77 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -442,15 +442,12 @@ public: * Draws an oval. * * @param paint describes how to color pixels. - * @param rect the bounding rect of the oval. - * @param strokeWidth if strokeWidth < 0, then the oval is filled, else - * the rect is stroked based on strokeWidth. If - * strokeWidth == 0, then the stroke is always a single - * pixel thick. + * @param oval the bounding rect of the oval. + * @param stroke the stroke information (width, style) */ void drawOval(const GrPaint& paint, - const GrRect& rect, - SkScalar strokeWidth); + const GrRect& oval, + const SkStrokeRec& stroke); /////////////////////////////////////////////////////////////////////////// // Misc. @@ -910,6 +907,9 @@ private: void internalDrawPath(const GrPaint& paint, const SkPath& path, const SkStrokeRec& stroke); + void internalDrawOval(const GrPaint& paint, const GrRect& oval, const SkStrokeRec& stroke); + bool canDrawOval(const GrPaint& paint, const GrRect& oval, const SkStrokeRec& stroke) const; + GrTexture* createResizedTexture(const GrTextureDesc& desc, const GrCacheID& cacheID, void* srcData, diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h index 45b069397e..815376fbfa 100644 --- a/include/gpu/SkGpuDevice.h +++ b/include/gpu/SkGpuDevice.h @@ -64,6 +64,8 @@ public: const SkPoint[], const SkPaint& paint) SK_OVERRIDE; virtual void drawRect(const SkDraw&, const SkRect& r, const SkPaint& paint) SK_OVERRIDE; + virtual void drawOval(const SkDraw&, const SkRect& oval, + const SkPaint& paint) SK_OVERRIDE; virtual void drawPath(const SkDraw&, const SkPath& path, const SkPaint& paint, const SkMatrix* prePathMatrix, bool pathIsMutable) SK_OVERRIDE; |