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

Side by Side Diff: gm/modecolorfilters.cpp

Issue 1827433002: Reland of [2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.o… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 | « gm/megalooper.cpp ('k') | gm/multipicturedraw.cpp » ('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 2012 Google Inc. 2 * Copyright 2012 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 "SkColorFilter.h" 9 #include "SkColorFilter.h"
10 #include "SkGradientShader.h" 10 #include "SkGradientShader.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 SkXfermode::kXor_Mode, 114 SkXfermode::kXor_Mode,
115 SkXfermode::kPlus_Mode, 115 SkXfermode::kPlus_Mode,
116 SkXfermode::kModulate_Mode, 116 SkXfermode::kModulate_Mode,
117 }; 117 };
118 118
119 SkPaint paint; 119 SkPaint paint;
120 int idx = 0; 120 int idx = 0;
121 static const int kRectsPerRow = SkMax32(this->getISize().fWidth / kRectW idth, 1); 121 static const int kRectsPerRow = SkMax32(this->getISize().fWidth / kRectW idth, 1);
122 for (size_t cfm = 0; cfm < SK_ARRAY_COUNT(modes); ++cfm) { 122 for (size_t cfm = 0; cfm < SK_ARRAY_COUNT(modes); ++cfm) {
123 for (size_t cfc = 0; cfc < SK_ARRAY_COUNT(colors); ++cfc) { 123 for (size_t cfc = 0; cfc < SK_ARRAY_COUNT(colors); ++cfc) {
124 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(c olors[cfc], 124 paint.setColorFilter(SkColorFilter::MakeModeFilter(colors[cfc], modes[cfm]));
125 m odes[cfm]));
126 paint.setColorFilter(cf);
127 for (size_t s = 0; s < SK_ARRAY_COUNT(shaders); ++s) { 125 for (size_t s = 0; s < SK_ARRAY_COUNT(shaders); ++s) {
128 paint.setShader(shaders[s]); 126 paint.setShader(shaders[s]);
129 bool hasShader = nullptr == paint.getShader(); 127 bool hasShader = nullptr == paint.getShader();
130 int paintColorCnt = hasShader ? SK_ARRAY_COUNT(alphas) : SK_ ARRAY_COUNT(colors); 128 int paintColorCnt = hasShader ? SK_ARRAY_COUNT(alphas) : SK_ ARRAY_COUNT(colors);
131 SkColor* paintColors = hasShader ? alphas : colors; 129 SkColor* paintColors = hasShader ? alphas : colors;
132 for (int pc = 0; pc < paintColorCnt; ++pc) { 130 for (int pc = 0; pc < paintColorCnt; ++pc) {
133 paint.setColor(paintColors[pc]); 131 paint.setColor(paintColors[pc]);
134 SkScalar x = SkIntToScalar(idx % kRectsPerRow); 132 SkScalar x = SkIntToScalar(idx % kRectsPerRow);
135 SkScalar y = SkIntToScalar(idx / kRectsPerRow); 133 SkScalar y = SkIntToScalar(idx / kRectsPerRow);
136 SkRect rect = SkRect::MakeXYWH(x * kRectWidth, y * kRect Height, 134 SkRect rect = SkRect::MakeXYWH(x * kRectWidth, y * kRect Height,
(...skipping 14 matching lines...) Expand all
151 sk_sp<SkShader> fBmpShader; 149 sk_sp<SkShader> fBmpShader;
152 typedef GM INHERITED; 150 typedef GM INHERITED;
153 }; 151 };
154 152
155 ////////////////////////////////////////////////////////////////////////////// 153 //////////////////////////////////////////////////////////////////////////////
156 154
157 static GM* MyFactory(void*) { return new ModeColorFilterGM; } 155 static GM* MyFactory(void*) { return new ModeColorFilterGM; }
158 static GMRegistry reg(MyFactory); 156 static GMRegistry reg(MyFactory);
159 157
160 } 158 }
OLDNEW
« no previous file with comments | « gm/megalooper.cpp ('k') | gm/multipicturedraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698