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

Unified Diff: tools/SkBitmapRegionCodec.cpp

Issue 1422023006: SkBitmapRegionCodec needs to use the rowBytes on the pixel ref (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Be robust and correct the rowBytes on the bitmap Created 5 years, 1 month 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/SkBitmapRegionCodec.cpp
diff --git a/tools/SkBitmapRegionCodec.cpp b/tools/SkBitmapRegionCodec.cpp
index cac99452e0d37bcffdf762063bf9e17c7c0515c5..0af7b62473e4eb4cda4a30fc1dd7bc2a58c78686 100644
--- a/tools/SkBitmapRegionCodec.cpp
+++ b/tools/SkBitmapRegionCodec.cpp
@@ -9,6 +9,7 @@
#include "SkAndroidCodec.h"
#include "SkCodecPriv.h"
#include "SkCodecTools.h"
+#include "SkPixelRef.h"
SkBitmapRegionCodec::SkBitmapRegionCodec(SkAndroidCodec* codec)
: INHERITED(codec->getInfo().width(), codec->getInfo().height())
@@ -93,7 +94,7 @@ bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBitmap::Allocator* al
scaledOutHeight += scaledOutY + scaledExtraY;
}
SkImageInfo outInfo = decodeInfo.makeWH(scaledOutWidth, scaledOutHeight);
- bitmap->setInfo(outInfo, outInfo.minRowBytes());
+ bitmap->setInfo(outInfo);
if (!bitmap->tryAllocPixels(allocator, colorTable.get())) {
SkCodecPrintf("Error: Could not allocate pixels.\n");
return false;
@@ -119,7 +120,14 @@ bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBitmap::Allocator* al
options.fColorPtr = colorPtr;
options.fColorCount = colorCountPtr;
void* dst = bitmap->getAddr(scaledOutX, scaledOutY);
- size_t rowBytes = bitmap->rowBytes();
+
+ // FIXME: skbug.com/4538
+ // It is important that we use the rowBytes on the pixelRef. They may not be
+ // set properly on the bitmap.
+ SkPixelRef* pr = SkRef(bitmap->pixelRef());
scroggo 2015/11/05 22:45:56 I just want to double check that the ref counting
+ size_t rowBytes = pr->rowBytes();
+ bitmap->setInfo(outInfo, rowBytes);
scroggo 2015/11/05 22:45:56 Behind our backs, this decrements the refCount, so
+ bitmap->setPixelRef(pr)->unref();
scroggo 2015/11/05 22:45:56 setPixelRef increments it again (RC + 1) and then
msarett 2015/11/05 22:49:05 Looks correct to me as well.
SkCodec::Result result = fCodec->getAndroidPixels(decodeInfo, dst, rowBytes, &options);
if (SkCodec::kSuccess != result && SkCodec::kIncompleteInput != result) {
SkCodecPrintf("Error: Could not get pixels.\n");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698