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

Unified Diff: src/gpu/GrLayerCache.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/GrLayerCache.h
diff --git a/src/gpu/GrLayerCache.h b/src/gpu/GrLayerCache.h
index 75e913056027113ce0b94c885dbc4bece527d7e2..97b3d301ffff5497f7229c207796c3d839d08d4a 100644
--- a/src/gpu/GrLayerCache.h
+++ b/src/gpu/GrLayerCache.h
@@ -76,31 +76,43 @@ struct GrCachedLayer {
public:
// For SkTDynamicHash
struct Key {
- Key(uint32_t pictureID, int start, const SkIRect& bounds, const SkMatrix& ctm)
+ Key(uint32_t pictureID, int start, const SkIRect& bounds, const SkMatrix& ctm,
+ const int* key, int keySize)
: fPictureID(pictureID)
, fStart(start)
, fBounds(bounds)
- , fCTM(ctm) {
+ , fCTM(ctm)
+ , fKey(key)
+ , fKeySize(keySize) {
fCTM.getType(); // force initialization of type so hashes match
+#if 0
// Key needs to be tightly packed.
GR_STATIC_ASSERT(sizeof(Key) == sizeof(uint32_t) + // picture ID
sizeof(int) + // start index
4 * sizeof(uint32_t) + // bounds
9 * sizeof(SkScalar) + sizeof(uint32_t)); // matrix
+#endif
}
bool operator==(const Key& other) const {
+ if (fKeySize != other.fKeySize) {
+ return false;
+ }
return fPictureID == other.fPictureID &&
fStart == other.fStart &&
fBounds == other.fBounds &&
- fCTM.cheapEqualTo(other.fCTM);
+ fCTM.cheapEqualTo(other.fCTM) &&
+ !memcmp(fKey, other.fKey, fKeySize * sizeof(int));
}
uint32_t pictureID() const { return fPictureID; }
int start() const { return fStart; }
const SkIRect& bound() const { return fBounds; }
+ const int* key() const { return fKey; }
+ int keySize() const { return fKeySize; }
+
private:
// ID of the picture of which this layer is a part
const uint32_t fPictureID;
@@ -110,18 +122,23 @@ public:
const SkIRect fBounds;
// The 2x2 portion of the CTM applied to this layer in the picture
SkMatrix fCTM;
+
+ const int* fKey;
+ const int fKeySize;
};
static const Key& GetKey(const GrCachedLayer& 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));
}
// GrCachedLayer proper
GrCachedLayer(uint32_t pictureID, int start, int stop,
const SkIRect& bounds, const SkMatrix& ctm,
+ const int* key, int keySize,
const SkPaint* paint)
- : fKey(pictureID, start, bounds, ctm)
+ : fKey(pictureID, start, bounds, ctm, key, keySize)
, fStop(stop)
, fPaint(paint ? SkNEW_ARGS(SkPaint, (*paint)) : NULL)
, fTexture(NULL)
@@ -139,6 +156,9 @@ public:
uint32_t pictureID() const { return fKey.pictureID(); }
int start() const { return fKey.start(); }
+ const int* key() const { return fKey.key(); }
+ int keySize() const { return fKey.keySize(); }
+
const SkIRect& bound() const { return fKey.bound(); }
int stop() const { return fStop; }
@@ -224,12 +244,14 @@ public:
// elements by the GrContext
void freeAll();
- GrCachedLayer* findLayer(uint32_t pictureID, int start,
- const SkIRect& bounds, const SkMatrix& ctm);
+ GrCachedLayer* findLayer(uint32_t pictureID, int start,
+ const SkIRect& bounds, const SkMatrix& ctm,
+ const int* key, int keySize);
GrCachedLayer* findLayerOrCreate(uint32_t pictureID,
int start, int stop,
const SkIRect& bounds,
const SkMatrix& ctm,
+ const int* key, int keySize,
const SkPaint* paint);
// Attempt to place 'layer' in the atlas. Return true on success; false on failure.
@@ -310,8 +332,9 @@ private:
void unlock(GrCachedLayer* layer);
void initAtlas();
- GrCachedLayer* createLayer(uint32_t pictureID, int start, int stop,
- const SkIRect& bounds, const SkMatrix& ctm,
+ GrCachedLayer* createLayer(uint32_t pictureID, int start, int stop,
+ const SkIRect& bounds, const SkMatrix& ctm,
+ const int* key, int keySize,
const SkPaint* paint);
// Remove all the layers (and unlock any resources) associated with 'pictureID'

Powered by Google App Engine
This is Rietveld 408576698