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

Unified Diff: src/images/SkDecodingImageGenerator.cpp

Issue 223903007: Add option to SkDecodingImageGenerator to require unpremul. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Match surrounding code line length. Created 6 years, 8 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 | « src/images/SkDecodingImageGenerator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkDecodingImageGenerator.cpp
diff --git a/src/images/SkDecodingImageGenerator.cpp b/src/images/SkDecodingImageGenerator.cpp
index 016362f43c24b741def05a605bb1fe18f765bf0c..5b842abf5f671da0c9d68dd1bdfec68cbf6f08c7 100644
--- a/src/images/SkDecodingImageGenerator.cpp
+++ b/src/images/SkDecodingImageGenerator.cpp
@@ -175,6 +175,8 @@ bool DecodingImageGenerator::getPixels(const SkImageInfo& info,
}
decoder->setDitherImage(fDitherImage);
decoder->setSampleSize(fSampleSize);
+ decoder->setRequireUnpremultipliedColors(
+ info.fAlphaType == kUnpremul_SkAlphaType);
SkBitmap bitmap;
TargetAllocator allocator(fInfo, pixels, rowBytes);
@@ -224,6 +226,7 @@ SkImageGenerator* CreateDecodingImageGenerator(
}
SkBitmap bitmap;
decoder->setSampleSize(opts.fSampleSize);
+ decoder->setRequireUnpremultipliedColors(opts.fRequireUnpremul);
if (!decoder->decode(stream, &bitmap,
SkImageDecoder::kDecodeBounds_Mode)) {
return NULL;
@@ -248,6 +251,10 @@ SkImageGenerator* CreateDecodingImageGenerator(
}
info.fColorType = opts.fRequestedColorType;
}
+
+ if (opts.fRequireUnpremul && info.fAlphaType != kOpaque_SkAlphaType) {
+ info.fAlphaType = kUnpremul_SkAlphaType;
+ }
return SkNEW_ARGS(DecodingImageGenerator,
(data, autoStream.detach(), info,
opts.fSampleSize, opts.fDitherImage));
« no previous file with comments | « src/images/SkDecodingImageGenerator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698