diff options
author | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-07-26 00:10:07 +0000 |
---|---|---|
committer | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-07-26 00:10:07 +0000 |
commit | 4e16bb2a322f2bd16cb1afd2f78c27e420a4b9db (patch) | |
tree | 01816c055ea7a369be49f367a89d35ddc1fa724c /include/effects/SkLightingImageFilter.h | |
parent | 4d24b747e272355395f456e088a2d0177c00ddb5 (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/SkLightingImageFilter.h')
-rw-r--r-- | include/effects/SkLightingImageFilter.h | 17 |
1 files changed, 10 insertions, 7 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; } |