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

Unified Diff: src/effects/SkMatrixConvolutionImageFilter.cpp

Issue 1869833002: Update MatrixConvolutionImageFilter to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to ToT Created 4 years, 8 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
« no previous file with comments | « samplecode/SampleFilterFuzz.cpp ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkMatrixConvolutionImageFilter.cpp
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp
index accebb5a4f085c5838e3f1df008a61340dd91ad9..3104336628e13d32ad27384452c0e47607bc32f9 100644
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp
@@ -22,23 +22,22 @@
// by the size of a scalar to know how many scalars we can read.
static const int32_t gMaxKernelSize = SK_MaxS32 / sizeof(SkScalar);
-SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(
- const SkISize& kernelSize,
- const SkScalar* kernel,
- SkScalar gain,
- SkScalar bias,
- const SkIPoint& kernelOffset,
- TileMode tileMode,
- bool convolveAlpha,
- SkImageFilter* input,
- const CropRect* cropRect)
- : INHERITED(1, &input, cropRect),
- fKernelSize(kernelSize),
- fGain(gain),
- fBias(bias),
- fKernelOffset(kernelOffset),
- fTileMode(tileMode),
- fConvolveAlpha(convolveAlpha) {
+SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(const SkISize& kernelSize,
+ const SkScalar* kernel,
+ SkScalar gain,
+ SkScalar bias,
+ const SkIPoint& kernelOffset,
+ TileMode tileMode,
+ bool convolveAlpha,
+ sk_sp<SkImageFilter> input,
+ const CropRect* cropRect)
+ : INHERITED(&input, 1, cropRect)
+ , fKernelSize(kernelSize)
+ , fGain(gain)
+ , fBias(bias)
+ , fKernelOffset(kernelOffset)
+ , fTileMode(tileMode)
+ , fConvolveAlpha(convolveAlpha) {
size_t size = (size_t) sk_64_mul(fKernelSize.width(), fKernelSize.height());
fKernel = new SkScalar[size];
memcpy(fKernel, kernel, size * sizeof(SkScalar));
@@ -47,16 +46,15 @@ SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(
SkASSERT(kernelOffset.fY >= 0 && kernelOffset.fY < kernelSize.fHeight);
}
-SkImageFilter* SkMatrixConvolutionImageFilter::Create(
- const SkISize& kernelSize,
- const SkScalar* kernel,
- SkScalar gain,
- SkScalar bias,
- const SkIPoint& kernelOffset,
- TileMode tileMode,
- bool convolveAlpha,
- SkImageFilter* input,
- const CropRect* cropRect) {
+sk_sp<SkImageFilter> SkMatrixConvolutionImageFilter::Make(const SkISize& kernelSize,
+ const SkScalar* kernel,
+ SkScalar gain,
+ SkScalar bias,
+ const SkIPoint& kernelOffset,
+ TileMode tileMode,
+ bool convolveAlpha,
+ sk_sp<SkImageFilter> input,
+ const CropRect* cropRect) {
if (kernelSize.width() < 1 || kernelSize.height() < 1) {
return nullptr;
}
@@ -70,8 +68,10 @@ SkImageFilter* SkMatrixConvolutionImageFilter::Create(
(kernelOffset.fY < 0) || (kernelOffset.fY >= kernelSize.fHeight)) {
return nullptr;
}
- return new SkMatrixConvolutionImageFilter(kernelSize, kernel, gain, bias, kernelOffset,
- tileMode, convolveAlpha, input, cropRect);
+ return sk_sp<SkImageFilter>(new SkMatrixConvolutionImageFilter(kernelSize, kernel, gain,
+ bias, kernelOffset,
+ tileMode, convolveAlpha,
+ std::move(input), cropRect));
}
sk_sp<SkFlattenable> SkMatrixConvolutionImageFilter::CreateProc(SkReadBuffer& buffer) {
@@ -96,8 +96,8 @@ sk_sp<SkFlattenable> SkMatrixConvolutionImageFilter::CreateProc(SkReadBuffer& bu
kernelOffset.fY = buffer.readInt();
TileMode tileMode = (TileMode)buffer.readInt();
bool convolveAlpha = buffer.readBool();
- return sk_sp<SkFlattenable>(Create(kernelSize, kernel.get(), gain, bias, kernelOffset, tileMode,
- convolveAlpha, common.getInput(0).get(), &common.cropRect()));
+ return Make(kernelSize, kernel.get(), gain, bias, kernelOffset, tileMode,
+ convolveAlpha, common.getInput(0), &common.cropRect());
}
void SkMatrixConvolutionImageFilter::flatten(SkWriteBuffer& buffer) const {
« no previous file with comments | « samplecode/SampleFilterFuzz.cpp ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698