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

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

Issue 23021015: Initial error handling code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Added ImageFilter derived classes safety checks (retry) 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
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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 245
246 //////////////////////////////////////////////////////////////////////////////// 246 ////////////////////////////////////////////////////////////////////////////////
247 SkMagnifierImageFilter::SkMagnifierImageFilter(SkFlattenableReadBuffer& buffer) 247 SkMagnifierImageFilter::SkMagnifierImageFilter(SkFlattenableReadBuffer& buffer)
248 : INHERITED(buffer) { 248 : INHERITED(buffer) {
249 float x = buffer.readScalar(); 249 float x = buffer.readScalar();
250 float y = buffer.readScalar(); 250 float y = buffer.readScalar();
251 float width = buffer.readScalar(); 251 float width = buffer.readScalar();
252 float height = buffer.readScalar(); 252 float height = buffer.readScalar();
253 fSrcRect = SkRect::MakeXYWH(x, y, width, height); 253 fSrcRect = SkRect::MakeXYWH(x, y, width, height);
254 fInset = buffer.readScalar(); 254 fInset = buffer.readScalar();
255
256 buffer.validateData(fSrcRect.isValid() && SkScalarIsFinite(fInset));
255 } 257 }
256 258
257 // FIXME: implement single-input semantics 259 // FIXME: implement single-input semantics
258 SkMagnifierImageFilter::SkMagnifierImageFilter(SkRect srcRect, SkScalar inset) 260 SkMagnifierImageFilter::SkMagnifierImageFilter(SkRect srcRect, SkScalar inset)
259 : INHERITED(0), fSrcRect(srcRect), fInset(inset) { 261 : INHERITED(0), fSrcRect(srcRect), fInset(inset) {
260 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0); 262 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0);
261 } 263 }
262 264
263 #if SK_SUPPORT_GPU 265 #if SK_SUPPORT_GPU
264 bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* textur e, const SkMatrix&) const { 266 bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* textur e, const SkMatrix&) const {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 344
343 int x_val = SkMin32(SkScalarFloorToInt(x_interp), width - 1); 345 int x_val = SkMin32(SkScalarFloorToInt(x_interp), width - 1);
344 int y_val = SkMin32(SkScalarFloorToInt(y_interp), height - 1); 346 int y_val = SkMin32(SkScalarFloorToInt(y_interp), height - 1);
345 347
346 *dptr = sptr[y_val * width + x_val]; 348 *dptr = sptr[y_val * width + x_val];
347 dptr++; 349 dptr++;
348 } 350 }
349 } 351 }
350 return true; 352 return true;
351 } 353 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698