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

Side by Side Diff: gm/color4f.cpp

Issue 1985903002: Prepare SkColorSpace to be a public API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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 | src/codec/SkPngCodec.cpp » ('j') | src/core/SkColorSpace.h » ('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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
98 const SkColor4f colors[] { 100 const SkColor4f colors[] {
99 { 1, 1, 0, 0 }, 101 { 1, 1, 0, 0 },
100 { 1, 0, 1, 0 }, 102 { 1, 0, 1, 0 },
101 { 1, 0, 0, 1 }, 103 { 1, 0, 0, 1 },
102 { 1, 0.5, 0.5, 0.5 }, 104 { 1, 0.5, 0.5, 0.5 },
103 }; 105 };
104 106
105 SkPaint paint; 107 SkPaint paint;
106 SkRect r = SkRect::MakeWH(100, 100); 108 SkRect r = SkRect::MakeWH(100, 100);
107 109
108 for (const auto& c4 : colors) { 110 for (const auto& c4 : colors) {
109 sk_sp<SkShader> shaders[] { 111 sk_sp<SkShader> shaders[] {
110 SkShader::MakeColorShader(c4, nullptr), 112 SkShader::MakeColorShader(c4, nullptr),
111 SkShader::MakeColorShader(c4, SkColorSpace::NewNamed(SkColorSpace::k SRGB_Named)), 113 SkShader::MakeColorShader(c4, SkColorSpace::NewNamed(SkColorSpace::k SRGB_Named)),
112 SkShader::MakeColorShader(c4, SkColorSpace::NewRGB(SkColorSpace::SkG ammas(1, 1, 1), 114 SkShader::MakeColorShader(c4, SkColorSpace::NewRGB(linearGamma, mat) ),
113 mat)),
114 }; 115 };
115 116
116 canvas->save(); 117 canvas->save();
117 for (const auto& s : shaders) { 118 for (const auto& s : shaders) {
118 paint.setShader(s); 119 paint.setShader(s);
119 canvas->drawRect(r, paint); 120 canvas->drawRect(r, paint);
120 canvas->translate(r.width() * 6 / 5, 0); 121 canvas->translate(r.width() * 6 / 5, 0);
121 } 122 }
122 canvas->restore(); 123 canvas->restore();
123 canvas->translate(0, r.height() * 6 / 5); 124 canvas->translate(0, r.height() * 6 / 5);
124 } 125 }
125 } 126 }
OLDNEW
« no previous file with comments | « no previous file | src/codec/SkPngCodec.cpp » ('j') | src/core/SkColorSpace.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698