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

Side by Side Diff: gm/imagefiltersgraph.cpp

Issue 1320673011: Minor code cleanup (left over from prior CL) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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/imagefiltersclipped.cpp ('k') | gm/imagefiltersscaled.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 2012 Google Inc. 2 * Copyright 2012 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 9
10 #include "SkArithmeticMode.h" 10 #include "SkArithmeticMode.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 str->append(")"); 96 str->append(")");
97 } 97 }
98 #endif 98 #endif
99 99
100 class ImageFiltersGraphGM : public skiagm::GM { 100 class ImageFiltersGraphGM : public skiagm::GM {
101 public: 101 public:
102 ImageFiltersGraphGM() {} 102 ImageFiltersGraphGM() {}
103 103
104 protected: 104 protected:
105 105
106 virtual SkString onShortName() { 106 SkString onShortName() override {
107 return SkString("imagefiltersgraph"); 107 return SkString("imagefiltersgraph");
108 } 108 }
109 109
110 void make_bitmap() {
111 fBitmap.allocN32Pixels(100, 100);
112 SkCanvas canvas(fBitmap);
113 canvas.clear(SK_ColorTRANSPARENT);
114 SkPaint paint;
115 paint.setAntiAlias(true);
116 sk_tool_utils::set_portable_typeface(&paint);
117 paint.setColor(SK_ColorWHITE);
118 paint.setTextSize(SkIntToScalar(96));
119 const char* str = "e";
120 canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), paint);
121 }
122
123 void drawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, const SkPai nt& paint) { 110 void drawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, const SkPai nt& paint) {
124 canvas->save(); 111 canvas->save();
125 canvas->clipRect(SkRect::MakeXYWH(0, 0, 112 canvas->clipRect(SkRect::MakeXYWH(0, 0,
126 SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height()))); 113 SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height())));
127 canvas->drawBitmap(bitmap, 0, 0, &paint); 114 canvas->drawBitmap(bitmap, 0, 0, &paint);
128 canvas->restore(); 115 canvas->restore();
129 } 116 }
130 117
131 virtual SkISize onISize() { return SkISize::Make(500, 150); } 118 SkISize onISize() override { return SkISize::Make(500, 150); }
132 119
133 virtual void onOnceBeforeDraw() { 120 void onOnceBeforeDraw() override {
134 this->make_bitmap(); 121 fBitmap = sk_tool_utils::create_string_bitmap(100, 100, SK_ColorWHITE, 2 0, 70, 96, "e");
135 } 122 }
136 123
137 virtual void onDraw(SkCanvas* canvas) { 124 void onDraw(SkCanvas* canvas) override {
138 canvas->clear(SK_ColorBLACK); 125 canvas->clear(SK_ColorBLACK);
139 { 126 {
140 SkAutoTUnref<SkImageFilter> bitmapSource(SkBitmapSource::Create(fBit map)); 127 SkAutoTUnref<SkImageFilter> bitmapSource(SkBitmapSource::Create(fBit map));
141 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_Co lorRED, 128 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_Co lorRED,
142 SkXfermode::kSrcIn_Mode )); 129 SkXfermode::kSrcIn_Mode ));
143 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(4.0f, 4.0 f, bitmapSource)); 130 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(4.0f, 4.0 f, bitmapSource));
144 SkAutoTUnref<SkImageFilter> erode(SkErodeImageFilter::Create(4, 4, b lur)); 131 SkAutoTUnref<SkImageFilter> erode(SkErodeImageFilter::Create(4, 4, b lur));
145 SkAutoTUnref<SkImageFilter> color(SkColorFilterImageFilter::Create(c f, erode)); 132 SkAutoTUnref<SkImageFilter> color(SkColorFilterImageFilter::Create(c f, erode));
146 SkAutoTUnref<SkImageFilter> merge(SkMergeImageFilter::Create(blur, c olor)); 133 SkAutoTUnref<SkImageFilter> merge(SkMergeImageFilter::Create(blur, c olor));
147 134
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 209 }
223 } 210 }
224 211
225 private: 212 private:
226 typedef GM INHERITED; 213 typedef GM INHERITED;
227 SkBitmap fBitmap; 214 SkBitmap fBitmap;
228 }; 215 };
229 216
230 /////////////////////////////////////////////////////////////////////////////// 217 ///////////////////////////////////////////////////////////////////////////////
231 218
232 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } 219 DEF_GM(return new ImageFiltersGraphGM;)
233 static skiagm::GMRegistry reg(MyFactory);
OLDNEW
« no previous file with comments | « gm/imagefiltersclipped.cpp ('k') | gm/imagefiltersscaled.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698