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

Side by Side Diff: gm/imagefiltersclipped.cpp

Issue 182983003: Factory methods for heap-allocated SkImageFilter objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 6 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 | « gm/imagefiltersbase.cpp ('k') | gm/imagefilterscropped.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 2014 Google Inc. 2 * Copyright 2014 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 "SkColor.h" 9 #include "SkColor.h"
10 #include "SkBitmapSource.h" 10 #include "SkBitmapSource.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } 80 }
81 81
82 virtual void onDraw(SkCanvas* canvas) { 82 virtual void onDraw(SkCanvas* canvas) {
83 if (!fInitialized) { 83 if (!fInitialized) {
84 this->make_checkerboard(); 84 this->make_checkerboard();
85 this->make_gradient_circle(64, 64); 85 this->make_gradient_circle(64, 64);
86 fInitialized = true; 86 fInitialized = true;
87 } 87 }
88 canvas->clear(0x00000000); 88 canvas->clear(0x00000000);
89 89
90 SkAutoTUnref<SkImageFilter> gradient(new SkBitmapSource(fGradientCircle) ); 90 SkAutoTUnref<SkImageFilter> gradient(SkBitmapSource::Create(fGradientCir cle));
91 SkAutoTUnref<SkImageFilter> checkerboard(new SkBitmapSource(fCheckerboar d)); 91 SkAutoTUnref<SkImageFilter> checkerboard(SkBitmapSource::Create(fChecker board));
92 SkAutoTUnref<SkShader> noise(SkPerlinNoiseShader::CreateFractalNoise( 92 SkAutoTUnref<SkShader> noise(SkPerlinNoiseShader::CreateFractalNoise(
93 SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0)); 93 SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0));
94 94
95 SkImageFilter* filters[] = { 95 SkImageFilter* filters[] = {
96 new SkBlurImageFilter(SkIntToScalar(12), SkIntToScalar(12)), 96 SkBlurImageFilter::Create(SkIntToScalar(12), SkIntToScalar(12)),
97 new SkDropShadowImageFilter(SkIntToScalar(10), SkIntToScalar(10), Sk IntToScalar(3), 97 SkDropShadowImageFilter::Create(SkIntToScalar(10), SkIntToScalar(10) , SkIntToScalar(3),
98 SK_ColorGREEN), 98 SK_ColorGREEN),
99 new SkDisplacementMapEffect(SkDisplacementMapEffect::kR_ChannelSelec torType, 99 SkDisplacementMapEffect::Create(SkDisplacementMapEffect::kR_ChannelS electorType,
100 SkDisplacementMapEffect::kR_ChannelSelec torType, 100 SkDisplacementMapEffect::kR_ChannelS electorType,
101 SkIntToScalar(12), 101 SkIntToScalar(12),
102 gradient.get(), 102 gradient.get(),
103 checkerboard.get()), 103 checkerboard.get()),
104 new SkDilateImageFilter(2, 2, checkerboard.get()), 104 SkDilateImageFilter::Create(2, 2, checkerboard.get()),
105 new SkErodeImageFilter(2, 2, checkerboard.get()), 105 SkErodeImageFilter::Create(2, 2, checkerboard.get()),
106 new SkOffsetImageFilter(SkIntToScalar(-16), SkIntToScalar(32)), 106 SkOffsetImageFilter::Create(SkIntToScalar(-16), SkIntToScalar(32)),
107 new SkResizeImageFilter(RESIZE_FACTOR_X, RESIZE_FACTOR_Y, SkPaint::k None_FilterLevel), 107 SkResizeImageFilter::Create(RESIZE_FACTOR_X, RESIZE_FACTOR_Y, SkPain t::kNone_FilterLevel),
108 SkRectShaderImageFilter::Create(noise), 108 SkRectShaderImageFilter::Create(noise),
109 }; 109 };
110 110
111 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); 111 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64));
112 SkScalar margin = SkIntToScalar(16); 112 SkScalar margin = SkIntToScalar(16);
113 SkRect bounds = r; 113 SkRect bounds = r;
114 bounds.outset(margin, margin); 114 bounds.outset(margin, margin);
115 115
116 for (int xOffset = 0; xOffset < 80; xOffset += 16) { 116 for (int xOffset = 0; xOffset < 80; xOffset += 16) {
117 canvas->save(); 117 canvas->save();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 SkBitmap fGradientCircle; 149 SkBitmap fGradientCircle;
150 typedef GM INHERITED; 150 typedef GM INHERITED;
151 }; 151 };
152 152
153 ////////////////////////////////////////////////////////////////////////////// 153 //////////////////////////////////////////////////////////////////////////////
154 154
155 static GM* MyFactory(void*) { return new ImageFiltersClippedGM; } 155 static GM* MyFactory(void*) { return new ImageFiltersClippedGM; }
156 static GMRegistry reg(MyFactory); 156 static GMRegistry reg(MyFactory);
157 157
158 } 158 }
OLDNEW
« no previous file with comments | « gm/imagefiltersbase.cpp ('k') | gm/imagefilterscropped.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698