OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 | 90 |
91 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 91 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
92 #include "SkColorSpace.h" | 92 #include "SkColorSpace.h" |
93 | 93 |
94 DEF_SIMPLE_GM(color4shader, canvas, 1024, 260) { | 94 DEF_SIMPLE_GM(color4shader, canvas, 1024, 260) { |
95 canvas->translate(10, 10); | 95 canvas->translate(10, 10); |
96 | 96 |
97 SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); | 97 SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); |
98 // red -> blue, green -> red, blue -> green | 98 // red -> blue, green -> red, blue -> green |
99 mat.set3x3(0, 1, 0, 0, 0, 1, 1, 0, 0); | 99 mat.set3x3(0, 0, 1, 1, 0, 0, 0, 1, 0); |
100 | 100 |
101 const SkColor4f colors[] { | 101 const SkColor4f colors[] { |
102 { 1, 0, 0, 1 }, | 102 { 1, 0, 0, 1 }, |
103 { 0, 1, 0, 1 }, | 103 { 0, 1, 0, 1 }, |
104 { 0, 0, 1, 1 }, | 104 { 0, 0, 1, 1 }, |
105 { 0.5, 0.5, 0.5, 1 }, | 105 { 0.5, 0.5, 0.5, 1 }, |
106 }; | 106 }; |
107 | 107 |
108 SkPaint paint; | 108 SkPaint paint; |
109 SkRect r = SkRect::MakeWH(100, 100); | 109 SkRect r = SkRect::MakeWH(100, 100); |
110 | 110 |
111 for (const auto& c4 : colors) { | 111 for (const auto& c4 : colors) { |
112 sk_sp<SkShader> shaders[] { | 112 sk_sp<SkShader> shaders[] { |
113 SkShader::MakeColorShader(c4, nullptr), | 113 SkShader::MakeColorShader(c4, nullptr), |
114 SkShader::MakeColorShader(c4, SkColorSpace::NewNamed(SkColorSpace::k
SRGB_Named)), | 114 SkShader::MakeColorShader(c4, SkColorSpace::NewNamed(SkColorSpace::k
SRGB_Named)), |
115 SkShader::MakeColorShader(c4, | 115 SkShader::MakeColorShader(c4, |
116 SkColorSpace::NewRGB(SkColorSpace::kLinear_RenderTargetGamma
, mat)), | 116 SkColorSpace::NewRGB(SkColorSpace::kLinear_RenderTargetGamma
, mat)), |
117 }; | 117 }; |
118 | 118 |
119 canvas->save(); | 119 canvas->save(); |
120 for (const auto& s : shaders) { | 120 for (const auto& s : shaders) { |
121 paint.setShader(s); | 121 paint.setShader(s); |
122 canvas->drawRect(r, paint); | 122 canvas->drawRect(r, paint); |
123 canvas->translate(r.width() * 6 / 5, 0); | 123 canvas->translate(r.width() * 6 / 5, 0); |
124 } | 124 } |
125 canvas->restore(); | 125 canvas->restore(); |
126 canvas->translate(0, r.height() * 6 / 5); | 126 canvas->translate(0, r.height() * 6 / 5); |
127 } | 127 } |
128 } | 128 } |
OLD | NEW |