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

Side by Side Diff: gm/offsetimagefilter.cpp

Issue 1204723002: add simple test for offsetimagefilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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 | no next file » | 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 2013 Google Inc. 2 * Copyright 2013 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 "sk_tool_utils.h" 8 #include "sk_tool_utils.h"
9 #include "SkBitmapSource.h" 9 #include "SkBitmapSource.h"
10 #include "SkOffsetImageFilter.h" 10 #include "SkOffsetImageFilter.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 drawClippedBitmap(canvas, fBitmap, paint, 2, cropRect); 98 drawClippedBitmap(canvas, fBitmap, paint, 2, cropRect);
99 } 99 }
100 private: 100 private:
101 typedef skiagm::GM INHERITED; 101 typedef skiagm::GM INHERITED;
102 SkBitmap fBitmap, fCheckerboard; 102 SkBitmap fBitmap, fCheckerboard;
103 }; 103 };
104 DEF_GM( return new OffsetImageFilterGM; ) 104 DEF_GM( return new OffsetImageFilterGM; )
105 105
106 ////////////////////////////////////////////////////////////////////////////// 106 //////////////////////////////////////////////////////////////////////////////
107 107
108 class SimpleOffsetImageFilterGM : public skiagm::GM {
109 public:
110 SimpleOffsetImageFilterGM() {}
111
112 protected:
113 SkString onShortName() override {
114 return SkString("simple-offsetimagefilter");
115 }
116
117 SkISize onISize() override { return SkISize::Make(140, 60); }
118
119 void doDraw(SkCanvas* canvas, const SkRect& r, SkImageFilter* imgf,
120 const SkRect* clipR = NULL) {
121 SkPaint p;
122
123 if (clipR) {
124 p.setColor(0xFF00FF00);
125 p.setStyle(SkPaint::kStroke_Style);
126 canvas->drawRect(clipR->makeInset(SK_ScalarHalf, SK_ScalarHalf), p);
127 p.setStyle(SkPaint::kFill_Style);
128 }
129
130 p.setImageFilter(imgf);
131 p.setColor(SK_ColorRED);
132 canvas->drawRect(r, p);
133
134 if (clipR) {
135 canvas->save();
136 canvas->clipRect(*clipR);
137 }
138 p.setImageFilter(NULL);
139 p.setColor(0x660000FF);
140 canvas->drawRect(r, p);
141 if (clipR) {
142 canvas->restore();
143 }
144 }
145
146 void onDraw(SkCanvas* canvas) override {
147 const SkRect r = SkRect::MakeWH(10, 10);
148 SkImageFilter::CropRect cr0(r);
149 SkImageFilter::CropRect cr1(SkRect::MakeWH(5, 5));
150
151 canvas->translate(20, 20);
152 this->doDraw(canvas, r, NULL);
153
154 canvas->translate(20, 0);
155 this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5));
156
157 canvas->translate(20, 0);
158 this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5, NULL, &cr0));
159
160 canvas->translate(20, 0);
161 this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5), &r);
162
163 canvas->translate(20, 0);
164 this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5, NULL, &cr1));
165 }
166
167 private:
168 typedef skiagm::GM INHERITED;
169 };
170 DEF_GM( return new SimpleOffsetImageFilterGM; )
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698