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

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

Issue 1013743003: Adding premul and 565 swizzles for bmp: (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Trybot fixes 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
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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 , fInfo_ptr(info_ptr) {} 340 , fInfo_ptr(info_ptr) {}
341 341
342 SkPngCodec::~SkPngCodec() { 342 SkPngCodec::~SkPngCodec() {
343 png_destroy_read_struct(&fPng_ptr, &fInfo_ptr, png_infopp_NULL); 343 png_destroy_read_struct(&fPng_ptr, &fInfo_ptr, png_infopp_NULL);
344 } 344 }
345 345
346 /////////////////////////////////////////////////////////////////////////////// 346 ///////////////////////////////////////////////////////////////////////////////
347 // Getting the pixels 347 // Getting the pixels
348 /////////////////////////////////////////////////////////////////////////////// 348 ///////////////////////////////////////////////////////////////////////////////
349 349
350 static bool conversion_possible(const SkImageInfo& A, const SkImageInfo& B) { 350 static bool conversion_possible(const SkImageInfo& dst, const SkImageInfo& src) {
351 // TODO: Support other conversions 351 // TODO: Support other conversions
352 if (A.colorType() != B.colorType()) { 352 if (dst.colorType() != src.colorType()) {
353 return false; 353 return false;
354 } 354 }
355 if (A.profileType() != B.profileType()) { 355 if (dst.profileType() != src.profileType()) {
356 return false; 356 return false;
357 } 357 }
358 if (A.alphaType() == B.alphaType()) { 358 if (dst.alphaType() == src.alphaType()) {
359 return true; 359 return true;
360 } 360 }
361 return premul_and_unpremul(A.alphaType(), B.alphaType()) 361 return kPremul_SkAlphaType == dst.alphaType() &&
362 || premul_and_unpremul(B.alphaType(), A.alphaType()); 362 kUnpremul_SkAlphaType == src.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, const Options& options, 366 size_t rowBytes, const Options& options,
367 SkPMColor ctable[], 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;
(...skipping 107 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

Powered by Google App Engine
This is Rietveld 408576698