| OLD | NEW |
| 1 | |
| 2 /* | 1 /* |
| 3 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 4 * | 3 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 7 */ | 6 */ |
| 8 | 7 |
| 9 #ifndef GrAADistanceFieldPathRenderer_DEFINED | 8 #ifndef GrAADistanceFieldPathRenderer_DEFINED |
| 10 #define GrAADistanceFieldPathRenderer_DEFINED | 9 #define GrAADistanceFieldPathRenderer_DEFINED |
| 11 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 30 | 29 |
| 31 bool onCanDrawPath(const CanDrawPathArgs&) const override; | 30 bool onCanDrawPath(const CanDrawPathArgs&) const override; |
| 32 | 31 |
| 33 bool onDrawPath(const DrawPathArgs&) override; | 32 bool onDrawPath(const DrawPathArgs&) override; |
| 34 | 33 |
| 35 struct PathData { | 34 struct PathData { |
| 36 class Key { | 35 class Key { |
| 37 public: | 36 public: |
| 38 // default ctor needed for new of uninitialized PathData | 37 // default ctor needed for new of uninitialized PathData |
| 39 // since fStroke has no default ctor | 38 // since fStroke has no default ctor |
| 40 Key() | 39 Key() |
| 41 : fGenID(0) | 40 : fGenID(0) |
| 42 , fDimension(0) | 41 , fDimension(0) |
| 43 , fStroke(SkStrokeRec::kFill_InitStyle) {} | 42 , fStroke(SkStrokeRec::kFill_InitStyle) {} |
| 44 Key(uint32_t genID, uint32_t dim, const SkStrokeRec& stroke) | 43 Key(uint32_t genID, uint32_t dim, const SkStrokeRec& stroke) |
| 45 : fGenID(genID) | 44 : fGenID(genID) |
| 46 , fDimension(dim) | 45 , fDimension(dim) |
| 47 , fStroke(stroke) {} | 46 , fStroke(stroke) {} |
| 48 | 47 |
| 49 bool operator==(const Key& other) const { | 48 bool operator==(const Key& other) const { |
| 50 return other.fGenID == fGenID && other.fDimension == fDimension
&& | 49 return other.fGenID == fGenID && other.fDimension == fDimension
&& |
| 51 fStroke.hasEqualEffect(other.fStroke); | 50 fStroke.hasEqualEffect(other.fStroke); |
| 52 } | 51 } |
| 53 | 52 |
| 54 private: | 53 private: |
| 55 uint32_t fGenID; | 54 uint32_t fGenID; |
| 56 // rendered size for stored path (32x32 max, 64x64 max, 128x128 max) | 55 // rendered size for stored path (32x32 max, 64x64 max, 128x128 max) |
| 57 uint32_t fDimension; | 56 uint32_t fDimension; |
| 58 // stroking information | 57 // stroking information |
| 59 SkStrokeRec fStroke; | 58 SkStrokeRec fStroke; |
| 60 }; | 59 }; |
| 61 Key fKey; | 60 Key fKey; |
| 62 SkScalar fScale; | 61 SkScalar fScale; |
| 63 GrBatchAtlas::AtlasID fID; | 62 GrBatchAtlas::AtlasID fID; |
| 64 SkRect fBounds; | 63 SkRect fBounds; |
| 65 SkIPoint16 fAtlasLocation; | 64 SkIPoint16 fAtlasLocation; |
| 66 SK_DECLARE_INTERNAL_LLIST_INTERFACE(PathData); | 65 SK_DECLARE_INTERNAL_LLIST_INTERFACE(PathData); |
| 67 | 66 |
| 68 static inline const Key& GetKey(const PathData& data) { | 67 static inline const Key& GetKey(const PathData& data) { |
| 69 return data.fKey; | 68 return data.fKey; |
| 70 } | 69 } |
| 71 | 70 |
| 72 static inline uint32_t Hash(Key key) { | 71 static inline uint32_t Hash(Key key) { |
| 73 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(&key),
sizeof(key)); | 72 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(&key),
sizeof(key)); |
| 74 } | 73 } |
| 75 }; | 74 }; |
| 76 | 75 |
| 77 static void HandleEviction(GrBatchAtlas::AtlasID, void*); | 76 static void HandleEviction(GrBatchAtlas::AtlasID, void*); |
| 78 | 77 |
| 79 typedef SkTDynamicHash<PathData, PathData::Key> PathCache; | 78 typedef SkTDynamicHash<PathData, PathData::Key> PathCache; |
| 80 typedef SkTInternalLList<PathData> PathDataList; | 79 typedef SkTInternalLList<PathData> PathDataList; |
| 81 | 80 |
| 82 GrBatchAtlas* fAtlas; | 81 GrBatchAtlas* fAtlas; |
| 83 PathCache fPathCache; | 82 PathCache fPathCache; |
| 84 PathDataList fPathList; | 83 PathDataList fPathList; |
| 85 | 84 |
| 86 typedef GrPathRenderer INHERITED; | 85 typedef GrPathRenderer INHERITED; |
| 87 | 86 |
| 88 friend class AADistanceFieldPathBatch; | 87 friend class AADistanceFieldPathBatch; |
| 89 friend struct PathTestStruct; | 88 friend struct PathTestStruct; |
| 90 }; | 89 }; |
| 91 | 90 |
| 92 #endif | 91 #endif |
| OLD | NEW |