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

Side by Side Diff: gm/imagefiltersscaled.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 | « gm/imagefiltersclipped.cpp ('k') | gm/imageresizetiled.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 "SkLightingImageFilter.h" 15 #include "SkLightingImageFilter.h"
16 #include "SkMorphologyImageFilter.h" 16 #include "SkMorphologyImageFilter.h"
17 #include "SkOffsetImageFilter.h" 17 #include "SkOffsetImageFilter.h"
18 #include "SkPerlinNoiseShader.h" 18 #include "SkPerlinNoiseShader.h"
19 #include "SkRectShaderImageFilter.h" 19 #include "SkRectShaderImageFilter.h"
20 #include "SkResizeImageFilter.h" 20 #include "SkMatrixImageFilter.h"
21 #include "SkScalar.h" 21 #include "SkScalar.h"
22 22
23 #define RESIZE_FACTOR SkIntToScalar(4) 23 #define RESIZE_FACTOR SkIntToScalar(4)
24 24
25 namespace skiagm { 25 namespace skiagm {
26 26
27 class ImageFiltersScaledGM : public GM { 27 class ImageFiltersScaledGM : public GM {
28 public: 28 public:
29 ImageFiltersScaledGM() : fInitialized(false) { 29 ImageFiltersScaledGM() : fInitialized(false) {
30 this->setBGColor(0x00000000); 30 this->setBGColor(0x00000000);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0)); 93 SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0));
94 94
95 SkPoint3 pointLocation(0, 0, SkIntToScalar(10)); 95 SkPoint3 pointLocation(0, 0, SkIntToScalar(10));
96 SkPoint3 spotLocation(SkIntToScalar(-10), SkIntToScalar(-10), SkIntToSca lar(20)); 96 SkPoint3 spotLocation(SkIntToScalar(-10), SkIntToScalar(-10), SkIntToSca lar(20));
97 SkPoint3 spotTarget(SkIntToScalar(40), SkIntToScalar(40), 0); 97 SkPoint3 spotTarget(SkIntToScalar(40), SkIntToScalar(40), 0);
98 SkScalar spotExponent = SK_Scalar1; 98 SkScalar spotExponent = SK_Scalar1;
99 SkScalar cutoffAngle = SkIntToScalar(15); 99 SkScalar cutoffAngle = SkIntToScalar(15);
100 SkScalar kd = SkIntToScalar(2); 100 SkScalar kd = SkIntToScalar(2);
101 SkScalar surfaceScale = SkIntToScalar(1); 101 SkScalar surfaceScale = SkIntToScalar(1);
102 SkColor white(0xFFFFFFFF); 102 SkColor white(0xFFFFFFFF);
103 SkMatrix resizeMatrix;
104 resizeMatrix.setScale(RESIZE_FACTOR, RESIZE_FACTOR);
103 105
104 SkImageFilter* filters[] = { 106 SkImageFilter* filters[] = {
105 SkBlurImageFilter::Create(SkIntToScalar(4), SkIntToScalar(4)), 107 SkBlurImageFilter::Create(SkIntToScalar(4), SkIntToScalar(4)),
106 SkDropShadowImageFilter::Create(SkIntToScalar(5), SkIntToScalar(10), SkIntToScalar(3), 108 SkDropShadowImageFilter::Create(SkIntToScalar(5), SkIntToScalar(10), SkIntToScalar(3),
107 SK_ColorYELLOW), 109 SK_ColorYELLOW),
108 SkDisplacementMapEffect::Create(SkDisplacementMapEffect::kR_ChannelS electorType, 110 SkDisplacementMapEffect::Create(SkDisplacementMapEffect::kR_ChannelS electorType,
109 SkDisplacementMapEffect::kR_ChannelS electorType, 111 SkDisplacementMapEffect::kR_ChannelS electorType,
110 SkIntToScalar(12), 112 SkIntToScalar(12),
111 gradient.get(), 113 gradient.get(),
112 checkerboard.get()), 114 checkerboard.get()),
113 SkDilateImageFilter::Create(1, 1, checkerboard.get()), 115 SkDilateImageFilter::Create(1, 1, checkerboard.get()),
114 SkErodeImageFilter::Create(1, 1, checkerboard.get()), 116 SkErodeImageFilter::Create(1, 1, checkerboard.get()),
115 SkOffsetImageFilter::Create(SkIntToScalar(32), 0), 117 SkOffsetImageFilter::Create(SkIntToScalar(32), 0),
116 SkResizeImageFilter::Create(RESIZE_FACTOR, RESIZE_FACTOR, SkPaint::k None_FilterLevel), 118 SkMatrixImageFilter::Create(resizeMatrix, SkPaint::kNone_FilterLevel ),
117 SkRectShaderImageFilter::Create(noise), 119 SkRectShaderImageFilter::Create(noise),
118 SkLightingImageFilter::CreatePointLitDiffuse(pointLocation, white, s urfaceScale, kd), 120 SkLightingImageFilter::CreatePointLitDiffuse(pointLocation, white, s urfaceScale, kd),
119 SkLightingImageFilter::CreateSpotLitDiffuse(spotLocation, spotTarget , spotExponent, 121 SkLightingImageFilter::CreateSpotLitDiffuse(spotLocation, spotTarget , spotExponent,
120 cutoffAngle, white, surf aceScale, kd), 122 cutoffAngle, white, surf aceScale, kd),
121 }; 123 };
122 124
123 SkVector scales[] = { 125 SkVector scales[] = {
124 SkVector::Make(SkScalarInvert(2), SkScalarInvert(2)), 126 SkVector::Make(SkScalarInvert(2), SkScalarInvert(2)),
125 SkVector::Make(SkIntToScalar(1), SkIntToScalar(1)), 127 SkVector::Make(SkIntToScalar(1), SkIntToScalar(1)),
126 SkVector::Make(SkIntToScalar(1), SkIntToScalar(2)), 128 SkVector::Make(SkIntToScalar(1), SkIntToScalar(2)),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 SkBitmap fGradientCircle; 170 SkBitmap fGradientCircle;
169 typedef GM INHERITED; 171 typedef GM INHERITED;
170 }; 172 };
171 173
172 ////////////////////////////////////////////////////////////////////////////// 174 //////////////////////////////////////////////////////////////////////////////
173 175
174 static GM* MyFactory(void*) { return new ImageFiltersScaledGM; } 176 static GM* MyFactory(void*) { return new ImageFiltersScaledGM; }
175 static GMRegistry reg(MyFactory); 177 static GMRegistry reg(MyFactory);
176 178
177 } 179 }
OLDNEW
« no previous file with comments | « gm/imagefiltersclipped.cpp ('k') | gm/imageresizetiled.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698