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

Unified Diff: gm/imagefiltersgraph.cpp

Issue 1637443003: Image filters: fix srcOffset handling in asFragmentProcessor() path. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update to ToT Created 4 years, 11 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 | « no previous file | src/core/SkImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/imagefiltersgraph.cpp
diff --git a/gm/imagefiltersgraph.cpp b/gm/imagefiltersgraph.cpp
index 14752dbab55738a21c19d828a1be02e15bd0ebfd..e7837891243cce6a89c782e699495f3f277dd7ab 100644
--- a/gm/imagefiltersgraph.cpp
+++ b/gm/imagefiltersgraph.cpp
@@ -15,6 +15,7 @@
#include "SkColorMatrixFilter.h"
#include "SkImage.h"
#include "SkImageSource.h"
+#include "SkMatrixConvolutionImageFilter.h"
#include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkMergeImageFilter.h"
@@ -107,7 +108,7 @@ protected:
return SkString("imagefiltersgraph");
}
- SkISize onISize() override { return SkISize::Make(500, 150); }
+ SkISize onISize() override { return SkISize::Make(600, 150); }
void onOnceBeforeDraw() override {
fImage.reset(SkImage::NewFromBitmap(
@@ -182,6 +183,40 @@ protected:
canvas->translate(SkIntToScalar(100), 0);
}
{
+ // Dilate -> matrix convolution.
+ // This tests that a filter using asFragmentProcessor (matrix
+ // convolution) correctly handles a non-zero source offset
+ // (supplied by the dilate).
+ SkAutoTUnref<SkImageFilter> dilate(SkDilateImageFilter::Create(5, 5));
+
+ SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcIn_Mode));
+
+ SkScalar kernel[9] = {
+ SkIntToScalar(-1), SkIntToScalar( -1 ), SkIntToScalar(-1),
+ SkIntToScalar(-1), SkIntToScalar( 7 ), SkIntToScalar(-1),
+ SkIntToScalar(-1), SkIntToScalar( -1 ), SkIntToScalar(-1),
+ };
+ SkISize kernelSize = SkISize::Make(3, 3);
+ SkScalar gain = 1.0f, bias = SkIntToScalar(0);
+ SkIPoint kernelOffset = SkIPoint::Make(1, 1);
+ auto tileMode = SkMatrixConvolutionImageFilter::kClamp_TileMode;
+ bool convolveAlpha = false;
+ SkAutoTUnref<SkImageFilter> convolve(
+ SkMatrixConvolutionImageFilter::Create(kernelSize,
+ kernel,
+ gain,
+ bias,
+ kernelOffset,
+ tileMode,
+ convolveAlpha,
+ dilate));
+
+ SkPaint paint;
+ paint.setImageFilter(convolve);
+ DrawClippedImage(canvas, fImage, paint);
+ canvas->translate(SkIntToScalar(100), 0);
+ }
+ {
// Test that crop offsets are absolute, not relative to the parent's crop rect.
SkAutoTUnref<SkColorFilter> cf1(SkColorFilter::CreateModeFilter(SK_ColorBLUE,
SkXfermode::kSrcIn_Mode));
« no previous file with comments | « no previous file | src/core/SkImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698