'<(skia_src_path)/gpu/gl/GrGLCreateNativeInterface_none.cpp',
'<(skia_src_path)/gpu/gl/GrGLDefaultInterface_none.cpp',
'<(skia_src_path)/gpu/gl/GrGLDefines.h',
+ '<(skia_src_path)/gpu/gl/GrGLEffect.cpp',
+ '<(skia_src_path)/gpu/gl/GrGLEffect.h',
'<(skia_src_path)/gpu/gl/GrGLIndexBuffer.cpp',
'<(skia_src_path)/gpu/gl/GrGLIndexBuffer.h',
'<(skia_src_path)/gpu/gl/GrGLInterface.cpp',
'<(skia_src_path)/gpu/gl/GrGLPath.h',
'<(skia_src_path)/gpu/gl/GrGLProgram.cpp',
'<(skia_src_path)/gpu/gl/GrGLProgram.h',
- '<(skia_src_path)/gpu/gl/GrGLProgramStage.cpp',
- '<(skia_src_path)/gpu/gl/GrGLProgramStage.h',
'<(skia_src_path)/gpu/gl/GrGLRenderTarget.cpp',
'<(skia_src_path)/gpu/gl/GrGLRenderTarget.h',
'<(skia_src_path)/gpu/gl/GrGLShaderBuilder.cpp',
their fields may not change. (Immutability isn't actually required
until they've been used in a draw call, but supporting that would require
setters and getters that could fail, copy-on-write, or deep copying of these
- objects when they're stored by a GrGLProgramStage.)
+ objects when they're stored by a GrGLEffect.)
*/
class GrEffect : public GrRefCnt {
an instance of templated class, GrTProgramStageFactory. It is templated
on the subclass of GrEffect. The subclass must have a nested type
(or typedef) named GLProgramStage which will be the subclass of
- GrGLProgramStage created by the factory.
+ GrGLEffect created by the factory.
Example:
class MyCustomEffect : public GrEffect {
#include "GrNoncopyable.h"
/** Given a GrEffect of a particular type, creates the corresponding
- graphics-backend-specific GrGLProgramStage. Also tracks equivalence
+ graphics-backend-specific GrGLEffect. Also tracks equivalence
of shaders generated via a key.
*/
class GrEffect;
-class GrGLProgramStage;
+class GrGLEffect;
class GrGLCaps;
class GrProgramStageFactory : public GrNoncopyable {
};
virtual StageKey glStageKey(const GrEffect&, const GrGLCaps&) const = 0;
- virtual GrGLProgramStage* createGLInstance(const GrEffect&) const = 0;
+ virtual GrGLEffect* createGLInstance(const GrEffect&) const = 0;
bool operator ==(const GrProgramStageFactory& b) const {
return fEffectClassID == b.fEffectClassID;
typedef typename EffectClass::GLProgramStage GLProgramStage;
/** Returns a human-readable name that is accessible via GrEffect or
- GrGLProgramStage and is consistent between the two of them.
+ GrGLEffect and is consistent between the two of them.
*/
virtual const char* name() const SK_OVERRIDE { return EffectClass::Name(); }
#if SK_SUPPORT_GPU
#include "SkGr.h"
#include "SkGrPixelRef.h"
-#include "gl/GrGLProgramStage.h"
+#include "gl/GrGLEffect.h"
#endif
namespace {
}
}
-GrGLProgramStage::StageKey GrGLBlendEffect::GenKey(const GrEffect& s, const GrGLCaps&) {
+GrGLEffect::StageKey GrGLBlendEffect::GenKey(const GrEffect& s, const GrGLCaps&) {
return static_cast<const GrBlendEffect&>(s).mode();
}
#endif
#if SK_SUPPORT_GPU
#include "GrEffect.h"
-#include "gl/GrGLProgramStage.h"
+#include "gl/GrGLEffect.h"
class ColorMatrixEffect : public GrEffect {
public:
#if SK_SUPPORT_GPU
#include "GrProgramStageFactory.h"
#include "effects/GrSingleTextureEffect.h"
-#include "gl/GrGLProgramStage.h"
+#include "gl/GrGLEffect.h"
#include "gl/GrGLTexture.h"
#include "GrEffect.h"
GrGLSLMulVarBy4f(code, 2, outputColor, inputColor);
}
-GrGLProgramStage::StageKey GrGLLightingEffect::GenKey(const GrEffect& s,
+GrGLEffect::StageKey GrGLLightingEffect::GenKey(const GrEffect& s,
const GrGLCaps& caps) {
return static_cast<const GrLightingEffect&>(s).light()->type();
}
////////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
#include "effects/GrSingleTextureEffect.h"
-#include "gl/GrGLProgramStage.h"
+#include "gl/GrGLEffect.h"
#include "gl/GrGLSL.h"
#include "gl/GrGLTexture.h"
#include "GrProgramStageFactory.h"
uman.set2f(fInsetVar, zoom.x_inset(), zoom.y_inset());
}
-GrGLProgramStage::StageKey GrGLMagnifierEffect::GenKey(const GrEffect& s,
+GrGLEffect::StageKey GrGLMagnifierEffect::GenKey(const GrEffect& s,
const GrGLCaps& caps) {
return 0;
}
#include "SkUnPreMultiply.h"
#if SK_SUPPORT_GPU
-#include "gl/GrGLProgramStage.h"
+#include "gl/GrGLEffect.h"
#endif
SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(const SkISize& kernelSize, const SkScalar* kernel, SkScalar gain, SkScalar bias, const SkIPoint& target, TileMode tileMode, bool convolveAlpha, SkImageFilter* input)
};
-GrGLProgramStage::StageKey GrGLMatrixConvolutionEffect::GenKey(const GrEffect& s,
+GrGLEffect::StageKey GrGLMatrixConvolutionEffect::GenKey(const GrEffect& s,
const GrGLCaps& caps) {
const GrMatrixConvolutionEffect& m = static_cast<const GrMatrixConvolutionEffect&>(s);
StageKey key = encodeXY(m.kernelSize().width(), m.kernelSize().height());
#include "GrContext.h"
#include "GrTexture.h"
#include "GrGpu.h"
-#include "gl/GrGLProgramStage.h"
+#include "gl/GrGLEffect.h"
#include "effects/Gr1DKernelEffect.h"
#endif
GrGLSLMulVarBy4f(code, 2, outputColor, inputColor);
}
-GrGLProgramStage::StageKey GrGLMorphologyEffect::GenKey(const GrEffect& s,
+GrGLEffect::StageKey GrGLMorphologyEffect::GenKey(const GrEffect& s,
const GrGLCaps& caps) {
const GrMorphologyEffect& m = static_cast<const GrMorphologyEffect&>(s);
StageKey key = static_cast<StageKey>(m.radius());
#if SK_SUPPORT_GPU
#include "GrEffect.h"
-#include "gl/GrGLProgramStage.h"
+#include "gl/GrGLEffect.h"
#include "SkGr.h"
class GLColorTableEffect;
code->appendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor);
}
-GrGLProgramStage::StageKey GLColorTableEffect::GenKey(const GrEffect& s,
+GrGLEffect::StageKey GLColorTableEffect::GenKey(const GrEffect& s,
const GrGLCaps& caps) {
return 0;
}
#if SK_SUPPORT_GPU
-#include "gl/GrGLProgramStage.h"
+#include "gl/GrGLEffect.h"
class GrSamplerState;
class GrProgramStageFactory;
*/
#include "GrConfigConversionEffect.h"
-#include "gl/GrGLProgramStage.h"
+#include "gl/GrGLEffect.h"
class GrGLConfigConversionEffect : public GrGLLegacyProgramStage {
public:
*/
#include "GrConvolutionEffect.h"
-#include "gl/GrGLProgramStage.h"
+#include "gl/GrGLEffect.h"
#include "gl/GrGLSL.h"
#include "gl/GrGLTexture.h"
#include "GrProgramStageFactory.h"
uman.set1fv(fKernelUni, 0, this->width(), conv.kernel());
}
-GrGLProgramStage::StageKey GrGLConvolutionEffect::GenKey(const GrEffect& s,
+GrGLEffect::StageKey GrGLConvolutionEffect::GenKey(const GrEffect& s,
const GrGLCaps& caps) {
return static_cast<const GrConvolutionEffect&>(s).radius();
}
*/
#include "effects/GrSingleTextureEffect.h"
-#include "gl/GrGLProgramStage.h"
+#include "gl/GrGLEffect.h"
#include "gl/GrGLSL.h"
#include "gl/GrGLTexture.h"
#include "GrProgramStageFactory.h"
*/
#include "GrTextureDomainEffect.h"
-#include "gl/GrGLProgramStage.h"
+#include "gl/GrGLEffect.h"
#include "GrProgramStageFactory.h"
class GrGLTextureDomainEffect : public GrGLLegacyProgramStage {
--- /dev/null
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrGLSL.h"
+#include "GrGLEffect.h"
+
+GrGLEffect::GrGLEffect(const GrProgramStageFactory& factory)
+ : fFactory(factory) {
+}
+
+GrGLEffect::~GrGLEffect() {
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void GrGLEffect::setData(const GrGLUniformManager&, const GrEffect&) {
+}
+
+GrGLEffect::StageKey GrGLEffect::GenTextureKey(const GrEffect& effect,
+ const GrGLCaps& caps) {
+ StageKey key = 0;
+ for (int index = 0; index < effect.numTextures(); ++index) {
+ const GrTextureAccess& access = effect.textureAccess(index);
+ StageKey value = GrGLShaderBuilder::KeyForTextureAccess(access, caps) << index;
+ GrAssert(0 == (value & key)); // keys for each access ought not to overlap
+ key |= value;
+ }
+ return key;
+}
--- /dev/null
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrGLProgramStage_DEFINED
+#define GrGLProgramStage_DEFINED
+
+#include "GrAllocator.h"
+#include "GrEffect.h"
+#include "GrGLProgram.h"
+#include "GrGLShaderBuilder.h"
+#include "GrGLShaderVar.h"
+#include "GrGLSL.h"
+
+struct GrGLInterface;
+class GrGLTexture;
+
+/** @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. They also
+ must have a function:
+ static inline StageKey GenKey(const GrEffect&, const GrGLCaps&)
+ that is used to implement a program cache. When two GrEffects produce the same key this means
+ that their GrGLProgramStages would emit the same GLSL code.
+
+ These objects are created by the factory object returned by the GrEffect::getFactory().
+*/
+
+class GrGLEffect {
+
+public:
+ typedef GrEffect::StageKey StageKey;
+ enum {
+ // the number of bits in StageKey available to GenKey
+ kProgramStageKeyBits = GrProgramStageFactory::kProgramStageKeyBits,
+ };
+
+ typedef GrGLShaderBuilder::TextureSamplerArray TextureSamplerArray;
+
+ GrGLEffect(const GrProgramStageFactory&);
+
+ virtual ~GrGLEffect();
+
+ /** 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
+ stages.
+
+ @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 StageKey() from the generating GrEffect.
+ @param vertexCoords A vec2 of texture coordinates in the VS, which may be altered. This will
+ be removed soon and stages will be responsible for computing their own
+ coords.
+ @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
+ NULL in which case the implied input is solid white (all ones).
+ 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
+ reads in the generated code.
+ */
+ virtual void emitCode(GrGLShaderBuilder* builder,
+ const GrEffect& effect,
+ StageKey key,
+ const char* vertexCoords,
+ const char* outputColor,
+ const char* inputColor,
+ 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 stage and uploads any uniform variables required
+ by the shaders created in emitCode(). */
+ virtual void setData(const GrGLUniformManager&, const GrEffect&);
+
+ const char* name() const { return fFactory.name(); }
+
+ static StageKey GenTextureKey(const GrEffect&, const GrGLCaps&);
+
+protected:
+
+ const GrProgramStageFactory& fFactory;
+};
+
+/**
+ * This allows program stages that implemented an older set of virtual functions on GrGLEffect
+ * to continue to work by change their parent class to this class. New program stages should not use
+ * this interface. It will be removed once older stages are modified to implement emitCode().
+ */
+class GrGLLegacyProgramStage : public GrGLEffect {
+public:
+ GrGLLegacyProgramStage(const GrProgramStageFactory& factory) : GrGLEffect(factory) {}
+
+ virtual void setupVariables(GrGLShaderBuilder* builder) {};
+ virtual void emitVS(GrGLShaderBuilder* builder,
+ const char* vertexCoords) = 0;
+ virtual void emitFS(GrGLShaderBuilder* builder,
+ const char* outputColor,
+ const char* inputColor,
+ const TextureSamplerArray&) = 0;
+
+ virtual void emitCode(GrGLShaderBuilder* builder,
+ const GrEffect&,
+ StageKey,
+ const char* vertexCoords,
+ const char* outputColor,
+ const char* inputColor,
+ const TextureSamplerArray& samplers) {
+ this->setupVariables(builder);
+ this->emitVS(builder, vertexCoords);
+ this->emitFS(builder, outputColor, inputColor, samplers);
+ }
+};
+
+#endif
#include "GrAllocator.h"
#include "GrEffect.h"
-#include "GrGLProgramStage.h"
+#include "GrGLEffect.h"
#include "gl/GrGLShaderBuilder.h"
#include "GrGLShaderVar.h"
#include "GrProgramStageFactory.h"
// Stage code generation
// TODO: Move this function to GrGLShaderBuilder
-GrGLProgramStage* GrGLProgram::GenStageCode(const GrEffect* effect,
+GrGLEffect* GrGLProgram::GenStageCode(const GrEffect* effect,
const StageDesc& desc,
StageUniforms* uniforms,
const char* fsInColor, // NULL means no incoming color
const char* vsInCoord,
GrGLShaderBuilder* builder) {
- GrGLProgramStage* glStage = effect->getFactory().createGLInstance(*effect);
+ GrGLEffect* glStage = effect->getFactory().createGLInstance(*effect);
/// Vertex Shader Stuff
#include "SkXfermode.h"
class GrBinHashKeyBuilder;
-class GrGLProgramStage;
+class GrGLEffect;
class GrGLShaderBuilder;
// optionally compile the experimental GS code. Set to GR_DEBUG
void genInputColor(GrGLShaderBuilder* builder, SkString* inColor);
- static GrGLProgramStage* GenStageCode(const GrEffect* effect,
+ static GrGLEffect* GenStageCode(const GrEffect* effect,
const StageDesc& desc, // TODO: Eliminate this
StageUniforms* stageUniforms, // TODO: Eliminate this
const char* fsInColor, // NULL means no incoming color
GrMatrix fTextureMatrices[GrDrawState::kNumStages];
GrGLTexture::Orientation fTextureOrientation[GrDrawState::kNumStages];
- GrGLProgramStage* fProgramStage[GrDrawState::kNumStages];
+ GrGLEffect* fProgramStage[GrDrawState::kNumStages];
Desc fDesc;
const GrGLContextInfo& fContextInfo;
+++ /dev/null
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "GrGLSL.h"
-#include "GrGLProgramStage.h"
-
-GrGLProgramStage::GrGLProgramStage(const GrProgramStageFactory& factory)
- : fFactory(factory) {
-}
-
-GrGLProgramStage::~GrGLProgramStage() {
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-void GrGLProgramStage::setData(const GrGLUniformManager&, const GrEffect&) {
-}
-
-GrGLProgramStage::StageKey GrGLProgramStage::GenTextureKey(const GrEffect& effect,
- const GrGLCaps& caps) {
- StageKey key = 0;
- for (int index = 0; index < effect.numTextures(); ++index) {
- const GrTextureAccess& access = effect.textureAccess(index);
- StageKey value = GrGLShaderBuilder::KeyForTextureAccess(access, caps) << index;
- GrAssert(0 == (value & key)); // keys for each access ought not to overlap
- key |= value;
- }
- return key;
-}
+++ /dev/null
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrGLProgramStage_DEFINED
-#define GrGLProgramStage_DEFINED
-
-#include "GrAllocator.h"
-#include "GrEffect.h"
-#include "GrGLProgram.h"
-#include "GrGLShaderBuilder.h"
-#include "GrGLShaderVar.h"
-#include "GrGLSL.h"
-
-struct GrGLInterface;
-class GrGLTexture;
-
-/** @file
- This file contains specializations for OpenGL of the shader stages declared in
- include/gpu/GrEffect.h. Objects of type GrGLProgramStage are responsible for emitting the
- GLSL code that implements a GrEffect and for uploading uniforms at draw time. They also
- must have a function:
- static inline StageKey GenKey(const GrEffect&, const GrGLCaps&)
- that is used to implement a program cache. When two GrEffects produce the same key this means
- that their GrGLProgramStages would emit the same GLSL code.
-
- These objects are created by the factory object returned by the GrEffect::getFactory().
-*/
-
-class GrGLProgramStage {
-
-public:
- typedef GrEffect::StageKey StageKey;
- enum {
- // the number of bits in StageKey available to GenKey
- kProgramStageKeyBits = GrProgramStageFactory::kProgramStageKeyBits,
- };
-
- typedef GrGLShaderBuilder::TextureSamplerArray TextureSamplerArray;
-
- GrGLProgramStage(const GrProgramStageFactory&);
-
- virtual ~GrGLProgramStage();
-
- /** 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
- stages.
-
- @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 StageKey() from the generating GrEffect.
- @param vertexCoords A vec2 of texture coordinates in the VS, which may be altered. This will
- be removed soon and stages will be responsible for computing their own
- coords.
- @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
- NULL in which case the implied input is solid white (all ones).
- 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
- GrGLProgramStage. These can be passed to the builder to emit texture
- reads in the generated code.
- */
- virtual void emitCode(GrGLShaderBuilder* builder,
- const GrEffect& effect,
- StageKey key,
- const char* vertexCoords,
- const char* outputColor,
- const char* inputColor,
- const TextureSamplerArray& samplers) = 0;
-
- /** A GrGLProgramStage instance can be reused with any GrEffect that produces the same stage
- key; this function reads data from a stage and uploads any uniform variables required
- by the shaders created in emitCode(). */
- virtual void setData(const GrGLUniformManager&, const GrEffect&);
-
- const char* name() const { return fFactory.name(); }
-
- static StageKey GenTextureKey(const GrEffect&, const GrGLCaps&);
-
-protected:
-
- const GrProgramStageFactory& fFactory;
-};
-
-/**
- * This allows program stages that implemented an older set of virtual functions on GrGLProgramStage
- * to continue to work by change their parent class to this class. New program stages should not use
- * this interface. It will be removed once older stages are modified to implement emitCode().
- */
-class GrGLLegacyProgramStage : public GrGLProgramStage {
-public:
- GrGLLegacyProgramStage(const GrProgramStageFactory& factory) : GrGLProgramStage(factory) {}
-
- virtual void setupVariables(GrGLShaderBuilder* builder) {};
- virtual void emitVS(GrGLShaderBuilder* builder,
- const char* vertexCoords) = 0;
- virtual void emitFS(GrGLShaderBuilder* builder,
- const char* outputColor,
- const char* inputColor,
- const TextureSamplerArray&) = 0;
-
- virtual void emitCode(GrGLShaderBuilder* builder,
- const GrEffect&,
- StageKey,
- const char* vertexCoords,
- const char* outputColor,
- const char* inputColor,
- const TextureSamplerArray& samplers) {
- this->setupVariables(builder);
- this->emitVS(builder, vertexCoords);
- this->emitFS(builder, outputColor, inputColor, samplers);
- }
-};
-
-#endif
* mulFactor may be either "" or NULL. In this case either nothing will be appended (kOnes) or an
* assignment of vec(0,0,0,0) will be appended (kZeros). The assignment is prepended by tabCnt tabs.
* A semicolon and newline are added after the assignment. (TODO: Remove tabCnt when we auto-insert
- * tabs to GrGLProgramStage-generated lines.) If a zeros vec is assigned then the return value is
+ * tabs to GrGLEffect-generated lines.) If a zeros vec is assigned then the return value is
* kZeros, otherwise kNone.
*/
GrSLConstantVec GrGLSLMulVarBy4f(SkString* outAppend,
#include "GrGpuGL.h"
#include "GrEffect.h"
-#include "GrGLProgramStage.h"
+#include "GrGLEffect.h"
#include "GrGpuVertex.h"
typedef GrGLUniformManager::UniformHandle UniformHandle;