diff options
-rw-r--r-- | gm/imagefiltersclipped.cpp | 5 | ||||
-rw-r--r-- | src/effects/SkLightingImageFilter.cpp | 8 |
2 files changed, 11 insertions, 2 deletions
diff --git a/gm/imagefiltersclipped.cpp b/gm/imagefiltersclipped.cpp index 28f3e0bde9..a641ca3473 100644 --- a/gm/imagefiltersclipped.cpp +++ b/gm/imagefiltersclipped.cpp @@ -12,9 +12,11 @@ #include "SkDisplacementMapEffect.h" #include "SkDropShadowImageFilter.h" #include "SkGradientShader.h" +#include "SkLightingImageFilter.h" #include "SkMorphologyImageFilter.h" #include "SkOffsetImageFilter.h" #include "SkPerlinNoiseShader.h" +#include "SkPoint3.h" #include "SkRectShaderImageFilter.h" #include "SkScalar.h" #include "gm.h" @@ -95,6 +97,7 @@ protected: SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0)); SkMatrix resizeMatrix; resizeMatrix.setScale(RESIZE_FACTOR_X, RESIZE_FACTOR_Y); + SkPoint3 pointLocation = SkPoint3::Make(32, 32, SkIntToScalar(10)); SkImageFilter* filters[] = { SkBlurImageFilter::Create(SkIntToScalar(12), SkIntToScalar(12)), @@ -110,6 +113,8 @@ protected: SkErodeImageFilter::Create(2, 2, checkerboard.get()), SkOffsetImageFilter::Create(SkIntToScalar(-16), SkIntToScalar(32)), SkImageFilter::CreateMatrixFilter(resizeMatrix, kNone_SkFilterQuality), + SkLightingImageFilter::CreatePointLitDiffuse(pointLocation, SK_ColorWHITE, SK_Scalar1, SkIntToScalar(2), checkerboard.get()), + }; SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index 2e25cbf502..58978b78ce 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -1207,7 +1207,9 @@ bool SkDiffuseLightingImageFilter::onFilterImage(Proxy* proxy, return false; } - SkAutoTUnref<SkImageFilterLight> transformedLight(light()->transform(ctx.ctm())); + SkMatrix matrix(ctx.ctm()); + matrix.postTranslate(SkIntToScalar(-srcOffset.x()), SkIntToScalar(-srcOffset.y())); + SkAutoTUnref<SkImageFilterLight> transformedLight(light()->transform(matrix)); DiffuseLightingType lightingType(fKD); offset->fX = bounds.left(); @@ -1351,8 +1353,10 @@ bool SkSpecularLightingImageFilter::onFilterImage(Proxy* proxy, SpecularLightingType lightingType(fKS, fShininess); offset->fX = bounds.left(); offset->fY = bounds.top(); + SkMatrix matrix(ctx.ctm()); + matrix.postTranslate(SkIntToScalar(-srcOffset.x()), SkIntToScalar(-srcOffset.y())); + SkAutoTUnref<SkImageFilterLight> transformedLight(light()->transform(matrix)); bounds.offset(-srcOffset); - SkAutoTUnref<SkImageFilterLight> transformedLight(light()->transform(ctx.ctm())); switch (transformedLight->type()) { case SkImageFilterLight::kDistant_LightType: lightBitmap<SpecularLightingType, SkDistantLight>(lightingType, |