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

Side by Side Diff: src/codec/SkCodec_libpng.cpp

Issue 980903002: Option for SkCodec to treat dst as all zeroes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update SkBmpCodec to use new ZeroInitialized API. Created 5 years, 9 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/codec/SkCodec_libpng.h ('k') | src/codec/SkSwizzler.h » ('j') | 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 2015 Google Inc. 2 * Copyright 2015 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 "SkCodec_libpng.h" 8 #include "SkCodec_libpng.h"
9 #include "SkCodecPriv.h" 9 #include "SkCodecPriv.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 return false; 356 return false;
357 } 357 }
358 if (A.alphaType() == B.alphaType()) { 358 if (A.alphaType() == B.alphaType()) {
359 return true; 359 return true;
360 } 360 }
361 return premul_and_unpremul(A.alphaType(), B.alphaType()) 361 return premul_and_unpremul(A.alphaType(), B.alphaType())
362 || premul_and_unpremul(B.alphaType(), A.alphaType()); 362 || premul_and_unpremul(B.alphaType(), A.alphaType());
363 } 363 }
364 364
365 SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& requestedInfo, void* dst, 365 SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& requestedInfo, void* dst,
366 size_t rowBytes, SkPMColor ctable[], 366 size_t rowBytes, const Options& options,
367 int* ctableCount) { 367 SkPMColor ctable[], int* ctableCount) {
368 if (!this->rewindIfNeeded()) { 368 if (!this->rewindIfNeeded()) {
369 return kCouldNotRewind; 369 return kCouldNotRewind;
370 } 370 }
371 if (requestedInfo.dimensions() != this->getOriginalInfo().dimensions()) { 371 if (requestedInfo.dimensions() != this->getOriginalInfo().dimensions()) {
372 return kInvalidScale; 372 return kInvalidScale;
373 } 373 }
374 if (!conversion_possible(requestedInfo, this->getOriginalInfo())) { 374 if (!conversion_possible(requestedInfo, this->getOriginalInfo())) {
375 return kInvalidConversion; 375 return kInvalidConversion;
376 } 376 }
377 377
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 // Note: we check the destination, since otherwise we would have 423 // Note: we check the destination, since otherwise we would have
424 // told png to upscale. 424 // told png to upscale.
425 SkASSERT(PNG_COLOR_TYPE_GRAY == pngColorType); 425 SkASSERT(PNG_COLOR_TYPE_GRAY == pngColorType);
426 sc = SkSwizzler::kGray; 426 sc = SkSwizzler::kGray;
427 } else if (this->getOriginalInfo().alphaType() == kOpaque_SkAlphaType) { 427 } else if (this->getOriginalInfo().alphaType() == kOpaque_SkAlphaType) {
428 sc = SkSwizzler::kRGBX; 428 sc = SkSwizzler::kRGBX;
429 } else { 429 } else {
430 sc = SkSwizzler::kRGBA; 430 sc = SkSwizzler::kRGBA;
431 } 431 }
432 const SkPMColor* colors = colorTable ? colorTable->readColors() : NULL; 432 const SkPMColor* colors = colorTable ? colorTable->readColors() : NULL;
433 // TODO: Support skipZeroes.
434 swizzler.reset(SkSwizzler::CreateSwizzler(sc, colors, requestedInfo, 433 swizzler.reset(SkSwizzler::CreateSwizzler(sc, colors, requestedInfo,
435 dst, rowBytes, false)); 434 dst, rowBytes,
435 options.fZeroInitialized));
436 if (!swizzler) { 436 if (!swizzler) {
437 // FIXME: CreateSwizzler could fail for another reason. 437 // FIXME: CreateSwizzler could fail for another reason.
438 return kUnimplemented; 438 return kUnimplemented;
439 } 439 }
440 440
441 // FIXME: Here is where we should likely insert some of the modifications 441 // FIXME: Here is where we should likely insert some of the modifications
442 // made in the factory. 442 // made in the factory.
443 png_read_update_info(fPng_ptr, fInfo_ptr); 443 png_read_update_info(fPng_ptr, fInfo_ptr);
444 444
445 if (numberPasses > 1) { 445 if (numberPasses > 1) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 480
481 // FIXME: do we need substituteTranspColor? 481 // FIXME: do we need substituteTranspColor?
482 482
483 if (reallyHasAlpha && requestedInfo.alphaType() != kOpaque_SkAlphaType) { 483 if (reallyHasAlpha && requestedInfo.alphaType() != kOpaque_SkAlphaType) {
484 // FIXME: We want to alert the caller. Is this the right way? 484 // FIXME: We want to alert the caller. Is this the right way?
485 SkImageInfo* modInfo = const_cast<SkImageInfo*>(&requestedInfo); 485 SkImageInfo* modInfo = const_cast<SkImageInfo*>(&requestedInfo);
486 *modInfo = requestedInfo.makeAlphaType(kOpaque_SkAlphaType); 486 *modInfo = requestedInfo.makeAlphaType(kOpaque_SkAlphaType);
487 } 487 }
488 return kSuccess; 488 return kSuccess;
489 } 489 }
OLDNEW
« no previous file with comments | « src/codec/SkCodec_libpng.h ('k') | src/codec/SkSwizzler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698