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

Unified Diff: src/core/SkBitmapProcState.cpp

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 | « include/core/SkPixelRef.h ('k') | src/core/SkPixelRef.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmapProcState.cpp
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index 64a8d3b1e1de20753eb50a20c4d9a6707aa9924a..30a64ed5a84e7f3b3bef80b5e429cc5d1d83457c 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -243,12 +243,43 @@
}
}
+static bool get_locked_pixels(const SkBitmap& src, int pow2, SkBitmap* dst) {
+ SkPixelRef* pr = src.pixelRef();
+ if (pr && pr->decodeInto(pow2, dst)) {
+ return true;
+ }
+
+ /*
+ * If decodeInto() fails, it is possibe that we have an old subclass that
+ * does not, or cannot, implement that. In that case we fall back to the
+ * older protocol of having the pixelRef handle the caching for us.
+ */
+ *dst = src;
+ dst->lockPixels();
+ return SkToBool(dst->getPixels());
+}
+
bool SkBitmapProcState::lockBaseBitmap() {
- // TODO(reed): use bitmap cache here?
- fScaledBitmap = fOrigBitmap;
- fScaledBitmap.lockPixels();
- if (NULL == fScaledBitmap.getPixels()) {
- return false;
+ SkPixelRef* pr = fOrigBitmap.pixelRef();
+
+ if (pr->isLocked() || !pr->implementsDecodeInto()) {
+ // fast-case, no need to look in our cache
+ fScaledBitmap = fOrigBitmap;
+ fScaledBitmap.lockPixels();
+ if (NULL == fScaledBitmap.getPixels()) {
+ return false;
+ }
+ } else {
+ if (!SkBitmapCache::Find(fOrigBitmap, 1, 1, &fScaledBitmap)) {
+ if (!get_locked_pixels(fOrigBitmap, 0, &fScaledBitmap)) {
+ return false;
+ }
+
+ // TODO: if fScaled comes back at a different width/height than fOrig,
+ // we need to update the matrix we are using to sample from this guy.
+
+ SkBitmapCache::Add(fOrigBitmap, 1, 1, fScaledBitmap);
+ }
}
fBitmap = &fScaledBitmap;
return true;
@@ -358,7 +389,7 @@
fShaderProc16 = NULL;
fSampleProc32 = NULL;
fSampleProc16 = NULL;
-
+
// recompute the triviality of the matrix here because we may have
// changed it!
@@ -532,10 +563,10 @@
fShaderProc32 = this->chooseShaderProc32();
}
}
-
+
// see if our platform has any accelerated overrides
this->platformProcs();
-
+
return true;
}
« no previous file with comments | « include/core/SkPixelRef.h ('k') | src/core/SkPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698