Index: src/gpu/batches/GrAADistanceFieldPathRenderer.h |
diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.h b/src/gpu/batches/GrAADistanceFieldPathRenderer.h |
index e5c7dceb12bdf9941e17c0460d5a4991d40728eb..db17b07d360ddc3835e47e16e663b3890e048c2e 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,67 @@ 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) { |
+ // Shapes' keys are for their pre-style geometry, but by now we shouldn't have any |
+ // relevant styling information. |
+ SkASSERT(shape.style().isSimpleFill()); |
+ SkASSERT(shape.hasUnstyledKey()); |
+ int shapeKeySize = shape.unstyledKeySize(); |
+ fKey.reset(1 + shapeKeySize); |
+ 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) |
- uint32_t fDimension; |
- // stroking information |
- SkStrokeRec fStroke; |
+ // The key is composed of the dimensions of the DF generated for the path (32x32 max, |
+ // 64x64 max, 128x128 max) and the GrShape's key. |
+ 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; |