| OLD | NEW |
| 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 } | 265 } |
| 266 | 266 |
| 267 // If we are not decoding to F16, we can color xform now and store the resul
ts | 267 // If we are not decoding to F16, we can color xform now and store the resul
ts |
| 268 // in the color table. | 268 // in the color table. |
| 269 if (fColorXform && kRGBA_F16_SkColorType != dstInfo.colorType()) { | 269 if (fColorXform && kRGBA_F16_SkColorType != dstInfo.colorType()) { |
| 270 SkColorSpaceXform::ColorFormat xformColorFormat = is_rgba(dstInfo.colorT
ype()) ? | 270 SkColorSpaceXform::ColorFormat xformColorFormat = is_rgba(dstInfo.colorT
ype()) ? |
| 271 SkColorSpaceXform::kRGBA_8888_ColorFormat : | 271 SkColorSpaceXform::kRGBA_8888_ColorFormat : |
| 272 SkColorSpaceXform::kBGRA_8888_ColorFormat; | 272 SkColorSpaceXform::kBGRA_8888_ColorFormat; |
| 273 SkAlphaType xformAlphaType = select_xform_alpha(dstInfo.alphaType(), | 273 SkAlphaType xformAlphaType = select_xform_alpha(dstInfo.alphaType(), |
| 274 this->getInfo().alphaTyp
e()); | 274 this->getInfo().alphaTyp
e()); |
| 275 fColorXform->apply(colorTable, colorTable, numColors, xformColorFormat,
xformAlphaType); | 275 fColorXform->apply(colorTable, colorTable, numColors, xformColorFormat, |
| 276 SkColorSpaceXform::kRGBA_8888_ColorFormat, xformAlpha
Type); |
| 276 } | 277 } |
| 277 | 278 |
| 278 // Pad the color table with the last color in the table (or black) in the ca
se that | 279 // Pad the color table with the last color in the table (or black) in the ca
se that |
| 279 // invalid pixel indices exceed the number of colors in the table. | 280 // invalid pixel indices exceed the number of colors in the table. |
| 280 const int maxColors = 1 << fBitDepth; | 281 const int maxColors = 1 << fBitDepth; |
| 281 if (numColors < maxColors) { | 282 if (numColors < maxColors) { |
| 282 SkPMColor lastColor = numColors > 0 ? colorTable[numColors - 1] : SK_Col
orBLACK; | 283 SkPMColor lastColor = numColors > 0 ? colorTable[numColors - 1] : SK_Col
orBLACK; |
| 283 sk_memset32(colorTable + numColors, lastColor, maxColors - numColors); | 284 sk_memset32(colorTable + numColors, lastColor, maxColors - numColors); |
| 284 } | 285 } |
| 285 | 286 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 case kSwizzleColor_XformMode: { | 487 case kSwizzleColor_XformMode: { |
| 487 const size_t colorXformBytes = dstInfo.width() * sizeof(uint32_t); | 488 const size_t colorXformBytes = dstInfo.width() * sizeof(uint32_t); |
| 488 fStorage.reset(colorXformBytes); | 489 fStorage.reset(colorXformBytes); |
| 489 fColorXformSrcRow = (uint32_t*) fStorage.get(); | 490 fColorXformSrcRow = (uint32_t*) fStorage.get(); |
| 490 break; | 491 break; |
| 491 } | 492 } |
| 492 } | 493 } |
| 493 } | 494 } |
| 494 | 495 |
| 495 void SkPngCodec::applyXformRow(void* dst, const void* src) { | 496 void SkPngCodec::applyXformRow(void* dst, const void* src) { |
| 497 const SkColorSpaceXform::ColorFormat srcColorFormat = SkColorSpaceXform::kRG
BA_8888_ColorFormat; |
| 496 switch (fXformMode) { | 498 switch (fXformMode) { |
| 497 case kSwizzleOnly_XformMode: | 499 case kSwizzleOnly_XformMode: |
| 498 fSwizzler->swizzle(dst, (const uint8_t*) src); | 500 fSwizzler->swizzle(dst, (const uint8_t*) src); |
| 499 break; | 501 break; |
| 500 case kColorOnly_XformMode: | 502 case kColorOnly_XformMode: |
| 501 fColorXform->apply(dst, (const uint32_t*) src, fXformWidth, fXformCo
lorFormat, | 503 fColorXform->apply(dst, (const uint32_t*) src, fXformWidth, fXformCo
lorFormat, |
| 502 fXformAlphaType); | 504 srcColorFormat, fXformAlphaType); |
| 503 break; | 505 break; |
| 504 case kSwizzleColor_XformMode: | 506 case kSwizzleColor_XformMode: |
| 505 fSwizzler->swizzle(fColorXformSrcRow, (const uint8_t*) src); | 507 fSwizzler->swizzle(fColorXformSrcRow, (const uint8_t*) src); |
| 506 fColorXform->apply(dst, fColorXformSrcRow, fXformWidth, fXformColorF
ormat, | 508 fColorXform->apply(dst, fColorXformSrcRow, fXformWidth, fXformColorF
ormat, |
| 507 fXformAlphaType); | 509 srcColorFormat, fXformAlphaType); |
| 508 break; | 510 break; |
| 509 } | 511 } |
| 510 } | 512 } |
| 511 | 513 |
| 512 class SkPngNormalDecoder : public SkPngCodec { | 514 class SkPngNormalDecoder : public SkPngCodec { |
| 513 public: | 515 public: |
| 514 SkPngNormalDecoder(const SkEncodedInfo& info, const SkImageInfo& imageInfo,
SkStream* stream, | 516 SkPngNormalDecoder(const SkEncodedInfo& info, const SkImageInfo& imageInfo,
SkStream* stream, |
| 515 SkPngChunkReader* reader, png_structp png_ptr, png_infop info_ptr, i
nt bitDepth) | 517 SkPngChunkReader* reader, png_structp png_ptr, png_infop info_ptr, i
nt bitDepth) |
| 516 : INHERITED(info, imageInfo, stream, reader, png_ptr, info_ptr, bitDepth
) | 518 : INHERITED(info, imageInfo, stream, reader, png_ptr, info_ptr, bitDepth
) |
| 517 , fLinesDecoded(0) | 519 , fLinesDecoded(0) |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1298 SkCodec* outCodec = nullptr; | 1300 SkCodec* outCodec = nullptr; |
| 1299 if (read_header(streamDeleter.get(), chunkReader, &outCodec, nullptr, nullpt
r)) { | 1301 if (read_header(streamDeleter.get(), chunkReader, &outCodec, nullptr, nullpt
r)) { |
| 1300 // Codec has taken ownership of the stream. | 1302 // Codec has taken ownership of the stream. |
| 1301 SkASSERT(outCodec); | 1303 SkASSERT(outCodec); |
| 1302 streamDeleter.release(); | 1304 streamDeleter.release(); |
| 1303 return outCodec; | 1305 return outCodec; |
| 1304 } | 1306 } |
| 1305 | 1307 |
| 1306 return nullptr; | 1308 return nullptr; |
| 1307 } | 1309 } |
| OLD | NEW |