Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: gm/color4f.cpp

Issue 2324843003: Fix storage of gamut transform matrices in SkColorSpace (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | gm/gamut.cpp » ('j') | src/core/SkColorSpaceXform.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « no previous file | gm/gamut.cpp » ('j') | src/core/SkColorSpaceXform.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698