diff options
author | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-11 16:01:22 +0000 |
---|---|---|
committer | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-11 16:01:22 +0000 |
commit | 894790d77c56cd4bae8070331d275c6d2897e33c (patch) | |
tree | 3eb922a14915b4a54f5788b323ae6d2c6c80fe45 /include | |
parent | eb715c8d5caa2191d611c4f9cfb22b4afc6c8d02 (diff) |
This patch implements the diffuse and specular lighting filters in Ganesh.
There are three light types for each: distant, point and spot, whose code
generation lives in a GrGLLight class hierarchy. This similar to the CPU
implementation, where each light type provides a function to compute the vector
from the surface plane to the light (surfaceToLight) and to compute the light
colour (emitLightColour). Instead of templated member functions, as in the CPU
implementation, these are virtual functions to emit the light-specific GLSL
code.
All of the code for the GPU path lives in the same file as that for the CPU
path, SkLightingImageFilter.cpp. In order to provide Ganesh a hook to access
it, SkImageFilter now has a asNewCustomStage() virtual, which allows an image
filter to return a GrCustomStage representing that filter.
Note that this patch does not handle the border conditions correctly (the
[top|bottom][Left|Right]Normal() functions in the CPU implementation). That
will come in a future patch.
Review URL: http://codereview.appspot.com/6345081/
git-svn-id: http://skia.googlecode.com/svn/trunk@4535 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkImageFilter.h | 12 | ||||
-rw-r--r-- | include/effects/SkLightingImageFilter.h | 3 | ||||
-rw-r--r-- | include/gpu/GrProgramStageFactory.h | 1 |
3 files changed, 16 insertions, 0 deletions
diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h index c27f69820c..b7bf8bcfef 100644 --- a/include/core/SkImageFilter.h +++ b/include/core/SkImageFilter.h @@ -14,6 +14,7 @@ class SkBitmap; class SkDevice; class SkMatrix; struct SkPoint; +class GrCustomStage; /** * Experimental. @@ -77,6 +78,17 @@ public: bool filterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst); /** + * Returns true if the filter can be expressed a single-pass + * GrCustomStage, used to process this filter on the GPU, or false if + * not. + * + * If stage is non-NULL, a new GrCustomStage instance is stored + * in it. The caller assumes ownership of the stage, and it is up to the + * caller to unref it. + */ + virtual bool asNewCustomStage(GrCustomStage** stage) const; + + /** * Experimental. * * If the filter can be expressed as a gaussian-blur, return true and diff --git a/include/effects/SkLightingImageFilter.h b/include/effects/SkLightingImageFilter.h index 5406e7e627..c1ef234ea4 100644 --- a/include/effects/SkLightingImageFilter.h +++ b/include/effects/SkLightingImageFilter.h @@ -39,6 +39,9 @@ public: SkPoint3 operator-(const SkPoint3& other) const { return SkPoint3(fX - other.fX, fY - other.fY, fZ - other.fZ); } + bool operator==(const SkPoint3& other) const { + return fX == other.fX && fY == other.fY && fZ == other.fZ; + } SkScalar fX, fY, fZ; }; diff --git a/include/gpu/GrProgramStageFactory.h b/include/gpu/GrProgramStageFactory.h index d133beb9fc..f2b4f5fc90 100644 --- a/include/gpu/GrProgramStageFactory.h +++ b/include/gpu/GrProgramStageFactory.h @@ -10,6 +10,7 @@ #include "GrTypes.h" #include "SkTemplates.h" +#include "GrNoncopyable.h" /** Given a GrCustomStage of a particular type, creates the corresponding graphics-backend-specific GrProgramStage. Also tracks equivalence |