start to remove lockPixels from bitmapshader
BUG=
R=scroggo@google.com
Review URL: https://codereview.chromium.org/23591030
git-svn-id: http://skia.googlecode.com/svn/trunk/include@11258 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/core/SkPixelRef.h b/core/SkPixelRef.h
index 0487e42..64e0876 100644
--- a/core/SkPixelRef.h
+++ b/core/SkPixelRef.h
@@ -141,6 +141,37 @@
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; }
@@ -190,6 +221,11 @@
/** 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).