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

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

Issue 23021015: Initial error handling code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Adding validation helper file 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 2013 The Android Open Source Project 2 * Copyright 2013 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 "SkBicubicImageFilter.h" 8 #include "SkBicubicImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 28 matching lines...) Expand all
39 DS( 0.0 / 18.0), DS( 0.0 / 18.0), DS( -6.0 / 18.0), DS( 7.0 / 18.0), 39 DS( 0.0 / 18.0), DS( 0.0 / 18.0), DS( -6.0 / 18.0), DS( 7.0 / 18.0),
40 }; 40 };
41 return SkNEW_ARGS(SkBicubicImageFilter, (scale, coefficients, input)); 41 return SkNEW_ARGS(SkBicubicImageFilter, (scale, coefficients, input));
42 } 42 }
43 43
44 SkBicubicImageFilter::SkBicubicImageFilter(SkFlattenableReadBuffer& buffer) : IN HERITED(buffer) { 44 SkBicubicImageFilter::SkBicubicImageFilter(SkFlattenableReadBuffer& buffer) : IN HERITED(buffer) {
45 SkDEBUGCODE(uint32_t readSize =) buffer.readScalarArray(fCoefficients); 45 SkDEBUGCODE(uint32_t readSize =) buffer.readScalarArray(fCoefficients);
46 SkASSERT(readSize == 16); 46 SkASSERT(readSize == 16);
47 fScale.fWidth = buffer.readScalar(); 47 fScale.fWidth = buffer.readScalar();
48 fScale.fHeight = buffer.readScalar(); 48 fScale.fHeight = buffer.readScalar();
49 buffer.validateData(SkScalarIsFinite(fScale.fWidth) &&
50 SkScalarIsFinite(fScale.fHeight) &&
51 (fScale.fWidth >= 0) &&
52 (fScale.fHeight >= 0));
49 } 53 }
50 54
51 void SkBicubicImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { 55 void SkBicubicImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
52 this->INHERITED::flatten(buffer); 56 this->INHERITED::flatten(buffer);
53 buffer.writeScalarArray(fCoefficients, 16); 57 buffer.writeScalarArray(fCoefficients, 16);
54 buffer.writeScalar(fScale.fWidth); 58 buffer.writeScalar(fScale.fWidth);
55 buffer.writeScalar(fScale.fHeight); 59 buffer.writeScalar(fScale.fHeight);
56 } 60 }
57 61
58 SkBicubicImageFilter::~SkBicubicImageFilter() { 62 SkBicubicImageFilter::~SkBicubicImageFilter() {
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 GrPaint paint; 367 GrPaint paint;
364 paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->un ref(); 368 paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->un ref();
365 SkRect srcRect; 369 SkRect srcRect;
366 srcBM.getBounds(&srcRect); 370 srcBM.getBounds(&srcRect);
367 context->drawRectToRect(paint, dstRect, srcRect); 371 context->drawRectToRect(paint, dstRect, srcRect);
368 return SkImageFilterUtils::WrapTexture(dst, desc.fWidth, desc.fHeight, resul t); 372 return SkImageFilterUtils::WrapTexture(dst, desc.fWidth, desc.fHeight, resul t);
369 } 373 }
370 #endif 374 #endif
371 375
372 /////////////////////////////////////////////////////////////////////////////// 376 ///////////////////////////////////////////////////////////////////////////////
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698