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

Unified Diff: src/effects/SkMatrixConvolutionImageFilter.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 side-by-side diff with in-line comments
Download patch
Index: src/effects/SkMatrixConvolutionImageFilter.cpp
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp
index d73f6335d74c7a1f13b8ee15985a7337041b68c1..f2a03d0976641fb3bd271a1fa930f79330113c9a 100644
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp
@@ -21,6 +21,22 @@
#endif
+namespace {
+
+bool TileModeIsValid(SkMatrixConvolutionImageFilter::TileMode tileMode) {
mtklein 2013/10/16 18:54:09 I just have this feeling tfarina is going to swoop
sugoi1 2013/10/16 20:07:41 Done.
+ switch (tileMode) {
+ case SkMatrixConvolutionImageFilter::kClamp_TileMode:
+ case SkMatrixConvolutionImageFilter::kRepeat_TileMode:
+ case SkMatrixConvolutionImageFilter::kClampToBlack_TileMode:
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
+}
+
SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(const SkISize& kernelSize, const SkScalar* kernel, SkScalar gain, SkScalar bias, const SkIPoint& target, TileMode tileMode, bool convolveAlpha, SkImageFilter* input)
: INHERITED(input),
fKernelSize(kernelSize),
@@ -50,6 +66,9 @@ SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(SkFlattenableRead
fTarget.fY = buffer.readInt();
fTileMode = (TileMode) buffer.readInt();
fConvolveAlpha = buffer.readBool();
+ buffer.validate(SkScalarIsFinite(fGain) &&
+ SkScalarIsFinite(fBias) &&
+ TileModeIsValid(fTileMode));
}
void SkMatrixConvolutionImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {

Powered by Google App Engine
This is Rietveld 408576698