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

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

Issue 16816016: Fix for PNG, coding style, skip opaque. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 6 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 | « samplecode/SampleUnpremul.cpp ('k') | tests/ImageDecodingTest.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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 sc = SkScaledBitmapSampler::kRGBA; 377 sc = SkScaledBitmapSampler::kRGBA;
378 } else { 378 } else {
379 sc = SkScaledBitmapSampler::kRGBX; 379 sc = SkScaledBitmapSampler::kRGBX;
380 } 380 }
381 381
382 /* We have to pass the colortable explicitly, since we may have one 382 /* We have to pass the colortable explicitly, since we may have one
383 even if our decodedBitmap doesn't, due to the request that we 383 even if our decodedBitmap doesn't, due to the request that we
384 upscale png's palette to a direct model 384 upscale png's palette to a direct model
385 */ 385 */
386 SkAutoLockColors ctLock(colorTable); 386 SkAutoLockColors ctLock(colorTable);
387 if (!sampler.begin(decodedBitmap, sc, doDither, ctLock.colors())) { 387 if (!sampler.begin(decodedBitmap, sc, doDither, ctLock.colors(),
388 this->getRequireUnpremultipliedColors())) {
388 return false; 389 return false;
389 } 390 }
390 const int height = decodedBitmap->height(); 391 const int height = decodedBitmap->height();
391 392
392 if (number_passes > 1) { 393 if (number_passes > 1) {
393 SkAutoMalloc storage(origWidth * origHeight * srcBytesPerPixel); 394 SkAutoMalloc storage(origWidth * origHeight * srcBytesPerPixel);
394 uint8_t* base = (uint8_t*)storage.get(); 395 uint8_t* base = (uint8_t*)storage.get();
395 size_t rowBytes = origWidth * srcBytesPerPixel; 396 size_t rowBytes = origWidth * srcBytesPerPixel;
396 397
397 for (int i = 0; i < number_passes; i++) { 398 for (int i = 0; i < number_passes; i++) {
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 sc = SkScaledBitmapSampler::kRGBA; 794 sc = SkScaledBitmapSampler::kRGBA;
794 } else { 795 } else {
795 sc = SkScaledBitmapSampler::kRGBX; 796 sc = SkScaledBitmapSampler::kRGBX;
796 } 797 }
797 798
798 /* We have to pass the colortable explicitly, since we may have one 799 /* We have to pass the colortable explicitly, since we may have one
799 even if our decodedBitmap doesn't, due to the request that we 800 even if our decodedBitmap doesn't, due to the request that we
800 upscale png's palette to a direct model 801 upscale png's palette to a direct model
801 */ 802 */
802 SkAutoLockColors ctLock(colorTable); 803 SkAutoLockColors ctLock(colorTable);
803 if (!sampler.begin(&decodedBitmap, sc, doDither, ctLock.colors())) { 804 if (!sampler.begin(&decodedBitmap, sc, doDither, ctLock.colors(),
805 this->getRequireUnpremultipliedColors())) {
804 return false; 806 return false;
805 } 807 }
806 const int height = decodedBitmap.height(); 808 const int height = decodedBitmap.height();
807 809
808 if (number_passes > 1) { 810 if (number_passes > 1) {
809 SkAutoMalloc storage(origWidth * origHeight * srcBytesPerPixel); 811 SkAutoMalloc storage(origWidth * origHeight * srcBytesPerPixel);
810 uint8_t* base = (uint8_t*)storage.get(); 812 uint8_t* base = (uint8_t*)storage.get();
811 size_t rb = origWidth * srcBytesPerPixel; 813 size_t rb = origWidth * srcBytesPerPixel;
812 814
813 for (int i = 0; i < number_passes; i++) { 815 for (int i = 0; i < number_passes; i++) {
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 return SkImageDecoder::kUnknown_Format; 1166 return SkImageDecoder::kUnknown_Format;
1165 } 1167 }
1166 1168
1167 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { 1169 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) {
1168 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; 1170 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL;
1169 } 1171 }
1170 1172
1171 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libpng_efacto ry); 1173 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libpng_efacto ry);
1172 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_png) ; 1174 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_png) ;
1173 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libpng_dfactory); 1175 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libpng_dfactory);
OLDNEW
« no previous file with comments | « samplecode/SampleUnpremul.cpp ('k') | tests/ImageDecodingTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698