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 "gm.h" | 8 #include "gm.h" |
9 | 9 |
10 #include "Resources.h" | 10 #include "Resources.h" |
11 #include "SkGradientShader.h" | 11 #include "SkGradientShader.h" |
12 #include "SkPM4fPriv.h" | 12 #include "SkPM4fPriv.h" |
13 | 13 |
14 DEF_SIMPLE_GM(gamma, canvas, 560, 200) { | 14 DEF_SIMPLE_GM(gamma, canvas, 560, 200) { |
15 SkPaint p; | 15 SkPaint p; |
16 const SkScalar sz = 50.0f; | 16 const SkScalar sz = 50.0f; |
17 const int szInt = SkScalarTruncToInt(sz); | 17 const int szInt = SkScalarTruncToInt(sz); |
18 const SkScalar tx = sz + 5.0f; | 18 const SkScalar tx = sz + 5.0f; |
19 const SkRect r = SkRect::MakeXYWH(0, 0, sz, sz); | 19 const SkRect r = SkRect::MakeXYWH(0, 0, sz, sz); |
20 SkShader::TileMode rpt = SkShader::kRepeat_TileMode; | 20 SkShader::TileMode rpt = SkShader::kRepeat_TileMode; |
21 auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); | |
22 | 21 |
23 SkBitmap ditherBmp; | 22 SkBitmap ditherBmp; |
24 ditherBmp.allocN32Pixels(2, 2); | 23 ditherBmp.allocN32Pixels(2, 2); |
25 SkPMColor* pixels = reinterpret_cast<SkPMColor*>(ditherBmp.getPixels()); | 24 SkPMColor* pixels = reinterpret_cast<SkPMColor*>(ditherBmp.getPixels()); |
26 pixels[0] = pixels[3] = SkPackARGB32(0xFF, 0xFF, 0xFF, 0xFF); | 25 pixels[0] = pixels[3] = SkPackARGB32(0xFF, 0xFF, 0xFF, 0xFF); |
27 pixels[1] = pixels[2] = SkPackARGB32(0xFF, 0, 0, 0); | 26 pixels[1] = pixels[2] = SkPackARGB32(0xFF, 0, 0, 0); |
28 | 27 |
29 SkBitmap linearGreyBmp; | 28 SkBitmap linearGreyBmp; |
30 SkImageInfo linearGreyInfo = SkImageInfo::MakeN32(szInt, szInt, kOpaque_SkAl
phaType, nullptr); | 29 SkImageInfo linearGreyInfo = SkImageInfo::MakeN32(szInt, szInt, kOpaque_SkAl
phaType, |
| 30 kLinear_SkColorProfileType
); |
31 linearGreyBmp.allocPixels(linearGreyInfo); | 31 linearGreyBmp.allocPixels(linearGreyInfo); |
32 linearGreyBmp.eraseARGB(0xFF, 0x7F, 0x7F, 0x7F); | 32 linearGreyBmp.eraseARGB(0xFF, 0x7F, 0x7F, 0x7F); |
33 | 33 |
34 SkBitmap srgbGreyBmp; | 34 SkBitmap srgbGreyBmp; |
35 SkImageInfo srgbGreyInfo = SkImageInfo::MakeN32(szInt, szInt, kOpaque_SkAlph
aType, | 35 SkImageInfo srgbGreyInfo = SkImageInfo::MakeN32(szInt, szInt, kOpaque_SkAlph
aType, |
36 srgbColorSpace); | 36 kSRGB_SkColorProfileType); |
37 srgbGreyBmp.allocPixels(srgbGreyInfo); | 37 srgbGreyBmp.allocPixels(srgbGreyInfo); |
38 // 0xBC = 255 * linear_to_srgb(0.5f) | 38 // 0xBC = 255 * linear_to_srgb(0.5f) |
39 srgbGreyBmp.eraseARGB(0xFF, 0xBC, 0xBC, 0xBC); | 39 srgbGreyBmp.eraseARGB(0xFF, 0xBC, 0xBC, 0xBC); |
40 | 40 |
41 SkBitmap mipmapBmp; | 41 SkBitmap mipmapBmp; |
42 SkImageInfo mipmapInfo = SkImageInfo::Make(2, 2, kN32_SkColorType, kOpaque_S
kAlphaType, | 42 SkImageInfo mipmapInfo = SkImageInfo::Make(2, 2, kN32_SkColorType, kOpaque_S
kAlphaType, |
43 srgbColorSpace); | 43 SkColorSpace::NewNamed(SkColorSpa
ce::kSRGB_Named)); |
44 mipmapBmp.allocPixels(mipmapInfo); | 44 mipmapBmp.allocPixels(mipmapInfo); |
45 SkPMColor* mipmapPixels = reinterpret_cast<SkPMColor*>(mipmapBmp.getPixels()
); | 45 SkPMColor* mipmapPixels = reinterpret_cast<SkPMColor*>(mipmapBmp.getPixels()
); |
46 unsigned s25 = 0x89; // 255 * linear_to_srgb(0.25f) | 46 unsigned s25 = 0x89; // 255 * linear_to_srgb(0.25f) |
47 unsigned s75 = 0xE1; // 255 * linear_to_srgb(0.75f) | 47 unsigned s75 = 0xE1; // 255 * linear_to_srgb(0.75f) |
48 mipmapPixels[0] = mipmapPixels[3] = SkPackARGB32(0xFF, s25, s25, s25); | 48 mipmapPixels[0] = mipmapPixels[3] = SkPackARGB32(0xFF, s25, s25, s25); |
49 mipmapPixels[1] = mipmapPixels[2] = SkPackARGB32(0xFF, s75, s75, s75); | 49 mipmapPixels[1] = mipmapPixels[2] = SkPackARGB32(0xFF, s75, s75, s75); |
50 | 50 |
51 SkPaint textPaint; | 51 SkPaint textPaint; |
52 textPaint.setColor(SK_ColorWHITE); | 52 textPaint.setColor(SK_ColorWHITE); |
53 | 53 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 nextXferRect(SK_ColorWHITE, SkXfermode::kSrcIn_Mode, 0x7fff00ff); | 175 nextXferRect(SK_ColorWHITE, SkXfermode::kSrcIn_Mode, 0x7fff00ff); |
176 nextXferRect(0x7fff00ff, SkXfermode::kDstIn_Mode, SK_ColorWHITE); | 176 nextXferRect(0x7fff00ff, SkXfermode::kDstIn_Mode, SK_ColorWHITE); |
177 nextXferRect(sqrtHalfWhite, SkXfermode::kSrcIn_Mode, sqrtHalfAlpha); | 177 nextXferRect(sqrtHalfWhite, SkXfermode::kSrcIn_Mode, sqrtHalfAlpha); |
178 nextXferRect(sqrtHalfAlpha, SkXfermode::kDstIn_Mode, sqrtHalfWhite); | 178 nextXferRect(sqrtHalfAlpha, SkXfermode::kDstIn_Mode, sqrtHalfWhite); |
179 | 179 |
180 nextXferRect(0xff3f3f3f, SkXfermode::kPlus_Mode, 0xff3f3f3f); | 180 nextXferRect(0xff3f3f3f, SkXfermode::kPlus_Mode, 0xff3f3f3f); |
181 nextXferRect(sqrtHalfWhite, SkXfermode::kModulate_Mode, sqrtHalfWhite); | 181 nextXferRect(sqrtHalfWhite, SkXfermode::kModulate_Mode, sqrtHalfWhite); |
182 | 182 |
183 canvas->restore(); | 183 canvas->restore(); |
184 } | 184 } |
OLD | NEW |