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

Side by Side Diff: samplecode/SampleDither.cpp

Issue 1772463002: use Make instead of Create to return a shared shader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: partial update of skia call-sites 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkView.h" 9 #include "SkView.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 16 matching lines...) Expand all
27 27
28 p.setAntiAlias(true); 28 p.setAntiAlias(true);
29 // p.setDither(true); 29 // p.setDither(true);
30 p.setStrokeWidth(SkIntToScalar(width/10)); 30 p.setStrokeWidth(SkIntToScalar(width/10));
31 p.setStyle(SkPaint::kStroke_Style); 31 p.setStyle(SkPaint::kStroke_Style);
32 32
33 r.set(0, 0, SkIntToScalar(width), SkIntToScalar(height)); 33 r.set(0, 0, SkIntToScalar(width), SkIntToScalar(height));
34 34
35 // SkColor colors[] = { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN, SK_Colo rCYAN }; 35 // SkColor colors[] = { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN, SK_Colo rCYAN };
36 SkColor colors[] = { 0x4c737373, 0x4c737373, 0xffffd300 }; 36 SkColor colors[] = { 0x4c737373, 0x4c737373, 0xffffd300 };
37 SkShader* s = SkGradientShader::CreateSweep(r.centerX(), r.centerY(), 37 p.setShader(SkGradientShader::MakeSweep(r.centerX(), r.centerY(),
38 colors, nullptr, SK_ARRAY_COUNT( colors)); 38 colors, nullptr, SK_ARRAY_COUNT(colo rs)));
39 p.setShader(s)->unref();
40 39
41 SkAutoCanvasRestore acr(c, true); 40 SkAutoCanvasRestore acr(c, true);
42 41
43 c->translate(r.centerX(), r.centerY()); 42 c->translate(r.centerX(), r.centerY());
44 c->rotate(angle); 43 c->rotate(angle);
45 c->translate(-r.centerX(), -r.centerY()); 44 c->translate(-r.centerX(), -r.centerY());
46 45
47 SkRect bounds = r; 46 SkRect bounds = r;
48 r.inset(p.getStrokeWidth(), p.getStrokeWidth()); 47 r.inset(p.getStrokeWidth(), p.getStrokeWidth());
49 SkRect innerBounds = r; 48 SkRect innerBounds = r;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } 168 }
170 169
171 private: 170 private:
172 typedef SampleView INHERITED; 171 typedef SampleView INHERITED;
173 }; 172 };
174 173
175 ////////////////////////////////////////////////////////////////////////////// 174 //////////////////////////////////////////////////////////////////////////////
176 175
177 static SkView* MyFactory() { return new DitherView; } 176 static SkView* MyFactory() { return new DitherView; }
178 static SkViewRegister reg(MyFactory); 177 static SkViewRegister reg(MyFactory);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698