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: src/effects/SkMagnifierImageFilter.cpp

Issue 376953003: Clean up SkImageFilter constructors. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixed 100-col issues Created 6 years, 5 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 | « 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 float width = buffer.readScalar(); 239 float width = buffer.readScalar();
240 float height = buffer.readScalar(); 240 float height = buffer.readScalar();
241 fSrcRect = SkRect::MakeXYWH(x, y, width, height); 241 fSrcRect = SkRect::MakeXYWH(x, y, width, height);
242 fInset = buffer.readScalar(); 242 fInset = buffer.readScalar();
243 243
244 buffer.validate(SkScalarIsFinite(fInset) && SkIsValidRect(fSrcRect) && 244 buffer.validate(SkScalarIsFinite(fInset) && SkIsValidRect(fSrcRect) &&
245 // Negative numbers in src rect are not supported 245 // Negative numbers in src rect are not supported
246 (fSrcRect.fLeft >= 0) && (fSrcRect.fTop >= 0)); 246 (fSrcRect.fLeft >= 0) && (fSrcRect.fTop >= 0));
247 } 247 }
248 248
249 // FIXME: implement single-input semantics 249 SkMagnifierImageFilter::SkMagnifierImageFilter(const SkRect& srcRect, SkScalar i nset,
250 SkMagnifierImageFilter::SkMagnifierImageFilter(const SkRect& srcRect, SkScalar i nset) 250 SkImageFilter* input)
251 : INHERITED(0), fSrcRect(srcRect), fInset(inset) { 251 : INHERITED(1, &input), fSrcRect(srcRect), fInset(inset) {
252 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0); 252 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0);
253 } 253 }
254 254
255 #if SK_SUPPORT_GPU 255 #if SK_SUPPORT_GPU
256 bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* textur e, const SkMatrix&, const SkIRect&) const { 256 bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* textur e, const SkMatrix&, const SkIRect&) const {
257 if (effect) { 257 if (effect) {
258 SkScalar yOffset = (texture->origin() == kTopLeft_GrSurfaceOrigin) ? fSr cRect.y() : 258 SkScalar yOffset = (texture->origin() == kTopLeft_GrSurfaceOrigin) ? fSr cRect.y() :
259 (texture->height() - (fSrcRect.y() + fSrcRect.height( ))); 259 (texture->height() - (fSrcRect.y() + fSrcRect.height( )));
260 SkScalar invInset = fInset > 0 ? SkScalarInvert(fInset) : SK_Scalar1; 260 SkScalar invInset = fInset > 0 ? SkScalarInvert(fInset) : SK_Scalar1;
261 *effect = GrMagnifierEffect::Create(texture, 261 *effect = GrMagnifierEffect::Create(texture,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 341
342 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1); 342 int x_val = SkPin32(SkScalarFloorToInt(x_interp), 0, width - 1);
343 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1); 343 int y_val = SkPin32(SkScalarFloorToInt(y_interp), 0, height - 1);
344 344
345 *dptr = sptr[y_val * width + x_val]; 345 *dptr = sptr[y_val * width + x_val];
346 dptr++; 346 dptr++;
347 } 347 }
348 } 348 }
349 return true; 349 return true;
350 } 350 }
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