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

Unified Diff: include/core/SkPixelRef.h

Issue 940323003: Revert of Make SkPixelRef::isLocked() debug-only, remove related dead code. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 months 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
« no previous file with comments | « no previous file | src/core/SkBitmapProcState.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkPixelRef.h
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h
index f859642921c4437d91e59ae0cfd5ce69f78bfc80..2a5e7ecbdcb59b521659adfe2dc8f5a9fa274336 100644
--- a/include/core/SkPixelRef.h
+++ b/include/core/SkPixelRef.h
@@ -86,7 +86,11 @@
}
};
- 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; })
/**
@@ -191,6 +195,37 @@
*/
SkData* refEncodedData() {
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?
@@ -268,6 +303,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).
« no previous file with comments | « no previous file | src/core/SkBitmapProcState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698