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

Side by Side Diff: src/effects/SkMagnifierImageFilter.cpp

Issue 26937006: Make SkImageFilter::asNewEffect() (and all derived-class overrides) protected. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 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 | « src/effects/SkLightingImageFilter.cpp ('k') | no next file » | 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 The Android Open Source Project 2 * Copyright 2012 The Android Open Source Project
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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkMagnifierImageFilter.h" 9 #include "SkMagnifierImageFilter.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 177 }
178 178
179 ///////////////////////////////////////////////////////////////////// 179 /////////////////////////////////////////////////////////////////////
180 180
181 GR_DEFINE_EFFECT_TEST(GrMagnifierEffect); 181 GR_DEFINE_EFFECT_TEST(GrMagnifierEffect);
182 182
183 GrEffectRef* GrMagnifierEffect::TestCreate(SkRandom* random, 183 GrEffectRef* GrMagnifierEffect::TestCreate(SkRandom* random,
184 GrContext* context, 184 GrContext* context,
185 const GrDrawTargetCaps&, 185 const GrDrawTargetCaps&,
186 GrTexture** textures) { 186 GrTexture** textures) {
187 GrTexture* texture = textures[0];
187 const int kMaxWidth = 200; 188 const int kMaxWidth = 200;
188 const int kMaxHeight = 200; 189 const int kMaxHeight = 200;
189 const int kMaxInset = 20; 190 const int kMaxInset = 20;
190 uint32_t width = random->nextULessThan(kMaxWidth); 191 uint32_t width = random->nextULessThan(kMaxWidth);
191 uint32_t height = random->nextULessThan(kMaxHeight); 192 uint32_t height = random->nextULessThan(kMaxHeight);
192 uint32_t x = random->nextULessThan(kMaxWidth - width); 193 uint32_t x = random->nextULessThan(kMaxWidth - width);
193 uint32_t y = random->nextULessThan(kMaxHeight - height); 194 uint32_t y = random->nextULessThan(kMaxHeight - height);
194 SkScalar inset = SkIntToScalar(random->nextULessThan(kMaxInset)); 195 uint32_t inset = random->nextULessThan(kMaxInset);
195 196
196 SkAutoTUnref<SkMagnifierImageFilter> filter( 197 GrEffectRef* effect = GrMagnifierEffect::Create(
197 new SkMagnifierImageFilter( 198 texture,
198 SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(y), 199 (float) width / texture->width(),
199 SkIntToScalar(width), SkIntToScalar(height)), 200 (float) height / texture->height(),
200 inset)); 201 texture->width() / (float) x,
201 GrEffectRef* effect; 202 texture->height() / (float) y,
202 filter->asNewEffect(&effect, textures[0], SkMatrix::I()); 203 (float) inset / texture->width(),
204 (float) inset / texture->height());
203 SkASSERT(NULL != effect); 205 SkASSERT(NULL != effect);
204 return effect; 206 return effect;
205 } 207 }
206 208
207 /////////////////////////////////////////////////////////////////////////////// 209 ///////////////////////////////////////////////////////////////////////////////
208 210
209 const GrBackendEffectFactory& GrMagnifierEffect::getFactory() const { 211 const GrBackendEffectFactory& GrMagnifierEffect::getFactory() const {
210 return GrTBackendEffectFactory<GrMagnifierEffect>::getInstance(); 212 return GrTBackendEffectFactory<GrMagnifierEffect>::getInstance();
211 } 213 }
212 214
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 328
327 int x_val = SkMin32(SkScalarFloorToInt(x_interp), width - 1); 329 int x_val = SkMin32(SkScalarFloorToInt(x_interp), width - 1);
328 int y_val = SkMin32(SkScalarFloorToInt(y_interp), height - 1); 330 int y_val = SkMin32(SkScalarFloorToInt(y_interp), height - 1);
329 331
330 *dptr = sptr[y_val * width + x_val]; 332 *dptr = sptr[y_val * width + x_val];
331 dptr++; 333 dptr++;
332 } 334 }
333 } 335 }
334 return true; 336 return true;
335 } 337 }
OLDNEW
« no previous file with comments | « src/effects/SkLightingImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698