OLD | NEW |
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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); | 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 canvas->setDrawFilter(new TestFilter)->unref(); |
61 canvas->setDrawFilter(&redNoBlur); | |
62 canvas->translate(120.0f, 40.0f); | 61 canvas->translate(120.0f, 40.0f); |
63 canvas->drawRect(r, p); | 62 canvas->drawRect(r, p); |
64 | |
65 // Must unset if the DrawFilter is from the stack to avoid refcount erro
rs! | |
66 canvas->setDrawFilter(nullptr); | 63 canvas->setDrawFilter(nullptr); |
67 } | 64 } |
68 | 65 |
69 private: | 66 private: |
70 typedef GM INHERITED; | 67 typedef GM INHERITED; |
71 }; | 68 }; |
72 | 69 |
73 DEF_GM( return new DrawFilterGM; ) | 70 DEF_GM( return new DrawFilterGM; ) |
74 | 71 |
75 #endif | 72 #endif |
OLD | NEW |