Index: src/effects/SkMatrixConvolutionImageFilter.cpp |
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp |
index 6e1d1a46521656bbfe7d196c1dad36b2572175e1..e01b6406185eba2c7d3d497838a44c4fc376725f 100644 |
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp |
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp |
@@ -17,18 +17,6 @@ |
#include "effects/GrMatrixConvolutionEffect.h" |
#endif |
-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( |
const SkISize& kernelSize, |
const SkScalar* kernel, |
@@ -54,6 +42,19 @@ SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter( |
SkASSERT(kernelOffset.fY >= 0 && kernelOffset.fY < kernelSize.fHeight); |
} |
+#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) { |
// We need to be able to read at most SK_MaxS32 bytes, so divide that |
@@ -86,6 +87,33 @@ SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(SkReadBuffer& buf |
(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); |
+ SkISize kernelSize; |
+ kernelSize.fWidth = buffer.readInt(); |
+ kernelSize.fHeight = buffer.readInt(); |
+ const int count = buffer.getArrayCount(); |
+ |
+ const int64_t kernelArea = sk_64_mul(kernelSize.width(), kernelSize.height()); |
+ if (!buffer.validate(kernelArea == count)) { |
+ return NULL; |
+ } |
+ SkAutoSTArray<16, SkScalar> kernel(count); |
+ if (!buffer.readScalarArray(kernel.get(), count)) { |
+ return NULL; |
+ } |
+ SkScalar gain = buffer.readScalar(); |
+ SkScalar bias = buffer.readScalar(); |
+ SkIPoint kernelOffset; |
+ kernelOffset.fX = buffer.readInt(); |
+ kernelOffset.fY = buffer.readInt(); |
+ TileMode tileMode = (TileMode)buffer.readInt(); |
+ bool convolveAlpha = buffer.readBool(); |
+ return Create(kernelSize, kernel.get(), gain, bias, kernelOffset, tileMode, convolveAlpha, |
+ common.getInput(0), &common.cropRect()); |
+} |
void SkMatrixConvolutionImageFilter::flatten(SkWriteBuffer& buffer) const { |
this->INHERITED::flatten(buffer); |