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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 for (auto profile : profiles) { | 77 for (auto profile : profiles) { |
78 const SkImageInfo info = SkImageInfo::Make(1024, 100, kN32_SkColorType,
kPremul_SkAlphaType, | 78 const SkImageInfo info = SkImageInfo::Make(1024, 100, kN32_SkColorType,
kPremul_SkAlphaType, |
79 profile); | 79 profile); |
80 auto surface(SkSurface::MakeRaster(info)); | 80 auto surface(SkSurface::MakeRaster(info)); |
81 surface->getCanvas()->drawPaint(bg); | 81 surface->getCanvas()->drawPaint(bg); |
82 draw_into_canvas(surface->getCanvas()); | 82 draw_into_canvas(surface->getCanvas()); |
83 surface->draw(canvas, 0, 0, nullptr); | 83 surface->draw(canvas, 0, 0, nullptr); |
84 canvas->translate(0, 120); | 84 canvas->translate(0, 120); |
85 } | 85 } |
86 } | 86 } |
| 87 |
| 88 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 89 #include "SkColorSpace.h" |
| 90 |
| 91 DEF_SIMPLE_GM(color4shader, canvas, 1024, 260) { |
| 92 canvas->translate(10, 10); |
| 93 |
| 94 SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); |
| 95 // red -> blue, green -> red, blue -> green |
| 96 mat.set3x3(0, 1, 0, 0, 0, 1, 1, 0, 0); |
| 97 |
| 98 const SkColor4f colors[] { |
| 99 { 1, 1, 0, 0 }, |
| 100 { 1, 0, 1, 0 }, |
| 101 { 1, 0, 0, 1 }, |
| 102 { 1, 0.5, 0.5, 0.5 }, |
| 103 }; |
| 104 |
| 105 SkPaint paint; |
| 106 SkRect r = SkRect::MakeWH(100, 100); |
| 107 |
| 108 for (const auto& c4 : colors) { |
| 109 sk_sp<SkShader> shaders[] { |
| 110 SkShader::MakeColorShader(c4, nullptr), |
| 111 SkShader::MakeColorShader(c4, SkColorSpace::NewNamed(SkColorSpace::k
SRGB_Named)), |
| 112 SkShader::MakeColorShader(c4, SkColorSpace::NewRGB(SkColorSpace::SkG
ammas(1, 1, 1), |
| 113 mat)), |
| 114 }; |
| 115 |
| 116 canvas->save(); |
| 117 for (const auto& s : shaders) { |
| 118 paint.setShader(s); |
| 119 canvas->drawRect(r, paint); |
| 120 canvas->translate(r.width() * 6 / 5, 0); |
| 121 } |
| 122 canvas->restore(); |
| 123 canvas->translate(0, r.height() * 6 / 5); |
| 124 } |
| 125 } |
OLD | NEW |