Chromium Code Reviews| Index: src/gpu/gl/GrGLProcessor.h |
| diff --git a/src/gpu/gl/GrGLEffect.h b/src/gpu/gl/GrGLProcessor.h |
| similarity index 59% |
| rename from src/gpu/gl/GrGLEffect.h |
| rename to src/gpu/gl/GrGLProcessor.h |
| index 61e3ed8e534f55655a9a056ccf0402f3aebafc5e..c7251e89ea9ef1564489512dbf9dd8a22e12c3b9 100644 |
| --- a/src/gpu/gl/GrGLEffect.h |
| +++ b/src/gpu/gl/GrGLProcessor.h |
| @@ -5,46 +5,45 @@ |
| * found in the LICENSE file. |
| */ |
| -#ifndef GrGLEffect_DEFINED |
| -#define GrGLEffect_DEFINED |
| +#ifndef GrGLProcessor_DEFINED |
| +#define GrGLProcessor_DEFINED |
| -#include "GrBackendEffectFactory.h" |
| +#include "GrBackendProcessorFactory.h" |
| #include "GrGLProgramEffects.h" |
| #include "GrGLShaderVar.h" |
| #include "GrGLSL.h" |
| -class GrGLShaderBuilder; |
| - |
| /** @file |
| This file contains specializations for OpenGL of the shader stages declared in |
| - include/gpu/GrEffect.h. Objects of type GrGLEffect are responsible for emitting the |
| - GLSL code that implements a GrEffect and for uploading uniforms at draw time. If they don't |
| + include/gpu/GrProcessor.h. Objects of type GrGLProcessor are responsible for emitting the |
| + GLSL code that implements a GrProcessor and for uploading uniforms at draw time. If they don't |
| always emit the same GLSL code, they must have a function: |
| - static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*) |
| - that is used to implement a program cache. When two GrEffects produce the same key this means |
| - that their GrGLEffects would emit the same GLSL code. |
| + static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) |
| + that is used to implement a program cache. When two GrProcessors produce the same key this means |
| + that their GrGLProcessors would emit the same GLSL code. |
| - The GrGLEffect subclass must also have a constructor of the form: |
| - EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrEffect&) |
| + The GrGLProcessor subclass must also have a constructor of the form: |
| + EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrProcessor&) |
| - These objects are created by the factory object returned by the GrEffect::getFactory(). |
| + These objects are created by the factory object returned by the GrProcessor::getFactory(). |
| */ |
| -class GrGLTexture; |
| -class GrGLGeometryProcessor; |
| - |
| -class GrGLEffect { |
| +class GrGLProcessor { |
| public: |
| + GrGLProcessor(const GrBackendProcessorFactory& factory) |
| + : fFactory(factory) { |
| + } |
| + |
| typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
| /** |
| - * Passed to GrGLEffects so they can add transformed coordinates to their shader code. |
| + * Passed to GrGLProcessors so they can add transformed coordinates to their shader code. |
| */ |
| typedef GrShaderVar TransformedCoords; |
| typedef SkTArray<GrShaderVar> TransformedCoordsArray; |
| /** |
| - * Passed to GrGLEffects so they can add texture reads to their shader code. |
| + * Passed to GrGLProcessors so they can add texture reads to their shader code. |
| */ |
| class TextureSampler { |
| public: |
| @@ -70,12 +69,32 @@ public: |
| typedef SkTArray<TextureSampler> TextureSamplerArray; |
| - GrGLEffect(const GrBackendEffectFactory& factory) |
| - : fFactory(factory) |
| - , fIsVertexEffect(false) { |
| + virtual ~GrGLProcessor() {} |
| + |
| + /** A GrGLProcessor instance can be reused with any GrProcessor that produces the same stage |
| + key; this function reads data from a GrProcessor and uploads any uniform variables required |
| + by the shaders created in emitCode(). The GrProcessor installed in the GrDrawEffect is |
| + guaranteed to be of the same type that created this GrGLProcessor and to have an identical |
| + effect key as the one that created this GrGLProcessor. Effects that use local coords have |
| + to consider whether the GrProcessorStage's coord change matrix should be used. When explicit |
| + local coordinates are used it can be ignored. */ |
| + virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) {} |
| + |
| + const char* name() const { return fFactory.name(); } |
| + |
| + static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {} |
| + |
| +protected: |
| + const GrBackendProcessorFactory& fFactory; |
| +}; |
| + |
| +class GrGLFragmentProcessor : public GrGLProcessor { |
| +public: |
| + GrGLFragmentProcessor(const GrBackendProcessorFactory& factory) |
| + : INHERITED(factory) { |
| } |
| - virtual ~GrGLEffect() {} |
| + virtual ~GrGLFragmentProcessor() {} |
| /** Called when the program stage should insert its code into the shaders. The code in each |
| shader will be in its own block ({}) and so locally scoped names will not collide across |
| @@ -83,7 +102,7 @@ public: |
| @param builder Interface used to emit code in the shaders. |
| @param effect The effect that generated this program stage. |
| - @param key The key that was computed by GenKey() from the generating GrEffect. |
| + @param key The key that was computed by GenKey() from the generating GrProcessor. |
| @param outputColor A predefined vec4 in the FS in which the stage should place its output |
| color (or coverage). |
| @param inputColor A vec4 that holds the input color to the stage in the FS. This may be |
| @@ -91,42 +110,20 @@ public: |
| TODO: Better system for communicating optimization info (e.g. input |
| color is solid white, trans black, known to be opaque, etc.) that allows |
| the effect to communicate back similar known info about its output. |
| - @param samplers One entry for each GrTextureAccess of the GrEffect that generated the |
| - GrGLEffect. These can be passed to the builder to emit texture |
| + @param samplers One entry for each GrTextureAccess of the GrProcessor that generated the |
|
bsalomon
2014/09/22 15:35:23
This comment was already busted, but how about:
C
|
| + GrGLProcessor. These can be passed to the builder to emit texture |
| reads in the generated code. |
| */ |
| virtual void emitCode(GrGLProgramBuilder* builder, |
| - const GrEffect& effect, |
| - const GrEffectKey& key, |
| + const GrFragmentProcessor& effect, |
| + const GrProcessorKey& key, |
| const char* outputColor, |
| const char* inputColor, |
| const TransformedCoordsArray& coords, |
| const TextureSamplerArray& samplers) = 0; |
| - /** A GrGLEffect instance can be reused with any GrEffect that produces the same stage |
| - key; this function reads data from a GrEffect and uploads any uniform variables required |
| - by the shaders created in emitCode(). The GrEffect is |
| - guaranteed to be of the same type that created this GrGLEffect and to have an identical |
| - effect key as the one that created this GrGLEffect. Effects that use local coords have |
| - to consider whether the GrEffectStage's coord change matrix should be used. When explicit |
| - local coordinates are used it can be ignored. */ |
| - virtual void setData(const GrGLProgramDataManager&, const GrEffect&) {} |
| - |
| - const char* name() const { return fFactory.name(); } |
| - |
| - static void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {} |
| - |
| - /** Used by the system when generating shader code, to see if this effect can be downcasted to |
| - the internal GrGLGeometryProcessor type */ |
| - bool isVertexEffect() const { return fIsVertexEffect; } |
| - |
| -protected: |
| - const GrBackendEffectFactory& fFactory; |
| - |
| private: |
| - friend class GrGLGeometryProcessor; // to set fIsVertexEffect |
| - |
| - bool fIsVertexEffect; |
| + typedef GrGLProcessor INHERITED; |
| }; |
| #endif |