Chromium Code Reviews| 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 static constexpr SkColorSpaceXform::ColorFormat srcColorFormat = | |
|
mtklein
2016/09/22 13:57:00
Usually this sort of thing is fine spelled "const"
msarett
2016/09/22 17:06:54
Done.
| |
| 498 SkColorSpaceXform::kRGBA_8888_ColorFormat; | |
| 496 switch (fXformMode) { | 499 switch (fXformMode) { |
| 497 case kSwizzleOnly_XformMode: | 500 case kSwizzleOnly_XformMode: |
| 498 fSwizzler->swizzle(dst, (const uint8_t*) src); | 501 fSwizzler->swizzle(dst, (const uint8_t*) src); |
| 499 break; | 502 break; |
| 500 case kColorOnly_XformMode: | 503 case kColorOnly_XformMode: |
| 501 fColorXform->apply(dst, (const uint32_t*) src, fXformWidth, fXformCo lorFormat, | 504 fColorXform->apply(dst, (const uint32_t*) src, fXformWidth, fXformCo lorFormat, |
| 502 fXformAlphaType); | 505 srcColorFormat, fXformAlphaType); |
| 503 break; | 506 break; |
| 504 case kSwizzleColor_XformMode: | 507 case kSwizzleColor_XformMode: |
| 505 fSwizzler->swizzle(fColorXformSrcRow, (const uint8_t*) src); | 508 fSwizzler->swizzle(fColorXformSrcRow, (const uint8_t*) src); |
| 506 fColorXform->apply(dst, fColorXformSrcRow, fXformWidth, fXformColorF ormat, | 509 fColorXform->apply(dst, fColorXformSrcRow, fXformWidth, fXformColorF ormat, |
| 507 fXformAlphaType); | 510 srcColorFormat, fXformAlphaType); |
| 508 break; | 511 break; |
| 509 } | 512 } |
| 510 } | 513 } |
| 511 | 514 |
| 512 class SkPngNormalDecoder : public SkPngCodec { | 515 class SkPngNormalDecoder : public SkPngCodec { |
| 513 public: | 516 public: |
| 514 SkPngNormalDecoder(const SkEncodedInfo& info, const SkImageInfo& imageInfo, SkStream* stream, | 517 SkPngNormalDecoder(const SkEncodedInfo& info, const SkImageInfo& imageInfo, SkStream* stream, |
| 515 SkPngChunkReader* reader, png_structp png_ptr, png_infop info_ptr, i nt bitDepth) | 518 SkPngChunkReader* reader, png_structp png_ptr, png_infop info_ptr, i nt bitDepth) |
| 516 : INHERITED(info, imageInfo, stream, reader, png_ptr, info_ptr, bitDepth ) | 519 : INHERITED(info, imageInfo, stream, reader, png_ptr, info_ptr, bitDepth ) |
| 517 , fLinesDecoded(0) | 520 , fLinesDecoded(0) |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1298 SkCodec* outCodec = nullptr; | 1301 SkCodec* outCodec = nullptr; |
| 1299 if (read_header(streamDeleter.get(), chunkReader, &outCodec, nullptr, nullpt r)) { | 1302 if (read_header(streamDeleter.get(), chunkReader, &outCodec, nullptr, nullpt r)) { |
| 1300 // Codec has taken ownership of the stream. | 1303 // Codec has taken ownership of the stream. |
| 1301 SkASSERT(outCodec); | 1304 SkASSERT(outCodec); |
| 1302 streamDeleter.release(); | 1305 streamDeleter.release(); |
| 1303 return outCodec; | 1306 return outCodec; |
| 1304 } | 1307 } |
| 1305 | 1308 |
| 1306 return nullptr; | 1309 return nullptr; |
| 1307 } | 1310 } |
| OLD | NEW |