aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar ajuma <ajuma@chromium.org>2016-01-08 14:58:35 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-08 14:58:35 -0800
commit77b6ba3b6e23b84a3a4f3a62812e4a9eb6de4c23 (patch)
treee567bf7da5cadf68009bbd21d2e65fb01895663a /gm
parentc146aa6fd45dffe29b4f565aafd4ec3a16d9f73b (diff)
Implement an SkPaint-based image filter
This implements SkPaintImageFilter, and is intended to replace SkRectShaderImageFilter. By allowing a paint and not just a shader as input, this allows consumers to control dithering. BUG=skia:4780 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1556553002 Review URL: https://codereview.chromium.org/1556553002
Diffstat (limited to 'gm')
-rw-r--r--gm/imagefiltersclipped.cpp6
-rw-r--r--gm/imagefiltersscaled.cpp6
2 files changed, 8 insertions, 4 deletions
diff --git a/gm/imagefiltersclipped.cpp b/gm/imagefiltersclipped.cpp
index a0fedfdeee..f5c9cefbb2 100644
--- a/gm/imagefiltersclipped.cpp
+++ b/gm/imagefiltersclipped.cpp
@@ -16,9 +16,9 @@
#include "SkLightingImageFilter.h"
#include "SkMorphologyImageFilter.h"
#include "SkOffsetImageFilter.h"
+#include "SkPaintImageFilter.h"
#include "SkPerlinNoiseShader.h"
#include "SkPoint3.h"
-#include "SkRectShaderImageFilter.h"
#include "SkScalar.h"
#include "SkSurface.h"
#include "gm.h"
@@ -139,7 +139,9 @@ protected:
SkSafeUnref(filters[i]);
}
- SkAutoTUnref<SkImageFilter> rectFilter(SkRectShaderImageFilter::Create(noise));
+ SkPaint noisePaint;
+ noisePaint.setShader(noise);
+ SkAutoTUnref<SkImageFilter> rectFilter(SkPaintImageFilter::Create(noisePaint));
canvas->translate(SK_ARRAY_COUNT(filters)*(r.width() + margin), 0);
for (int xOffset = 0; xOffset < 80; xOffset += 16) {
bounds.fLeft = SkIntToScalar(xOffset);
diff --git a/gm/imagefiltersscaled.cpp b/gm/imagefiltersscaled.cpp
index 3221c88cae..7576ee1375 100644
--- a/gm/imagefiltersscaled.cpp
+++ b/gm/imagefiltersscaled.cpp
@@ -16,9 +16,9 @@
#include "SkLightingImageFilter.h"
#include "SkMorphologyImageFilter.h"
#include "SkOffsetImageFilter.h"
+#include "SkPaintImageFilter.h"
#include "SkPerlinNoiseShader.h"
#include "SkPoint3.h"
-#include "SkRectShaderImageFilter.h"
#include "SkScalar.h"
#include "SkSurface.h"
#include "gm.h"
@@ -56,6 +56,8 @@ protected:
SkAutoTUnref<SkImageFilter> checkerboard(SkImageSource::Create(fCheckerboard));
SkAutoTUnref<SkShader> noise(SkPerlinNoiseShader::CreateFractalNoise(
SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0));
+ SkPaint noisePaint;
+ noisePaint.setShader(noise);
SkPoint3 pointLocation = SkPoint3::Make(0, 0, SkIntToScalar(10));
SkPoint3 spotLocation = SkPoint3::Make(SkIntToScalar(-10),
@@ -84,7 +86,7 @@ protected:
SkErodeImageFilter::Create(1, 1, checkerboard.get()),
SkOffsetImageFilter::Create(SkIntToScalar(32), 0),
SkImageFilter::CreateMatrixFilter(resizeMatrix, kNone_SkFilterQuality),
- SkRectShaderImageFilter::Create(noise),
+ SkPaintImageFilter::Create(noisePaint),
SkLightingImageFilter::CreatePointLitDiffuse(pointLocation, white, surfaceScale, kd),
SkLightingImageFilter::CreateSpotLitDiffuse(spotLocation, spotTarget, spotExponent,
cutoffAngle, white, surfaceScale, kd),