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

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

Issue 23295017: In image filters, apply the CTM and offset to the crop rect. This is necessary to compensate for bo… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix documentation comment. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/effects/SkLightingImageFilter.cpp ('k') | src/effects/SkMatrixConvolutionImageFilter.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 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 uint32_t x = random->nextULessThan(kMaxWidth - width); 208 uint32_t x = random->nextULessThan(kMaxWidth - width);
209 uint32_t y = random->nextULessThan(kMaxHeight - height); 209 uint32_t y = random->nextULessThan(kMaxHeight - height);
210 SkScalar inset = SkIntToScalar(random->nextULessThan(kMaxInset)); 210 SkScalar inset = SkIntToScalar(random->nextULessThan(kMaxInset));
211 211
212 SkAutoTUnref<SkMagnifierImageFilter> filter( 212 SkAutoTUnref<SkMagnifierImageFilter> filter(
213 new SkMagnifierImageFilter( 213 new SkMagnifierImageFilter(
214 SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(y), 214 SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(y),
215 SkIntToScalar(width), SkIntToScalar(height)), 215 SkIntToScalar(width), SkIntToScalar(height)),
216 inset)); 216 inset));
217 GrEffectRef* effect; 217 GrEffectRef* effect;
218 filter->asNewEffect(&effect, textures[0], SkIPoint::Make(0, 0)); 218 filter->asNewEffect(&effect, textures[0], SkMatrix::I());
219 SkASSERT(NULL != effect); 219 SkASSERT(NULL != effect);
220 return effect; 220 return effect;
221 } 221 }
222 222
223 /////////////////////////////////////////////////////////////////////////////// 223 ///////////////////////////////////////////////////////////////////////////////
224 224
225 const GrBackendEffectFactory& GrMagnifierEffect::getFactory() const { 225 const GrBackendEffectFactory& GrMagnifierEffect::getFactory() const {
226 return GrTBackendEffectFactory<GrMagnifierEffect>::getInstance(); 226 return GrTBackendEffectFactory<GrMagnifierEffect>::getInstance();
227 } 227 }
228 228
(...skipping 25 matching lines...) Expand all
254 fInset = buffer.readScalar(); 254 fInset = buffer.readScalar();
255 } 255 }
256 256
257 // FIXME: implement single-input semantics 257 // FIXME: implement single-input semantics
258 SkMagnifierImageFilter::SkMagnifierImageFilter(SkRect srcRect, SkScalar inset) 258 SkMagnifierImageFilter::SkMagnifierImageFilter(SkRect srcRect, SkScalar inset)
259 : INHERITED(0), fSrcRect(srcRect), fInset(inset) { 259 : INHERITED(0), fSrcRect(srcRect), fInset(inset) {
260 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0); 260 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0);
261 } 261 }
262 262
263 #if SK_SUPPORT_GPU 263 #if SK_SUPPORT_GPU
264 bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* textur e, const SkIPoint&) const { 264 bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* textur e, const SkMatrix&) const {
265 if (effect) { 265 if (effect) {
266 *effect = GrMagnifierEffect::Create(texture, 266 *effect = GrMagnifierEffect::Create(texture,
267 fSrcRect.x() / texture->width(), 267 fSrcRect.x() / texture->width(),
268 fSrcRect.y() / texture->height(), 268 fSrcRect.y() / texture->height(),
269 texture->width() / fSrcRect.width(), 269 texture->width() / fSrcRect.width(),
270 texture->height() / fSrcRect.height( ), 270 texture->height() / fSrcRect.height( ),
271 fInset / texture->width(), 271 fInset / texture->width(),
272 fInset / texture->height()); 272 fInset / texture->height());
273 } 273 }
274 return true; 274 return true;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 342
343 int x_val = SkMin32(SkScalarFloorToInt(x_interp), width - 1); 343 int x_val = SkMin32(SkScalarFloorToInt(x_interp), width - 1);
344 int y_val = SkMin32(SkScalarFloorToInt(y_interp), height - 1); 344 int y_val = SkMin32(SkScalarFloorToInt(y_interp), height - 1);
345 345
346 *dptr = sptr[y_val * width + x_val]; 346 *dptr = sptr[y_val * width + x_val];
347 dptr++; 347 dptr++;
348 } 348 }
349 } 349 }
350 return true; 350 return true;
351 } 351 }
OLDNEW
« no previous file with comments | « src/effects/SkLightingImageFilter.cpp ('k') | src/effects/SkMatrixConvolutionImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698