aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/effects
diff options
context:
space:
mode:
authorGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-26 00:10:07 +0000
committerGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-26 00:10:07 +0000
commit4e16bb2a322f2bd16cb1afd2f78c27e420a4b9db (patch)
tree01816c055ea7a369be49f367a89d35ddc1fa724c /include/effects
parent4d24b747e272355395f456e088a2d0177c00ddb5 (diff)
Implement crop rect for lighting image filters. Changes for the CPU path were fairly straightforward: use the bounds rectangle when traversing the pixels, not the source rectangle.
For the GPU path, this required modifying the signature of SkImageFilter::asNewEffect() to receive the bounds offset, so that the lighting filters could offset the light position by the offset. It also required modifying the base-class implementation of SkImageFilter::filterImageGPU() (which implements single-pass filters) to intersect against the bounds rect, to pass its offset to asNewEffect(), and to modify the caller's offset (so it's drawn in the correct place). Note: this will require rebaselining the lighting GM. Six new test cases were added, to accommodate a cropped version of each lighting filter. R=bsalomon@google.com, reed@google.com Review URL: https://codereview.chromium.org/20426002 git-svn-id: http://skia.googlecode.com/svn/trunk@10379 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/effects')
-rw-r--r--include/effects/SkLightingImageFilter.h17
-rw-r--r--include/effects/SkMagnifierImageFilter.h2
-rw-r--r--include/effects/SkMatrixConvolutionImageFilter.h2
3 files changed, 12 insertions, 9 deletions
diff --git a/include/effects/SkLightingImageFilter.h b/include/effects/SkLightingImageFilter.h
index 5e9028d92a..07f713b0af 100644
--- a/include/effects/SkLightingImageFilter.h
+++ b/include/effects/SkLightingImageFilter.h
@@ -51,30 +51,33 @@ class SK_API SkLightingImageFilter : public SkImageFilter {
public:
static SkImageFilter* CreateDistantLitDiffuse(const SkPoint3& direction,
SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
- SkImageFilter* input = NULL);
+ SkImageFilter* input = NULL, const SkIRect* cropRect = NULL);
static SkImageFilter* CreatePointLitDiffuse(const SkPoint3& location,
SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
- SkImageFilter* input = NULL);
+ SkImageFilter* input = NULL, const SkIRect* cropRect = NULL);
static SkImageFilter* CreateSpotLitDiffuse(const SkPoint3& location,
const SkPoint3& target, SkScalar specularExponent, SkScalar cutoffAngle,
SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
- SkImageFilter* input = NULL);
+ SkImageFilter* input = NULL, const SkIRect* cropRect = NULL);
static SkImageFilter* CreateDistantLitSpecular(const SkPoint3& direction,
SkColor lightColor, SkScalar surfaceScale, SkScalar ks,
- SkScalar shininess, SkImageFilter* input = NULL);
+ SkScalar shininess, SkImageFilter* input = NULL, const SkIRect* cropRect = NULL);
static SkImageFilter* CreatePointLitSpecular(const SkPoint3& location,
SkColor lightColor, SkScalar surfaceScale, SkScalar ks,
- SkScalar shininess, SkImageFilter* input = NULL);
+ SkScalar shininess, SkImageFilter* input = NULL, const SkIRect* cropRect = NULL);
static SkImageFilter* CreateSpotLitSpecular(const SkPoint3& location,
const SkPoint3& target, SkScalar specularExponent, SkScalar cutoffAngle,
SkColor lightColor, SkScalar surfaceScale, SkScalar ks,
- SkScalar shininess, SkImageFilter* input = NULL);
+ SkScalar shininess, SkImageFilter* input = NULL, const SkIRect* cropRect = NULL);
~SkLightingImageFilter();
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
protected:
- SkLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkImageFilter* input);
+ SkLightingImageFilter(SkLight* light,
+ SkScalar surfaceScale,
+ SkImageFilter* input,
+ const SkIRect* cropRect = NULL);
explicit SkLightingImageFilter(SkFlattenableReadBuffer& buffer);
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
const SkLight* light() const { return fLight; }
diff --git a/include/effects/SkMagnifierImageFilter.h b/include/effects/SkMagnifierImageFilter.h
index 80e3af6302..b5cbd74ab1 100644
--- a/include/effects/SkMagnifierImageFilter.h
+++ b/include/effects/SkMagnifierImageFilter.h
@@ -17,7 +17,7 @@ public:
SkMagnifierImageFilter(SkRect srcRect, SkScalar inset);
#if SK_SUPPORT_GPU
- virtual bool asNewEffect(GrEffectRef** effect, GrTexture* texture) const SK_OVERRIDE;
+ virtual bool asNewEffect(GrEffectRef** effect, GrTexture* texture, const SkIPoint& offset) const SK_OVERRIDE;
#endif
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMagnifierImageFilter)
diff --git a/include/effects/SkMatrixConvolutionImageFilter.h b/include/effects/SkMatrixConvolutionImageFilter.h
index 78a66f8d70..71c8938901 100644
--- a/include/effects/SkMatrixConvolutionImageFilter.h
+++ b/include/effects/SkMatrixConvolutionImageFilter.h
@@ -62,7 +62,7 @@ protected:
SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;
#if SK_SUPPORT_GPU
- virtual bool asNewEffect(GrEffectRef** effect, GrTexture*) const SK_OVERRIDE;
+ virtual bool asNewEffect(GrEffectRef** effect, GrTexture*, const SkIPoint& offset) const SK_OVERRIDE;
#endif
private: