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

Side by Side Diff: gm/imagefiltersclipped.cpp

Issue 211103006: Implement a generic matrix transform image filter. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Rename the GM too 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 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"
11 #include "SkBlurImageFilter.h" 11 #include "SkBlurImageFilter.h"
12 #include "SkDisplacementMapEffect.h" 12 #include "SkDisplacementMapEffect.h"
13 #include "SkDropShadowImageFilter.h" 13 #include "SkDropShadowImageFilter.h"
14 #include "SkGradientShader.h" 14 #include "SkGradientShader.h"
15 #include "SkMorphologyImageFilter.h" 15 #include "SkMorphologyImageFilter.h"
16 #include "SkOffsetImageFilter.h" 16 #include "SkOffsetImageFilter.h"
17 #include "SkPerlinNoiseShader.h" 17 #include "SkPerlinNoiseShader.h"
18 #include "SkRectShaderImageFilter.h" 18 #include "SkRectShaderImageFilter.h"
19 #include "SkResizeImageFilter.h" 19 #include "SkMatrixImageFilter.h"
20 #include "SkScalar.h" 20 #include "SkScalar.h"
21 21
22 #define RESIZE_FACTOR_X SkIntToScalar(2) 22 #define RESIZE_FACTOR_X SkIntToScalar(2)
23 #define RESIZE_FACTOR_Y SkIntToScalar(5) 23 #define RESIZE_FACTOR_Y SkIntToScalar(5)
24 24
25 namespace skiagm { 25 namespace skiagm {
26 26
27 class ImageFiltersClippedGM : public GM { 27 class ImageFiltersClippedGM : public GM {
28 public: 28 public:
29 ImageFiltersClippedGM() : fInitialized(false) { 29 ImageFiltersClippedGM() : fInitialized(false) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(SkBitmapSource::Create(fGradientCir cle)); 90 SkAutoTUnref<SkImageFilter> gradient(SkBitmapSource::Create(fGradientCir cle));
91 SkAutoTUnref<SkImageFilter> checkerboard(SkBitmapSource::Create(fChecker board)); 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 SkMatrix resizeMatrix;
95 resizeMatrix.setScale(RESIZE_FACTOR_X, RESIZE_FACTOR_Y);
94 96
95 SkImageFilter* filters[] = { 97 SkImageFilter* filters[] = {
96 SkBlurImageFilter::Create(SkIntToScalar(12), SkIntToScalar(12)), 98 SkBlurImageFilter::Create(SkIntToScalar(12), SkIntToScalar(12)),
97 SkDropShadowImageFilter::Create(SkIntToScalar(10), SkIntToScalar(10) , SkIntToScalar(3), 99 SkDropShadowImageFilter::Create(SkIntToScalar(10), SkIntToScalar(10) , SkIntToScalar(3),
98 SK_ColorGREEN), 100 SK_ColorGREEN),
99 SkDisplacementMapEffect::Create(SkDisplacementMapEffect::kR_ChannelS electorType, 101 SkDisplacementMapEffect::Create(SkDisplacementMapEffect::kR_ChannelS electorType,
100 SkDisplacementMapEffect::kR_ChannelS electorType, 102 SkDisplacementMapEffect::kR_ChannelS electorType,
101 SkIntToScalar(12), 103 SkIntToScalar(12),
102 gradient.get(), 104 gradient.get(),
103 checkerboard.get()), 105 checkerboard.get()),
104 SkDilateImageFilter::Create(2, 2, checkerboard.get()), 106 SkDilateImageFilter::Create(2, 2, checkerboard.get()),
105 SkErodeImageFilter::Create(2, 2, checkerboard.get()), 107 SkErodeImageFilter::Create(2, 2, checkerboard.get()),
106 SkOffsetImageFilter::Create(SkIntToScalar(-16), SkIntToScalar(32)), 108 SkOffsetImageFilter::Create(SkIntToScalar(-16), SkIntToScalar(32)),
107 SkResizeImageFilter::Create(RESIZE_FACTOR_X, RESIZE_FACTOR_Y, SkPain t::kNone_FilterLevel), 109 SkMatrixImageFilter::Create(resizeMatrix, SkPaint::kNone_FilterLevel ),
108 SkRectShaderImageFilter::Create(noise), 110 SkRectShaderImageFilter::Create(noise),
109 }; 111 };
110 112
111 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); 113 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64));
112 SkScalar margin = SkIntToScalar(16); 114 SkScalar margin = SkIntToScalar(16);
113 SkRect bounds = r; 115 SkRect bounds = r;
114 bounds.outset(margin, margin); 116 bounds.outset(margin, margin);
115 117
116 for (int xOffset = 0; xOffset < 80; xOffset += 16) { 118 for (int xOffset = 0; xOffset < 80; xOffset += 16) {
117 canvas->save(); 119 canvas->save();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 SkBitmap fGradientCircle; 151 SkBitmap fGradientCircle;
150 typedef GM INHERITED; 152 typedef GM INHERITED;
151 }; 153 };
152 154
153 ////////////////////////////////////////////////////////////////////////////// 155 //////////////////////////////////////////////////////////////////////////////
154 156
155 static GM* MyFactory(void*) { return new ImageFiltersClippedGM; } 157 static GM* MyFactory(void*) { return new ImageFiltersClippedGM; }
156 static GMRegistry reg(MyFactory); 158 static GMRegistry reg(MyFactory);
157 159
158 } 160 }
OLDNEW
« no previous file with comments | « no previous file | gm/imagefiltersscaled.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698