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

Side by Side Diff: gm/color4f.cpp

Issue 1934313002: move colorshader into its own .cpp, add color4f variant (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: register for serialization, amend GM view for future picture expansion 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 | gyp/core.gypi » ('j') | no next file with comments »
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « no previous file | gyp/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698