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

Unified Diff: dm/DMSrcSink.cpp

Issue 1418093006: Refactor SkBitmapRegionDecoderInterface for Android (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Better comments Created 5 years, 2 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 | « bench/nanobench.cpp ('k') | tools/SkBitmapRegionCanvas.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMSrcSink.cpp
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index e0ec5e139ce988d07a8dbfe76a34b0ba2611a279..b14c57367908229782086112ae76c57f041db84f 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -125,12 +125,18 @@ Error BRDSrc::draw(SkCanvas* canvas) const {
}
switch (fMode) {
case kFullImage_Mode: {
- SkAutoTDelete<SkBitmap> bitmap(brd->decodeRegion(0, 0, width, height, fSampleSize,
- colorType));
- if (nullptr == bitmap.get() || colorType != bitmap->colorType()) {
+ SkBitmap bitmap;
+ if (!brd->decodeRegion(&bitmap, nullptr, SkIRect::MakeXYWH(0, 0, width, height),
+ fSampleSize, colorType, false)) {
+ // FIXME: Make this a fatal error. We need to disable webps for kCanvas_Strategy
+ // because we have not implemented kCanvas_Strategy for webp. We may also need to
+ // deal with color conversion errors for kOriginal_Strategy.
+ return Error::Nonfatal("Cannot decode region.\n");
+ }
+ if (colorType != bitmap.colorType()) {
return Error::Nonfatal("Cannot convert to color type.\n");
}
- canvas->drawBitmap(*bitmap, 0, 0);
+ canvas->drawBitmap(bitmap, 0, 0);
return "";
}
case kDivisor_Mode: {
@@ -178,13 +184,20 @@ Error BRDSrc::draw(SkCanvas* canvas) const {
const int decodeTop = top - unscaledBorder;
const uint32_t decodeWidth = subsetWidth + unscaledBorder * 2;
const uint32_t decodeHeight = subsetHeight + unscaledBorder * 2;
- SkAutoTDelete<SkBitmap> bitmap(brd->decodeRegion(decodeLeft,
- decodeTop, decodeWidth, decodeHeight, fSampleSize, colorType));
- if (nullptr == bitmap.get() || colorType != bitmap->colorType()) {
+ SkBitmap bitmap;
+ if (!brd->decodeRegion(&bitmap, nullptr, SkIRect::MakeXYWH(decodeLeft,
+ decodeTop, decodeWidth, decodeHeight), fSampleSize, colorType, false)) {
+ // FIXME: Make this a fatal error. We need to disable webps for
+ // kCanvas_Strategy because we have not implemented kCanvas_Strategy for
+ // webp. We may also need to deal with color conversion errors for
+ // kOriginal_Strategy.
+ return Error::Nonfatal("Cannot not decode region.\n");
+ }
+ if (colorType != bitmap.colorType()) {
return Error::Nonfatal("Cannot convert to color type.\n");
}
- canvas->drawBitmapRect(*bitmap,
+ canvas->drawBitmapRect(bitmap,
SkRect::MakeXYWH((SkScalar) scaledBorder, (SkScalar) scaledBorder,
(SkScalar) (subsetWidth / fSampleSize),
(SkScalar) (subsetHeight / fSampleSize)),
« no previous file with comments | « bench/nanobench.cpp ('k') | tools/SkBitmapRegionCanvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698