OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #ifndef GrAADistanceFieldPathRenderer_DEFINED | 9 #ifndef GrAADistanceFieldPathRenderer_DEFINED |
10 #define GrAADistanceFieldPathRenderer_DEFINED | 10 #define GrAADistanceFieldPathRenderer_DEFINED |
11 | 11 |
12 #include "GrAtlas.h" | 12 #include "GrBatchAtlas.h" |
13 #include "GrPathRenderer.h" | 13 #include "GrPathRenderer.h" |
14 #include "GrRect.h" | 14 #include "GrRect.h" |
15 | 15 |
16 #include "SkChecksum.h" | 16 #include "SkChecksum.h" |
17 #include "SkTDynamicHash.h" | 17 #include "SkTDynamicHash.h" |
18 | 18 |
19 class GrContext; | 19 class GrContext; |
20 class GrPlot; | |
21 | 20 |
22 class GrAADistanceFieldPathRenderer : public GrPathRenderer { | 21 class GrAADistanceFieldPathRenderer : public GrPathRenderer { |
23 public: | 22 public: |
24 GrAADistanceFieldPathRenderer(GrContext* context); | 23 GrAADistanceFieldPathRenderer(GrContext* context); |
25 virtual ~GrAADistanceFieldPathRenderer(); | 24 virtual ~GrAADistanceFieldPathRenderer(); |
26 | 25 |
27 virtual bool canDrawPath(const GrDrawTarget*, | 26 virtual bool canDrawPath(const GrDrawTarget*, |
28 const GrPipelineBuilder*, | 27 const GrPipelineBuilder*, |
29 const SkMatrix& viewMatrix, | 28 const SkMatrix& viewMatrix, |
30 const SkPath&, | 29 const SkPath&, |
(...skipping 17 matching lines...) Expand all Loading... |
48 private: | 47 private: |
49 struct PathData { | 48 struct PathData { |
50 struct Key { | 49 struct Key { |
51 uint32_t fGenID; | 50 uint32_t fGenID; |
52 // rendered size for stored path (32x32 max, 64x64 max, 128x128 max) | 51 // rendered size for stored path (32x32 max, 64x64 max, 128x128 max) |
53 uint32_t fDimension; | 52 uint32_t fDimension; |
54 bool operator==(const Key& other) const { | 53 bool operator==(const Key& other) const { |
55 return other.fGenID == fGenID && other.fDimension == fDimension; | 54 return other.fGenID == fGenID && other.fDimension == fDimension; |
56 } | 55 } |
57 }; | 56 }; |
58 Key fKey; | 57 Key fKey; |
59 SkScalar fScale; | 58 SkScalar fScale; |
60 GrPlot* fPlot; | 59 GrBatchAtlas::AtlasID fID; |
61 SkRect fBounds; | 60 SkRect fBounds; |
62 SkIPoint16 fAtlasLocation; | 61 SkIPoint16 fAtlasLocation; |
63 SK_DECLARE_INTERNAL_LLIST_INTERFACE(PathData); | 62 SK_DECLARE_INTERNAL_LLIST_INTERFACE(PathData); |
64 | 63 |
65 static inline const Key& GetKey(const PathData& data) { | 64 static inline const Key& GetKey(const PathData& data) { |
66 return data.fKey; | 65 return data.fKey; |
67 } | 66 } |
68 | 67 |
69 static inline uint32_t Hash(Key key) { | 68 static inline uint32_t Hash(Key key) { |
70 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(&key),
sizeof(key)); | 69 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(&key),
sizeof(key)); |
71 } | 70 } |
72 }; | 71 }; |
| 72 |
| 73 static void HandleEviction(GrBatchAtlas::AtlasID, void*); |
| 74 |
73 typedef SkTInternalLList<PathData> PathDataList; | 75 typedef SkTInternalLList<PathData> PathDataList; |
74 | 76 |
75 GrContext* fContext; | 77 GrContext* fContext; |
76 GrAtlas* fAtlas; | 78 GrBatchAtlas* fAtlas; |
77 SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor; | |
78 // current set of flags used to create the cached geometry processor | |
79 uint32_t fEffectFlags; | |
80 GrAtlas::ClientPlotUsage fPlotUsage; | |
81 SkTDynamicHash<PathData, PathData::Key> fPathCache; | 79 SkTDynamicHash<PathData, PathData::Key> fPathCache; |
82 PathDataList fPathList; | 80 PathDataList fPathList; |
83 | 81 |
84 bool internalDrawPath(GrDrawTarget*, GrPipelineBuilder*, GrColor, const SkMa
trix& viewMatrix, | |
85 const SkPath& path, const PathData* pathData); | |
86 inline bool uploadPath(GrPlot** plot, SkIPoint16* atlasLocation, int width,
int height, | |
87 void* dfStorage); | |
88 PathData* addPathToAtlas(const SkPath& path, const SkStrokeRec& stroke, bool
antiAlias, | |
89 uint32_t dimension, SkScalar scale); | |
90 bool freeUnusedPlot(); | |
91 | |
92 typedef GrPathRenderer INHERITED; | 82 typedef GrPathRenderer INHERITED; |
| 83 |
| 84 friend class AADistanceFieldPathBatch; |
93 }; | 85 }; |
94 | 86 |
95 #endif | 87 #endif |
OLD | NEW |