CustomStage Renaming Part 1

Search and replace:
GrCustomStage->GrEffect
GrCustomStageTestFactory->GrEffectTestFactory

renamed the cpp/h files from customStage->effect

reordered gypi, #includes, forward decls to maintain alphabetical sort.

manually fixed up some whitespace and linewraps

deleted a commented out #include

R=robertphillips@google.com
Review URL: https://codereview.appspot.com/6758046

git-svn-id: http://skia.googlecode.com/svn/trunk@6076 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bsalomon@google.com 2012-10-24 18:28:34 +00:00
parent 96182216f1
commit a469c28c3c
53 changed files with 333 additions and 337 deletions

View File

@ -15,8 +15,8 @@
'<(skia_include_path)/gpu/GrConfig.h',
'<(skia_include_path)/gpu/GrContext.h',
'<(skia_include_path)/gpu/GrContextFactory.h',
'<(skia_include_path)/gpu/GrCustomStage.h',
'<(skia_include_path)/gpu/GrCustomStageUnitTest.h',
'<(skia_include_path)/gpu/GrEffect.h',
'<(skia_include_path)/gpu/GrFontScaler.h',
'<(skia_include_path)/gpu/GrGlyph.h',
'<(skia_include_path)/gpu/GrInstanceCounter.h',
@ -60,13 +60,13 @@
'<(skia_src_path)/gpu/GrCacheID.cpp',
'<(skia_src_path)/gpu/GrClipData.cpp',
'<(skia_src_path)/gpu/GrContext.cpp',
'<(skia_src_path)/gpu/GrCustomStage.cpp',
'<(skia_src_path)/gpu/GrDefaultPathRenderer.cpp',
'<(skia_src_path)/gpu/GrDefaultPathRenderer.h',
'<(skia_src_path)/gpu/GrDrawState.cpp',
'<(skia_src_path)/gpu/GrDrawState.h',
'<(skia_src_path)/gpu/GrDrawTarget.cpp',
'<(skia_src_path)/gpu/GrDrawTarget.h',
'<(skia_src_path)/gpu/GrEffect.cpp',
'<(skia_src_path)/gpu/GrGeometryBuffer.cpp',
'<(skia_src_path)/gpu/GrGeometryBuffer.h',
'<(skia_src_path)/gpu/GrClipMaskCache.h',

View File

