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

Side by Side Diff: samplecode/SampleAnimBlur.cpp

Issue 1852113003: switch maskfilters to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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 | « samplecode/SampleAll.cpp ('k') | samplecode/SampleBigBlur.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 "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkAnimTimer.h" 9 #include "SkAnimTimer.h"
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
(...skipping 28 matching lines...) Expand all
39 void onDrawContent(SkCanvas* canvas) override { 39 void onDrawContent(SkCanvas* canvas) override {
40 static const SkBlurStyle gStyles[] = { 40 static const SkBlurStyle gStyles[] = {
41 kNormal_SkBlurStyle, 41 kNormal_SkBlurStyle,
42 kInner_SkBlurStyle, 42 kInner_SkBlurStyle,
43 kSolid_SkBlurStyle, 43 kSolid_SkBlurStyle,
44 kOuter_SkBlurStyle, 44 kOuter_SkBlurStyle,
45 }; 45 };
46 SkRandom random; 46 SkRandom random;
47 47
48 for (size_t i = 0; i < SK_ARRAY_COUNT(gStyles); ++i) { 48 for (size_t i = 0; i < SK_ARRAY_COUNT(gStyles); ++i) {
49 SkMaskFilter* mf = SkBlurMaskFilter::Create(
50 gStyles[i],
51 fBlurSigma,
52 SkBlurMaskFilter::kHighQuality_BlurFlag);
53 SkPaint paint; 49 SkPaint paint;
54 SkSafeUnref(paint.setMaskFilter(mf)); 50 paint.setMaskFilter(SkBlurMaskFilter::Make(gStyles[i],
51 fBlurSigma,
52 SkBlurMaskFilter::kHighQu ality_BlurFlag));
55 paint.setColor(random.nextU() | 0xff000000); 53 paint.setColor(random.nextU() | 0xff000000);
56 canvas->drawCircle(200 * SK_Scalar1 + 400 * (i % 2) * SK_Scalar1, 54 canvas->drawCircle(200 * SK_Scalar1 + 400 * (i % 2) * SK_Scalar1,
57 200 * SK_Scalar1 + i / 2 * 400 * SK_Scalar1, 55 200 * SK_Scalar1 + i / 2 * 400 * SK_Scalar1,
58 fCircleRadius, paint); 56 fCircleRadius, paint);
59 } 57 }
60 } 58 }
61 59
62 bool onAnimate(const SkAnimTimer& timer) override { 60 bool onAnimate(const SkAnimTimer& timer) override {
63 fBlurSigma = get_anim_sin(timer.secs(), 100, 4, 5); 61 fBlurSigma = get_anim_sin(timer.secs(), 100, 4, 5);
64 fCircleRadius = 3 + get_anim_sin(timer.secs(), 150, 25, 3); 62 fCircleRadius = 3 + get_anim_sin(timer.secs(), 150, 25, 3);
65 return true; 63 return true;
66 } 64 }
67 65
68 private: 66 private:
69 SkScalar fBlurSigma, fCircleRadius; 67 SkScalar fBlurSigma, fCircleRadius;
70 68
71 typedef SampleView INHERITED; 69 typedef SampleView INHERITED;
72 }; 70 };
73 71
74 ////////////////////////////////////////////////////////////////////////////// 72 //////////////////////////////////////////////////////////////////////////////
75 73
76 static SkView* MyFactory() { return new AnimBlurView; } 74 static SkView* MyFactory() { return new AnimBlurView; }
77 static SkViewRegister reg(MyFactory); 75 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleAll.cpp ('k') | samplecode/SampleBigBlur.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698