Fix CTM scaling and clipping of SkRectShaderImageFilter.

Pass the CTM as part of the local matrix passed by
SkRectShaderImageFilter. Teach SkPerlinNoiseShader to respect the local
matrix. Embiggen imagefiltersscaled GM size to accommodate the new test
cases.

Note: will require rebaselines of imagefiltersscaled and imagefiltersclipped

R=sugoi@chromium.org
BUG=skia:

Review URL: https://codereview.chromium.org/184973007

git-svn-id: http://skia.googlecode.com/svn/trunk@13637 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
senorblanco@chromium.org 2014-03-03 14:58:09 +00:00
parent c9b2c885be
commit 47d98c8e85
5 changed files with 19 additions and 3 deletions

View File

@ -36,3 +36,8 @@
# This GM has probably always drawn incorrectly. We need to clarify the API
# http://skbug.com/2222 : Inverse filled paths get inverse stroked
inverse_paths
# Added as part of https://codereview.chromium.org/184973007/.
# senorblanco will rebaseline.
imagefiltersclipped
imagefiltersscaled

View File

@ -14,6 +14,8 @@
#include "SkGradientShader.h"
#include "SkMorphologyImageFilter.h"
#include "SkOffsetImageFilter.h"
#include "SkPerlinNoiseShader.h"
#include "SkRectShaderImageFilter.h"
#include "SkResizeImageFilter.h"
#include "SkScalar.h"
@ -87,6 +89,8 @@ protected:
SkAutoTUnref<SkImageFilter> gradient(new SkBitmapSource(fGradientCircle));
SkAutoTUnref<SkImageFilter> checkerboard(new SkBitmapSource(fCheckerboard));
SkAutoTUnref<SkShader> noise(SkPerlinNoiseShader::CreateFractalNoise(
SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0));
SkImageFilter* filters[] = {
new SkBlurImageFilter(SkIntToScalar(12), SkIntToScalar(12)),
@ -101,6 +105,7 @@ protected:
new SkErodeImageFilter(2, 2, checkerboard.get()),
new SkOffsetImageFilter(SkIntToScalar(-16), SkIntToScalar(32)),
new SkResizeImageFilter(RESIZE_FACTOR_X, RESIZE_FACTOR_Y, SkPaint::kNone_FilterLevel),
SkRectShaderImageFilter::Create(noise),
};
SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64));

View File

@ -14,6 +14,8 @@
#include "SkGradientShader.h"
#include "SkMorphologyImageFilter.h"
#include "SkOffsetImageFilter.h"
#include "SkPerlinNoiseShader.h"
#include "SkRectShaderImageFilter.h"
#include "SkResizeImageFilter.h"
#include "SkScalar.h"
@ -33,7 +35,7 @@ protected:
}
virtual SkISize onISize() {
return make_isize(1020, 500);
return make_isize(1140, 500);
}
void make_checkerboard() {
@ -86,6 +88,8 @@ protected:
SkAutoTUnref<SkImageFilter> gradient(new SkBitmapSource(fGradientCircle));
SkAutoTUnref<SkImageFilter> checkerboard(new SkBitmapSource(fCheckerboard));
SkAutoTUnref<SkShader> noise(SkPerlinNoiseShader::CreateFractalNoise(
SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0));
SkImageFilter* filters[] = {
new SkBlurImageFilter(SkIntToScalar(4), SkIntToScalar(4)),
@ -100,6 +104,7 @@ protected:
new SkErodeImageFilter(1, 1, checkerboard.get()),
new SkOffsetImageFilter(SkIntToScalar(32), 0),
new SkResizeImageFilter(RESIZE_FACTOR, RESIZE_FACTOR, SkPaint::kNone_FilterLevel),
SkRectShaderImageFilter::Create(noise),
};
SkVector scales[] = {

View File

@ -450,6 +450,7 @@ SkScalar SkPerlinNoiseShader::calculateTurbulenceValueForPoint(
SkPMColor SkPerlinNoiseShader::shade(const SkPoint& point, StitchData& stitchData) {
SkMatrix matrix = fMatrix;
matrix.postConcat(getLocalMatrix());
SkMatrix invMatrix;
if (!matrix.invert(&invMatrix)) {
invMatrix.reset();

View File

@ -69,8 +69,8 @@ bool SkRectShaderImageFilter::onFilterImage(Proxy* proxy,
SkCanvas canvas(device.get());
SkPaint paint;
paint.setShader(fShader);
SkMatrix matrix;
matrix.setTranslate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop));
SkMatrix matrix(ctm);
matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
fShader->setLocalMatrix(matrix);
SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bounds.height()));
canvas.drawRect(rect, paint);