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: dm/DMSrcSink.cpp

Issue 2389983002: Refactored SkColorSpace and added in a Lab PCS GM (Closed)
Patch Set: migrated call from SkColorSpace_Base::makeLinearGamma() to SkColorSpace_XYZ::makeLinearGamma() 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 | « bench/ColorCodecBench.cpp ('k') | gm/gamut.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 "DMSrcSink.h" 8 #include "DMSrcSink.h"
9 #include "Resources.h" 9 #include "Resources.h"
10 #include "SkAndroidCodec.h" 10 #include "SkAndroidCodec.h"
11 #include "SkCodec.h" 11 #include "SkCodec.h"
12 #include "SkCodecImageGenerator.h" 12 #include "SkCodecImageGenerator.h"
13 #include "SkColorSpace.h" 13 #include "SkColorSpace.h"
14 #include "SkColorSpace_Base.h" 14 #include "SkColorSpace_XYZ.h"
15 #include "SkColorSpaceXform.h" 15 #include "SkColorSpaceXform.h"
16 #include "SkCommonFlags.h" 16 #include "SkCommonFlags.h"
17 #include "SkData.h" 17 #include "SkData.h"
18 #include "SkDeferredCanvas.h" 18 #include "SkDeferredCanvas.h"
19 #include "SkDocument.h" 19 #include "SkDocument.h"
20 #include "SkImageGenerator.h" 20 #include "SkImageGenerator.h"
21 #include "SkImageGeneratorCG.h" 21 #include "SkImageGeneratorCG.h"
22 #include "SkImageGeneratorWIC.h" 22 #include "SkImageGeneratorWIC.h"
23 #include "SkLiteDL.h" 23 #include "SkLiteDL.h"
24 #include "SkLiteRecorder.h" 24 #include "SkLiteRecorder.h"
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 dstSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); 913 dstSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
914 } else if (kDst_HPZR30w_Mode == fMode) { 914 } else if (kDst_HPZR30w_Mode == fMode) {
915 dstSpace = SkColorSpace::NewICC(dstData->data(), dstData->size()); 915 dstSpace = SkColorSpace::NewICC(dstData->data(), dstData->size());
916 } 916 }
917 917
918 SkImageInfo decodeInfo = codec->getInfo().makeColorType(fColorType).makeColo rSpace(dstSpace); 918 SkImageInfo decodeInfo = codec->getInfo().makeColorType(fColorType).makeColo rSpace(dstSpace);
919 if (kUnpremul_SkAlphaType == decodeInfo.alphaType()) { 919 if (kUnpremul_SkAlphaType == decodeInfo.alphaType()) {
920 decodeInfo = decodeInfo.makeAlphaType(kPremul_SkAlphaType); 920 decodeInfo = decodeInfo.makeAlphaType(kPremul_SkAlphaType);
921 } 921 }
922 if (kRGBA_F16_SkColorType == fColorType) { 922 if (kRGBA_F16_SkColorType == fColorType) {
923 decodeInfo = decodeInfo.makeColorSpace(as_CSB(decodeInfo.colorSpace())-> makeLinearGamma()); 923 SkASSERT(SkColorSpace_Base::Type::kXYZ == as_CSB(decodeInfo.colorSpace() )->type());
924 SkColorSpace_XYZ* csXYZ = static_cast<SkColorSpace_XYZ*>(decodeInfo.colo rSpace());
925 decodeInfo = decodeInfo.makeColorSpace(csXYZ->makeLinearGamma());
924 } 926 }
925 927
926 SkImageInfo bitmapInfo = decodeInfo; 928 SkImageInfo bitmapInfo = decodeInfo;
927 if (kRGBA_8888_SkColorType == decodeInfo.colorType() || 929 if (kRGBA_8888_SkColorType == decodeInfo.colorType() ||
928 kBGRA_8888_SkColorType == decodeInfo.colorType()) 930 kBGRA_8888_SkColorType == decodeInfo.colorType())
929 { 931 {
930 bitmapInfo = bitmapInfo.makeColorType(kN32_SkColorType); 932 bitmapInfo = bitmapInfo.makeColorType(kN32_SkColorType);
931 } 933 }
932 934
933 SkBitmap bitmap; 935 SkBitmap bitmap;
934 if (!bitmap.tryAllocPixels(bitmapInfo)) { 936 if (!bitmap.tryAllocPixels(bitmapInfo)) {
935 return SkStringPrintf("Image(%s) is too large (%d x %d)", fPath.c_str(), 937 return SkStringPrintf("Image(%s) is too large (%d x %d)", fPath.c_str(),
936 bitmapInfo.width(), bitmapInfo.height()); 938 bitmapInfo.width(), bitmapInfo.height());
937 } 939 }
938 940
939 size_t rowBytes = bitmap.rowBytes(); 941 size_t rowBytes = bitmap.rowBytes();
940 SkCodec::Result r = codec->getPixels(decodeInfo, bitmap.getPixels(), rowByte s); 942 SkCodec::Result r = codec->getPixels(decodeInfo, bitmap.getPixels(), rowByte s);
941 if (SkCodec::kSuccess != r && SkCodec::kIncompleteInput != r) { 943 if (SkCodec::kSuccess != r && SkCodec::kIncompleteInput != r) {
942 return SkStringPrintf("Couldn't getPixels %s. Error code %d", fPath.c_st r(), r); 944 if (kRGBA_F16_SkColorType == decodeInfo.colorType()) {
945 // FIXME (raftias):
946 // Get the codecs to not fail when there is no color xform,
947 // which currently happens in F16 mode.
948 return Error::Nonfatal(SkStringPrintf("Couldn't getPixels %s in F16. Error code %d",
949 fPath.c_str()));
950 } else {
951 return SkStringPrintf("Couldn't getPixels %s. Error code %d", fPath. c_str(), r);
952 }
943 } 953 }
944 954
945 switch (fMode) { 955 switch (fMode) {
946 case kBaseline_Mode: 956 case kBaseline_Mode:
947 case kDst_sRGB_Mode: 957 case kDst_sRGB_Mode:
948 case kDst_HPZR30w_Mode: 958 case kDst_HPZR30w_Mode:
949 canvas->drawBitmap(bitmap, 0, 0); 959 canvas->drawBitmap(bitmap, 0, 0);
950 break; 960 break;
951 #if defined(SK_TEST_QCMS) 961 #if defined(SK_TEST_QCMS)
952 case kQCMS_HPZR30w_Mode: { 962 case kQCMS_HPZR30w_Mode: {
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 Error err = src.draw(&rec); 1714 Error err = src.draw(&rec);
1705 if (!err.isEmpty()) { 1715 if (!err.isEmpty()) {
1706 return err; 1716 return err;
1707 } 1717 }
1708 dl->draw(canvas); 1718 dl->draw(canvas);
1709 return check_against_reference(bitmap, src, fSink); 1719 return check_against_reference(bitmap, src, fSink);
1710 }); 1720 });
1711 } 1721 }
1712 1722
1713 } // namespace DM 1723 } // namespace DM
OLDNEW
« no previous file with comments | « bench/ColorCodecBench.cpp ('k') | gm/gamut.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698