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

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

Issue 25275004: store SkAlphaType inside SkBitmap, on road to support unpremul (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/images/SkImageDecoder_libjpeg.cpp ('k') | src/images/SkImageDecoder_libwebp.cpp » ('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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkImageDecoder.h" 10 #include "SkImageDecoder.h"
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 if (0 != theTranspColor) { 430 if (0 != theTranspColor) {
431 reallyHasAlpha |= substituteTranspColor(decodedBitmap, theTranspColor); 431 reallyHasAlpha |= substituteTranspColor(decodedBitmap, theTranspColor);
432 } 432 }
433 if (reallyHasAlpha && this->getRequireUnpremultipliedColors() && 433 if (reallyHasAlpha && this->getRequireUnpremultipliedColors() &&
434 SkBitmap::kARGB_8888_Config != decodedBitmap->config()) { 434 SkBitmap::kARGB_8888_Config != decodedBitmap->config()) {
435 // If the caller wants an unpremultiplied bitmap, and we let them get 435 // If the caller wants an unpremultiplied bitmap, and we let them get
436 // away with a config other than 8888, and it has alpha after all, 436 // away with a config other than 8888, and it has alpha after all,
437 // return false, since the result will have premultiplied colors. 437 // return false, since the result will have premultiplied colors.
438 return false; 438 return false;
439 } 439 }
440 decodedBitmap->setIsOpaque(!reallyHasAlpha); 440 decodedBitmap->setAlphaType(reallyHasAlpha ? kPremul_SkAlphaType : kOpaque_S kAlphaType);
scroggo 2013/10/02 18:49:58 In addition to checking for unpremultiply, this ne
reed1 2013/10/03 08:22:54 Not sure what the change to the code should be. If
scroggo 2013/10/03 14:05:19 It doesn't currently change reallyHasAlpha, but it
reed1 2013/10/18 15:27:06 Done.
441 return true; 441 return true;
442 } 442 }
443 443
444 444
445 445
446 bool SkPNGImageDecoder::getBitmapConfig(png_structp png_ptr, png_infop info_ptr, 446 bool SkPNGImageDecoder::getBitmapConfig(png_structp png_ptr, png_infop info_ptr,
447 SkBitmap::Config* SK_RESTRICT configp, 447 SkBitmap::Config* SK_RESTRICT configp,
448 bool* SK_RESTRICT hasAlphap, 448 bool* SK_RESTRICT hasAlphap,
449 bool* SK_RESTRICT doDitherp, 449 bool* SK_RESTRICT doDitherp,
450 SkPMColor* SK_RESTRICT theTranspColorp) { 450 SkPMColor* SK_RESTRICT theTranspColorp) {
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 if (y < height - 1) { 882 if (y < height - 1) {
883 skip_src_rows(png_ptr, srcRow, sampler.srcDY() - 1); 883 skip_src_rows(png_ptr, srcRow, sampler.srcDY() - 1);
884 } 884 }
885 } 885 }
886 } 886 }
887 } 887 }
888 888
889 if (0 != theTranspColor) { 889 if (0 != theTranspColor) {
890 reallyHasAlpha |= substituteTranspColor(&decodedBitmap, theTranspColor); 890 reallyHasAlpha |= substituteTranspColor(&decodedBitmap, theTranspColor);
891 } 891 }
892 decodedBitmap.setIsOpaque(!reallyHasAlpha); 892 decodedBitmap.setAlphaType(reallyHasAlpha ? kPremul_SkAlphaType : kOpaque_Sk AlphaType);
893 893
894 if (swapOnly) { 894 if (swapOnly) {
895 bm->swap(decodedBitmap); 895 bm->swap(decodedBitmap);
896 return true; 896 return true;
897 } 897 }
898 return this->cropBitmap(bm, &decodedBitmap, sampleSize, region.x(), region.y (), 898 return this->cropBitmap(bm, &decodedBitmap, sampleSize, region.x(), region.y (),
899 region.width(), region.height(), 0, rect.y()); 899 region.width(), region.height(), 0, rect.y());
900 } 900 }
901 #endif 901 #endif
902 902
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 return SkImageDecoder::kUnknown_Format; 1197 return SkImageDecoder::kUnknown_Format;
1198 } 1198 }
1199 1199
1200 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { 1200 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) {
1201 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; 1201 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL;
1202 } 1202 }
1203 1203
1204 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); 1204 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory);
1205 static SkImageDecoder_FormatReg gFormatReg(get_format_png); 1205 static SkImageDecoder_FormatReg gFormatReg(get_format_png);
1206 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); 1206 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libjpeg.cpp ('k') | src/images/SkImageDecoder_libwebp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698