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

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: Comments fixed 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
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"
11 #include "SkFlattenableBuffers.h" 11 #include "SkFlattenableBuffers.h"
12 #include "SkValidationUtils.h"
12 13
13 //////////////////////////////////////////////////////////////////////////////// 14 ////////////////////////////////////////////////////////////////////////////////
14 #if SK_SUPPORT_GPU 15 #if SK_SUPPORT_GPU
15 #include "effects/GrSingleTextureEffect.h" 16 #include "effects/GrSingleTextureEffect.h"
16 #include "gl/GrGLEffect.h" 17 #include "gl/GrGLEffect.h"
17 #include "gl/GrGLSL.h" 18 #include "gl/GrGLSL.h"
18 #include "gl/GrGLTexture.h" 19 #include "gl/GrGLTexture.h"
19 #include "GrTBackendEffectFactory.h" 20 #include "GrTBackendEffectFactory.h"
20 21
21 class GrGLMagnifierEffect; 22 class GrGLMagnifierEffect;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 230
230 //////////////////////////////////////////////////////////////////////////////// 231 ////////////////////////////////////////////////////////////////////////////////
231 SkMagnifierImageFilter::SkMagnifierImageFilter(SkFlattenableReadBuffer& buffer) 232 SkMagnifierImageFilter::SkMagnifierImageFilter(SkFlattenableReadBuffer& buffer)
232 : INHERITED(buffer) { 233 : INHERITED(buffer) {
233 float x = buffer.readScalar(); 234 float x = buffer.readScalar();
234 float y = buffer.readScalar(); 235 float y = buffer.readScalar();
235 float width = buffer.readScalar(); 236 float width = buffer.readScalar();
236 float height = buffer.readScalar(); 237 float height = buffer.readScalar();
237 fSrcRect = SkRect::MakeXYWH(x, y, width, height); 238 fSrcRect = SkRect::MakeXYWH(x, y, width, height);
238 fInset = buffer.readScalar(); 239 fInset = buffer.readScalar();
240
241 buffer.validate(SkIsValidRect(fSrcRect) && SkScalarIsFinite(fInset));
239 } 242 }
240 243
241 // FIXME: implement single-input semantics 244 // FIXME: implement single-input semantics
242 SkMagnifierImageFilter::SkMagnifierImageFilter(SkRect srcRect, SkScalar inset) 245 SkMagnifierImageFilter::SkMagnifierImageFilter(SkRect srcRect, SkScalar inset)
243 : INHERITED(0), fSrcRect(srcRect), fInset(inset) { 246 : INHERITED(0), fSrcRect(srcRect), fInset(inset) {
244 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0); 247 SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0);
245 } 248 }
246 249
247 #if SK_SUPPORT_GPU 250 #if SK_SUPPORT_GPU
248 bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* textur e, const SkMatrix&) const { 251 bool SkMagnifierImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* textur e, const SkMatrix&) const {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 329
327 int x_val = SkMin32(SkScalarFloorToInt(x_interp), width - 1); 330 int x_val = SkMin32(SkScalarFloorToInt(x_interp), width - 1);
328 int y_val = SkMin32(SkScalarFloorToInt(y_interp), height - 1); 331 int y_val = SkMin32(SkScalarFloorToInt(y_interp), height - 1);
329 332
330 *dptr = sptr[y_val * width + x_val]; 333 *dptr = sptr[y_val * width + x_val];
331 dptr++; 334 dptr++;
332 } 335 }
333 } 336 }
334 return true; 337 return true;
335 } 338 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698