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

Side by Side Diff: gm/drawfilter.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 | « gm/drawbitmaprect.cpp ('k') | gm/drawlooper.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 2015 Google Inc. 2 * Copyright 2015 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 "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
(...skipping 15 matching lines...) Expand all
26 public: 26 public:
27 bool filter(SkPaint* p, Type) override { 27 bool filter(SkPaint* p, Type) override {
28 p->setColor(SK_ColorRED); 28 p->setColor(SK_ColorRED);
29 p->setMaskFilter(nullptr); 29 p->setMaskFilter(nullptr);
30 return true; 30 return true;
31 } 31 }
32 }; 32 };
33 } 33 }
34 34
35 class DrawFilterGM : public skiagm::GM { 35 class DrawFilterGM : public skiagm::GM {
36 SkAutoTUnref<SkMaskFilter> fBlur; 36 sk_sp<SkMaskFilter> fBlur;
37 37
38 protected: 38 protected:
39 SkISize onISize() override { 39 SkISize onISize() override {
40 return SkISize::Make(320, 240); 40 return SkISize::Make(320, 240);
41 } 41 }
42 42
43 SkString onShortName() override { 43 SkString onShortName() override {
44 return SkString("drawfilter"); 44 return SkString("drawfilter");
45 } 45 }
46 46
47 void onOnceBeforeDraw() override { 47 void onOnceBeforeDraw() override {
48 fBlur.reset(SkBlurMaskFilter::Create(kNormal_SkBlurStyle, 48 fBlur = SkBlurMaskFilter::Make(kNormal_SkBlurStyle,
49 SkBlurMask::ConvertRadiusToSigma(10.0f), 49 SkBlurMask::ConvertRadiusToSigma(10.0f),
50 kLow_SkBlurQuality)); 50 kLow_SkBlurQuality);
51 } 51 }
52 52
53 void onDraw(SkCanvas* canvas) override { 53 void onDraw(SkCanvas* canvas) override {
54 SkPaint p; 54 SkPaint p;
55 p.setColor(SK_ColorBLUE); 55 p.setColor(SK_ColorBLUE);
56 p.setMaskFilter(fBlur.get()); 56 p.setMaskFilter(fBlur);
57 SkRect r = { 20, 20, 100, 100 }; 57 SkRect r = { 20, 20, 100, 100 };
58 canvas->setDrawFilter(nullptr); 58 canvas->setDrawFilter(nullptr);
59 canvas->drawRect(r, p); 59 canvas->drawRect(r, p);
60 TestFilter redNoBlur; 60 TestFilter redNoBlur;
61 canvas->setDrawFilter(&redNoBlur); 61 canvas->setDrawFilter(&redNoBlur);
62 canvas->translate(120.0f, 40.0f); 62 canvas->translate(120.0f, 40.0f);
63 canvas->drawRect(r, p); 63 canvas->drawRect(r, p);
64 64
65 // Must unset if the DrawFilter is from the stack to avoid refcount erro rs! 65 // Must unset if the DrawFilter is from the stack to avoid refcount erro rs!
66 canvas->setDrawFilter(nullptr); 66 canvas->setDrawFilter(nullptr);
67 } 67 }
68 68
69 private: 69 private:
70 typedef GM INHERITED; 70 typedef GM INHERITED;
71 }; 71 };
72 72
73 DEF_GM( return new DrawFilterGM; ) 73 DEF_GM( return new DrawFilterGM; )
74 74
75 #endif 75 #endif
OLDNEW
« no previous file with comments | « gm/drawbitmaprect.cpp ('k') | gm/drawlooper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698