Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Unified Diff: src/gpu/GrRecordReplaceDraw.h

Issue 753253002: Use variable length key (rather than accumulated matrix) as save layer hoisting key (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Compiling Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrRecordReplaceDraw.h
diff --git a/src/gpu/GrRecordReplaceDraw.h b/src/gpu/GrRecordReplaceDraw.h
index 9110ac82f9e09884b355cf7a2ba2b0d472fa61d4..ba6b1c1c514b058fb892ee702f53cafbbb1fdab2 100644
--- a/src/gpu/GrRecordReplaceDraw.h
+++ b/src/gpu/GrRecordReplaceDraw.h
@@ -32,41 +32,41 @@ public:
class ReplacementInfo {
public:
struct Key {
- Key(uint32_t pictureID, unsigned int start, const SkMatrix& ctm)
+ Key(uint32_t pictureID, unsigned int start, const int* key, int keySize)
: fPictureID(pictureID)
, fStart(start)
- , fCTM(ctm) {
- fCTM.getType(); // force initialization of type so hashes match
-
- // Key needs to be tightly packed.
- GR_STATIC_ASSERT(sizeof(Key) == sizeof(uint32_t) + // picture ID
- sizeof(int) + // start
- 9 * sizeof(SkScalar) // 3x3 from CTM
- +sizeof(uint32_t)); // matrix's type
+ , fKey(key)
+ , fKeySize(keySize) {
}
- bool operator==(const Key& other) const {
- return fPictureID == other.fPictureID &&
- fStart == other.fStart &&
- fCTM.cheapEqualTo(other.fCTM); // TODO: should be fuzzy
+ bool operator==(const Key& other) const {
+ if (fKeySize != other.fKeySize) {
+ return false;
+ }
+ return !memcmp(fKey, other.fKey, fKeySize * sizeof(int));
}
uint32_t pictureID() const { return fPictureID; }
unsigned int start() const { return fStart; }
+ const int* key() const { return fKey; }
+ int keySize() const { return fKeySize; }
+
private:
const uint32_t fPictureID;
const unsigned int fStart;
- const SkMatrix fCTM;
+ const int* fKey;
+ const int fKeySize;
};
static const Key& GetKey(const ReplacementInfo& layer) { return layer.fKey; }
static uint32_t Hash(const Key& key) {
- return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(&key), sizeof(Key));
+ return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(key.key()),
+ key.keySize()*sizeof(int));
}
- ReplacementInfo(uint32_t pictureID, unsigned int start, const SkMatrix& ctm)
- : fKey(pictureID, start, ctm)
+ ReplacementInfo(uint32_t pictureID, unsigned int start, const int* key, int keySize)
+ : fKey(pictureID, start, key, keySize)
, fImage(NULL)
, fPaint(NULL) {
}
@@ -86,12 +86,12 @@ public:
~GrReplacements() { this->freeAll(); }
// Add a new replacement range.
- ReplacementInfo* newReplacement(uint32_t pictureID, unsigned int start, const SkMatrix& ctm);
+ ReplacementInfo* newReplacement(uint32_t pictureID, unsigned int start, const int* key, int keySize);
// look up a replacement range by its pictureID, start offset and the CTM
// TODO: also need to add clip to lookup
- const ReplacementInfo* lookupByStart(uint32_t pictureID, size_t start,
- const SkMatrix& ctm) const;
+ const ReplacementInfo* lookupByStart(uint32_t pictureID, int start,
+ const int* key, int keyBytes) const;
private:
SkTDynamicHash<ReplacementInfo, ReplacementInfo::Key> fReplacementHash;

Powered by Google App Engine
This is Rietveld 408576698