Chromium Code Reviews| Index: src/gpu/batches/GrAADistanceFieldPathRenderer.h |
| diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.h b/src/gpu/batches/GrAADistanceFieldPathRenderer.h |
| index e5c7dceb12bdf9941e17c0460d5a4991d40728eb..3f80113fa8c61c28483d4a3a729b1112d4e7f293 100755 |
| --- a/src/gpu/batches/GrAADistanceFieldPathRenderer.h |
| +++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.h |
| @@ -11,6 +11,7 @@ |
| #include "GrBatchAtlas.h" |
| #include "GrPathRenderer.h" |
| #include "GrRect.h" |
| +#include "GrShape.h" |
| #include "SkChecksum.h" |
| #include "SkTDynamicHash.h" |
| @@ -31,56 +32,63 @@ private: |
| bool onDrawPath(const DrawPathArgs&) override; |
| - struct PathData { |
| + struct ShapeData { |
| class Key { |
| public: |
| - // default ctor needed for new of uninitialized PathData |
| - // since fStroke has no default ctor |
| - Key() |
| - : fGenID(0) |
| - , fDimension(0) |
| - , fStroke(SkStrokeRec::kFill_InitStyle) {} |
| - Key(uint32_t genID, uint32_t dim, const SkStrokeRec& stroke) |
| - : fGenID(genID) |
| - , fDimension(dim) |
| - , fStroke(stroke) {} |
| - |
| - bool operator==(const Key& other) const { |
| - return other.fGenID == fGenID && other.fDimension == fDimension && |
| - fStroke.hasEqualEffect(other.fStroke); |
| + Key() {} |
| + Key(const Key& that) { *this = that; } |
| + Key(const GrShape& shape, uint32_t dim) { this->set(shape, dim); } |
| + |
| + Key& operator=(const Key& that) { |
| + fKey.reset(that.fKey.count()); |
| + memcpy(fKey.get(), that.fKey.get(), fKey.count() * sizeof(uint32_t)); |
| + return *this; |
| } |
| + void set(const GrShape& shape, uint32_t dim) { |
| + SkASSERT(shape.hasUnstyledKey()); |
| + int shapeCnt = shape.unstyledKeySize(); |
|
egdaniel
2016/06/27 13:16:58
shapeCnt? maybe keySize or unstyledKeySize?
|
| + fKey.reset(1 + shapeCnt); |
| + fKey[0] = dim; |
| + shape.writeUnstyledKey(&fKey[1]); |
| + } |
| + |
| + bool operator==(const Key& that) const { |
| + return fKey.count() == that.fKey.count() && |
| + 0 == memcmp(fKey.get(), that.fKey.get(), sizeof(uint32_t) * fKey.count()); |
| + } |
| + |
| + int count32() const { return fKey.count(); } |
| + const uint32_t* data() const { return fKey.get(); } |
| + |
| private: |
| - uint32_t fGenID; |
| // rendered size for stored path (32x32 max, 64x64 max, 128x128 max) |
|
egdaniel
2016/06/27 13:16:58
I don't think this comment is clear that it refers
bsalomon
2016/06/27 13:37:52
Done.
|
| - uint32_t fDimension; |
| - // stroking information |
| - SkStrokeRec fStroke; |
| + SkAutoSTArray<24, uint32_t> fKey; |
| }; |
| Key fKey; |
| SkScalar fScale; |
| GrBatchAtlas::AtlasID fID; |
| SkRect fBounds; |
| SkIPoint16 fAtlasLocation; |
| - SK_DECLARE_INTERNAL_LLIST_INTERFACE(PathData); |
| + SK_DECLARE_INTERNAL_LLIST_INTERFACE(ShapeData); |
| - static inline const Key& GetKey(const PathData& data) { |
| + static inline const Key& GetKey(const ShapeData& data) { |
| return data.fKey; |
| } |
| static inline uint32_t Hash(Key key) { |
| - return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(&key), sizeof(key)); |
| + return SkChecksum::Murmur3(key.data(), sizeof(uint32_t) * key.count32()); |
| } |
| }; |
| static void HandleEviction(GrBatchAtlas::AtlasID, void*); |
| - typedef SkTDynamicHash<PathData, PathData::Key> PathCache; |
| - typedef SkTInternalLList<PathData> PathDataList; |
| + typedef SkTDynamicHash<ShapeData, ShapeData::Key> ShapeCache; |
| + typedef SkTInternalLList<ShapeData> ShapeDataList; |
| GrBatchAtlas* fAtlas; |
| - PathCache fPathCache; |
| - PathDataList fPathList; |
| + ShapeCache fShapeCache; |
| + ShapeDataList fShapeList; |
| typedef GrPathRenderer INHERITED; |