OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "gm.h" | 8 #include "gm.h" |
9 | 9 |
10 #include "SkColorSpace_Base.h" | 10 #include "SkColorSpace_Base.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 0.7161046f, 0.1009296f, 0.1471858f, // -> X | 120 0.7161046f, 0.1009296f, 0.1471858f, // -> X |
121 0.2581874f, 0.7249378f, 0.0168748f, // -> Y | 121 0.2581874f, 0.7249378f, 0.0168748f, // -> Y |
122 0.0000000f, 0.0517813f, 0.7734287f, // -> Z | 122 0.0000000f, 0.0517813f, 0.7734287f, // -> Z |
123 }; | 123 }; |
124 | 124 |
125 SkMatrix44 wideGamutRGB_toXYZD50(SkMatrix44::kUninitialized_Constructor); | 125 SkMatrix44 wideGamutRGB_toXYZD50(SkMatrix44::kUninitialized_Constructor); |
126 wideGamutRGB_toXYZD50.set3x3RowMajorf(gWideGamutRGB_toXYZD50); | 126 wideGamutRGB_toXYZD50.set3x3RowMajorf(gWideGamutRGB_toXYZD50); |
127 | 127 |
128 // Use the original canvas' color type, but account for gamma requirements | 128 // Use the original canvas' color type, but account for gamma requirements |
129 SkImageInfo origInfo = canvas->imageInfo(); | 129 SkImageInfo origInfo = canvas->imageInfo(); |
130 auto srgbCS = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); | 130 sk_sp<SkColorSpace> srgbCS; |
131 auto wideCS = SkColorSpace::NewRGB(SkColorSpace::kSRGB_RenderTargetGamma, | 131 sk_sp<SkColorSpace> wideCS; |
132 wideGamutRGB_toXYZD50); | |
133 switch (origInfo.colorType()) { | 132 switch (origInfo.colorType()) { |
134 case kRGBA_8888_SkColorType: | 133 case kRGBA_8888_SkColorType: |
135 case kBGRA_8888_SkColorType: | 134 case kBGRA_8888_SkColorType: |
| 135 srgbCS = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); |
| 136 wideCS = SkColorSpace::NewRGB(SkColorSpace::kSRGB_RenderTargetGamma, |
| 137 wideGamutRGB_toXYZD50); |
136 break; | 138 break; |
137 case kRGBA_F16_SkColorType: | 139 case kRGBA_F16_SkColorType: |
138 srgbCS = as_CSB(srgbCS.get())->makeLinearGamma(); | 140 srgbCS = SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named); |
139 wideCS = as_CSB(wideCS.get())->makeLinearGamma(); | 141 wideCS = SkColorSpace::NewRGB(SkColorSpace::kLinear_RenderTargetGamm
a, |
| 142 wideGamutRGB_toXYZD50); |
140 break; | 143 break; |
141 default: | 144 default: |
142 return; | 145 return; |
143 } | 146 } |
| 147 SkASSERT(srgbCS); |
| 148 SkASSERT(wideCS); |
144 | 149 |
145 // Make our two working surfaces (one sRGB, one Adobe) | 150 // Make our two working surfaces (one sRGB, one Adobe) |
146 SkImageInfo srgbGamutInfo = SkImageInfo::Make(gRectSize, gRectSize, origInfo
.colorType(), | 151 SkImageInfo srgbGamutInfo = SkImageInfo::Make(gRectSize, gRectSize, origInfo
.colorType(), |
147 kPremul_SkAlphaType, srgbCS); | 152 kPremul_SkAlphaType, srgbCS); |
148 SkImageInfo wideGamutInfo = SkImageInfo::Make(gRectSize, gRectSize, origInfo
.colorType(), | 153 SkImageInfo wideGamutInfo = SkImageInfo::Make(gRectSize, gRectSize, origInfo
.colorType(), |
149 kPremul_SkAlphaType, wideCS); | 154 kPremul_SkAlphaType, wideCS); |
150 // readPixels doesn't do color conversion (yet), so we can use it to see the
raw (wide) data | 155 // readPixels doesn't do color conversion (yet), so we can use it to see the
raw (wide) data |
151 SkImageInfo dstInfo = srgbGamutInfo.makeColorSpace(nullptr); | 156 SkImageInfo dstInfo = srgbGamutInfo.makeColorSpace(nullptr); |
152 sk_sp<SkSurface> srgbGamutSurface = canvas->makeSurface(srgbGamutInfo); | 157 sk_sp<SkSurface> srgbGamutSurface = canvas->makeSurface(srgbGamutInfo); |
153 sk_sp<SkSurface> wideGamutSurface = canvas->makeSurface(wideGamutInfo); | 158 sk_sp<SkSurface> wideGamutSurface = canvas->makeSurface(wideGamutInfo); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 renderers.push_back(new GradientCellRenderer(SK_ColorRED, SK_ColorGREEN, tru
e)); | 224 renderers.push_back(new GradientCellRenderer(SK_ColorRED, SK_ColorGREEN, tru
e)); |
220 renderers.push_back(new GradientCellRenderer(SK_ColorGREEN, SK_ColorBLACK, t
rue)); | 225 renderers.push_back(new GradientCellRenderer(SK_ColorGREEN, SK_ColorBLACK, t
rue)); |
221 renderers.push_back(new GradientCellRenderer(SK_ColorGREEN, SK_ColorWHITE, t
rue)); | 226 renderers.push_back(new GradientCellRenderer(SK_ColorGREEN, SK_ColorWHITE, t
rue)); |
222 | 227 |
223 // Vertex colors | 228 // Vertex colors |
224 renderers.push_back(new VerticesCellRenderer(SK_ColorRED, SK_ColorRED)); | 229 renderers.push_back(new VerticesCellRenderer(SK_ColorRED, SK_ColorRED)); |
225 renderers.push_back(new VerticesCellRenderer(SK_ColorRED, SK_ColorGREEN)); | 230 renderers.push_back(new VerticesCellRenderer(SK_ColorRED, SK_ColorGREEN)); |
226 | 231 |
227 draw_gamut_grid(canvas, renderers); | 232 draw_gamut_grid(canvas, renderers); |
228 } | 233 } |
OLD | NEW |