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

Side by Side Diff: gm/drawfilter.cpp

Issue 984883003: New GM to test SkDrawFilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix bad upload Created 5 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 | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "gm.h"
9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h"
11 #include "SkCanvas.h"
12 #include "SkDrawFilter.h"
13 #include "SkPaint.h"
14
15
16 class TestFilter : public SkDrawFilter {
17 public:
18 bool filter(SkPaint* p, Type) SK_OVERRIDE {
19 p->setColor(SK_ColorRED);
20 p->setMaskFilter(NULL);
21 return true;
22 }
23 };
24
25 class DrawFilterGM : public skiagm::GM {
26 SkAutoTUnref<SkMaskFilter> fBlur;
27
28 protected:
29 SkISize onISize() SK_OVERRIDE {
30 return SkISize::Make(320, 240);
31 }
32
33 SkString onShortName() SK_OVERRIDE {
34 return SkString("drawfilter");
35 }
36
37 void onOnceBeforeDraw() SK_OVERRIDE {
38 fBlur.reset(SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
39 SkBlurMask::ConvertRadiusToSigma(10.0f),
40 kLow_SkBlurQuality));
41 }
42
43 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
44 SkPaint p;
45 p.setColor(SK_ColorBLUE);
46 p.setMaskFilter(fBlur.get());
47 SkRect r = { 20, 20, 100, 100 };
48 canvas->setDrawFilter(NULL);
scroggo 2015/03/06 13:51:41 Is this line needed?
49 canvas->drawRect(r, p);
50 TestFilter redNoBlur;
51 canvas->setDrawFilter(&redNoBlur);
52 canvas->translate(120.0f, 120.0f);
53 canvas->drawRect(r, p);
54
55 // Must unset if the DrawFilter is from the stack to avoid refcount erro rs!
56 canvas->setDrawFilter(NULL);
57 }
58
59 private:
60 typedef GM INHERITED;
61 };
62
63 static skiagm::GM* MyFactory(void*) { return new DrawFilterGM; }
64 static skiagm::GMRegistry reg(MyFactory);
65
OLDNEW
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698