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

Side by Side Diff: gm/testimagefilters.cpp

Issue 2094083002: remove DownSample imagefilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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/imagefiltersgraph.cpp ('k') | gyp/effects.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 2011 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 "SkCanvas.h"
10 #include "SkColorFilter.h"
11 #include "SkColorPriv.h"
12 #include "SkShader.h"
13
14 #include "SkBlurImageFilter.h"
15 #include "SkColorFilterImageFilter.h"
16 #include "SkComposeImageFilter.h"
17 #include "SkMergeImageFilter.h"
18 #include "SkOffsetImageFilter.h"
19 #include "SkTestImageFilters.h"
20
21 #define FILTER_WIDTH SkIntToScalar(150)
22 #define FILTER_HEIGHT SkIntToScalar(200)
23
24 static sk_sp<SkImageFilter> make0() {
25 return SkDownSampleImageFilter::Make(SK_Scalar1 / 5, nullptr);
26 }
27
28 static sk_sp<SkImageFilter> make1() {
29 return SkOffsetImageFilter::Make(SkIntToScalar(16), SkIntToScalar(16), nullp tr);
30 }
31
32 static sk_sp<SkImageFilter> make2() {
33 sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(SK_ColorBLUE, SkXfermo de::kSrcIn_Mode));
34 return SkColorFilterImageFilter::Make(std::move(cf), nullptr);
35 }
36
37 static sk_sp<SkImageFilter> make3() {
38 return SkBlurImageFilter::Make(8, 0, nullptr);
39 }
40
41 static sk_sp<SkImageFilter> make4() {
42 sk_sp<SkImageFilter> outer(SkOffsetImageFilter::Make(SkIntToScalar(16),
43 SkIntToScalar(16),
44 nullptr));
45 sk_sp<SkImageFilter> inner(SkDownSampleImageFilter::Make(SK_Scalar1 / 5, nul lptr));
46 return SkComposeImageFilter::Make(std::move(outer), std::move(inner));
47 }
48
49 static sk_sp<SkImageFilter> make5() {
50 sk_sp<SkImageFilter> first(SkOffsetImageFilter::Make(SkIntToScalar(16),
51 SkIntToScalar(16),
52 nullptr));
53 sk_sp<SkImageFilter> second(SkDownSampleImageFilter::Make(SK_Scalar1 / 5, nu llptr));
54 return SkMergeImageFilter::Make(std::move(first), std::move(second));
55 }
56
57 static sk_sp<SkImageFilter> make6() {
58 sk_sp<SkImageFilter> outer(SkOffsetImageFilter::Make(SkIntToScalar(16),
59 SkIntToScalar(16),
60 nullptr));
61 sk_sp<SkImageFilter> inner(SkDownSampleImageFilter::Make(SK_Scalar1 / 5, nul lptr));
62 sk_sp<SkImageFilter> compose(SkComposeImageFilter::Make(std::move(outer), st d::move(inner)));
63
64 sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(0x880000FF, SkXfermode ::kSrcIn_Mode));
65 sk_sp<SkImageFilter> blue(SkColorFilterImageFilter::Make(std::move(cf), null ptr));
66
67 return SkMergeImageFilter::Make(std::move(compose), std::move(blue));
68 }
69
70 static sk_sp<SkImageFilter> make7() {
71 sk_sp<SkImageFilter> outer(SkOffsetImageFilter::Make(SkIntToScalar(16),
72 SkIntToScalar(16),
73 nullptr));
74 sk_sp<SkImageFilter> inner(make3());
75 sk_sp<SkImageFilter> compose(SkComposeImageFilter::Make(std::move(outer), st d::move(inner)));
76
77 sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(0x880000FF, SkXfermode ::kSrcIn_Mode));
78 sk_sp<SkImageFilter> blue(SkColorFilterImageFilter::Make(std::move(cf), null ptr));
79
80 return SkMergeImageFilter::Make(std::move(compose), std::move(blue));
81 }
82
83 static void draw0(SkCanvas* canvas) {
84 SkPaint p;
85 p.setAntiAlias(true);
86 SkRect r = SkRect::MakeWH(FILTER_WIDTH, FILTER_HEIGHT);
87 r.inset(SK_Scalar1 * 12, SK_Scalar1 * 12);
88 p.setColor(SK_ColorRED);
89 canvas->drawOval(r, p);
90 }
91
92 class TestImageFiltersGM : public skiagm::GM {
93 public:
94 TestImageFiltersGM () {}
95
96 protected:
97
98 SkString onShortName() override {
99 return SkString("testimagefilters");
100 }
101
102 SkISize onISize() override { return SkISize::Make(700, 460); }
103
104 void onDraw(SkCanvas* canvas) override {
105 // this->drawSizeBounds(canvas, 0xFFCCCCCC);
106
107 static sk_sp<SkImageFilter> (*gFilterProc[])() = {
108 make0, make1, make2, make3, make4, make5, make6, make7
109 };
110
111 const SkRect bounds = SkRect::MakeWH(FILTER_WIDTH, FILTER_HEIGHT);
112
113 const SkScalar dx = bounds.width() * 8 / 7;
114 const SkScalar dy = bounds.height() * 8 / 7;
115
116 canvas->translate(SkIntToScalar(8), SkIntToScalar(8));
117
118 for (int i = 0; i < (int)SK_ARRAY_COUNT(gFilterProc); ++i) {
119 int ix = i % 4;
120 int iy = i / 4;
121
122 SkAutoCanvasRestore acr(canvas, true);
123 canvas->translate(ix * dx, iy * dy);
124
125 SkPaint p;
126 p.setStyle(SkPaint::kStroke_Style);
127 canvas->drawRect(bounds, p);
128
129 SkPaint paint;
130 paint.setImageFilter(gFilterProc[i]());
131 canvas->saveLayer(&bounds, &paint);
132 draw0(canvas);
133 }
134 }
135
136 private:
137 typedef GM INHERITED;
138 };
139
140 //////////////////////////////////////////////////////////////////////////////
141
142 DEF_GM( return new TestImageFiltersGM; )
OLDNEW
« no previous file with comments | « gm/imagefiltersgraph.cpp ('k') | gyp/effects.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698