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

Unified Diff: dm/DMSrcSink.cpp

Issue 1418093006: Refactor SkBitmapRegionDecoderInterface for Android (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Pass in the allocator, decodeRegion() in a single call 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
Index: dm/DMSrcSink.cpp
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index e0ec5e139ce988d07a8dbfe76a34b0ba2611a279..5eff189fa81b649c06269c223b292c88f93df14c 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -125,12 +125,16 @@ 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.
scroggo 2015/10/27 18:53:55 Why is this not fatal, and what do you need to do
msarett 2015/10/27 19:06:16 I *think* the only thing that needs to be done is
scroggo 2015/10/27 19:23:37 I'm fine if that is left to a separate change, but
+ 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 +182,17 @@ 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.
+ 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)),

Powered by Google App Engine
This is Rietveld 408576698