diff options
author | 2015-11-05 15:00:56 -0800 | |
---|---|---|
committer | 2015-11-05 15:00:56 -0800 | |
commit | fcff08c8301b1ca08eee20911d0df5fb9db41156 (patch) | |
tree | a54ed4ffad1796d1ea2debe463f9cd2aa614d372 /tools | |
parent | c57e0ded7d535523cfc6bf07c78e5f3479bb8c42 (diff) |
SkBitmapRegionCodec needs to use the rowBytes on the pixel ref
BUG=skia:4538
Review URL: https://codereview.chromium.org/1422023006
Diffstat (limited to 'tools')
-rw-r--r-- | tools/SkBitmapRegionCodec.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/SkBitmapRegionCodec.cpp b/tools/SkBitmapRegionCodec.cpp index cac99452e0..0af7b62473 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()); + size_t rowBytes = pr->rowBytes(); + bitmap->setInfo(outInfo, rowBytes); + bitmap->setPixelRef(pr)->unref(); SkCodec::Result result = fCodec->getAndroidPixels(decodeInfo, dst, rowBytes, &options); if (SkCodec::kSuccess != result && SkCodec::kIncompleteInput != result) { SkCodecPrintf("Error: Could not get pixels.\n"); |