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