aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar reed <reed@chromium.org>2015-02-19 20:00:33 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-19 20:00:33 -0800
commitb92b706dfdd68958f0fec76f8f5e0b7590798907 (patch)
tree6eb910a3adc08240f03c03499cbabe8da936d903 /include/core
parent56f4ace232b78dccbe77daf30b7c95ea9d5c8a83 (diff)
Revert of Make SkPixelRef::isLocked() debug-only, remove related dead code. (patchset #1 id:1 of https://codereview.chromium.org/940083002/)
Reason for revert: Broke callers in chrome ../../skia/ext/platform_canvas_unittest.cc:421:56: error: no member named 'isLocked' in 'SkPixelRef' EXPECT_TRUE(platform_bitmap->GetBitmap().pixelRef()->isLocked()); Original issue's description: > Make SkPixelRef::isLocked() debug-only, remove related dead code. > > DM's okay locally with no diffs, no failures. > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/8e65712486c66108677a9b0a55ad3e7ca94db555 TBR=reed@google.com,mtklein@google.com,mtklein@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/940323003
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkPixelRef.h42
1 files changed, 41 insertions, 1 deletions
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h
index f859642921..2a5e7ecbdc 100644
--- a/include/core/SkPixelRef.h
+++ b/include/core/SkPixelRef.h
@@ -86,7 +86,11 @@ public:
}
};
- SkDEBUGCODE(bool isLocked() const { return fLockCount > 0; })
+ /**
+ * Returns true if the lockcount > 0
+ */
+ bool isLocked() const { return fLockCount > 0; }
+
SkDEBUGCODE(int getLockCount() const { return fLockCount; })
/**
@@ -193,6 +197,37 @@ public:
return this->onRefEncodedData();
}
+ /**
+ * Experimental -- tells the caller if it is worth it to call decodeInto().
+ * Just an optimization at this point, to avoid checking the cache first.
+ * We may remove/change this call in the future.
+ */
+ bool implementsDecodeInto() {
+ return this->onImplementsDecodeInto();
+ }
+
+ /**
+ * Return a decoded instance of this pixelRef in bitmap. If this cannot be
+ * done, return false and the bitmap parameter is ignored/unchanged.
+ *
+ * pow2 is the requeste power-of-two downscale that the caller needs. This
+ * can be ignored, and the "original" size can be returned, but if the
+ * underlying codec can efficiently return a smaller size, that should be
+ * done. Some examples:
+ *
+ * To request the "base" version (original scale), pass 0 for pow2
+ * To request 1/2 scale version (1/2 width, 1/2 height), pass 1 for pow2
+ * To request 1/4 scale version (1/4 width, 1/4 height), pass 2 for pow2
+ * ...
+ *
+ * If this returns true, then bitmap must be "locked" such that
+ * bitmap->getPixels() will return the correct address.
+ */
+ bool decodeInto(int pow2, SkBitmap* bitmap) {
+ SkASSERT(pow2 >= 0);
+ return this->onDecodeInto(pow2, bitmap);
+ }
+
/** Are we really wrapping a texture instead of a bitmap?
*/
virtual GrTexture* getTexture() { return NULL; }
@@ -268,6 +303,11 @@ protected:
/** Default impl returns true */
virtual bool onLockPixelsAreWritable() const;
+ // returns false;
+ virtual bool onImplementsDecodeInto();
+ // returns false;
+ virtual bool onDecodeInto(int pow2, SkBitmap* bitmap);
+
/**
* For pixelrefs that don't have access to their raw pixels, they may be
* able to make a copy of them (e.g. if the pixels are on the GPU).