Index: src/effects/SkMatrixConvolutionImageFilter.cpp |
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp |
index 045f6a96d58cce817489badad9c3162e01c342b6..cdcf66f6921ec939b42460301a5b7a94b58da36b 100644 |
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp |
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp |
@@ -75,6 +75,50 @@ |
kernelOffset, tileMode, convolveAlpha, |
input, cropRect, uniqueID)); |
} |
+ |
+#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
+static bool tile_mode_is_valid(SkMatrixConvolutionImageFilter::TileMode tileMode) { |
+ switch (tileMode) { |
+ case SkMatrixConvolutionImageFilter::kClamp_TileMode: |
+ case SkMatrixConvolutionImageFilter::kRepeat_TileMode: |
+ case SkMatrixConvolutionImageFilter::kClampToBlack_TileMode: |
+ return true; |
+ default: |
+ break; |
+ } |
+ return false; |
+} |
+ |
+SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(SkReadBuffer& buffer) |
+ : INHERITED(1, buffer) { |
+ fKernelSize.fWidth = buffer.readInt(); |
+ fKernelSize.fHeight = buffer.readInt(); |
+ if ((fKernelSize.fWidth >= 1) && (fKernelSize.fHeight >= 1) && |
+ // Make sure size won't be larger than a signed int, |
+ // which would still be extremely large for a kernel, |
+ // but we don't impose a hard limit for kernel size |
+ (gMaxKernelSize / fKernelSize.fWidth >= fKernelSize.fHeight)) { |
+ size_t size = fKernelSize.fWidth * fKernelSize.fHeight; |
+ fKernel = SkNEW_ARRAY(SkScalar, size); |
+ SkDEBUGCODE(bool success =) buffer.readScalarArray(fKernel, size); |
+ SkASSERT(success); |
+ } else { |
+ fKernel = 0; |
+ } |
+ fGain = buffer.readScalar(); |
+ fBias = buffer.readScalar(); |
+ fKernelOffset.fX = buffer.readInt(); |
+ fKernelOffset.fY = buffer.readInt(); |
+ fTileMode = (TileMode) buffer.readInt(); |
+ fConvolveAlpha = buffer.readBool(); |
+ buffer.validate((fKernel != 0) && |
+ SkScalarIsFinite(fGain) && |
+ SkScalarIsFinite(fBias) && |
+ tile_mode_is_valid(fTileMode) && |
+ (fKernelOffset.fX >= 0) && (fKernelOffset.fX < fKernelSize.fWidth) && |
+ (fKernelOffset.fY >= 0) && (fKernelOffset.fY < fKernelSize.fHeight)); |
+} |
+#endif |
SkFlattenable* SkMatrixConvolutionImageFilter::CreateProc(SkReadBuffer& buffer) { |
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |