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

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

Issue 2390263002: Add SkColorSpaceXform to the public API (Closed)
Patch Set: Remove type on enum Created 4 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
« no previous file with comments | « src/codec/SkJpegCodec.cpp ('k') | src/codec/SkWebpCodec.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 * 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
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, 275 SkAssertResult(fColorXform->apply(xformColorFormat, colorTable,
276 SkColorSpaceXform::kRGBA_8888_ColorFormat, xformAlpha Type); 276 SkColorSpaceXform::kRGBA_8888_ColorFor mat, colorTable,
277 numColors, xformAlphaType));
277 } 278 }
278 279
279 // Pad the color table with the last color in the table (or black) in the ca se that 280 // Pad the color table with the last color in the table (or black) in the ca se that
280 // invalid pixel indices exceed the number of colors in the table. 281 // invalid pixel indices exceed the number of colors in the table.
281 const int maxColors = 1 << fBitDepth; 282 const int maxColors = 1 << fBitDepth;
282 if (numColors < maxColors) { 283 if (numColors < maxColors) {
283 SkPMColor lastColor = numColors > 0 ? colorTable[numColors - 1] : SK_Col orBLACK; 284 SkPMColor lastColor = numColors > 0 ? colorTable[numColors - 1] : SK_Col orBLACK;
284 sk_memset32(colorTable + numColors, lastColor, maxColors - numColors); 285 sk_memset32(colorTable + numColors, lastColor, maxColors - numColors);
285 } 286 }
286 287
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 } 494 }
494 } 495 }
495 496
496 void SkPngCodec::applyXformRow(void* dst, const void* src) { 497 void SkPngCodec::applyXformRow(void* dst, const void* src) {
497 const SkColorSpaceXform::ColorFormat srcColorFormat = SkColorSpaceXform::kRG BA_8888_ColorFormat; 498 const SkColorSpaceXform::ColorFormat srcColorFormat = SkColorSpaceXform::kRG BA_8888_ColorFormat;
498 switch (fXformMode) { 499 switch (fXformMode) {
499 case kSwizzleOnly_XformMode: 500 case kSwizzleOnly_XformMode:
500 fSwizzler->swizzle(dst, (const uint8_t*) src); 501 fSwizzler->swizzle(dst, (const uint8_t*) src);
501 break; 502 break;
502 case kColorOnly_XformMode: 503 case kColorOnly_XformMode:
503 fColorXform->apply(dst, (const uint32_t*) src, fXformWidth, fXformCo lorFormat, 504 SkAssertResult(fColorXform->apply(fXformColorFormat, dst, srcColorFo rmat, src,
504 srcColorFormat, fXformAlphaType); 505 fXformWidth, fXformAlphaType));
505 break; 506 break;
506 case kSwizzleColor_XformMode: 507 case kSwizzleColor_XformMode:
507 fSwizzler->swizzle(fColorXformSrcRow, (const uint8_t*) src); 508 fSwizzler->swizzle(fColorXformSrcRow, (const uint8_t*) src);
508 fColorXform->apply(dst, fColorXformSrcRow, fXformWidth, fXformColorF ormat, 509 SkAssertResult(fColorXform->apply(fXformColorFormat, dst, srcColorFo rmat, fColorXformSrcRow,
509 srcColorFormat, fXformAlphaType); 510 fXformWidth, fXformAlphaType));
510 break; 511 break;
511 } 512 }
512 } 513 }
513 514
514 class SkPngNormalDecoder : public SkPngCodec { 515 class SkPngNormalDecoder : public SkPngCodec {
515 public: 516 public:
516 SkPngNormalDecoder(const SkEncodedInfo& info, const SkImageInfo& imageInfo, SkStream* stream, 517 SkPngNormalDecoder(const SkEncodedInfo& info, const SkImageInfo& imageInfo, SkStream* stream,
517 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)
518 : INHERITED(info, imageInfo, stream, reader, png_ptr, info_ptr, bitDepth ) 519 : INHERITED(info, imageInfo, stream, reader, png_ptr, info_ptr, bitDepth )
519 , fLinesDecoded(0) 520 , fLinesDecoded(0)
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 SkCodec* outCodec = nullptr; 1301 SkCodec* outCodec = nullptr;
1301 if (read_header(streamDeleter.get(), chunkReader, &outCodec, nullptr, nullpt r)) { 1302 if (read_header(streamDeleter.get(), chunkReader, &outCodec, nullptr, nullpt r)) {
1302 // Codec has taken ownership of the stream. 1303 // Codec has taken ownership of the stream.
1303 SkASSERT(outCodec); 1304 SkASSERT(outCodec);
1304 streamDeleter.release(); 1305 streamDeleter.release();
1305 return outCodec; 1306 return outCodec;
1306 } 1307 }
1307 1308
1308 return nullptr; 1309 return nullptr;
1309 } 1310 }
OLDNEW
« no previous file with comments | « src/codec/SkJpegCodec.cpp ('k') | src/codec/SkWebpCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698