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

Side by Side Diff: src/images/SkDecodingImageGenerator.cpp

Issue 346593003: Adjust the alpha type for pixelRefs. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix alignment. Created 6 years, 5 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 unified diff | Download patch
« no previous file with comments | « src/core/SkPixelRef.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkData.h" 8 #include "SkData.h"
9 #include "SkDecodingImageGenerator.h" 9 #include "SkDecodingImageGenerator.h"
10 #include "SkImageDecoder.h" 10 #include "SkImageDecoder.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 if (!bitmap.canCopyTo(opts.fRequestedColorType)) { 239 if (!bitmap.canCopyTo(opts.fRequestedColorType)) {
240 SkASSERT(bitmap.colorType() != opts.fRequestedColorType); 240 SkASSERT(bitmap.colorType() != opts.fRequestedColorType);
241 return NULL; // Can not translate to needed config. 241 return NULL; // Can not translate to needed config.
242 } 242 }
243 info.fColorType = opts.fRequestedColorType; 243 info.fColorType = opts.fRequestedColorType;
244 } 244 }
245 245
246 if (opts.fRequireUnpremul && info.fAlphaType != kOpaque_SkAlphaType) { 246 if (opts.fRequireUnpremul && info.fAlphaType != kOpaque_SkAlphaType) {
247 info.fAlphaType = kUnpremul_SkAlphaType; 247 info.fAlphaType = kUnpremul_SkAlphaType;
248 } 248 }
249
250 if (!SkColorTypeValidateAlphaType(info.fColorType, info.fAlphaType, &info.fA lphaType)) {
251 return NULL;
252 }
253
249 return SkNEW_ARGS(DecodingImageGenerator, 254 return SkNEW_ARGS(DecodingImageGenerator,
250 (data, autoStream.detach(), info, 255 (data, autoStream.detach(), info,
251 opts.fSampleSize, opts.fDitherImage)); 256 opts.fSampleSize, opts.fDitherImage));
252 } 257 }
253 258
254 } // namespace 259 } // namespace
255 260
256 //////////////////////////////////////////////////////////////////////////////// 261 ////////////////////////////////////////////////////////////////////////////////
257 262
258 SkImageGenerator* SkDecodingImageGenerator::Create( 263 SkImageGenerator* SkDecodingImageGenerator::Create(
(...skipping 13 matching lines...) Expand all
272 SkStreamRewindable* stream, 277 SkStreamRewindable* stream,
273 const SkDecodingImageGenerator::Options& opts) { 278 const SkDecodingImageGenerator::Options& opts) {
274 SkASSERT(stream != NULL); 279 SkASSERT(stream != NULL);
275 SkASSERT(stream->unique()); 280 SkASSERT(stream->unique());
276 if ((stream == NULL) || !stream->unique()) { 281 if ((stream == NULL) || !stream->unique()) {
277 SkSafeUnref(stream); 282 SkSafeUnref(stream);
278 return NULL; 283 return NULL;
279 } 284 }
280 return CreateDecodingImageGenerator(NULL, stream, opts); 285 return CreateDecodingImageGenerator(NULL, stream, opts);
281 } 286 }
OLDNEW
« no previous file with comments | « src/core/SkPixelRef.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698