OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef GrPathRendering_DEFINED |
| 9 #define GrPathRendering_DEFINED |
| 10 |
| 11 #include "SkPath.h" |
| 12 |
| 13 class SkStrokeRec; |
| 14 class GrPath; |
| 15 class GrPathRange; |
| 16 class GrGpu; |
| 17 |
| 18 /** |
| 19 * Abstract class wrapping HW path rendering API. |
| 20 * |
| 21 * The subclasses of this class use the possible HW API to render paths (as oppo
sed to path |
| 22 * rendering implemented in Skia on top of a "3d" HW API). |
| 23 * The subclasses hold the global state needed to render paths, including shadow
of the global HW |
| 24 * API state. Similar to GrGpu. |
| 25 * |
| 26 * It is expected that the lifetimes of GrGpuXX and GrXXPathRendering are the sa
me. The call context |
| 27 * interface (eg. * the concrete instance of GrGpu subclass) should be provided
to the instance |
| 28 * during construction. |
| 29 */ |
| 30 class GrPathRendering { |
| 31 public: |
| 32 virtual ~GrPathRendering() { } |
| 33 |
| 34 enum PathTransformType { |
| 35 kNone_PathTransformType, //!< [] |
| 36 kTranslateX_PathTransformType, //!< [kMTransX] |
| 37 kTranslateY_PathTransformType, //!< [kMTransY] |
| 38 kTranslate_PathTransformType, //!< [kMTransX, kMTransY] |
| 39 kAffine_PathTransformType, //!< [kMScaleX, kMSkewX, kMTransX, kMSke
wY, kMScaleY, kMTransY] |
| 40 |
| 41 kLast_PathTransformType = kAffine_PathTransformType |
| 42 }; |
| 43 |
| 44 static inline int PathTransformSize(PathTransformType type) { |
| 45 switch (type) { |
| 46 case kNone_PathTransformType: |
| 47 return 0; |
| 48 case kTranslateX_PathTransformType: |
| 49 case kTranslateY_PathTransformType: |
| 50 return 1; |
| 51 case kTranslate_PathTransformType: |
| 52 return 2; |
| 53 case kAffine_PathTransformType: |
| 54 return 6; |
| 55 |
| 56 default: |
| 57 SkFAIL("Unknown path transform type"); |
| 58 return 0; |
| 59 } |
| 60 } |
| 61 |
| 62 virtual GrPath* createPath(const SkPath&, const SkStrokeRec&) = 0; |
| 63 virtual GrPathRange* createPathRange(size_t size, const SkStrokeRec&) = 0; |
| 64 virtual void stencilPath(const GrPath*, SkPath::FillType) = 0; |
| 65 virtual void drawPath(const GrPath*, SkPath::FillType) = 0; |
| 66 virtual void drawPaths(const GrPathRange*, const uint32_t indices[], int cou
nt, |
| 67 const float transforms[], PathTransformType, SkPath::
FillType) = 0; |
| 68 protected: |
| 69 GrPathRendering() { } |
| 70 |
| 71 private: |
| 72 GrPathRendering& operator=(const GrPathRendering&); |
| 73 }; |
| 74 |
| 75 #endif |
OLD | NEW |