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

Unified Diff: tools/SkBitmapRegionCanvas.cpp

Issue 1332053002: Fill incomplete images in SkCodec parent class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Response to comments Created 5 years, 3 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
Index: tools/SkBitmapRegionCanvas.cpp
diff --git a/tools/SkBitmapRegionCanvas.cpp b/tools/SkBitmapRegionCanvas.cpp
index 2344d9020f8250299151640034bb4d7fae119744..3ae098d69fbe60d468755aa3e77051af6329e71c 100644
--- a/tools/SkBitmapRegionCanvas.cpp
+++ b/tools/SkBitmapRegionCanvas.cpp
@@ -8,6 +8,7 @@
#include "SkBitmapRegionCanvas.h"
#include "SkCanvas.h"
#include "SkScanlineDecoder.h"
+#include "SkSwizzler.h"
SkBitmapRegionCanvas::SkBitmapRegionCanvas(SkScanlineDecoder* decoder)
: INHERITED(decoder->getInfo().width(), decoder->getInfo().height())
@@ -129,21 +130,18 @@ SkBitmap* SkBitmapRegionCanvas::decodeRegion(int inputX, int inputY,
}
// Skip the unneeded rows
- if (SkCodec::kSuccess != fDecoder->skipScanlines(imageSubsetY)) {
+ if (!fDecoder->skipScanlines(imageSubsetY)) {
SkDebugf("Error: Failed to skip scanlines.\n");
return nullptr;
}
// Decode the necessary rows
- SkCodec::Result result = fDecoder->getScanlines(tmp.getAddr(0, 0), imageSubsetHeight,
- tmp.rowBytes());
- switch (result) {
- case SkCodec::kSuccess:
- case SkCodec::kIncompleteInput:
- break;
- default:
- SkDebugf("Error: Failed to get scanlines.\n");
- return nullptr;
+ uint32_t lines = fDecoder->getScanlines(tmp.getAddr(0, 0), imageSubsetHeight, tmp.rowBytes());
+ if (lines != (uint32_t) imageSubsetHeight) {
+ const SkImageInfo fillInfo = tmpInfo.makeWH(tmpInfo.width(), imageSubsetHeight - lines);
+ const uint32_t fillValue = fDecoder->getFillValue(fillInfo);
+ SkSwizzler::Fill(tmp.getAddr(0, lines), fillInfo, tmp.rowBytes(), fillValue,
+ SkCodec::kNo_ZeroInitialized);
}
// Calculate the size of the output

Powered by Google App Engine
This is Rietveld 408576698