@ -15,7 +15,7 @@
#include "SkXfermode.h"
class SkBitmap;
class GrCustomStage;
class GrEffect;
class GrContext;
class SK_API SkColorFilter : public SkFlattenable {
@ -118,7 +118,7 @@ public:
/** A subclass may implement this factory function to work with the GPU backend. If the return
is non-NULL then the caller owns a ref on the returned object.
*/
virtual GrCustomStage* asNewCustomStage(GrContext*) const;
virtual GrEffect* asNewCustomStage(GrContext*) const;
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
protected:

View File

@ -17,7 +17,7 @@ class SkMatrix;
struct SkIPoint;
struct SkIRect;
struct SkRect;
class GrCustomStage;
class GrEffect;
class GrTexture;
/**
@ -83,14 +83,14 @@ public:
/**
* Returns true if the filter can be expressed a single-pass
* GrCustomStage, used to process this filter on the GPU, or false if
* GrEffect, used to process this filter on the GPU, or false if
* not.
*
* If stage is non-NULL, a new GrCustomStage instance is stored
* If stage is non-NULL, a new GrEffect 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, GrTexture*) const;
virtual bool asNewCustomStage(GrEffect** stage, GrTexture*) const;
/**
* Returns true if the filter can be processed on the GPU. This is most

View File

@ -18,7 +18,7 @@
class SkPath;
class GrContext;
class GrCustomStage;
class GrEffect;
class GrSamplerState;
/** \class SkShader
@ -306,11 +306,11 @@ public:
virtual GradientType asAGradient(GradientInfo* info) const;
/**
* If the shader subclass has a GrCustomStage implementation, this installs
* If the shader subclass has a GrEffect implementation, this installs
* a custom stage on the sampler. A GrContext pointer is required since custom
* stages may need to create textures. The sampler parameter is necessary to set a
* texture matrix. It will eventually be removed and this function will operate as a
* GrCustomStage factory.
* GrEffect factory.
*/
virtual bool asNewCustomStage(GrContext* context, GrSamplerState* sampler) const;

View File

@ -22,7 +22,7 @@ public:
virtual uint32_t getFlags() SK_OVERRIDE;
virtual bool asColorMatrix(SkScalar matrix[20]) SK_OVERRIDE;
#if SK_SUPPORT_GPU
virtual GrCustomStage* asNewCustomStage(GrContext*) const SK_OVERRIDE;
virtual GrEffect* asNewCustomStage(GrContext*) const SK_OVERRIDE;
#endif
struct State {

View File

@ -16,7 +16,7 @@ class SK_API SkMagnifierImageFilter : public SkImageFilter {
public:
SkMagnifierImageFilter(SkRect srcRect, SkScalar inset);
virtual bool asNewCustomStage(GrCustomStage** stage,
virtual bool asNewCustomStage(GrEffect** stage,
GrTexture* texture) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMagnifierImageFilter)

View File

@ -62,7 +62,7 @@ protected:
SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;
#if SK_SUPPORT_GPU
virtual bool asNewCustomStage(GrCustomStage** stage, GrTexture*) const SK_OVERRIDE;
virtual bool asNewCustomStage(GrEffect** stage, GrTexture*) const SK_OVERRIDE;
#endif
private:

View File

@ -23,9 +23,9 @@
class GrAutoScratchTexture;
class GrCacheKey;
class GrCustomStage;
class GrDrawState;
class GrDrawTarget;
class GrEffect;
class GrFontCache;
class GrGpu;
class GrIndexBuffer;
@ -920,8 +920,8 @@ private:
// for use with textures released from an GrAutoScratchTexture.
void addExistingTextureToCache(GrTexture* texture);
GrCustomStage* createPMToUPMEffect(GrTexture* texture, bool swapRAndB);
GrCustomStage* createUPMToPMEffect(GrTexture* texture, bool swapRAndB);
GrEffect* createPMToUPMEffect(GrTexture* texture, bool swapRAndB);
GrEffect* createUPMToPMEffect(GrTexture* texture, bool swapRAndB);
typedef GrRefCnt INHERITED;
};

View File

@ -22,56 +22,56 @@ enum {
#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
class GrCustomStage;
class GrContext;
class GrEffect;
class GrTexture;
class GrCustomStageTestFactory : GrNoncopyable {
class GrEffectTestFactory : GrNoncopyable {
public:
typedef GrCustomStage* (*CreateProc)(SkRandom*, GrContext*, GrTexture* dummyTextures[]);
typedef GrEffect* (*CreateProc)(SkRandom*, GrContext*, GrTexture* dummyTextures[]);
GrCustomStageTestFactory(CreateProc createProc) {
GrEffectTestFactory(CreateProc createProc) {
fCreateProc = createProc;
GetFactories()->push_back(this);
}
static GrCustomStage* CreateStage(SkRandom* random,
static GrEffect* CreateStage(SkRandom* random,
GrContext* context,
GrTexture* dummyTextures[]) {
uint32_t idx = random->nextRangeU(0, GetFactories()->count() - 1);
GrCustomStageTestFactory* factory = (*GetFactories())[idx];
GrEffectTestFactory* factory = (*GetFactories())[idx];
return factory->fCreateProc(random, context, dummyTextures);
}
private:
CreateProc fCreateProc;
static SkTArray<GrCustomStageTestFactory*, true>* GetFactories();
static SkTArray<GrEffectTestFactory*, true>* GetFactories();
};
/** GrCustomStage subclasses should insert this macro in their declaration to be included in the
/** GrEffect subclasses should insert this macro in their declaration to be included in the
* program generation unit test.
*/
#define GR_DECLARE_CUSTOM_STAGE_TEST \
static GrCustomStageTestFactory gTestFactory; \
static GrCustomStage* TestCreate(SkRandom*, GrContext*, GrTexture* dummyTextures[2])
static GrEffectTestFactory gTestFactory; \
static GrEffect* TestCreate(SkRandom*, GrContext*, GrTexture* dummyTextures[2])
/** GrCustomStage subclasses should insert this macro in their implemenation file. They must then
/** GrEffect subclasses should insert this macro in their implemenation file. They must then
* also implement this static function:
* GrCustomStage* TestCreate(SkRandom*, GrContext*, GrTexture* dummyTextures[2]);
* GrEffect* TestCreate(SkRandom*, GrContext*, GrTexture* dummyTextures[2]);
* dummyTextures[] are valied textures that they can optionally use for their texture accesses. The
* first texture has config kSkia8888_PM_GrPixelConfig and the second has kAlpha_8_GrPixelConfig.
* TestCreate functions are also free to create additional textures using the GrContext.
*/
#define GR_DEFINE_CUSTOM_STAGE_TEST(CustomStage) \
GrCustomStageTestFactory CustomStage :: gTestFactory(CustomStage :: TestCreate)
GrEffectTestFactory CustomStage :: gTestFactory(CustomStage :: TestCreate)
#else // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
// The unit test relies on static initializers. Just declare the TestCreate function so that
// its definitions will compile.
#define GR_DECLARE_CUSTOM_STAGE_TEST \
static GrCustomStage* TestCreate(SkRandom*, GrContext*, GrTexture* dummyTextures[2])
static GrEffect* TestCreate(SkRandom*, GrContext*, GrTexture* dummyTextures[2])
#define GR_DEFINE_CUSTOM_STAGE_TEST(X)
#endif // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS

View File

@ -22,21 +22,21 @@ class SkString;
particular stage of the Ganesh shading pipeline.
Subclasses must have a function that produces a human-readable name:
static const char* Name();
GrCustomStage objects *must* be immutable: after being constructed,
GrEffect objects *must* be immutable: after being constructed,
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.)
*/
class GrCustomStage : public GrRefCnt {
class GrEffect : public GrRefCnt {
public:
SK_DECLARE_INST_COUNT(GrCustomStage)
SK_DECLARE_INST_COUNT(GrEffect)
typedef GrProgramStageFactory::StageKey StageKey;
explicit GrCustomStage(int numTextures);
virtual ~GrCustomStage();
explicit GrEffect(int numTextures);
virtual ~GrEffect();
/** If given an input texture that is/is not opaque, is this
stage guaranteed to produce an opaque output? */
@ -45,12 +45,12 @@ public:
/** This object, besides creating back-end-specific helper
objects, is used for run-time-type-identification. The factory should be
an instance of templated class, GrTProgramStageFactory. It is templated
on the subclass of GrCustomStage. The subclass must have a nested type
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.
Example:
class MyCustomStage : public GrCustomStage {
class MyCustomStage : public GrEffect {
...
virtual const GrProgramStageFactory& getFactory() const
SK_OVERRIDE {
@ -75,7 +75,7 @@ public:
the two stages have the same return value for numTextures() and
for texture() over all valid indicse.
*/
virtual bool isEqual(const GrCustomStage&) const;
virtual bool isEqual(const GrEffect&) const;
/** Human-meaningful string to identify this effect; may be embedded
in generated shader code. */

View File

@ -20,7 +20,7 @@
* functions and the how color is blended with the destination pixel.
*
* The paint allows installation of custom color and coverage stages. New types of stages are
* created by subclassing GrCustomStage.
* created by subclassing GrEffect.
*
* The primitive color computation starts with the color specified by setColor(). This color is the
* input to the first color stage. Each color stage feeds its output to the next color stage. The
@ -39,7 +39,7 @@
* Note that the coverage is applied after the blend. This is why they are computed as distinct
* values.
*
* TODO: Encapsulate setXfermodeColorFilter in a GrCustomStage and remove from GrPaint.
* TODO: Encapsulate setXfermodeColorFilter in a GrEffect and remove from GrPaint.
*/
class GrPaint {
public:

View File

@ -12,12 +12,12 @@
#include "SkTemplates.h"
#include "GrNoncopyable.h"
/** Given a GrCustomStage of a particular type, creates the corresponding
/** Given a GrEffect of a particular type, creates the corresponding
graphics-backend-specific GrProgramStage. Also tracks equivalence
of shaders generated via a key.
*/
class GrCustomStage;
class GrEffect;
class GrGLProgramStage;
class GrGLCaps;
@ -29,10 +29,10 @@ public:
kTexturingStageKeyBits = 6
};
virtual StageKey glStageKey(const GrCustomStage& stage,
virtual StageKey glStageKey(const GrEffect& stage,
const GrGLCaps& caps ) const = 0;
virtual GrGLProgramStage* createGLInstance(
const GrCustomStage& stage) const = 0;
const GrEffect& stage) const = 0;
bool operator ==(const GrProgramStageFactory& b) const {
return fStageClassID == b.fStageClassID;
@ -73,17 +73,17 @@ class GrTProgramStageFactory : public GrProgramStageFactory {
public:
typedef typename StageClass::GLProgramStage GLProgramStage;
/** Returns a human-readable name that is accessible via GrCustomStage or
/** Returns a human-readable name that is accessible via GrEffect or
GrGLProgramStage and is consistent between the two of them.
*/
virtual const char* name() const SK_OVERRIDE { return StageClass::Name(); }
/** Returns a value that idenitifes the GLSL shader code generated by
a GrCustomStage. This enables caching of generated shaders. Part of the
a GrEffect. This enables caching of generated shaders. Part of the
id identifies the GrCustomShader subclass. The remainder is based
on the aspects of the GrCustomStage object's configuration that affect
on the aspects of the GrEffect object's configuration that affect
GLSL code generation. */
virtual StageKey glStageKey(const GrCustomStage& stage,
virtual StageKey glStageKey(const GrEffect& stage,
const GrGLCaps& caps) const SK_OVERRIDE {
GrAssert(kIllegalStageClassID != fStageClassID);
StageKey stageID = GLProgramStage::GenKey(stage, caps);
@ -101,10 +101,10 @@ public:
}
/** Returns a new instance of the appropriate *GL* implementation class
for the given GrCustomStage; caller is responsible for deleting
for the given GrEffect; caller is responsible for deleting
the object. */
virtual GLProgramStage* createGLInstance(
const GrCustomStage& stage) const SK_OVERRIDE {
const GrEffect& stage) const SK_OVERRIDE {
return SkNEW_ARGS(GLProgramStage, (*this, stage));
}

View File

@ -11,7 +11,7 @@
#ifndef GrSamplerState_DEFINED
#define GrSamplerState_DEFINED
#include "GrCustomStage.h"
#include "GrEffect.h"
#include "GrMatrix.h"
#include "GrTypes.h"
@ -70,7 +70,7 @@ public:
class SavedCoordChange {
private:
GrMatrix fCoordChangeMatrix;
GR_DEBUGCODE(mutable SkAutoTUnref<GrCustomStage> fCustomStage;)
GR_DEBUGCODE(mutable SkAutoTUnref<GrEffect> fCustomStage;)
friend class GrSamplerState;
};
@ -100,7 +100,7 @@ public:
}
/**
* Gets the texture matrix. This is will be removed soon and be managed by GrCustomStage.
* Gets the texture matrix. This is will be removed soon and be managed by GrEffect.
*/
const GrMatrix& getMatrix() const { return fMatrix; }
@ -117,7 +117,7 @@ public:
GrSafeSetNull(fCustomStage);
}
GrCustomStage* setCustomStage(GrCustomStage* stage) {
GrEffect* setCustomStage(GrEffect* stage) {
GrAssert(0 == fSavedCoordChangeCnt);
GrSafeAssign(fCustomStage, stage);
fMatrix.reset();
@ -125,7 +125,7 @@ public:
return stage;
}
GrCustomStage* setCustomStage(GrCustomStage* stage, const GrMatrix& matrix) {
GrEffect* setCustomStage(GrEffect* stage, const GrMatrix& matrix) {
GrAssert(0 == fSavedCoordChangeCnt);
GrSafeAssign(fCustomStage, stage);
fMatrix = matrix;
@ -133,12 +133,12 @@ public:
return stage;
}
const GrCustomStage* getCustomStage() const { return fCustomStage; }
const GrEffect* getCustomStage() const { return fCustomStage; }
private:
GrMatrix fCoordChangeMatrix;
GrMatrix fMatrix; // TODO: remove this, store in GrCustomStage
GrCustomStage* fCustomStage;
GrMatrix fMatrix; // TODO: remove this, store in GrEffect
GrEffect* fCustomStage;
GR_DEBUGCODE(mutable int fSavedCoordChangeCnt;)
};

View File

@ -103,14 +103,14 @@ private:
/** A class representing the swizzle access pattern for a texture. Note that if the texture is
* an alpha-only texture then the alpha channel is substituted for other components. Any mangling
* to handle the r,g,b->a conversions for alpha textures is automatically included in the stage
* key. However, if a GrCustomStage uses different swizzles based on its input then it must
* key. However, if a GrEffect uses different swizzles based on its input then it must
* consider that variation in its key-generation.
*/
class GrTextureAccess : GrNoncopyable {
public:
/**
* A default GrTextureAccess must have reset() called on it in a GrCustomStage subclass's
* constructor if it will be accessible via GrCustomStage::textureAccess().
* A default GrTextureAccess must have reset() called on it in a GrEffect subclass's
* constructor if it will be accessible via GrEffect::textureAccess().
*/
GrTextureAccess();

View File

@ -40,7 +40,7 @@ SkColor SkColorFilter::filterColor(SkColor c) {
return SkUnPreMultiply::PMColorToColor(dst);
}
GrCustomStage* SkColorFilter::asNewCustomStage(GrContext*) const {
GrEffect* SkColorFilter::asNewCustomStage(GrContext*) const {
return NULL;
}

View File

@ -117,7 +117,7 @@ bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
return true;
}
bool SkImageFilter::asNewCustomStage(GrCustomStage**, GrTexture*) const {
bool SkImageFilter::asNewCustomStage(GrEffect**, GrTexture*) const {
return false;
}

View File

@ -113,7 +113,7 @@ bool SkBlendImageFilter::onFilterImage(Proxy* proxy,
class GrGLBlendEffect : public GrGLLegacyProgramStage {
public:
GrGLBlendEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage);
const GrEffect& stage);
virtual ~GrGLBlendEffect();
virtual void emitFS(GrGLShaderBuilder* builder,
@ -124,7 +124,7 @@ public:
virtual void emitVS(GrGLShaderBuilder* builder,
const char* vertexCoords) SK_OVERRIDE {}
static inline StageKey GenKey(const GrCustomStage& s, const GrGLCaps&);
static inline StageKey GenKey(const GrEffect& s, const GrGLCaps&);
private:
typedef GrGLLegacyProgramStage INHERITED;
@ -138,7 +138,7 @@ public:
GrBlendEffect(SkBlendImageFilter::Mode mode, GrTexture* foreground);
virtual ~GrBlendEffect();
virtual bool isEqual(const GrCustomStage&) const SK_OVERRIDE;
virtual bool isEqual(const GrEffect&) const SK_OVERRIDE;
const GrProgramStageFactory& getFactory() const;
SkBlendImageFilter::Mode mode() const { return fMode; }
@ -224,7 +224,7 @@ GrBlendEffect::GrBlendEffect(SkBlendImageFilter::Mode mode, GrTexture* foregroun
GrBlendEffect::~GrBlendEffect() {
}
bool GrBlendEffect::isEqual(const GrCustomStage& sBase) const {
bool GrBlendEffect::isEqual(const GrEffect& sBase) const {
const GrBlendEffect& s = static_cast<const GrBlendEffect&>(sBase);
return INHERITED::isEqual(sBase) &&
fMode == s.fMode;
@ -237,7 +237,7 @@ const GrProgramStageFactory& GrBlendEffect::getFactory() const {
///////////////////////////////////////////////////////////////////////////////
GrGLBlendEffect::GrGLBlendEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage)
const GrEffect& stage)
: INHERITED(factory),
fMode(static_cast<const GrBlendEffect&>(stage).mode()) {
}
@ -275,7 +275,7 @@ void GrGLBlendEffect::emitFS(GrGLShaderBuilder* builder,
}
}
GrGLProgramStage::StageKey GrGLBlendEffect::GenKey(const GrCustomStage& s, const GrGLCaps&) {
GrGLProgramStage::StageKey GrGLBlendEffect::GenKey(const GrEffect& s, const GrGLCaps&) {
return static_cast<const GrBlendEffect&>(s).mode();
}
#endif

View File

@ -319,20 +319,20 @@ bool SkColorMatrixFilter::asColorMatrix(SkScalar matrix[20]) {
}
#if SK_SUPPORT_GPU
#include "GrCustomStage.h"
#include "GrEffect.h"
#include "gl/GrGLProgramStage.h"
class ColorMatrixEffect : public GrCustomStage {
class ColorMatrixEffect : public GrEffect {
public:
static const char* Name() { return "Color Matrix"; }
ColorMatrixEffect(const SkColorMatrix& matrix) : GrCustomStage(0), fMatrix(matrix) {}
ColorMatrixEffect(const SkColorMatrix& matrix) : GrEffect(0), fMatrix(matrix) {}
virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE {
return GrTProgramStageFactory<ColorMatrixEffect>::getInstance();
}
virtual bool isEqual(const GrCustomStage& s) const {
virtual bool isEqual(const GrEffect& s) const {
const ColorMatrixEffect& cme = static_cast<const ColorMatrixEffect&>(s);
return cme.fMatrix == fMatrix;
}
@ -342,10 +342,10 @@ public:
class GLProgramStage : public GrGLLegacyProgramStage {
public:
// this class always generates the same code.
static StageKey GenKey(const GrCustomStage& s, const GrGLCaps&) { return 0; }
static StageKey GenKey(const GrEffect& s, const GrGLCaps&) { return 0; }
GLProgramStage(const GrProgramStageFactory& factory,
const GrCustomStage& stage)
const GrEffect& stage)
: INHERITED(factory)
, fMatrixHandle(GrGLUniformManager::kInvalidUniformHandle)
, fVectorHandle(GrGLUniformManager::kInvalidUniformHandle) {
@ -383,7 +383,7 @@ public:
}
virtual void setData(const GrGLUniformManager& uniManager,
const GrCustomStage& stage) SK_OVERRIDE {
const GrEffect& stage) SK_OVERRIDE {
const ColorMatrixEffect& cme = static_cast<const ColorMatrixEffect&>(stage);
const float* m = cme.fMatrix.fMat;
// The GL matrix is transposed from SkColorMatrix.
@ -414,9 +414,9 @@ private:
GR_DEFINE_CUSTOM_STAGE_TEST(ColorMatrixEffect);
GrCustomStage* ColorMatrixEffect::TestCreate(SkRandom* random,
GrContext*,
GrTexture* dummyTextures[2]) {
GrEffect* ColorMatrixEffect::TestCreate(SkRandom* random,
GrContext*,
GrTexture* dummyTextures[2]) {
SkColorMatrix colorMatrix;
for (int i = 0; i < SK_ARRAY_COUNT(colorMatrix.fMat); ++i) {
colorMatrix.fMat[i] = random->nextSScalar1();
@ -424,7 +424,7 @@ GrCustomStage* ColorMatrixEffect::TestCreate(SkRandom* random,
return SkNEW_ARGS(ColorMatrixEffect, (colorMatrix));
}
GrCustomStage* SkColorMatrixFilter::asNewCustomStage(GrContext*) const {
GrEffect* SkColorMatrixFilter::asNewCustomStage(GrContext*) const {
return SkNEW_ARGS(ColorMatrixEffect, (fMatrix));
}

View File

@ -18,7 +18,7 @@
#include "effects/GrSingleTextureEffect.h"
#include "gl/GrGLProgramStage.h"
#include "gl/GrGLTexture.h"
#include "GrCustomStage.h"
#include "GrEffect.h"
class GrGLDiffuseLightingEffect;
class GrGLSpecularLightingEffect;
@ -264,7 +264,7 @@ public:
SkScalar kd, SkImageFilter* input);
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiffuseLightingImageFilter)
virtual bool asNewCustomStage(GrCustomStage** stage, GrTexture*) const SK_OVERRIDE;
virtual bool asNewCustomStage(GrEffect** stage, GrTexture*) const SK_OVERRIDE;
SkScalar kd() const { return fKD; }
protected:
@ -284,7 +284,7 @@ public:
SkSpecularLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, SkImageFilter* input);
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSpecularLightingImageFilter)
virtual bool asNewCustomStage(GrCustomStage** stage, GrTexture*) const SK_OVERRIDE;
virtual bool asNewCustomStage(GrEffect** stage, GrTexture*) const SK_OVERRIDE;
SkScalar ks() const { return fKS; }
SkScalar shininess() const { return fShininess; }
@ -307,7 +307,7 @@ public:
GrLightingEffect(GrTexture* texture, const SkLight* light, SkScalar surfaceScale);
virtual ~GrLightingEffect();
virtual bool isEqual(const GrCustomStage&) const SK_OVERRIDE;
virtual bool isEqual(const GrEffect&) const SK_OVERRIDE;
const SkLight* light() const { return fLight; }
SkScalar surfaceScale() const { return fSurfaceScale; }
@ -329,7 +329,7 @@ public:
typedef GrGLDiffuseLightingEffect GLProgramStage;
virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE;
virtual bool isEqual(const GrCustomStage&) const SK_OVERRIDE;
virtual bool isEqual(const GrEffect&) const SK_OVERRIDE;
SkScalar kd() const { return fKD; }
private:
GR_DECLARE_CUSTOM_STAGE_TEST;
@ -350,7 +350,7 @@ public:
typedef GrGLSpecularLightingEffect GLProgramStage;
virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE;
virtual bool isEqual(const GrCustomStage&) const SK_OVERRIDE;
virtual bool isEqual(const GrEffect&) const SK_OVERRIDE;
SkScalar ks() const { return fKS; }
SkScalar shininess() const { return fShininess; }
@ -821,7 +821,7 @@ bool SkDiffuseLightingImageFilter::onFilterImage(Proxy*,
return true;
}
bool SkDiffuseLightingImageFilter::asNewCustomStage(GrCustomStage** stage,
bool SkDiffuseLightingImageFilter::asNewCustomStage(GrEffect** stage,
GrTexture* texture) const {
#if SK_SUPPORT_GPU
if (stage) {
@ -890,7 +890,7 @@ bool SkSpecularLightingImageFilter::onFilterImage(Proxy*,
return true;
}
bool SkSpecularLightingImageFilter::asNewCustomStage(GrCustomStage** stage,
bool SkSpecularLightingImageFilter::asNewCustomStage(GrEffect** stage,
GrTexture* texture) const {
#if SK_SUPPORT_GPU
if (stage) {
@ -942,7 +942,7 @@ SkLight* create_random_light(SkRandom* random) {
class GrGLLightingEffect : public GrGLLegacyProgramStage {
public:
GrGLLightingEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage);
const GrEffect& stage);
virtual ~GrGLLightingEffect();
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
@ -955,9 +955,9 @@ public:
virtual void emitLightFunc(GrGLShaderBuilder*, SkString* funcName) = 0;
static inline StageKey GenKey(const GrCustomStage& s, const GrGLCaps& caps);
static inline StageKey GenKey(const GrEffect& s, const GrGLCaps& caps);
virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrEffect&) SK_OVERRIDE;
private:
typedef GrGLLegacyProgramStage INHERITED;
@ -972,10 +972,10 @@ private:
class GrGLDiffuseLightingEffect : public GrGLLightingEffect {
public:
GrGLDiffuseLightingEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage);
const GrEffect& stage);
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
virtual void emitLightFunc(GrGLShaderBuilder*, SkString* funcName) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrEffect&) SK_OVERRIDE;
private:
typedef GrGLLightingEffect INHERITED;
@ -988,10 +988,10 @@ private:
class GrGLSpecularLightingEffect : public GrGLLightingEffect {
public:
GrGLSpecularLightingEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage);
const GrEffect& stage);
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
virtual void emitLightFunc(GrGLShaderBuilder*, SkString* funcName) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrEffect&) SK_OVERRIDE;
private:
typedef GrGLLightingEffect INHERITED;
@ -1013,7 +1013,7 @@ GrLightingEffect::~GrLightingEffect() {
fLight->unref();
}
bool GrLightingEffect::isEqual(const GrCustomStage& sBase) const {
bool GrLightingEffect::isEqual(const GrEffect& sBase) const {
const GrLightingEffect& s =
static_cast<const GrLightingEffect&>(sBase);
return INHERITED::isEqual(sBase) &&
@ -1031,7 +1031,7 @@ const GrProgramStageFactory& GrDiffuseLightingEffect::getFactory() const {
return GrTProgramStageFactory<GrDiffuseLightingEffect>::getInstance();
}
bool GrDiffuseLightingEffect::isEqual(const GrCustomStage& sBase) const {
bool GrDiffuseLightingEffect::isEqual(const GrEffect& sBase) const {
const GrDiffuseLightingEffect& s =
static_cast<const GrDiffuseLightingEffect&>(sBase);
return INHERITED::isEqual(sBase) &&
@ -1040,9 +1040,9 @@ bool GrDiffuseLightingEffect::isEqual(const GrCustomStage& sBase) const {
GR_DEFINE_CUSTOM_STAGE_TEST(GrDiffuseLightingEffect);
GrCustomStage* GrDiffuseLightingEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture* textures[]) {
GrEffect* GrDiffuseLightingEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture* textures[]) {
SkScalar surfaceScale = random->nextSScalar1();
SkScalar kd = random->nextUScalar1();
SkAutoTUnref<SkLight> light(create_random_light(random));
@ -1054,7 +1054,7 @@ GrCustomStage* GrDiffuseLightingEffect::TestCreate(SkRandom* random,
///////////////////////////////////////////////////////////////////////////////
GrGLLightingEffect::GrGLLightingEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage)
const GrEffect& stage)
: INHERITED(factory)
, fImageIncrementUni(kInvalidUniformHandle)
, fSurfaceScaleUni(kInvalidUniformHandle) {
@ -1168,12 +1168,12 @@ void GrGLLightingEffect::emitFS(GrGLShaderBuilder* builder,
GrGLSLMulVarBy4f(code, 2, outputColor, inputColor);
}
GrGLProgramStage::StageKey GrGLLightingEffect::GenKey(const GrCustomStage& s,
GrGLProgramStage::StageKey GrGLLightingEffect::GenKey(const GrEffect& s,
const GrGLCaps& caps) {
return static_cast<const GrLightingEffect&>(s).light()->type();
}
void GrGLLightingEffect::setData(const GrGLUniformManager& uman, const GrCustomStage& data) {
void GrGLLightingEffect::setData(const GrGLUniformManager& uman, const GrEffect& data) {
const GrLightingEffect& effect =
static_cast<const GrLightingEffect&>(data);
GrGLTexture* texture = static_cast<GrGLTexture*>(data.texture(0));
@ -1188,7 +1188,7 @@ void GrGLLightingEffect::setData(const GrGLUniformManager& uman, const GrCustomS
///////////////////////////////////////////////////////////////////////////////
GrGLDiffuseLightingEffect::GrGLDiffuseLightingEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage)
const GrEffect& stage)
: INHERITED(factory, stage)
, fKDUni(kInvalidUniformHandle) {
}
@ -1217,7 +1217,7 @@ void GrGLDiffuseLightingEffect::emitLightFunc(GrGLShaderBuilder* builder, SkStri
funcName);
}
void GrGLDiffuseLightingEffect::setData(const GrGLUniformManager& uman, const GrCustomStage& data) {
void GrGLDiffuseLightingEffect::setData(const GrGLUniformManager& uman, const GrEffect& data) {
INHERITED::setData(uman, data);
const GrDiffuseLightingEffect& effect =
static_cast<const GrDiffuseLightingEffect&>(data);
@ -1236,7 +1236,7 @@ const GrProgramStageFactory& GrSpecularLightingEffect::getFactory() const {
return GrTProgramStageFactory<GrSpecularLightingEffect>::getInstance();
}
bool GrSpecularLightingEffect::isEqual(const GrCustomStage& sBase) const {
bool GrSpecularLightingEffect::isEqual(const GrEffect& sBase) const {
const GrSpecularLightingEffect& s =
static_cast<const GrSpecularLightingEffect&>(sBase);
return INHERITED::isEqual(sBase) &&
@ -1246,9 +1246,9 @@ bool GrSpecularLightingEffect::isEqual(const GrCustomStage& sBase) const {
GR_DEFINE_CUSTOM_STAGE_TEST(GrSpecularLightingEffect);
GrCustomStage* GrSpecularLightingEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture* textures[]) {
GrEffect* GrSpecularLightingEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture* textures[]) {
SkScalar surfaceScale = random->nextSScalar1();
SkScalar ks = random->nextUScalar1();
SkScalar shininess = random->nextUScalar1();
@ -1260,7 +1260,7 @@ GrCustomStage* GrSpecularLightingEffect::TestCreate(SkRandom* random,
///////////////////////////////////////////////////////////////////////////////
GrGLSpecularLightingEffect::GrGLSpecularLightingEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage)
const GrEffect& stage)
: GrGLLightingEffect(factory, stage)
, fKSUni(kInvalidUniformHandle)
, fShininessUni(kInvalidUniformHandle) {
@ -1297,7 +1297,7 @@ void GrGLSpecularLightingEffect::emitLightFunc(GrGLShaderBuilder* builder, SkStr
}
void GrGLSpecularLightingEffect::setData(const GrGLUniformManager& uman,
const GrCustomStage& data) {
const GrEffect& data) {
INHERITED::setData(uman, data);
const GrSpecularLightingEffect& effect = static_cast<const GrSpecularLightingEffect&>(data);
uman.set1f(fKSUni, effect.ks());

View File

@ -45,7 +45,7 @@ public:
static const char* Name() { return "Magnifier"; }
virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE;
virtual bool isEqual(const GrCustomStage&) const SK_OVERRIDE;
virtual bool isEqual(const GrEffect&) const SK_OVERRIDE;
float x_offset() const { return fXOffset; }
float y_offset() const { return fYOffset; }
@ -75,7 +75,7 @@ typedef GrGLUniformManager::UniformHandle UniformHandle;
class GrGLMagnifierEffect : public GrGLLegacyProgramStage {
public:
GrGLMagnifierEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage);
const GrEffect& stage);
virtual void setupVariables(GrGLShaderBuilder* state) SK_OVERRIDE;
virtual void emitVS(GrGLShaderBuilder* state,
@ -86,9 +86,9 @@ public:
const TextureSamplerArray&) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager& uman,
const GrCustomStage& data) SK_OVERRIDE;
const GrEffect& data) SK_OVERRIDE;
static inline StageKey GenKey(const GrCustomStage&, const GrGLCaps&);
static inline StageKey GenKey(const GrEffect&, const GrGLCaps&);
private:
@ -100,7 +100,7 @@ private:
};
GrGLMagnifierEffect::GrGLMagnifierEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage)
const GrEffect& stage)
: INHERITED(factory)
, fOffsetVar(GrGLUniformManager::kInvalidUniformHandle)
, fZoomVar(GrGLUniformManager::kInvalidUniformHandle)
@ -165,7 +165,7 @@ void GrGLMagnifierEffect::emitFS(GrGLShaderBuilder* state,
}
void GrGLMagnifierEffect::setData(const GrGLUniformManager& uman,
const GrCustomStage& data) {
const GrEffect& data) {
const GrMagnifierEffect& zoom =
static_cast<const GrMagnifierEffect&>(data);
@ -174,7 +174,7 @@ void GrGLMagnifierEffect::setData(const GrGLUniformManager& uman,
uman.set2f(fInsetVar, zoom.x_inset(), zoom.y_inset());
}
GrGLProgramStage::StageKey GrGLMagnifierEffect::GenKey(const GrCustomStage& s,
GrGLProgramStage::StageKey GrGLMagnifierEffect::GenKey(const GrEffect& s,
const GrGLCaps& caps) {
return 0;
}
@ -183,9 +183,9 @@ GrGLProgramStage::StageKey GrGLMagnifierEffect::GenKey(const GrCustomStage& s,
GR_DEFINE_CUSTOM_STAGE_TEST(GrMagnifierEffect);
GrCustomStage* GrMagnifierEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture** textures) {
GrEffect* GrMagnifierEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture** textures) {
const int kMaxWidth = 200;
const int kMaxHeight = 200;
const int kMaxInset = 20;
@ -201,7 +201,7 @@ GrCustomStage* GrMagnifierEffect::TestCreate(SkRandom* random,
SkIntToScalar(width), SkIntToScalar(height)),
inset));
GrSamplerState sampler;
GrCustomStage* stage;
GrEffect* stage;
filter->asNewCustomStage(&stage, textures[0]);
GrAssert(NULL != stage);
return stage;
@ -213,7 +213,7 @@ const GrProgramStageFactory& GrMagnifierEffect::getFactory() const {
return GrTProgramStageFactory<GrMagnifierEffect>::getInstance();
}
bool GrMagnifierEffect::isEqual(const GrCustomStage& sBase) const {
bool GrMagnifierEffect::isEqual(const GrEffect& sBase) const {
const GrMagnifierEffect& s =
static_cast<const GrMagnifierEffect&>(sBase);
return (this->fXOffset == s.fXOffset &&
@ -243,7 +243,7 @@ SkMagnifierImageFilter::SkMagnifierImageFilter(SkRect srcRect, SkScalar inset)
SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0);
}
bool SkMagnifierImageFilter::asNewCustomStage(GrCustomStage** stage,
bool SkMagnifierImageFilter::asNewCustomStage(GrEffect** stage,
GrTexture* texture) const {
#if SK_SUPPORT_GPU
if (stage) {

View File

@ -263,7 +263,7 @@ public:
typedef GrGLMatrixConvolutionEffect GLProgramStage;
virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE;
virtual bool isEqual(const GrCustomStage&) const SK_OVERRIDE;
virtual bool isEqual(const GrEffect&) const SK_OVERRIDE;
private:
SkISize fKernelSize;
@ -282,7 +282,7 @@ private:
class GrGLMatrixConvolutionEffect : public GrGLLegacyProgramStage {
public:
GrGLMatrixConvolutionEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage);
const GrEffect& stage);
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
virtual void emitVS(GrGLShaderBuilder* state,
const char* vertexCoords) SK_OVERRIDE {}
@ -291,9 +291,9 @@ public:
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
static inline StageKey GenKey(const GrCustomStage& s, const GrGLCaps& caps);
static inline StageKey GenKey(const GrEffect& s, const GrGLCaps& caps);
virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrEffect&) SK_OVERRIDE;
private:
typedef GrGLUniformManager::UniformHandle UniformHandle;
@ -312,7 +312,7 @@ private:
};
GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage)
const GrEffect& stage)
: INHERITED(factory)
, fKernelUni(GrGLUniformManager::kInvalidUniformHandle)
, fImageIncrementUni(GrGLUniformManager::kInvalidUniformHandle)
@ -415,7 +415,7 @@ int encodeXY(int x, int y) {
};
GrGLProgramStage::StageKey GrGLMatrixConvolutionEffect::GenKey(const GrCustomStage& s,
GrGLProgramStage::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());
@ -425,7 +425,7 @@ GrGLProgramStage::StageKey GrGLMatrixConvolutionEffect::GenKey(const GrCustomSta
}
void GrGLMatrixConvolutionEffect::setData(const GrGLUniformManager& uman,
const GrCustomStage& data) {
const GrEffect& data) {
const GrMatrixConvolutionEffect& effect =
static_cast<const GrMatrixConvolutionEffect&>(data);
GrGLTexture& texture =
@ -473,7 +473,7 @@ const GrProgramStageFactory& GrMatrixConvolutionEffect::getFactory() const {
return GrTProgramStageFactory<GrMatrixConvolutionEffect>::getInstance();
}
bool GrMatrixConvolutionEffect::isEqual(const GrCustomStage& sBase) const {
bool GrMatrixConvolutionEffect::isEqual(const GrEffect& sBase) const {
const GrMatrixConvolutionEffect& s =
static_cast<const GrMatrixConvolutionEffect&>(sBase);
return INHERITED::isEqual(sBase) &&
@ -492,9 +492,9 @@ GR_DEFINE_CUSTOM_STAGE_TEST(GrMatrixConvolutionEffect);
// Allows for a 5x5 kernel (or 25x1, for that matter).
#define MAX_KERNEL_SIZE 25
GrCustomStage* GrMatrixConvolutionEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture* textures[]) {
GrEffect* GrMatrixConvolutionEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture* textures[]) {
int texIdx = random->nextBool() ? GrCustomStageUnitTest::kSkiaPMTextureIdx :
GrCustomStageUnitTest::kAlphaTextureIdx;
int width = random->nextRangeU(1, MAX_KERNEL_SIZE);
@ -521,7 +521,7 @@ GrCustomStage* GrMatrixConvolutionEffect::TestCreate(SkRandom* random,
}
bool SkMatrixConvolutionImageFilter::asNewCustomStage(GrCustomStage** stage,
bool SkMatrixConvolutionImageFilter::asNewCustomStage(GrEffect** stage,
GrTexture* texture) const {
bool ok = fKernelSize.width() * fKernelSize.height() <= MAX_KERNEL_SIZE;
if (ok && stage) {

View File

@ -252,7 +252,7 @@ public:
typedef GrGLMorphologyEffect GLProgramStage;
virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE;
virtual bool isEqual(const GrCustomStage&) const SK_OVERRIDE;
virtual bool isEqual(const GrEffect&) const SK_OVERRIDE;
protected:
@ -269,7 +269,7 @@ private:
class GrGLMorphologyEffect : public GrGLLegacyProgramStage {
public:
GrGLMorphologyEffect (const GrProgramStageFactory& factory,
const GrCustomStage& stage);
const GrEffect& stage);
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
virtual void emitVS(GrGLShaderBuilder* state,
@ -279,9 +279,9 @@ public:
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
static inline StageKey GenKey(const GrCustomStage& s, const GrGLCaps& caps);
static inline StageKey GenKey(const GrEffect& s, const GrGLCaps& caps);
virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrEffect&) SK_OVERRIDE;
private:
int width() const { return GrMorphologyEffect::WidthFromRadius(fRadius); }
@ -294,7 +294,7 @@ private:
};
GrGLMorphologyEffect::GrGLMorphologyEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage)
const GrEffect& stage)
: INHERITED(factory)
, fImageIncrementUni(GrGLUniformManager::kInvalidUniformHandle) {
const GrMorphologyEffect& m = static_cast<const GrMorphologyEffect&>(stage);
@ -341,7 +341,7 @@ void GrGLMorphologyEffect::emitFS(GrGLShaderBuilder* builder,
GrGLSLMulVarBy4f(code, 2, outputColor, inputColor);
}
GrGLProgramStage::StageKey GrGLMorphologyEffect::GenKey(const GrCustomStage& s,
GrGLProgramStage::StageKey GrGLMorphologyEffect::GenKey(const GrEffect& s,
const GrGLCaps& caps) {
const GrMorphologyEffect& m = static_cast<const GrMorphologyEffect&>(s);
StageKey key = static_cast<StageKey>(m.radius());
@ -349,7 +349,7 @@ GrGLProgramStage::StageKey GrGLMorphologyEffect::GenKey(const GrCustomStage& s,
return key;
}
void GrGLMorphologyEffect::setData(const GrGLUniformManager& uman, const GrCustomStage& data) {
void GrGLMorphologyEffect::setData(const GrGLUniformManager& uman, const GrEffect& data) {
const Gr1DKernelEffect& kern =
static_cast<const Gr1DKernelEffect&>(data);
GrGLTexture& texture =
@ -387,7 +387,7 @@ const GrProgramStageFactory& GrMorphologyEffect::getFactory() const {
return GrTProgramStageFactory<GrMorphologyEffect>::getInstance();
}
bool GrMorphologyEffect::isEqual(const GrCustomStage& sBase) const {
bool GrMorphologyEffect::isEqual(const GrEffect& sBase) const {
const GrMorphologyEffect& s =
static_cast<const GrMorphologyEffect&>(sBase);
return (INHERITED::isEqual(sBase) &&
@ -400,9 +400,9 @@ bool GrMorphologyEffect::isEqual(const GrCustomStage& sBase) const {
GR_DEFINE_CUSTOM_STAGE_TEST(GrMorphologyEffect);
GrCustomStage* GrMorphologyEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture* textures[]) {
GrEffect* GrMorphologyEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture* textures[]) {
int texIdx = random->nextBool() ? GrCustomStageUnitTest::kSkiaPMTextureIdx :
GrCustomStageUnitTest::kAlphaTextureIdx;
Direction dir = random->nextBool() ? kX_Direction : kY_Direction;

View File

@ -41,7 +41,7 @@ public:
virtual bool asComponentTable(SkBitmap* table) const SK_OVERRIDE;
#if SK_SUPPORT_GPU
virtual GrCustomStage* asNewCustomStage(GrContext* context) const SK_OVERRIDE;
virtual GrEffect* asNewCustomStage(GrContext* context) const SK_OVERRIDE;
#endif
virtual void filterSpan(const SkPMColor src[], int count,
@ -216,13 +216,13 @@ bool SkTable_ColorFilter::asComponentTable(SkBitmap* table) const {
#if SK_SUPPORT_GPU
#include "GrCustomStage.h"
#include "GrEffect.h"
#include "gl/GrGLProgramStage.h"
#include "SkGr.h"
class GLColorTableEffect;
class ColorTableEffect : public GrCustomStage {
class ColorTableEffect : public GrEffect {
public:
explicit ColorTableEffect(GrTexture* texture);
@ -230,7 +230,7 @@ public:
static const char* Name() { return "ColorTable"; }
virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE;
virtual bool isEqual(const GrCustomStage&) const SK_OVERRIDE;
virtual bool isEqual(const GrEffect&) const SK_OVERRIDE;
virtual const GrTextureAccess& textureAccess(int index) const SK_OVERRIDE;
@ -241,13 +241,13 @@ private:
GrTextureAccess fTextureAccess;
typedef GrCustomStage INHERITED;
typedef GrEffect INHERITED;
};
class GLColorTableEffect : public GrGLLegacyProgramStage {
public:
GLColorTableEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage);
const GrEffect& stage);
virtual void setupVariables(GrGLShaderBuilder* state) SK_OVERRIDE {}
virtual void emitVS(GrGLShaderBuilder* state,
@ -257,9 +257,9 @@ public:
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE {}
virtual void setData(const GrGLUniformManager&, const GrEffect&) SK_OVERRIDE {}
static StageKey GenKey(const GrCustomStage&, const GrGLCaps&);
static StageKey GenKey(const GrEffect&, const GrGLCaps&);
private:
@ -267,7 +267,7 @@ private:
};
GLColorTableEffect::GLColorTableEffect(
const GrProgramStageFactory& factory, const GrCustomStage& stage)
const GrProgramStageFactory& factory, const GrEffect& stage)
: INHERITED(factory) {
}
@ -312,7 +312,7 @@ void GLColorTableEffect::emitFS(GrGLShaderBuilder* builder,
code->appendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor);
}
GrGLProgramStage::StageKey GLColorTableEffect::GenKey(const GrCustomStage& s,
GrGLProgramStage::StageKey GLColorTableEffect::GenKey(const GrEffect& s,
const GrGLCaps& caps) {
return 0;
}
@ -331,7 +331,7 @@ const GrProgramStageFactory& ColorTableEffect::getFactory() const {
return GrTProgramStageFactory<ColorTableEffect>::getInstance();
}
bool ColorTableEffect::isEqual(const GrCustomStage& sBase) const {
bool ColorTableEffect::isEqual(const GrEffect& sBase) const {
return INHERITED::isEqual(sBase);
}
@ -344,18 +344,18 @@ const GrTextureAccess& ColorTableEffect::textureAccess(int index) const {
GR_DEFINE_CUSTOM_STAGE_TEST(ColorTableEffect);
GrCustomStage* ColorTableEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture* textures[]) {
GrEffect* ColorTableEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture* textures[]) {
return SkNEW_ARGS(ColorTableEffect, (textures[GrCustomStageUnitTest::kAlphaTextureIdx]));
}
GrCustomStage* SkTable_ColorFilter::asNewCustomStage(GrContext* context) const {
GrEffect* SkTable_ColorFilter::asNewCustomStage(GrContext* context) const {
SkBitmap bitmap;
this->asComponentTable(&bitmap);
// passing NULL because this custom effect does no tiling or filtering.
GrTexture* texture = GrLockCachedBitmapTexture(context, bitmap, NULL);
GrCustomStage* stage = SkNEW_ARGS(ColorTableEffect, (texture));
GrEffect* stage = SkNEW_ARGS(ColorTableEffect, (texture));
// Unlock immediately, this is not great, but we don't have a way of
// knowing when else to unlock it currently. TODO: Remove this when

View File

@ -687,7 +687,7 @@ void GrGLGradientStage::setupVariables(GrGLShaderBuilder* builder) {
kFloat_GrSLType, "GradientYCoordFS");
}
void GrGLGradientStage::setData(const GrGLUniformManager& uman, const GrCustomStage& stage) {
void GrGLGradientStage::setData(const GrGLUniformManager& uman, const GrEffect& stage) {
GrScalar yCoord = static_cast<const GrGradientEffect&>(stage).getYCoord();
if (yCoord != fCachedYCoord) {
uman.set1f(fFSYUni, yCoord);

View File

@ -223,7 +223,7 @@ class GrProgramStageFactory;
class GrTextureStripAtlas;
// Base class for Gr gradient effects
class GrGradientEffect : public GrCustomStage {
class GrGradientEffect : public GrEffect {
public:
GrGradientEffect(GrContext* ctx,
@ -237,7 +237,7 @@ public:
bool useAtlas() const { return SkToBool(-1 != fRow); }
GrScalar getYCoord() const { return fYCoord; };
virtual bool isEqual(const GrCustomStage& stage) const SK_OVERRIDE {
virtual bool isEqual(const GrEffect& stage) const SK_OVERRIDE {
const GrGradientEffect& s = static_cast<const GrGradientEffect&>(stage);
return INHERITED::isEqual(stage) && this->useAtlas() == s.useAtlas() &&
fYCoord == s.getYCoord();
@ -264,7 +264,7 @@ private:
GrTextureStripAtlas* fAtlas;
int fRow;
typedef GrCustomStage INHERITED;
typedef GrEffect INHERITED;
};
@ -278,7 +278,7 @@ public:
virtual ~GrGLGradientStage();
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrEffect&) SK_OVERRIDE;
// emit code that gets a fragment's color from an expression for t; for now
// this always uses the texture, but for simpler cases we'll be able to lerp

View File

@ -480,7 +480,7 @@ class GrGLLinearGradient : public GrGLGradientStage {
public:
GrGLLinearGradient(const GrProgramStageFactory& factory,
const GrCustomStage&)
const GrEffect&)
: INHERITED (factory) { }
virtual ~GrGLLinearGradient() { }
@ -491,7 +491,7 @@ public:
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
static StageKey GenKey(const GrCustomStage& s, const GrGLCaps& caps) { return 0; }
static StageKey GenKey(const GrEffect& s, const GrGLCaps& caps) { return 0; }
private:
@ -524,9 +524,9 @@ private:
GR_DEFINE_CUSTOM_STAGE_TEST(GrLinearGradient);
GrCustomStage* GrLinearGradient::TestCreate(SkRandom* random,
GrContext* context,
GrTexture**) {
GrEffect* GrLinearGradient::TestCreate(SkRandom* random,
GrContext* context,
GrTexture**) {
SkPoint points[] = {{random->nextUScalar1(), random->nextUScalar1()},
{random->nextUScalar1(), random->nextUScalar1()}};
@ -541,9 +541,9 @@ GrCustomStage* GrLinearGradient::TestCreate(SkRandom* random,
GrSamplerState sampler;
shader->asNewCustomStage(context, &sampler);
GrAssert(NULL != sampler.getCustomStage());
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrCustomStage*
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrEffect*
sampler.getCustomStage()->ref();
return const_cast<GrCustomStage*>(sampler.getCustomStage());
return const_cast<GrEffect*>(sampler.getCustomStage());
}
/////////////////////////////////////////////////////////////////////
@ -562,7 +562,7 @@ void GrGLLinearGradient::emitFS(GrGLShaderBuilder* builder,
bool SkLinearGradient::asNewCustomStage(GrContext* context, GrSamplerState* sampler) const {
SkASSERT(NULL != context && NULL != sampler);
SkAutoTUnref<GrCustomStage> stage(SkNEW_ARGS(GrLinearGradient, (context, *this, fTileMode)));
SkAutoTUnref<GrEffect> stage(SkNEW_ARGS(GrLinearGradient, (context, *this, fTileMode)));
SkMatrix matrix;
if (this->getLocalMatrix(&matrix)) {

View File

@ -477,7 +477,7 @@ class GrGLRadialGradient : public GrGLGradientStage {
public:
GrGLRadialGradient(const GrProgramStageFactory& factory,
const GrCustomStage&) : INHERITED (factory) { }
const GrEffect&) : INHERITED (factory) { }
virtual ~GrGLRadialGradient() { }
virtual void emitVS(GrGLShaderBuilder* builder,
@ -487,7 +487,7 @@ public:
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
static StageKey GenKey(const GrCustomStage& s, const GrGLCaps& caps) { return 0; }
static StageKey GenKey(const GrEffect& s, const GrGLCaps& caps) { return 0; }
private:
@ -523,9 +523,9 @@ private:
GR_DEFINE_CUSTOM_STAGE_TEST(GrRadialGradient);
GrCustomStage* GrRadialGradient::TestCreate(SkRandom* random,
GrContext* context,
GrTexture**) {
GrEffect* GrRadialGradient::TestCreate(SkRandom* random,
GrContext* context,
GrTexture**) {
SkPoint center = {random->nextUScalar1(), random->nextUScalar1()};
SkScalar radius = random->nextUScalar1();
@ -540,9 +540,9 @@ GrCustomStage* GrRadialGradient::TestCreate(SkRandom* random,
GrSamplerState sampler;
shader->asNewCustomStage(context, &sampler);
GrAssert(NULL != sampler.getCustomStage());
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrCustomStage*
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrEffect*
sampler.getCustomStage()->ref();
return const_cast<GrCustomStage*>(sampler.getCustomStage());
return const_cast<GrEffect*>(sampler.getCustomStage());
}
/////////////////////////////////////////////////////////////////////
@ -560,7 +560,7 @@ void GrGLRadialGradient::emitFS(GrGLShaderBuilder* builder,
bool SkRadialGradient::asNewCustomStage(GrContext* context, GrSamplerState* sampler) const {
SkASSERT(NULL != context && NULL != sampler);
SkAutoTUnref<GrCustomStage> stage(SkNEW_ARGS(GrRadialGradient, (context, *this, fTileMode)));
SkAutoTUnref<GrEffect> stage(SkNEW_ARGS(GrRadialGradient, (context, *this, fTileMode)));
SkMatrix matrix;
if (this->getLocalMatrix(&matrix)) {

View File

@ -386,7 +386,7 @@ class GrGLSweepGradient : public GrGLGradientStage {
public:
GrGLSweepGradient(const GrProgramStageFactory& factory,
const GrCustomStage&) : INHERITED (factory) { }
const GrEffect&) : INHERITED (factory) { }
virtual ~GrGLSweepGradient() { }
virtual void emitVS(GrGLShaderBuilder* builder,
@ -396,7 +396,7 @@ public:
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
static StageKey GenKey(const GrCustomStage& s, const GrGLCaps& caps) { return 0; }
static StageKey GenKey(const GrEffect& s, const GrGLCaps& caps) { return 0; }
private:
@ -431,9 +431,9 @@ private:
GR_DEFINE_CUSTOM_STAGE_TEST(GrSweepGradient);
GrCustomStage* GrSweepGradient::TestCreate(SkRandom* random,
GrContext* context,
GrTexture**) {
GrEffect* GrSweepGradient::TestCreate(SkRandom* random,
GrContext* context,
GrTexture**) {
SkPoint center = {random->nextUScalar1(), random->nextUScalar1()};
SkColor colors[kMaxRandomGradientColors];
@ -446,9 +446,9 @@ GrCustomStage* GrSweepGradient::TestCreate(SkRandom* random,
GrSamplerState sampler;
shader->asNewCustomStage(context, &sampler);
GrAssert(NULL != sampler.getCustomStage());
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrCustomStage*
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrEffect*
sampler.getCustomStage()->ref();
return const_cast<GrCustomStage*>(sampler.getCustomStage());
return const_cast<GrEffect*>(sampler.getCustomStage());
}
/////////////////////////////////////////////////////////////////////
@ -466,7 +466,7 @@ void GrGLSweepGradient::emitFS(GrGLShaderBuilder* builder,
/////////////////////////////////////////////////////////////////////
bool SkSweepGradient::asNewCustomStage(GrContext* context, GrSamplerState* sampler) const {
SkAutoTUnref<GrCustomStage> stage(SkNEW_ARGS(GrSweepGradient, (context, *this)));
SkAutoTUnref<GrEffect> stage(SkNEW_ARGS(GrSweepGradient, (context, *this)));
SkMatrix matrix;

View File

@ -323,7 +323,7 @@ class GrGLConical2Gradient : public GrGLGradientStage {
public:
GrGLConical2Gradient(const GrProgramStageFactory& factory,
const GrCustomStage&);
const GrEffect&);
virtual ~GrGLConical2Gradient() { }
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
@ -333,9 +333,9 @@ public:
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrEffect&) SK_OVERRIDE;
static StageKey GenKey(const GrCustomStage& s, const GrGLCaps& caps);
static StageKey GenKey(const GrEffect& s, const GrGLCaps& caps);
protected:
@ -381,7 +381,7 @@ public:
virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE {
return GrTProgramStageFactory<GrConical2Gradient>::getInstance();
}
virtual bool isEqual(const GrCustomStage& sBase) const SK_OVERRIDE {
virtual bool isEqual(const GrEffect& sBase) const SK_OVERRIDE {
const GrConical2Gradient& s = static_cast<const GrConical2Gradient&>(sBase);
return (INHERITED::isEqual(sBase) &&
this->fCenterX1 == s.fCenterX1 &&
@ -415,9 +415,9 @@ private:
GR_DEFINE_CUSTOM_STAGE_TEST(GrConical2Gradient);
GrCustomStage* GrConical2Gradient::TestCreate(SkRandom* random,
GrContext* context,
GrTexture**) {
GrEffect* GrConical2Gradient::TestCreate(SkRandom* random,
GrContext* context,
GrTexture**) {
SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()};
SkScalar radius1 = random->nextUScalar1();
SkPoint center2;
@ -440,9 +440,9 @@ GrCustomStage* GrConical2Gradient::TestCreate(SkRandom* random,
GrSamplerState sampler;
shader->asNewCustomStage(context, &sampler);
GrAssert(NULL != sampler.getCustomStage());
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrCustomStage*
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrEffect*
sampler.getCustomStage()->ref();
return const_cast<GrCustomStage*>(sampler.getCustomStage());
return const_cast<GrEffect*>(sampler.getCustomStage());
}
@ -450,7 +450,7 @@ GrCustomStage* GrConical2Gradient::TestCreate(SkRandom* random,
GrGLConical2Gradient::GrGLConical2Gradient(
const GrProgramStageFactory& factory,
const GrCustomStage& baseData)
const GrEffect& baseData)
: INHERITED(factory)
, fVSParamUni(kInvalidUniformHandle)
, fFSParamUni(kInvalidUniformHandle)
@ -626,7 +626,7 @@ void GrGLConical2Gradient::emitFS(GrGLShaderBuilder* builder,
}
}
void GrGLConical2Gradient::setData(const GrGLUniformManager& uman, const GrCustomStage& baseData) {
void GrGLConical2Gradient::setData(const GrGLUniformManager& uman, const GrEffect& baseData) {
INHERITED::setData(uman, baseData);
const GrConical2Gradient& data =
static_cast<const GrConical2Gradient&>(baseData);
@ -663,7 +663,7 @@ void GrGLConical2Gradient::setData(const GrGLUniformManager& uman, const GrCusto
}
}
GrCustomStage::StageKey GrGLConical2Gradient::GenKey(const GrCustomStage& s, const GrGLCaps& caps) {
GrEffect::StageKey GrGLConical2Gradient::GenKey(const GrEffect& s, const GrGLCaps& caps) {
return (static_cast<const GrConical2Gradient&>(s).isDegenerate());
}

View File

@ -358,7 +358,7 @@ class GrGLRadial2Gradient : public GrGLGradientStage {
public:
GrGLRadial2Gradient(const GrProgramStageFactory& factory,
const GrCustomStage&);
const GrEffect&);
virtual ~GrGLRadial2Gradient() { }
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
@ -368,9 +368,9 @@ public:
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrEffect&) SK_OVERRIDE;
static StageKey GenKey(const GrCustomStage& s, const GrGLCaps& caps);
static StageKey GenKey(const GrEffect& s, const GrGLCaps& caps);
protected:
@ -413,7 +413,7 @@ public:
virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE {
return GrTProgramStageFactory<GrRadial2Gradient>::getInstance();
}
virtual bool isEqual(const GrCustomStage& sBase) const SK_OVERRIDE {
virtual bool isEqual(const GrEffect& sBase) const SK_OVERRIDE {
const GrRadial2Gradient& s = static_cast<const GrRadial2Gradient&>(sBase);
return (INHERITED::isEqual(sBase) &&
this->fCenterX1 == s.fCenterX1 &&
@ -449,9 +449,9 @@ private:
GR_DEFINE_CUSTOM_STAGE_TEST(GrRadial2Gradient);
GrCustomStage* GrRadial2Gradient::TestCreate(SkRandom* random,
GrContext* context,
GrTexture**) {
GrEffect* GrRadial2Gradient::TestCreate(SkRandom* random,
GrContext* context,
GrTexture**) {
SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()};
SkScalar radius1 = random->nextUScalar1();
SkPoint center2;
@ -474,16 +474,16 @@ GrCustomStage* GrRadial2Gradient::TestCreate(SkRandom* random,
GrSamplerState sampler;
shader->asNewCustomStage(context, &sampler);
GrAssert(NULL != sampler.getCustomStage());
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrCustomStage*
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrEffect*
sampler.getCustomStage()->ref();
return const_cast<GrCustomStage*>(sampler.getCustomStage());
return const_cast<GrEffect*>(sampler.getCustomStage());
}
/////////////////////////////////////////////////////////////////////
GrGLRadial2Gradient::GrGLRadial2Gradient(
const GrProgramStageFactory& factory,
const GrCustomStage& baseData)
const GrEffect& baseData)
: INHERITED(factory)
, fVSParamUni(kInvalidUniformHandle)
, fFSParamUni(kInvalidUniformHandle)
@ -601,7 +601,7 @@ void GrGLRadial2Gradient::emitFS(GrGLShaderBuilder* builder,
this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplers[0]);
}
void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman, const GrCustomStage& baseData) {
void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman, const GrEffect& baseData) {
INHERITED::setData(uman, baseData);
const GrRadial2Gradient& data =
static_cast<const GrRadial2Gradient&>(baseData);
@ -636,7 +636,7 @@ void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman, const GrCustom
}
}
GrCustomStage::StageKey GrGLRadial2Gradient::GenKey(const GrCustomStage& s, const GrGLCaps& caps) {
GrEffect::StageKey GrGLRadial2Gradient::GenKey(const GrEffect& s, const GrGLCaps& caps) {
return (static_cast<const GrRadial2Gradient&>(s).isDegenerate());
}

View File

@ -1317,7 +1317,7 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
ast.set(this, desc, match);
GrTexture* texture = ast.texture();
if (texture) {
SkAutoTUnref<GrCustomStage> stage;
SkAutoTUnref<GrEffect> stage;
if (unpremul) {
stage.reset(this->createPMToUPMEffect(src, swapRAndB));
}
@ -1490,7 +1490,7 @@ void GrContext::writeRenderTargetPixels(GrRenderTarget* target,
return;
}
#endif
SkAutoTUnref<GrCustomStage> stage;
SkAutoTUnref<GrEffect> stage;
bool swapRAndB = (fGpu->preferredReadPixelsConfig(config) == GrPixelConfigSwapRAndB(config));
GrPixelConfig textureConfig;
@ -1736,7 +1736,7 @@ void test_pm_conversions(GrContext* ctx, int* pmToUPMValue, int* upmToPMValue) {
}
}
GrCustomStage* GrContext::createPMToUPMEffect(GrTexture* texture, bool swapRAndB) {
GrEffect* GrContext::createPMToUPMEffect(GrTexture* texture, bool swapRAndB) {
if (!fDidTestPMConversions) {
test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion);
fDidTestPMConversions = true;
@ -1750,7 +1750,7 @@ GrCustomStage* GrContext::createPMToUPMEffect(GrTexture* texture, bool swapRAndB
}
}
GrCustomStage* GrContext::createUPMToPMEffect(GrTexture* texture, bool swapRAndB) {
GrEffect* GrContext::createUPMToPMEffect(GrTexture* texture, bool swapRAndB) {
if (!fDidTestPMConversions) {
test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion);
fDidTestPMConversions = true;

View File

@ -196,14 +196,14 @@ public:
}
void createTextureEffect(int stage, GrTexture* texture, const GrMatrix& matrix) {
GrAssert(!this->getSampler(stage).getCustomStage());
GrCustomStage* customStage = SkNEW_ARGS(GrSingleTextureEffect, (texture));
GrEffect* customStage = SkNEW_ARGS(GrSingleTextureEffect, (texture));
this->sampler(stage)->setCustomStage(customStage, matrix)->unref();
}
void createTextureEffect(int stage, GrTexture* texture,
const GrMatrix& matrix,
const GrTextureParams& params) {
GrAssert(!this->getSampler(stage).getCustomStage());
GrCustomStage* customStage = SkNEW_ARGS(GrSingleTextureEffect, (texture, params));
GrEffect* customStage = SkNEW_ARGS(GrSingleTextureEffect, (texture, params));
this->sampler(stage)->setCustomStage(customStage, matrix)->unref();
}

View File

@ -748,7 +748,7 @@ bool GrDrawTarget::checkDraw(GrPrimitiveType type, int startVertex,
GrAssert(NULL != drawState.getRenderTarget());
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
if (drawState.isStageEnabled(s)) {
const GrCustomStage* stage = drawState.getSampler(s).getCustomStage();
const GrEffect* stage = drawState.getSampler(s).getCustomStage();
int numTextures = stage->numTextures();
for (int t = 0; t < numTextures; ++t) {
GrTexture* texture = stage->texture(t);
@ -831,7 +831,7 @@ bool GrDrawTarget::srcAlphaWillBeOne(GrVertexLayout layout) const {
// Check if a color stage could create a partial alpha
for (int s = 0; s < drawState.getFirstCoverageStage(); ++s) {
if (this->isStageEnabled(s)) {
const GrCustomStage* stage = drawState.getSampler(s).getCustomStage();
const GrEffect* stage = drawState.getSampler(s).getCustomStage();
// FIXME: The param indicates whether the texture is opaque or not. However, the stage
// already controls its textures. It really needs to know whether the incoming color
// (from a uni, per-vertex colors, or previous stage) is opaque or not.

View File

@ -6,15 +6,15 @@
*/
#include "GrContext.h"
#include "GrCustomStage.h"
#include "GrEffect.h"
#include "GrMemoryPool.h"
#include "SkTLS.h"
SK_DEFINE_INST_COUNT(GrCustomStage)
SK_DEFINE_INST_COUNT(GrEffect)
#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
SkTArray<GrCustomStageTestFactory*, true>* GrCustomStageTestFactory::GetFactories() {
static SkTArray<GrCustomStageTestFactory*, true> gFactories;
SkTArray<GrEffectTestFactory*, true>* GrEffectTestFactory::GetFactories() {
static SkTArray<GrEffectTestFactory*, true> gFactories;
return &gFactories;
}
#endif
@ -38,19 +38,19 @@ private:
int32_t GrProgramStageFactory::fCurrStageClassID =
GrProgramStageFactory::kIllegalStageClassID;
GrCustomStage::GrCustomStage(int numTextures)
GrEffect::GrEffect(int numTextures)
: fNumTextures(numTextures) {
}
GrCustomStage::~GrCustomStage() {
GrEffect::~GrEffect() {
}
bool GrCustomStage::isOpaque(bool inputTextureIsOpaque) const {
bool GrEffect::isOpaque(bool inputTextureIsOpaque) const {
return false;
}
bool GrCustomStage::isEqual(const GrCustomStage& s) const {
bool GrEffect::isEqual(const GrEffect& s) const {
if (this->numTextures() != s.numTextures()) {
return false;
}
@ -62,16 +62,16 @@ bool GrCustomStage::isEqual(const GrCustomStage& s) const {
return true;
}
const GrTextureAccess& GrCustomStage::textureAccess(int index) const {
const GrTextureAccess& GrEffect::textureAccess(int index) const {
GrCrash("We shouldn't be calling this function on the base class.");
static GrTextureAccess kDummy;
return kDummy;
}
void * GrCustomStage::operator new(size_t size) {
void * GrEffect::operator new(size_t size) {
return GrCustomStage_Globals::GetTLS()->allocate(size);
}
void GrCustomStage::operator delete(void* target) {
void GrEffect::operator delete(void* target) {
GrCustomStage_Globals::GetTLS()->release(target);
}

View File

@ -512,7 +512,7 @@ inline bool skPaint2GrPaintNoShader(SkGpuDevice* dev,
SkColor filtered = colorFilter->filterColor(skPaint.getColor());
grPaint->setColor(SkColor2GrColor(filtered));
} else {
SkAutoTUnref<GrCustomStage> stage(colorFilter->asNewCustomStage(dev->context()));
SkAutoTUnref<GrEffect> stage(colorFilter->asNewCustomStage(dev->context()));
if (NULL != stage.get()) {
grPaint->colorSampler(kColorFilterTextureIdx)->setCustomStage(stage);
} else {
@ -1415,7 +1415,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
}
GrRect textureDomain = GrRect::MakeEmpty();
SkAutoTUnref<GrCustomStage> stage;
SkAutoTUnref<GrEffect> stage;
if (needsTextureDomain) {
// Use a constrained texture domain to avoid color bleeding
GrScalar left, top, right, bottom;
@ -1448,7 +1448,7 @@ void apply_custom_stage(GrContext* context,
GrTexture* srcTexture,
GrTexture* dstTexture,
const GrRect& rect,
GrCustomStage* stage) {
GrEffect* stage) {
SkASSERT(srcTexture && srcTexture->getContext() == context);
GrContext::AutoMatrix am;
am.setIdentity(context);
@ -1475,7 +1475,7 @@ static GrTexture* filter_texture(SkDevice* device, GrContext* context,
desc.fWidth = SkScalarCeilToInt(rect.width());
desc.fHeight = SkScalarCeilToInt(rect.height());
desc.fConfig = kRGBA_8888_GrPixelConfig;
GrCustomStage* stage;
GrEffect* stage;
if (filter->canFilterImageGPU()) {
// Save the render target and set it to NULL, so we don't accidentally draw to it in the

View File

@ -11,7 +11,7 @@
class GrGLConfigConversionEffect : public GrGLLegacyProgramStage {
public:
GrGLConfigConversionEffect(const GrProgramStageFactory& factory,
const GrCustomStage& s) : INHERITED (factory) {
const GrEffect& s) : INHERITED (factory) {
const GrConfigConversionEffect& stage = static_cast<const GrConfigConversionEffect&>(s);
fSwapRedAndBlue = stage.swapsRedAndBlue();
fPMConversion = stage.pmConversion();
@ -58,7 +58,7 @@ public:
GrGLSLMulVarBy4f(&builder->fFSCode, 2, outputColor, inputColor);
}
static inline StageKey GenKey(const GrCustomStage& s, const GrGLCaps&) {
static inline StageKey GenKey(const GrEffect& s, const GrGLCaps&) {
const GrConfigConversionEffect& stage = static_cast<const GrConfigConversionEffect&>(s);
return static_cast<int>(stage.swapsRedAndBlue()) | (stage.pmConversion() << 1);
}
@ -89,7 +89,7 @@ const GrProgramStageFactory& GrConfigConversionEffect::getFactory() const {
return GrTProgramStageFactory<GrConfigConversionEffect>::getInstance();
}
bool GrConfigConversionEffect::isEqual(const GrCustomStage& s) const {
bool GrConfigConversionEffect::isEqual(const GrEffect& s) const {
const GrConfigConversionEffect& other = static_cast<const GrConfigConversionEffect&>(s);
return other.fSwapRedAndBlue == fSwapRedAndBlue && other.fPMConversion == fPMConversion;
}
@ -98,9 +98,9 @@ bool GrConfigConversionEffect::isEqual(const GrCustomStage& s) const {
GR_DEFINE_CUSTOM_STAGE_TEST(GrConfigConversionEffect);
GrCustomStage* GrConfigConversionEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture* textures[]) {
GrEffect* GrConfigConversionEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture* textures[]) {
PMConversion pmConv = static_cast<PMConversion>(random->nextULessThan(kPMConversionCnt));
bool swapRB;
if (kNone_PMConversion == pmConv) {
@ -177,12 +177,12 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
GrPaint paint;
SkAutoTUnref<GrCustomStage> pmToUPMStage1(SkNEW_ARGS(GrConfigConversionEffect,
(dataTex, false, *pmToUPMRule)));
SkAutoTUnref<GrCustomStage> upmToPMStage(SkNEW_ARGS(GrConfigConversionEffect,
(readTex, false, *upmToPMRule)));
SkAutoTUnref<GrCustomStage> pmToUPMStage2(SkNEW_ARGS(GrConfigConversionEffect,
(tempTex, false, *pmToUPMRule)));
SkAutoTUnref<GrEffect> pmToUPMStage1(SkNEW_ARGS(GrConfigConversionEffect,
(dataTex, false, *pmToUPMRule)));
SkAutoTUnref<GrEffect> upmToPMStage(SkNEW_ARGS(GrConfigConversionEffect,
(readTex, false, *upmToPMRule)));
SkAutoTUnref<GrEffect> pmToUPMStage2(SkNEW_ARGS(GrConfigConversionEffect,
(tempTex, false, *pmToUPMRule)));
context->setRenderTarget(readTex->asRenderTarget());
paint.colorSampler(0)->setCustomStage(pmToUPMStage1);
@ -215,7 +215,7 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
}
}
GrCustomStage* GrConfigConversionEffect::Create(GrTexture* texture,
GrEffect* GrConfigConversionEffect::Create(GrTexture* texture,
bool swapRedAndBlue,
PMConversion pmConversion) {
if (!swapRedAndBlue && kNone_PMConversion == pmConversion) {

View File

@ -34,7 +34,7 @@ public:
};
// This will fail if the config is not 8888 and a PM conversion is requested.
static GrCustomStage* Create(GrTexture*,
static GrEffect* Create(GrTexture*,
bool swapRedAndBlue,
PMConversion pmConversion = kNone_PMConversion);
@ -42,7 +42,7 @@ public:
typedef GrGLConfigConversionEffect GLProgramStage;
virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE;
virtual bool isEqual(const GrCustomStage&) const SK_OVERRIDE;
virtual bool isEqual(const GrEffect&) const SK_OVERRIDE;
bool swapsRedAndBlue() const { return fSwapRedAndBlue; }
PMConversion pmConversion() const { return fPMConversion; }

View File

@ -18,7 +18,7 @@ static const UniformHandle kInvalidUniformHandle = GrGLUniformManager::kInvalidU
class GrGLConvolutionEffect : public GrGLLegacyProgramStage {
public:
GrGLConvolutionEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage);
const GrEffect& stage);
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
virtual void emitVS(GrGLShaderBuilder* builder,
@ -28,9 +28,9 @@ public:
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager& uman, const GrCustomStage&) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager& uman, const GrEffect&) SK_OVERRIDE;
static inline StageKey GenKey(const GrCustomStage&, const GrGLCaps&);
static inline StageKey GenKey(const GrEffect&, const GrGLCaps&);
private:
int width() const { return Gr1DKernelEffect::WidthFromRadius(fRadius); }
@ -43,7 +43,7 @@ private:
};
GrGLConvolutionEffect::GrGLConvolutionEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage)
const GrEffect& stage)
: INHERITED(factory)
, fKernelUni(kInvalidUniformHandle)
, fImageIncrementUni(kInvalidUniformHandle) {
@ -88,7 +88,7 @@ void GrGLConvolutionEffect::emitFS(GrGLShaderBuilder* builder,
GrGLSLMulVarBy4f(&builder->fFSCode, 2, outputColor, inputColor);
}
void GrGLConvolutionEffect::setData(const GrGLUniformManager& uman, const GrCustomStage& data) {
void GrGLConvolutionEffect::setData(const GrGLUniformManager& uman, const GrEffect& data) {
const GrConvolutionEffect& conv =
static_cast<const GrConvolutionEffect&>(data);
GrTexture& texture = *data.texture(0);
@ -109,7 +109,7 @@ void GrGLConvolutionEffect::setData(const GrGLUniformManager& uman, const GrCust
uman.set1fv(fKernelUni, 0, this->width(), conv.kernel());
}
GrGLProgramStage::StageKey GrGLConvolutionEffect::GenKey(const GrCustomStage& s,
GrGLProgramStage::StageKey GrGLConvolutionEffect::GenKey(const GrEffect& s,
const GrGLCaps& caps) {
return static_cast<const GrConvolutionEffect&>(s).radius();
}
@ -161,7 +161,7 @@ const GrProgramStageFactory& GrConvolutionEffect::getFactory() const {
return GrTProgramStageFactory<GrConvolutionEffect>::getInstance();
}
bool GrConvolutionEffect::isEqual(const GrCustomStage& sBase) const {
bool GrConvolutionEffect::isEqual(const GrEffect& sBase) const {
const GrConvolutionEffect& s =
static_cast<const GrConvolutionEffect&>(sBase);
return (INHERITED::isEqual(sBase) &&
@ -174,9 +174,9 @@ bool GrConvolutionEffect::isEqual(const GrCustomStage& sBase) const {
GR_DEFINE_CUSTOM_STAGE_TEST(GrConvolutionEffect);
GrCustomStage* GrConvolutionEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture* textures[]) {
GrEffect* GrConvolutionEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture* textures[]) {
int texIdx = random->nextBool() ? GrCustomStageUnitTest::kSkiaPMTextureIdx :
GrCustomStageUnitTest::kAlphaTextureIdx;
Direction dir = random->nextBool() ? kX_Direction : kY_Direction;

View File

@ -37,7 +37,7 @@ public:
typedef GrGLConvolutionEffect GLProgramStage;
virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE;
virtual bool isEqual(const GrCustomStage&) const SK_OVERRIDE;
virtual bool isEqual(const GrEffect&) const SK_OVERRIDE;
enum {
// This was decided based on the min allowed value for the max texture

View File

@ -15,7 +15,7 @@
class GrGLSingleTextureEffect : public GrGLLegacyProgramStage {
public:
GrGLSingleTextureEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage) : INHERITED (factory) { }
const GrEffect& stage) : INHERITED (factory) { }
virtual void emitVS(GrGLShaderBuilder* builder,
const char* vertexCoords) SK_OVERRIDE { }
@ -28,7 +28,7 @@ public:
builder->fFSCode.append(";\n");
}
static inline StageKey GenKey(const GrCustomStage&, const GrGLCaps&) { return 0; }
static inline StageKey GenKey(const GrEffect&, const GrGLCaps&) { return 0; }
private:
@ -68,9 +68,9 @@ const GrProgramStageFactory& GrSingleTextureEffect::getFactory() const {
GR_DEFINE_CUSTOM_STAGE_TEST(GrSingleTextureEffect);
GrCustomStage* GrSingleTextureEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture* textures[]) {
GrEffect* GrSingleTextureEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture* textures[]) {
int texIdx = random->nextBool() ? GrCustomStageUnitTest::kSkiaPMTextureIdx :
GrCustomStageUnitTest::kAlphaTextureIdx;
return SkNEW_ARGS(GrSingleTextureEffect, (textures[texIdx]));

View File

@ -8,14 +8,14 @@
#ifndef GrSingleTextureEffect_DEFINED
#define GrSingleTextureEffect_DEFINED
#include "GrCustomStage.h"
#include "GrEffect.h"
class GrGLSingleTextureEffect;
/**
* An effect that merely blits a single texture; commonly used as a base class.
*/
class GrSingleTextureEffect : public GrCustomStage {
class GrSingleTextureEffect : public GrEffect {
public:
/** Uses default texture params (unfiltered, clamp) */
@ -41,7 +41,7 @@ private:
GrTextureAccess fTextureAccess;
typedef GrCustomStage INHERITED;
typedef GrEffect INHERITED;
};
#endif

View File

@ -12,7 +12,7 @@
class GrGLTextureDomainEffect : public GrGLLegacyProgramStage {
public:
GrGLTextureDomainEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage);
const GrEffect& stage);
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
virtual void emitVS(GrGLShaderBuilder* builder,
@ -22,9 +22,9 @@ public:
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrCustomStage&) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager&, const GrEffect&) SK_OVERRIDE;
static inline StageKey GenKey(const GrCustomStage&, const GrGLCaps&) { return 0; }
static inline StageKey GenKey(const GrEffect&, const GrGLCaps&) { return 0; }
private:
GrGLUniformManager::UniformHandle fNameUni;
@ -33,7 +33,7 @@ private:
};
GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrProgramStageFactory& factory,
const GrCustomStage& stage)
const GrEffect& stage)
: INHERITED(factory)
, fNameUni(GrGLUniformManager::kInvalidUniformHandle) {
}
@ -60,7 +60,7 @@ void GrGLTextureDomainEffect::emitFS(GrGLShaderBuilder* builder,
builder->fFSCode.append(";\n");
}
void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman, const GrCustomStage& data) {
void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman, const GrEffect& data) {
const GrTextureDomainEffect& effect = static_cast<const GrTextureDomainEffect&>(data);
const GrRect& domain = effect.domain();
@ -105,7 +105,7 @@ const GrProgramStageFactory& GrTextureDomainEffect::getFactory() const {
return GrTProgramStageFactory<GrTextureDomainEffect>::getInstance();
}
bool GrTextureDomainEffect::isEqual(const GrCustomStage& sBase) const {
bool GrTextureDomainEffect::isEqual(const GrEffect& sBase) const {
const GrTextureDomainEffect& s = static_cast<const GrTextureDomainEffect&>(sBase);
return (INHERITED::isEqual(sBase) && this->fTextureDomain == s.fTextureDomain);
}
@ -114,9 +114,9 @@ bool GrTextureDomainEffect::isEqual(const GrCustomStage& sBase) const {
GR_DEFINE_CUSTOM_STAGE_TEST(GrTextureDomainEffect);
GrCustomStage* GrTextureDomainEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture* textures[]) {
GrEffect* GrTextureDomainEffect::TestCreate(SkRandom* random,
GrContext* context,
GrTexture* textures[]) {
int texIdx = random->nextBool() ? GrCustomStageUnitTest::kSkiaPMTextureIdx :
GrCustomStageUnitTest::kAlphaTextureIdx;
GrRect domain;

View File

@ -8,7 +8,6 @@
#ifndef GrTextureDomainEffect_DEFINED
#define GrTextureDomainEffect_DEFINED
//#include "GrCustomStage.h"
#include "GrSingleTextureEffect.h"
#include "GrRect.h"
@ -32,7 +31,7 @@ public:
typedef GrGLTextureDomainEffect GLProgramStage;
virtual const GrProgramStageFactory& getFactory() const SK_OVERRIDE;
virtual bool isEqual(const GrCustomStage&) const SK_OVERRIDE;
virtual bool isEqual(const GrEffect&) const SK_OVERRIDE;
const GrRect& domain() const { return fTextureDomain; }

View File

@ -8,7 +8,7 @@
#include "GrGLProgram.h"
#include "GrAllocator.h"
#include "GrCustomStage.h"
#include "GrEffect.h"
#include "GrGLProgramStage.h"
#include "gl/GrGLShaderBuilder.h"
#include "GrGLShaderVar.h"
@ -53,7 +53,7 @@ inline const char* dual_source_output_name() { return "dualSourceOut"; }
GrGLProgram* GrGLProgram::Create(const GrGLContextInfo& gl,
const Desc& desc,
const GrCustomStage** customStages) {
const GrEffect** customStages) {
GrGLProgram* program = SkNEW_ARGS(GrGLProgram, (gl, desc, customStages));
if (!program->succeeded()) {
delete program;
@ -64,7 +64,7 @@ GrGLProgram* GrGLProgram::Create(const GrGLContextInfo& gl,
GrGLProgram::GrGLProgram(const GrGLContextInfo& gl,
const Desc& desc,
const GrCustomStage** customStages)
const GrEffect** customStages)
: fContextInfo(gl)
, fUniformManager(gl) {
fDesc = desc;
@ -500,7 +500,7 @@ bool GrGLProgram::compileShaders(const GrGLShaderBuilder& builder) {
return true;
}
bool GrGLProgram::genProgram(const GrCustomStage** customStages) {
bool GrGLProgram::genProgram(const GrEffect** customStages) {
GrAssert(0 == fProgramID);
GrGLShaderBuilder builder(fContextInfo, fUniformManager);
@ -896,7 +896,7 @@ void GrGLProgram::initSamplerUniforms() {
// Stage code generation
// TODO: Move this function to GrGLShaderBuilder
GrGLProgramStage* GrGLProgram::GenStageCode(const GrCustomStage* stage,
GrGLProgramStage* GrGLProgram::GenStageCode(const GrEffect* stage,
const StageDesc& desc,
StageUniforms* uniforms,
const char* fsInColor, // NULL means no incoming color

View File

@ -43,7 +43,7 @@ public:
static GrGLProgram* Create(const GrGLContextInfo& gl,
const Desc& desc,
const GrCustomStage** customStages);
const GrEffect** customStages);
virtual ~GrGLProgram();
@ -67,8 +67,8 @@ public:
static int TexCoordAttributeIdx(int tcIdx) { return 4 + tcIdx; }
/**
* This function uploads uniforms and calls each GrCustomStage's setData. It is called before a
* draw occurs using the program after the program has already been bound.
* This function uploads uniforms and calls each GrEffect's setData. It is called before a draw
* occurs using the program after the program has already been bound.
*/
void setData(const GrDrawState& drawState);
@ -164,18 +164,18 @@ private:
GrGLProgram(const GrGLContextInfo& gl,
const Desc& desc,
const GrCustomStage** customStages);
const GrEffect** customStages);
bool succeeded() const { return 0 != fProgramID; }
/**
* This is the heavy initialization routine for building a GLProgram.
*/
bool genProgram(const GrCustomStage** customStages);
bool genProgram(const GrEffect** customStages);
void genInputColor(GrGLShaderBuilder* builder, SkString* inColor);
static GrGLProgramStage* GenStageCode(const GrCustomStage* stage,
static GrGLProgramStage* GenStageCode(const GrEffect* stage,
const StageDesc& desc, // TODO: Eliminate this
StageUniforms* stageUniforms, // TODO: Eliminate this
const char* fsInColor, // NULL means no incoming color

View File

@ -17,10 +17,10 @@ GrGLProgramStage::~GrGLProgramStage() {
///////////////////////////////////////////////////////////////////////////////
void GrGLProgramStage::setData(const GrGLUniformManager&, const GrCustomStage&) {
void GrGLProgramStage::setData(const GrGLUniformManager&, const GrEffect&) {
}
GrGLProgramStage::StageKey GrGLProgramStage::GenTextureKey(const GrCustomStage& stage,
GrGLProgramStage::StageKey GrGLProgramStage::GenTextureKey(const GrEffect& stage,
const GrGLCaps& caps) {
StageKey key = 0;
for (int index = 0; index < stage.numTextures(); ++index) {

View File

@ -9,7 +9,7 @@
#define GrGLCustomStage_DEFINED
#include "GrAllocator.h"
#include "GrCustomStage.h"
#include "GrEffect.h"
#include "GrGLProgram.h"
#include "GrGLShaderBuilder.h"
#include "GrGLShaderVar.h"
@ -20,20 +20,20 @@ class GrGLTexture;
/** @file
This file contains specializations for OpenGL of the shader stages declared in
include/gpu/GrCustomStage.h. Objects of type GrGLProgramStage are responsible for emitting the
GLSL code that implements a GrCustomStage and for uploading uniforms at draw time. They also
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 GrCustomStage&, const GrGLCaps&)
that is used to implement a program cache. When two GrCustomStages produce the same key this
static inline StageKey GenKey(const GrEffect&, const GrGLCaps&)
that is used to implement a program cache. When two GrCustomEffects 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 GrCustomStage::getFactory().
These objects are created by the factory object returned by the GrEffect::getFactory().
*/
class GrGLProgramStage {
public:
typedef GrCustomStage::StageKey StageKey;
typedef GrEffect::StageKey StageKey;
enum {
// the number of bits in StageKey available to GenKey
kProgramStageKeyBits = GrProgramStageFactory::kProgramStageKeyBits,
@ -51,8 +51,7 @@ public:
@param builder Interface used to emit code in the shaders.
@param stage The custom stage that generated this program stage.
@param key The key that was computed by StageKey() from the generating
GrCustomStage.
@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.
@ -64,26 +63,26 @@ public:
color is solid white, trans black, known to be opaque, etc.) that allows
the custom stage to communicate back similar known info about its
output.
@param samplers One entry for each GrTextureAccess of the GrCustomStage that generated
the GrGLProgramStage. These can be passed to the builder to emit texture
@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 GrCustomStage& stage,
const GrEffect& stage,
StageKey key,
const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) = 0;
/** A GrGLProgramStage instance can be reused with any GrCustomStage that produces the same
stage key; this function reads data from a stage and uploads any uniform variables required
/** 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 GrCustomStage& stage);
virtual void setData(const GrGLUniformManager&, const GrEffect& stage);
const char* name() const { return fFactory.name(); }
static StageKey GenTextureKey(const GrCustomStage&, const GrGLCaps&);
static StageKey GenTextureKey(const GrEffect&, const GrGLCaps&);
protected:
@ -108,7 +107,7 @@ public:
const TextureSamplerArray&) = 0;
virtual void emitCode(GrGLShaderBuilder* builder,
const GrCustomStage&,
const GrEffect&,
StageKey,
const char* vertexCoords,
const char* outputColor,

View File

@ -153,9 +153,9 @@ void GrGLShaderBuilder::appendTextureLookupAndModulate(
GrGLSLModulate4f(out, modulation, lookup.c_str());
}
GrCustomStage::StageKey GrGLShaderBuilder::KeyForTextureAccess(const GrTextureAccess& access,
GrEffect::StageKey GrGLShaderBuilder::KeyForTextureAccess(const GrTextureAccess& access,
const GrGLCaps& caps) {
GrCustomStage::StageKey key = 0;
GrEffect::StageKey key = 0;
// Assume that swizzle support implies that we never have to modify a shader to adjust
// for texture format/swizzle settings.

View File

@ -9,7 +9,7 @@
#define GrGLShaderBuilder_DEFINED
#include "GrAllocator.h"
#include "GrCustomStage.h"
#include "GrEffect.h"
#include "gl/GrGLShaderVar.h"
#include "gl/GrGLSL.h"
#include "gl/GrGLUniformManager.h"
@ -122,7 +122,7 @@ public:
/** Generates a StageKey for the shader code based on the texture access parameters and the
capabilities of the GL context. This is useful for keying the shader programs that may
have multiple representations, based on the type/format of textures used. */
static GrCustomStage::StageKey KeyForTextureAccess(const GrTextureAccess& access,
static GrEffect::StageKey KeyForTextureAccess(const GrTextureAccess& access,
const GrGLCaps& caps);
/** If texture swizzling is available using tex parameters then it is preferred over mangling

View File

@ -2019,7 +2019,7 @@ inline GrGLenum tile_to_gl_wrap(SkShader::TileMode tm) {
void GrGpuGL::flushBoundTextureAndParams(int stage) {
GrDrawState* drawState = this->drawState();
// FIXME: Assuming at most one texture per custom stage
const GrCustomStage* customStage = drawState->sampler(stage)->getCustomStage();
const GrEffect* customStage = drawState->sampler(stage)->getCustomStage();
if (customStage->numTextures() > 0) {
GrGLTexture* nextTexture = static_cast<GrGLTexture*>(customStage->texture(0));
if (NULL != nextTexture) {

View File

@ -166,7 +166,7 @@ private:
ProgramCache(const GrGLContextInfo& gl);
void abandon();
GrGLProgram* getProgram(const GrGLProgram::Desc& desc, const GrCustomStage** stages);
GrGLProgram* getProgram(const GrGLProgram::Desc& desc, const GrEffect** stages);
private:
enum {
kKeySize = sizeof(ProgramDesc),
@ -240,7 +240,7 @@ private:
void buildProgram(bool isPoints,
BlendOptFlags blendOpts,
GrBlendCoeff dstCoeff,
const GrCustomStage** customStages,
const GrEffect** customStages,
ProgramDesc* desc);
// Inits GrDrawTarget::Caps, subclass may enable additional caps.

View File

@ -7,7 +7,7 @@
#include "GrGpuGL.h"
#include "GrCustomStage.h"
#include "GrEffect.h"
#include "GrGLProgramStage.h"
#include "GrGpuVertex.h"
@ -33,7 +33,7 @@ void GrGpuGL::ProgramCache::abandon() {
}
GrGLProgram* GrGpuGL::ProgramCache::getProgram(const ProgramDesc& desc,
const GrCustomStage** stages) {
const GrEffect** stages) {
Entry newEntry;
newEntry.fKey.setKeyData(desc.asKey());
@ -199,7 +199,7 @@ void GrGpuGL::flushTextureMatrix(int s) {
const GrDrawState& drawState = this->getDrawState();
// FIXME: Still assuming only a single texture per custom stage
const GrCustomStage* stage = drawState.getSampler(s).getCustomStage();
const GrEffect* stage = drawState.getSampler(s).getCustomStage();
if (0 == stage->numTextures()) {
return;
}
@ -350,7 +350,7 @@ bool GrGpuGL::flushGraphicsState(DrawType type) {
return false;
}
const GrCustomStage* customStages [GrDrawState::kNumStages];
const GrEffect* customStages [GrDrawState::kNumStages];
GrGLProgram::Desc desc;
this->buildProgram(kDrawPoints_DrawType == type, blendOpts, dstCoeff, customStages, &desc);
@ -568,9 +568,9 @@ namespace {
void setup_custom_stage(GrGLProgram::Desc::StageDesc* stage,
const GrSamplerState& sampler,
const GrGLCaps& caps,
const GrCustomStage** customStages,
const GrEffect** customStages,
GrGLProgram* program, int index) {
const GrCustomStage* customStage = sampler.getCustomStage();
const GrEffect* customStage = sampler.getCustomStage();
if (customStage) {
const GrProgramStageFactory& factory = customStage->getFactory();
stage->fCustomStageKey = factory.glStageKey(*customStage, caps);
@ -586,7 +586,7 @@ void setup_custom_stage(GrGLProgram::Desc::StageDesc* stage,
void GrGpuGL::buildProgram(bool isPoints,
BlendOptFlags blendOpts,
GrBlendCoeff dstCoeff,
const GrCustomStage** customStages,
const GrEffect** customStages,
ProgramDesc* desc) {
const GrDrawState& drawState = this->getDrawState();
@ -675,7 +675,7 @@ void GrGpuGL::buildProgram(bool isPoints,
lastEnabledStage = s;
const GrSamplerState& sampler = drawState.getSampler(s);
// FIXME: Still assuming one texture per custom stage
const GrCustomStage* customStage = drawState.getSampler(s).getCustomStage();
const GrEffect* customStage = drawState.getSampler(s).getCustomStage();
if (customStage->numTextures() > 0) {
const GrGLTexture* texture =

View File

@ -35,7 +35,7 @@ typedef GrGLProgram::StageDesc StageDesc;
// TODO: Effects should be able to register themselves for inclusion in the
// randomly generated shaders. They should be able to configure themselves
// randomly.
const GrCustomStage* create_random_effect(StageDesc* stageDesc,
const GrEffect* create_random_effect(StageDesc* stageDesc,
GrRandom* random,
GrContext* context,
GrTexture* dummyTextures[]) {
@ -44,9 +44,7 @@ const GrCustomStage* create_random_effect(StageDesc* stageDesc,
// TODO: Remove GrRandom.
SkRandom sk_random;
sk_random.setSeed(random->nextU());
GrCustomStage* stage = GrCustomStageTestFactory::CreateStage(&sk_random,
context,
dummyTextures);
GrEffect* stage = GrEffectTestFactory::CreateStage(&sk_random, context, dummyTextures);
GrAssert(stage);
return stage;
}
@ -120,7 +118,7 @@ bool GrGpuGL::programUnitTest() {
pdesc.fDualSrcOutput = ProgramDesc::kNone_DualSrcOutput;
}
SkAutoTUnref<const GrCustomStage> customStages[GrDrawState::kNumStages];
SkAutoTUnref<const GrEffect> customStages[GrDrawState::kNumStages];
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
StageDesc& stage = pdesc.fStages[s];
@ -155,8 +153,8 @@ bool GrGpuGL::programUnitTest() {
}
}
GR_STATIC_ASSERT(sizeof(customStages) ==
GrDrawState::kNumStages * sizeof(GrCustomStage*));
const GrCustomStage** stages = reinterpret_cast<const GrCustomStage**>(&customStages);
GrDrawState::kNumStages * sizeof(GrEffect*));
const GrEffect** stages = reinterpret_cast<const GrEffect**>(&customStages);
SkAutoTUnref<GrGLProgram> program(GrGLProgram::Create(this->glContextInfo(),
pdesc,
stages));