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

Side by Side Diff: gm/imagefiltersclipped.cpp

Issue 1310053004: Fix clipped lighting image filters. (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 | « no previous file | src/effects/SkLightingImageFilter.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 "sk_tool_utils.h" 8 #include "sk_tool_utils.h"
9 #include "SkBitmapSource.h" 9 #include "SkBitmapSource.h"
10 #include "SkBlurImageFilter.h" 10 #include "SkBlurImageFilter.h"
11 #include "SkColor.h" 11 #include "SkColor.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 "SkMorphologyImageFilter.h" 16 #include "SkMorphologyImageFilter.h"
16 #include "SkOffsetImageFilter.h" 17 #include "SkOffsetImageFilter.h"
17 #include "SkPerlinNoiseShader.h" 18 #include "SkPerlinNoiseShader.h"
19 #include "SkPoint3.h"
18 #include "SkRectShaderImageFilter.h" 20 #include "SkRectShaderImageFilter.h"
19 #include "SkScalar.h" 21 #include "SkScalar.h"
20 #include "gm.h" 22 #include "gm.h"
21 23
22 #define RESIZE_FACTOR_X SkIntToScalar(2) 24 #define RESIZE_FACTOR_X SkIntToScalar(2)
23 #define RESIZE_FACTOR_Y SkIntToScalar(5) 25 #define RESIZE_FACTOR_Y SkIntToScalar(5)
24 26
25 namespace skiagm { 27 namespace skiagm {
26 28
27 class ImageFiltersClippedGM : public GM { 29 class ImageFiltersClippedGM : public GM {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 fInitialized = true; 90 fInitialized = true;
89 } 91 }
90 canvas->clear(SK_ColorBLACK); 92 canvas->clear(SK_ColorBLACK);
91 93
92 SkAutoTUnref<SkImageFilter> gradient(SkBitmapSource::Create(fGradientCir cle)); 94 SkAutoTUnref<SkImageFilter> gradient(SkBitmapSource::Create(fGradientCir cle));
93 SkAutoTUnref<SkImageFilter> checkerboard(SkBitmapSource::Create(fChecker board)); 95 SkAutoTUnref<SkImageFilter> checkerboard(SkBitmapSource::Create(fChecker board));
94 SkAutoTUnref<SkShader> noise(SkPerlinNoiseShader::CreateFractalNoise( 96 SkAutoTUnref<SkShader> noise(SkPerlinNoiseShader::CreateFractalNoise(
95 SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0)); 97 SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0));
96 SkMatrix resizeMatrix; 98 SkMatrix resizeMatrix;
97 resizeMatrix.setScale(RESIZE_FACTOR_X, RESIZE_FACTOR_Y); 99 resizeMatrix.setScale(RESIZE_FACTOR_X, RESIZE_FACTOR_Y);
100 SkPoint3 pointLocation = SkPoint3::Make(32, 32, SkIntToScalar(10));
98 101
99 SkImageFilter* filters[] = { 102 SkImageFilter* filters[] = {
100 SkBlurImageFilter::Create(SkIntToScalar(12), SkIntToScalar(12)), 103 SkBlurImageFilter::Create(SkIntToScalar(12), SkIntToScalar(12)),
101 SkDropShadowImageFilter::Create(SkIntToScalar(10), SkIntToScalar(10) , 104 SkDropShadowImageFilter::Create(SkIntToScalar(10), SkIntToScalar(10) ,
102 SkIntToScalar(3), SkIntToScalar(3), SK_ColorGREEN, 105 SkIntToScalar(3), SkIntToScalar(3), SK_ColorGREEN,
103 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode), 106 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode),
104 SkDisplacementMapEffect::Create(SkDisplacementMapEffect::kR_ChannelS electorType, 107 SkDisplacementMapEffect::Create(SkDisplacementMapEffect::kR_ChannelS electorType,
105 SkDisplacementMapEffect::kR_ChannelS electorType, 108 SkDisplacementMapEffect::kR_ChannelS electorType,
106 SkIntToScalar(12), 109 SkIntToScalar(12),
107 gradient.get(), 110 gradient.get(),
108 checkerboard.get()), 111 checkerboard.get()),
109 SkDilateImageFilter::Create(2, 2, checkerboard.get()), 112 SkDilateImageFilter::Create(2, 2, checkerboard.get()),
110 SkErodeImageFilter::Create(2, 2, checkerboard.get()), 113 SkErodeImageFilter::Create(2, 2, checkerboard.get()),
111 SkOffsetImageFilter::Create(SkIntToScalar(-16), SkIntToScalar(32)), 114 SkOffsetImageFilter::Create(SkIntToScalar(-16), SkIntToScalar(32)),
112 SkImageFilter::CreateMatrixFilter(resizeMatrix, kNone_SkFilterQualit y), 115 SkImageFilter::CreateMatrixFilter(resizeMatrix, kNone_SkFilterQualit y),
116 SkLightingImageFilter::CreatePointLitDiffuse(pointLocation, SK_Color WHITE, SK_Scalar1, SkIntToScalar(2), checkerboard.get()),
117
113 }; 118 };
114 119
115 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); 120 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64));
116 SkScalar margin = SkIntToScalar(16); 121 SkScalar margin = SkIntToScalar(16);
117 SkRect bounds = r; 122 SkRect bounds = r;
118 bounds.outset(margin, margin); 123 bounds.outset(margin, margin);
119 124
120 canvas->save(); 125 canvas->save();
121 for (int xOffset = 0; xOffset < 80; xOffset += 16) { 126 for (int xOffset = 0; xOffset < 80; xOffset += 16) {
122 canvas->save(); 127 canvas->save();
(...skipping 27 matching lines...) Expand all
150 SkBitmap fGradientCircle; 155 SkBitmap fGradientCircle;
151 typedef GM INHERITED; 156 typedef GM INHERITED;
152 }; 157 };
153 158
154 ////////////////////////////////////////////////////////////////////////////// 159 //////////////////////////////////////////////////////////////////////////////
155 160
156 static GM* MyFactory(void*) { return new ImageFiltersClippedGM; } 161 static GM* MyFactory(void*) { return new ImageFiltersClippedGM; }
157 static GMRegistry reg(MyFactory); 162 static GMRegistry reg(MyFactory);
158 163
159 } 164 }
OLDNEW
« no previous file with comments | « no previous file | src/effects/SkLightingImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698