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

Unified Diff: src/lazy/SkCachingPixelRef.cpp

Issue 68973005: Expand pixelref to return SkImageInfo and rowbytes (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add SK_SUPPORT_LEGACY_ONLOCKPIXELS so we can land in stages for Chrome Created 7 years 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/lazy/SkCachingPixelRef.cpp
diff --git a/src/lazy/SkCachingPixelRef.cpp b/src/lazy/SkCachingPixelRef.cpp
index d12b7cf881cffa08e403a1073cdc7b9ace06a9a8..0732c31adf3bef0b57bdbd1a7a6bc946dcbd4cf3 100644
--- a/src/lazy/SkCachingPixelRef.cpp
+++ b/src/lazy/SkCachingPixelRef.cpp
@@ -18,7 +18,16 @@ SkCachingPixelRef::~SkCachingPixelRef() {
// Assert always unlock before unref.
}
-bool SkCachingPixelRef::getInfo(SkImageInfo* info) {
+bool SkCachingPixelRef::configure(SkBitmap* bitmap) {
+ SkASSERT(bitmap != NULL);
+ SkImageInfo info;
+ if (!this->getInfo(&info)) {
+ return false;
+ }
+ return bitmap->setConfig(info, 0);
+}
+
+bool SkCachingPixelRef::onGetInfo(SkImageInfo* info) {
SkASSERT(info != NULL);
if (fErrorInDecoding) {
return false; // Don't try again.
@@ -36,21 +45,11 @@ bool SkCachingPixelRef::getInfo(SkImageInfo* info) {
return true;
}
-bool SkCachingPixelRef::configure(SkBitmap* bitmap) {
- SkASSERT(bitmap != NULL);
+bool SkCachingPixelRef::onNewLockPixels(LockRec* rec) {
SkImageInfo info;
if (!this->getInfo(&info)) {
return false;
}
- return bitmap->setConfig(info, 0);
-}
-
-void* SkCachingPixelRef::onLockPixels(SkColorTable** colorTable) {
- (void)colorTable;
- SkImageInfo info;
- if (!this->getInfo(&info)) {
- return NULL;
- }
SkBitmap bitmap;
fScaledCacheId = SkScaledImageCache::FindAndLock(this->getGenerationID(),
@@ -60,7 +59,7 @@ void* SkCachingPixelRef::onLockPixels(SkColorTable** colorTable) {
if (NULL == fScaledCacheId) {
// Cache has been purged, must re-decode.
if (!this->onDecodeInto(0, &bitmap)) {
- return NULL;
+ return false;
}
fScaledCacheId = SkScaledImageCache::AddAndLock(this->getGenerationID(),
info.fWidth,
@@ -73,6 +72,7 @@ void* SkCachingPixelRef::onLockPixels(SkColorTable** colorTable) {
SkAutoLockPixels autoLockPixels(bitmap);
void* pixels = bitmap.getPixels();
SkASSERT(pixels != NULL);
+
// At this point, the autoLockPixels will unlockPixels()
// to remove bitmap's lock on the pixels. We will then
// destroy bitmap. The *only* guarantee that this pointer
@@ -81,7 +81,10 @@ void* SkCachingPixelRef::onLockPixels(SkColorTable** colorTable) {
// bitmap (SkScaledImageCache::Rec.fBitmap) that holds a
// reference to the concrete PixelRef while this record is
// locked.
- return pixels;
+ rec->fPixels = pixels;
+ rec->fColorTable = NULL;
+ rec->fRowBytes = bitmap.rowBytes();
+ return true;
}
void SkCachingPixelRef::onUnlockPixels() {

Powered by Google App Engine
This is Rietveld 408576698