diff options
author | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-08 19:43:22 +0000 |
---|---|---|
committer | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-08 19:43:22 +0000 |
commit | d043ccee3788ea4192806bd8c94484ed003fa828 (patch) | |
tree | 68ce7206cd22f64fd6152346b30a18a59489ca29 /src/effects/SkLightingImageFilter.cpp | |
parent | 2e87ba0c7c0dfe57e39e6e030db59b69275966cd (diff) |
Allow single-pass filters (which use asNewEffect()) to participate in the image filter DAG. This was done by introducing the SkSinglePassImageFilter abstract base class, which implements canFilterImageGPU() and filterImageGPU() on behalf of the derived class. The derived class still only needs to asNewEffect(). This allows us to recurse on the filter input in SkSinglePassImageFilter::onFilterImageGPU(). It also allows us to remove any knowledge of single-pass image filters from SkGpuDevice and from the SkImageFilter base class as well.
BUG=
Review URL: https://codereview.chromium.org/13602013
git-svn-id: http://skia.googlecode.com/svn/trunk@8563 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/effects/SkLightingImageFilter.cpp')
-rw-r--r-- | src/effects/SkLightingImageFilter.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index a22bc6f8e9..bb2927bbf4 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -264,7 +264,9 @@ public: SkScalar kd, SkImageFilter* input); SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiffuseLightingImageFilter) +#if SK_SUPPORT_GPU virtual bool asNewEffect(GrEffectRef** effect, GrTexture*) const SK_OVERRIDE; +#endif SkScalar kd() const { return fKD; } protected: @@ -284,7 +286,10 @@ public: SkSpecularLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, SkImageFilter* input); SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSpecularLightingImageFilter) +#if SK_SUPPORT_GPU virtual bool asNewEffect(GrEffectRef** effect, GrTexture*) const SK_OVERRIDE; +#endif + SkScalar ks() const { return fKS; } SkScalar shininess() const { return fShininess; } @@ -859,19 +864,15 @@ bool SkDiffuseLightingImageFilter::onFilterImage(Proxy*, return true; } -bool SkDiffuseLightingImageFilter::asNewEffect(GrEffectRef** effect, - GrTexture* texture) const { #if SK_SUPPORT_GPU +bool SkDiffuseLightingImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* texture) const { if (effect) { SkScalar scale = SkScalarMul(surfaceScale(), SkIntToScalar(255)); *effect = GrDiffuseLightingEffect::Create(texture, light(), scale, kd()); } return true; -#else - SkDEBUGFAIL("Should not call in GPU-less build"); - return false; -#endif } +#endif /////////////////////////////////////////////////////////////////////////////// @@ -928,19 +929,15 @@ bool SkSpecularLightingImageFilter::onFilterImage(Proxy*, return true; } -bool SkSpecularLightingImageFilter::asNewEffect(GrEffectRef** effect, - GrTexture* texture) const { #if SK_SUPPORT_GPU +bool SkSpecularLightingImageFilter::asNewEffect(GrEffectRef** effect, GrTexture* texture) const { if (effect) { SkScalar scale = SkScalarMul(surfaceScale(), SkIntToScalar(255)); *effect = GrSpecularLightingEffect::Create(texture, light(), scale, ks(), shininess()); } return true; -#else - SkDEBUGFAIL("Should not call in GPU-less build"); - return false; -#endif } +#endif /////////////////////////////////////////////////////////////////////////////// |