зеркало из https://github.com/mozilla/moz-skia.git
GrCustomStage Renaming Part 5
Stuff found by searching for "stage". R=robertphillips@google.com Review URL: https://codereview.appspot.com/6772043 git-svn-id: http://skia.googlecode.com/svn/trunk@6089 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
8b0e2340e1
Коммит
021fc736f8
|
@ -86,11 +86,11 @@ public:
|
|||
* GrEffect, used to process this filter on the GPU, or false if
|
||||
* not.
|
||||
*
|
||||
* If stage is non-NULL, a new GrEffect instance is stored
|
||||
* If effect 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 asNewEffect(GrEffect** stage, GrTexture*) const;
|
||||
virtual bool asNewEffect(GrEffect** effect, GrTexture*) const;
|
||||
|
||||
/**
|
||||
* Returns true if the filter can be processed on the GPU. This is most
|
||||
|
|
|
@ -16,7 +16,7 @@ class SK_API SkMagnifierImageFilter : public SkImageFilter {
|
|||
public:
|
||||
SkMagnifierImageFilter(SkRect srcRect, SkScalar inset);
|
||||
|
||||
virtual bool asNewEffect(GrEffect** stage,
|
||||
virtual bool asNewEffect(GrEffect** effect,
|
||||
GrTexture* texture) const SK_OVERRIDE;
|
||||
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMagnifierImageFilter)
|
||||
|
|
|
@ -62,7 +62,7 @@ protected:
|
|||
SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
virtual bool asNewEffect(GrEffect** stage, GrTexture*) const SK_OVERRIDE;
|
||||
virtual bool asNewEffect(GrEffect**, GrTexture*) const SK_OVERRIDE;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
virtual ~GrEffect();
|
||||
|
||||
/** If given an input texture that is/is not opaque, is this
|
||||
stage guaranteed to produce an opaque output? */
|
||||
effect guaranteed to produce an opaque output? */
|
||||
virtual bool isOpaque(bool inputTextureIsOpaque) const;
|
||||
|
||||
/** This object, besides creating back-end-specific helper
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "GrNoncopyable.h"
|
||||
|
||||
/** Given a GrEffect of a particular type, creates the corresponding
|
||||
graphics-backend-specific GrProgramStage. Also tracks equivalence
|
||||
graphics-backend-specific GrGLProgramStage. Also tracks equivalence
|
||||
of shaders generated via a key.
|
||||
*/
|
||||
|
||||
|
@ -29,13 +29,11 @@ public:
|
|||
kTexturingStageKeyBits = 6
|
||||
};
|
||||
|
||||
virtual StageKey glStageKey(const GrEffect& stage,
|
||||
const GrGLCaps& caps ) const = 0;
|
||||
virtual GrGLProgramStage* createGLInstance(
|
||||
const GrEffect& stage) const = 0;
|
||||
virtual StageKey glStageKey(const GrEffect&, const GrGLCaps&) const = 0;
|
||||
virtual GrGLProgramStage* createGLInstance(const GrEffect&) const = 0;
|
||||
|
||||
bool operator ==(const GrProgramStageFactory& b) const {
|
||||
return fStageClassID == b.fStageClassID;
|
||||
return fEffectClassID == b.fEffectClassID;
|
||||
}
|
||||
bool operator !=(const GrProgramStageFactory& b) const {
|
||||
return !(*this == b);
|
||||
|
@ -45,67 +43,64 @@ public:
|
|||
|
||||
protected:
|
||||
enum {
|
||||
kIllegalStageClassID = 0,
|
||||
kIllegalEffectClassID = 0,
|
||||
};
|
||||
|
||||
GrProgramStageFactory() {
|
||||
fStageClassID = kIllegalStageClassID;
|
||||
fEffectClassID = kIllegalEffectClassID;
|
||||
}
|
||||
|
||||
static StageKey GenID() {
|
||||
// fCurrStageClassID has been initialized to kIllegalStageClassID. The
|
||||
// fCurrEffectClassID has been initialized to kIllegalEffectClassID. The
|
||||
// atomic inc returns the old value not the incremented value. So we add
|
||||
// 1 to the returned value.
|
||||
int32_t id = sk_atomic_inc(&fCurrStageClassID) + 1;
|
||||
int32_t id = sk_atomic_inc(&fCurrEffectClassID) + 1;
|
||||
GrAssert(id < (1 << (8 * sizeof(StageKey) - kProgramStageKeyBits)));
|
||||
return id;
|
||||
}
|
||||
|
||||
StageKey fStageClassID;
|
||||
StageKey fEffectClassID;
|
||||
|
||||
private:
|
||||
static int32_t fCurrStageClassID;
|
||||
static int32_t fCurrEffectClassID;
|
||||
};
|
||||
|
||||
template <typename StageClass>
|
||||
template <typename EffectClass>
|
||||
class GrTProgramStageFactory : public GrProgramStageFactory {
|
||||
|
||||
public:
|
||||
typedef typename StageClass::GLProgramStage GLProgramStage;
|
||||
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.
|
||||
*/
|
||||
virtual const char* name() const SK_OVERRIDE { return StageClass::Name(); }
|
||||
virtual const char* name() const SK_OVERRIDE { return EffectClass::Name(); }
|
||||
|
||||
/** Returns a value that idenitifes the GLSL shader code generated by
|
||||
/** Returns a value that identifies the GLSL shader code generated by
|
||||
a GrEffect. This enables caching of generated shaders. Part of the
|
||||
id identifies the GrEffect subclass. The remainder is based
|
||||
on the aspects of the GrEffect object's configuration that affect
|
||||
GLSL code generation. */
|
||||
virtual StageKey glStageKey(const GrEffect& stage,
|
||||
const GrGLCaps& caps) const SK_OVERRIDE {
|
||||
GrAssert(kIllegalStageClassID != fStageClassID);
|
||||
StageKey stageID = GLProgramStage::GenKey(stage, caps);
|
||||
StageKey textureKey = GLProgramStage::GenTextureKey(stage, caps);
|
||||
virtual StageKey glStageKey(const GrEffect& effect, const GrGLCaps& caps) const SK_OVERRIDE {
|
||||
GrAssert(kIllegalEffectClassID != fEffectClassID);
|
||||
StageKey stageID = GLProgramStage::GenKey(effect, caps);
|
||||
StageKey textureKey = GLProgramStage::GenTextureKey(effect, caps);
|
||||
#if GR_DEBUG
|
||||
static const StageKey kIllegalIDMask =
|
||||
(uint16_t) (~((1U << kProgramStageKeyBits) - 1));
|
||||
static const StageKey kIllegalIDMask = (uint16_t) (~((1U << kProgramStageKeyBits) - 1));
|
||||
GrAssert(!(kIllegalIDMask & stageID));
|
||||
|
||||
static const StageKey kIllegalTextureKeyMask =
|
||||
(uint16_t) (~((1U << kTexturingStageKeyBits) - 1));
|
||||
GrAssert(!(kIllegalTextureKeyMask & textureKey));
|
||||
#endif
|
||||
return fStageClassID | (textureKey << kProgramStageKeyBits) | stageID;
|
||||
return fEffectClassID | (textureKey << kProgramStageKeyBits) | stageID;
|
||||
}
|
||||
|
||||
/** Returns a new instance of the appropriate *GL* implementation class
|
||||
for the given GrEffect; caller is responsible for deleting
|
||||
the object. */
|
||||
virtual GLProgramStage* createGLInstance(
|
||||
const GrEffect& stage) const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GLProgramStage, (*this, stage));
|
||||
virtual GLProgramStage* createGLInstance(const GrEffect& effect) const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GLProgramStage, (*this, effect));
|
||||
}
|
||||
|
||||
/** This class is a singleton. This function returns the single instance.
|
||||
|
@ -122,7 +117,7 @@ public:
|
|||
|
||||
protected:
|
||||
GrTProgramStageFactory() {
|
||||
fStageClassID = GenID() << (kProgramStageKeyBits + kTexturingStageKeyBits) ;
|
||||
fEffectClassID = GenID() << (kProgramStageKeyBits + kTexturingStageKeyBits) ;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ bool SkBlendImageFilter::onFilterImage(Proxy* proxy,
|
|||
class GrGLBlendEffect : public GrGLLegacyProgramStage {
|
||||
public:
|
||||
GrGLBlendEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage);
|
||||
const GrEffect& effect);
|
||||
virtual ~GrGLBlendEffect();
|
||||
|
||||
virtual void emitFS(GrGLShaderBuilder* builder,
|
||||
|
@ -237,9 +237,9 @@ const GrProgramStageFactory& GrBlendEffect::getFactory() const {
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGLBlendEffect::GrGLBlendEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory),
|
||||
fMode(static_cast<const GrBlendEffect&>(stage).mode()) {
|
||||
fMode(static_cast<const GrBlendEffect&>(effect).mode()) {
|
||||
}
|
||||
|
||||
GrGLBlendEffect::~GrGLBlendEffect() {
|
||||
|
|
|
@ -345,7 +345,7 @@ public:
|
|||
static StageKey GenKey(const GrEffect& s, const GrGLCaps&) { return 0; }
|
||||
|
||||
GLProgramStage(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory)
|
||||
, fMatrixHandle(GrGLUniformManager::kInvalidUniformHandle)
|
||||
, fVectorHandle(GrGLUniformManager::kInvalidUniformHandle) {
|
||||
|
@ -383,8 +383,8 @@ public:
|
|||
}
|
||||
|
||||
virtual void setData(const GrGLUniformManager& uniManager,
|
||||
const GrEffect& stage) SK_OVERRIDE {
|
||||
const ColorMatrixEffect& cme = static_cast<const ColorMatrixEffect&>(stage);
|
||||
const GrEffect& effect) SK_OVERRIDE {
|
||||
const ColorMatrixEffect& cme = static_cast<const ColorMatrixEffect&>(effect);
|
||||
const float* m = cme.fMatrix.fMat;
|
||||
// The GL matrix is transposed from SkColorMatrix.
|
||||
GrGLfloat mt[] = {
|
||||
|
|
|
@ -264,7 +264,7 @@ public:
|
|||
SkScalar kd, SkImageFilter* input);
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiffuseLightingImageFilter)
|
||||
|
||||
virtual bool asNewEffect(GrEffect** stage, GrTexture*) const SK_OVERRIDE;
|
||||
virtual bool asNewEffect(GrEffect** effect, 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 asNewEffect(GrEffect** stage, GrTexture*) const SK_OVERRIDE;
|
||||
virtual bool asNewEffect(GrEffect** effect, GrTexture*) const SK_OVERRIDE;
|
||||
SkScalar ks() const { return fKS; }
|
||||
SkScalar shininess() const { return fShininess; }
|
||||
|
||||
|
@ -821,12 +821,12 @@ bool SkDiffuseLightingImageFilter::onFilterImage(Proxy*,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SkDiffuseLightingImageFilter::asNewEffect(GrEffect** stage,
|
||||
bool SkDiffuseLightingImageFilter::asNewEffect(GrEffect** effect,
|
||||
GrTexture* texture) const {
|
||||
#if SK_SUPPORT_GPU
|
||||
if (stage) {
|
||||
if (effect) {
|
||||
SkScalar scale = SkScalarMul(surfaceScale(), SkIntToScalar(255));
|
||||
*stage = SkNEW_ARGS(GrDiffuseLightingEffect, (texture, light(), scale, kd()));
|
||||
*effect = SkNEW_ARGS(GrDiffuseLightingEffect, (texture, light(), scale, kd()));
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
|
@ -890,12 +890,12 @@ bool SkSpecularLightingImageFilter::onFilterImage(Proxy*,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SkSpecularLightingImageFilter::asNewEffect(GrEffect** stage,
|
||||
bool SkSpecularLightingImageFilter::asNewEffect(GrEffect** effect,
|
||||
GrTexture* texture) const {
|
||||
#if SK_SUPPORT_GPU
|
||||
if (stage) {
|
||||
if (effect) {
|
||||
SkScalar scale = SkScalarMul(surfaceScale(), SkIntToScalar(255));
|
||||
*stage = SkNEW_ARGS(GrSpecularLightingEffect, (texture, light(), scale, ks(), shininess()));
|
||||
*effect = SkNEW_ARGS(GrSpecularLightingEffect, (texture, light(), scale, ks(), shininess()));
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
|
@ -942,7 +942,7 @@ SkLight* create_random_light(SkRandom* random) {
|
|||
class GrGLLightingEffect : public GrGLLegacyProgramStage {
|
||||
public:
|
||||
GrGLLightingEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage);
|
||||
const GrEffect& effect);
|
||||
virtual ~GrGLLightingEffect();
|
||||
|
||||
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
|
||||
|
@ -972,7 +972,7 @@ private:
|
|||
class GrGLDiffuseLightingEffect : public GrGLLightingEffect {
|
||||
public:
|
||||
GrGLDiffuseLightingEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage);
|
||||
const GrEffect& effect);
|
||||
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
|
||||
virtual void emitLightFunc(GrGLShaderBuilder*, SkString* funcName) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLUniformManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
@ -988,7 +988,7 @@ private:
|
|||
class GrGLSpecularLightingEffect : public GrGLLightingEffect {
|
||||
public:
|
||||
GrGLSpecularLightingEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage);
|
||||
const GrEffect& effect);
|
||||
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
|
||||
virtual void emitLightFunc(GrGLShaderBuilder*, SkString* funcName) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLUniformManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
@ -1054,11 +1054,11 @@ GrEffect* GrDiffuseLightingEffect::TestCreate(SkRandom* random,
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGLLightingEffect::GrGLLightingEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory)
|
||||
, fImageIncrementUni(kInvalidUniformHandle)
|
||||
, fSurfaceScaleUni(kInvalidUniformHandle) {
|
||||
const GrLightingEffect& m = static_cast<const GrLightingEffect&>(stage);
|
||||
const GrLightingEffect& m = static_cast<const GrLightingEffect&>(effect);
|
||||
fLight = m.light()->createGLLight();
|
||||
}
|
||||
|
||||
|
@ -1188,8 +1188,8 @@ void GrGLLightingEffect::setData(const GrGLUniformManager& uman, const GrEffect&
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGLDiffuseLightingEffect::GrGLDiffuseLightingEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage)
|
||||
: INHERITED(factory, stage)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory, effect)
|
||||
, fKDUni(kInvalidUniformHandle) {
|
||||
}
|
||||
|
||||
|
@ -1260,8 +1260,8 @@ GrEffect* GrSpecularLightingEffect::TestCreate(SkRandom* random,
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGLSpecularLightingEffect::GrGLSpecularLightingEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage)
|
||||
: GrGLLightingEffect(factory, stage)
|
||||
const GrEffect& effect)
|
||||
: GrGLLightingEffect(factory, effect)
|
||||
, fKSUni(kInvalidUniformHandle)
|
||||
, fShininessUni(kInvalidUniformHandle) {
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ typedef GrGLUniformManager::UniformHandle UniformHandle;
|
|||
class GrGLMagnifierEffect : public GrGLLegacyProgramStage {
|
||||
public:
|
||||
GrGLMagnifierEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage);
|
||||
const GrEffect& effect);
|
||||
|
||||
virtual void setupVariables(GrGLShaderBuilder* state) SK_OVERRIDE;
|
||||
virtual void emitVS(GrGLShaderBuilder* state,
|
||||
|
@ -100,7 +100,7 @@ private:
|
|||
};
|
||||
|
||||
GrGLMagnifierEffect::GrGLMagnifierEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory)
|
||||
, fOffsetVar(GrGLUniformManager::kInvalidUniformHandle)
|
||||
, fZoomVar(GrGLUniformManager::kInvalidUniformHandle)
|
||||
|
@ -201,10 +201,10 @@ GrEffect* GrMagnifierEffect::TestCreate(SkRandom* random,
|
|||
SkIntToScalar(width), SkIntToScalar(height)),
|
||||
inset));
|
||||
GrSamplerState sampler;
|
||||
GrEffect* stage;
|
||||
filter->asNewEffect(&stage, textures[0]);
|
||||
GrAssert(NULL != stage);
|
||||
return stage;
|
||||
GrEffect* effect;
|
||||
filter->asNewEffect(&effect, textures[0]);
|
||||
GrAssert(NULL != effect);
|
||||
return effect;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -243,18 +243,17 @@ SkMagnifierImageFilter::SkMagnifierImageFilter(SkRect srcRect, SkScalar inset)
|
|||
SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0);
|
||||
}
|
||||
|
||||
bool SkMagnifierImageFilter::asNewEffect(GrEffect** stage,
|
||||
bool SkMagnifierImageFilter::asNewEffect(GrEffect** effect,
|
||||
GrTexture* texture) const {
|
||||
#if SK_SUPPORT_GPU
|
||||
if (stage) {
|
||||
*stage =
|
||||
SkNEW_ARGS(GrMagnifierEffect, (texture,
|
||||
fSrcRect.x() / texture->width(),
|
||||
fSrcRect.y() / texture->height(),
|
||||
texture->width() / fSrcRect.width(),
|
||||
texture->height() / fSrcRect.height(),
|
||||
fInset / texture->width(),
|
||||
fInset / texture->height()));
|
||||
if (effect) {
|
||||
*effect = SkNEW_ARGS(GrMagnifierEffect, (texture,
|
||||
fSrcRect.x() / texture->width(),
|
||||
fSrcRect.y() / texture->height(),
|
||||
texture->width() / fSrcRect.width(),
|
||||
texture->height() / fSrcRect.height(),
|
||||
fInset / texture->width(),
|
||||
fInset / texture->height()));
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
|
|
|
@ -282,7 +282,7 @@ private:
|
|||
class GrGLMatrixConvolutionEffect : public GrGLLegacyProgramStage {
|
||||
public:
|
||||
GrGLMatrixConvolutionEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage);
|
||||
const GrEffect& effect);
|
||||
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
|
||||
virtual void emitVS(GrGLShaderBuilder* state,
|
||||
const char* vertexCoords) SK_OVERRIDE {}
|
||||
|
@ -312,14 +312,14 @@ private:
|
|||
};
|
||||
|
||||
GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory)
|
||||
, fKernelUni(GrGLUniformManager::kInvalidUniformHandle)
|
||||
, fImageIncrementUni(GrGLUniformManager::kInvalidUniformHandle)
|
||||
, fTargetUni(GrGLUniformManager::kInvalidUniformHandle)
|
||||
, fGainUni(GrGLUniformManager::kInvalidUniformHandle)
|
||||
, fBiasUni(GrGLUniformManager::kInvalidUniformHandle) {
|
||||
const GrMatrixConvolutionEffect& m = static_cast<const GrMatrixConvolutionEffect&>(stage);
|
||||
const GrMatrixConvolutionEffect& m = static_cast<const GrMatrixConvolutionEffect&>(effect);
|
||||
fKernelSize = m.kernelSize();
|
||||
fTileMode = m.tileMode();
|
||||
fConvolveAlpha = m.convolveAlpha();
|
||||
|
@ -521,18 +521,18 @@ GrEffect* GrMatrixConvolutionEffect::TestCreate(SkRandom* random,
|
|||
|
||||
}
|
||||
|
||||
bool SkMatrixConvolutionImageFilter::asNewEffect(GrEffect** stage,
|
||||
bool SkMatrixConvolutionImageFilter::asNewEffect(GrEffect** effect,
|
||||
GrTexture* texture) const {
|
||||
bool ok = fKernelSize.width() * fKernelSize.height() <= MAX_KERNEL_SIZE;
|
||||
if (ok && stage) {
|
||||
*stage = SkNEW_ARGS(GrMatrixConvolutionEffect, (texture,
|
||||
fKernelSize,
|
||||
fKernel,
|
||||
fGain,
|
||||
fBias,
|
||||
fTarget,
|
||||
fTileMode,
|
||||
fConvolveAlpha));
|
||||
if (ok && effect) {
|
||||
*effect = SkNEW_ARGS(GrMatrixConvolutionEffect, (texture,
|
||||
fKernelSize,
|
||||
fKernel,
|
||||
fGain,
|
||||
fBias,
|
||||
fTarget,
|
||||
fTileMode,
|
||||
fConvolveAlpha));
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ private:
|
|||
class GrGLMorphologyEffect : public GrGLLegacyProgramStage {
|
||||
public:
|
||||
GrGLMorphologyEffect (const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage);
|
||||
const GrEffect& effect);
|
||||
|
||||
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
|
||||
virtual void emitVS(GrGLShaderBuilder* state,
|
||||
|
@ -294,10 +294,10 @@ private:
|
|||
};
|
||||
|
||||
GrGLMorphologyEffect::GrGLMorphologyEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory)
|
||||
, fImageIncrementUni(GrGLUniformManager::kInvalidUniformHandle) {
|
||||
const GrMorphologyEffect& m = static_cast<const GrMorphologyEffect&>(stage);
|
||||
const GrMorphologyEffect& m = static_cast<const GrMorphologyEffect&>(effect);
|
||||
fRadius = m.radius();
|
||||
fType = m.type();
|
||||
}
|
||||
|
|
|
@ -247,7 +247,7 @@ private:
|
|||
class GLColorTableEffect : public GrGLLegacyProgramStage {
|
||||
public:
|
||||
GLColorTableEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage);
|
||||
const GrEffect& effect);
|
||||
|
||||
virtual void setupVariables(GrGLShaderBuilder* state) SK_OVERRIDE {}
|
||||
virtual void emitVS(GrGLShaderBuilder* state,
|
||||
|
@ -267,7 +267,7 @@ private:
|
|||
};
|
||||
|
||||
GLColorTableEffect::GLColorTableEffect(
|
||||
const GrProgramStageFactory& factory, const GrEffect& stage)
|
||||
const GrProgramStageFactory& factory, const GrEffect& effect)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
|
||||
|
@ -355,13 +355,13 @@ GrEffect* SkTable_ColorFilter::asNewEffect(GrContext* context) const {
|
|||
this->asComponentTable(&bitmap);
|
||||
// passing NULL because this effect does no tiling or filtering.
|
||||
GrTexture* texture = GrLockCachedBitmapTexture(context, bitmap, NULL);
|
||||
GrEffect* stage = SkNEW_ARGS(ColorTableEffect, (texture));
|
||||
GrEffect* effect = 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
|
||||
// unref becomes the unlock replacement for all types of textures.
|
||||
GrUnlockCachedBitmapTexture(texture);
|
||||
return stage;
|
||||
return effect;
|
||||
}
|
||||
|
||||
#endif // SK_SUPPORT_GPU
|
||||
|
|
|
@ -687,8 +687,8 @@ void GrGLGradientStage::setupVariables(GrGLShaderBuilder* builder) {
|
|||
kFloat_GrSLType, "GradientYCoordFS");
|
||||
}
|
||||
|
||||
void GrGLGradientStage::setData(const GrGLUniformManager& uman, const GrEffect& stage) {
|
||||
GrScalar yCoord = static_cast<const GrGradientEffect&>(stage).getYCoord();
|
||||
void GrGLGradientStage::setData(const GrGLUniformManager& uman, const GrEffect& effect) {
|
||||
GrScalar yCoord = static_cast<const GrGradientEffect&>(effect).getYCoord();
|
||||
if (yCoord != fCachedYCoord) {
|
||||
uman.set1f(fFSYUni, yCoord);
|
||||
fCachedYCoord = yCoord;
|
||||
|
|
|
@ -237,9 +237,9 @@ public:
|
|||
bool useAtlas() const { return SkToBool(-1 != fRow); }
|
||||
GrScalar getYCoord() const { return fYCoord; };
|
||||
|
||||
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() &&
|
||||
virtual bool isEqual(const GrEffect& effect) const SK_OVERRIDE {
|
||||
const GrGradientEffect& s = static_cast<const GrGradientEffect&>(effect);
|
||||
return INHERITED::isEqual(effect) && this->useAtlas() == s.useAtlas() &&
|
||||
fYCoord == s.getYCoord();
|
||||
}
|
||||
|
||||
|
|
|
@ -562,7 +562,7 @@ void GrGLLinearGradient::emitFS(GrGLShaderBuilder* builder,
|
|||
bool SkLinearGradient::asNewEffect(GrContext* context, GrSamplerState* sampler) const {
|
||||
SkASSERT(NULL != context && NULL != sampler);
|
||||
|
||||
SkAutoTUnref<GrEffect> stage(SkNEW_ARGS(GrLinearGradient, (context, *this, fTileMode)));
|
||||
SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrLinearGradient, (context, *this, fTileMode)));
|
||||
|
||||
SkMatrix matrix;
|
||||
if (this->getLocalMatrix(&matrix)) {
|
||||
|
@ -570,9 +570,9 @@ bool SkLinearGradient::asNewEffect(GrContext* context, GrSamplerState* sampler)
|
|||
return false;
|
||||
}
|
||||
matrix.postConcat(fPtsToUnit);
|
||||
sampler->setEffect(stage, matrix);
|
||||
sampler->setEffect(effect, matrix);
|
||||
} else {
|
||||
sampler->setEffect(stage, fPtsToUnit);
|
||||
sampler->setEffect(effect, fPtsToUnit);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -560,7 +560,7 @@ void GrGLRadialGradient::emitFS(GrGLShaderBuilder* builder,
|
|||
|
||||
bool SkRadialGradient::asNewEffect(GrContext* context, GrSamplerState* sampler) const {
|
||||
SkASSERT(NULL != context && NULL != sampler);
|
||||
SkAutoTUnref<GrEffect> stage(SkNEW_ARGS(GrRadialGradient, (context, *this, fTileMode)));
|
||||
SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrRadialGradient, (context, *this, fTileMode)));
|
||||
|
||||
SkMatrix matrix;
|
||||
if (this->getLocalMatrix(&matrix)) {
|
||||
|
@ -568,9 +568,9 @@ bool SkRadialGradient::asNewEffect(GrContext* context, GrSamplerState* sampler)
|
|||
return false;
|
||||
}
|
||||
matrix.postConcat(fPtsToUnit);
|
||||
sampler->setEffect(stage, matrix);
|
||||
sampler->setEffect(effect, matrix);
|
||||
} else {
|
||||
sampler->setEffect(stage, fPtsToUnit);
|
||||
sampler->setEffect(effect, fPtsToUnit);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -466,8 +466,7 @@ void GrGLSweepGradient::emitFS(GrGLShaderBuilder* builder,
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool SkSweepGradient::asNewEffect(GrContext* context, GrSamplerState* sampler) const {
|
||||
SkAutoTUnref<GrEffect> stage(SkNEW_ARGS(GrSweepGradient, (context, *this)));
|
||||
|
||||
SkAutoTUnref<GrEffect> effect(SkNEW_ARGS(GrSweepGradient, (context, *this)));
|
||||
|
||||
SkMatrix matrix;
|
||||
if (this->getLocalMatrix(&matrix)) {
|
||||
|
@ -475,9 +474,9 @@ bool SkSweepGradient::asNewEffect(GrContext* context, GrSamplerState* sampler) c
|
|||
return false;
|
||||
}
|
||||
matrix.postConcat(fPtsToUnit);
|
||||
sampler->setEffect(stage, matrix);
|
||||
sampler->setEffect(effect, matrix);
|
||||
} else {
|
||||
sampler->setEffect(stage, fPtsToUnit);
|
||||
sampler->setEffect(effect, fPtsToUnit);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1317,16 +1317,16 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
|
|||
ast.set(this, desc, match);
|
||||
GrTexture* texture = ast.texture();
|
||||
if (texture) {
|
||||
SkAutoTUnref<GrEffect> stage;
|
||||
SkAutoTUnref<GrEffect> effect;
|
||||
if (unpremul) {
|
||||
stage.reset(this->createPMToUPMEffect(src, swapRAndB));
|
||||
effect.reset(this->createPMToUPMEffect(src, swapRAndB));
|
||||
}
|
||||
// If we failed to create a PM->UPM effect and have no other conversions to perform then
|
||||
// there is no longer any point to using the scratch.
|
||||
if (NULL != stage || flipY || swapRAndB) {
|
||||
if (NULL == stage) {
|
||||
stage.reset(GrConfigConversionEffect::Create(src, swapRAndB));
|
||||
GrAssert(NULL != stage);
|
||||
if (NULL != effect || flipY || swapRAndB) {
|
||||
if (NULL == effect) {
|
||||
effect.reset(GrConfigConversionEffect::Create(src, swapRAndB));
|
||||
GrAssert(NULL != effect);
|
||||
} else {
|
||||
unpremul = false; // we will handle the UPM conversion in the draw
|
||||
}
|
||||
|
@ -1345,7 +1345,7 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
|
|||
matrix.setTranslate(SK_Scalar1 *left, SK_Scalar1 *top);
|
||||
}
|
||||
matrix.postIDiv(src->width(), src->height());
|
||||
drawState->sampler(0)->setEffect(stage, matrix);
|
||||
drawState->sampler(0)->setEffect(effect, matrix);
|
||||
GrRect rect = GrRect::MakeWH(GrIntToScalar(width), GrIntToScalar(height));
|
||||
fGpu->drawSimpleRect(rect, NULL);
|
||||
// we want to read back from the scratch's origin
|
||||
|
@ -1490,7 +1490,7 @@ void GrContext::writeRenderTargetPixels(GrRenderTarget* target,
|
|||
return;
|
||||
}
|
||||
#endif
|
||||
SkAutoTUnref<GrEffect> stage;
|
||||
SkAutoTUnref<GrEffect> effect;
|
||||
bool swapRAndB = (fGpu->preferredReadPixelsConfig(config) == GrPixelConfigSwapRAndB(config));
|
||||
|
||||
GrPixelConfig textureConfig;
|
||||
|
@ -1516,8 +1516,8 @@ void GrContext::writeRenderTargetPixels(GrRenderTarget* target,
|
|||
if (kRGBA_8888_GrPixelConfig != config && kBGRA_8888_GrPixelConfig != config) {
|
||||
return;
|
||||
}
|
||||
stage.reset(this->createUPMToPMEffect(texture, swapRAndB));
|
||||
if (NULL == stage) {
|
||||
effect.reset(this->createUPMToPMEffect(texture, swapRAndB));
|
||||
if (NULL == effect) {
|
||||
SkCanvas::Config8888 srcConfig8888, dstConfig8888;
|
||||
GR_DEBUGCODE(bool success = )
|
||||
grconfig_to_config8888(config, true, &srcConfig8888);
|
||||
|
@ -1534,9 +1534,9 @@ void GrContext::writeRenderTargetPixels(GrRenderTarget* target,
|
|||
rowBytes = 4 * width;
|
||||
}
|
||||
}
|
||||
if (NULL == stage) {
|
||||
stage.reset(GrConfigConversionEffect::Create(texture, swapRAndB));
|
||||
GrAssert(NULL != stage);
|
||||
if (NULL == effect) {
|
||||
effect.reset(GrConfigConversionEffect::Create(texture, swapRAndB));
|
||||
GrAssert(NULL != effect);
|
||||
}
|
||||
|
||||
this->writeTexturePixels(texture,
|
||||
|
@ -1553,7 +1553,7 @@ void GrContext::writeRenderTargetPixels(GrRenderTarget* target,
|
|||
drawState->setRenderTarget(target);
|
||||
|
||||
matrix.setIDiv(texture->width(), texture->height());
|
||||
drawState->sampler(0)->setEffect(stage, matrix);
|
||||
drawState->sampler(0)->setEffect(effect, matrix);
|
||||
|
||||
fGpu->drawSimpleRect(GrRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)), NULL);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
SK_DECLARE_INST_COUNT(GrDrawState)
|
||||
|
||||
/**
|
||||
* Number of texture stages. Each stage takes as input a color and
|
||||
* Number of effect stages. Each stage takes as input a color and
|
||||
* 2D texture coordinates. The color input to the first enabled stage is the
|
||||
* per-vertex color or the constant color (setColor/setAlpha) if there are
|
||||
* no per-vertex colors. For subsequent stages the input color is the output
|
||||
|
@ -190,8 +190,7 @@ public:
|
|||
*/
|
||||
void createTextureEffect(int stage, GrTexture* texture) {
|
||||
GrAssert(!this->getSampler(stage).getEffect());
|
||||
this->sampler(stage)->setEffect(
|
||||
SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
|
||||
this->sampler(stage)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
|
||||
}
|
||||
void createTextureEffect(int stage, GrTexture* texture, const GrMatrix& matrix) {
|
||||
GrAssert(!this->getSampler(stage).getEffect());
|
||||
|
|
|
@ -748,10 +748,10 @@ bool GrDrawTarget::checkDraw(GrPrimitiveType type, int startVertex,
|
|||
GrAssert(NULL != drawState.getRenderTarget());
|
||||
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
|
||||
if (drawState.isStageEnabled(s)) {
|
||||
const GrEffect* stage = drawState.getSampler(s).getEffect();
|
||||
int numTextures = stage->numTextures();
|
||||
const GrEffect* effect = drawState.getSampler(s).getEffect();
|
||||
int numTextures = effect->numTextures();
|
||||
for (int t = 0; t < numTextures; ++t) {
|
||||
GrTexture* texture = stage->texture(t);
|
||||
GrTexture* texture = effect->texture(t);
|
||||
GrAssert(texture->asRenderTarget() != drawState.getRenderTarget());
|
||||
}
|
||||
}
|
||||
|
@ -831,11 +831,11 @@ 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 GrEffect* stage = drawState.getSampler(s).getEffect();
|
||||
// FIXME: The param indicates whether the texture is opaque or not. However, the stage
|
||||
const GrEffect* effect = drawState.getSampler(s).getEffect();
|
||||
// FIXME: The param indicates whether the texture is opaque or not. However, the effect
|
||||
// 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.
|
||||
if (!stage->isOpaque(true)) {
|
||||
if (!effect->isOpaque(true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -913,7 +913,7 @@ GrDrawTarget::getBlendOpts(bool forceCoverage,
|
|||
}
|
||||
|
||||
// check for coverage due to constant coverage, per-vertex coverage,
|
||||
// edge aa or coverage texture stage
|
||||
// edge aa or coverage stage
|
||||
bool hasCoverage = forceCoverage ||
|
||||
0xffffffff != drawState.getCoverage() ||
|
||||
(layout & kCoverage_VertexLayoutBit) ||
|
||||
|
|
|
@ -35,8 +35,7 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
int32_t GrProgramStageFactory::fCurrStageClassID =
|
||||
GrProgramStageFactory::kIllegalStageClassID;
|
||||
int32_t GrProgramStageFactory::fCurrEffectClassID = GrProgramStageFactory::kIllegalEffectClassID;
|
||||
|
||||
GrEffect::GrEffect(int numTextures)
|
||||
: fNumTextures(numTextures) {
|
||||
|
|
|
@ -512,9 +512,9 @@ inline bool skPaint2GrPaintNoShader(SkGpuDevice* dev,
|
|||
SkColor filtered = colorFilter->filterColor(skPaint.getColor());
|
||||
grPaint->setColor(SkColor2GrColor(filtered));
|
||||
} else {
|
||||
SkAutoTUnref<GrEffect> stage(colorFilter->asNewEffect(dev->context()));
|
||||
if (NULL != stage.get()) {
|
||||
grPaint->colorSampler(kColorFilterTextureIdx)->setEffect(stage);
|
||||
SkAutoTUnref<GrEffect> effect(colorFilter->asNewEffect(dev->context()));
|
||||
if (NULL != effect.get()) {
|
||||
grPaint->colorSampler(kColorFilterTextureIdx)->setEffect(effect);
|
||||
} else {
|
||||
// TODO: rewrite this using asNewEffect()
|
||||
SkColor color;
|
||||
|
@ -1415,7 +1415,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
|
|||
}
|
||||
|
||||
GrRect textureDomain = GrRect::MakeEmpty();
|
||||
SkAutoTUnref<GrEffect> stage;
|
||||
SkAutoTUnref<GrEffect> effect;
|
||||
if (needsTextureDomain) {
|
||||
// Use a constrained texture domain to avoid color bleeding
|
||||
GrScalar left, top, right, bottom;
|
||||
|
@ -1434,11 +1434,11 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
|
|||
top = bottom = GrScalarHalf(paintRect.top() + paintRect.bottom());
|
||||
}
|
||||
textureDomain.setLTRB(left, top, right, bottom);
|
||||
stage.reset(SkNEW_ARGS(GrTextureDomainEffect, (texture, textureDomain, params)));
|
||||
effect.reset(SkNEW_ARGS(GrTextureDomainEffect, (texture, textureDomain, params)));
|
||||
} else {
|
||||
stage.reset(SkNEW_ARGS(GrSingleTextureEffect, (texture, params)));
|
||||
effect.reset(SkNEW_ARGS(GrSingleTextureEffect, (texture, params)));
|
||||
}
|
||||
grPaint->colorSampler(kBitmapTextureIdx)->setEffect(stage);
|
||||
grPaint->colorSampler(kBitmapTextureIdx)->setEffect(effect);
|
||||
fContext->drawRectToRect(*grPaint, dstRect, paintRect, &m);
|
||||
}
|
||||
|
||||
|
@ -1475,18 +1475,18 @@ static GrTexture* filter_texture(SkDevice* device, GrContext* context,
|
|||
desc.fWidth = SkScalarCeilToInt(rect.width());
|
||||
desc.fHeight = SkScalarCeilToInt(rect.height());
|
||||
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
||||
GrEffect* stage;
|
||||
GrEffect* effect;
|
||||
|
||||
if (filter->canFilterImageGPU()) {
|
||||
// Save the render target and set it to NULL, so we don't accidentally draw to it in the
|
||||
// filter. Also set the clip wide open and the matrix to identity.
|
||||
GrContext::AutoWideOpenIdentityDraw awo(context, NULL);
|
||||
texture = filter->onFilterImageGPU(&proxy, texture, rect);
|
||||
} else if (filter->asNewEffect(&stage, texture)) {
|
||||
} else if (filter->asNewEffect(&effect, texture)) {
|
||||
GrAutoScratchTexture dst(context, desc);
|
||||
apply_effect(context, texture, dst.texture(), rect, stage);
|
||||
apply_effect(context, texture, dst.texture(), rect, effect);
|
||||
texture = dst.detach();
|
||||
stage->unref();
|
||||
effect->unref();
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ class GrGLConfigConversionEffect : public GrGLLegacyProgramStage {
|
|||
public:
|
||||
GrGLConfigConversionEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& s) : INHERITED (factory) {
|
||||
const GrConfigConversionEffect& stage = static_cast<const GrConfigConversionEffect&>(s);
|
||||
fSwapRedAndBlue = stage.swapsRedAndBlue();
|
||||
fPMConversion = stage.pmConversion();
|
||||
const GrConfigConversionEffect& effect = static_cast<const GrConfigConversionEffect&>(s);
|
||||
fSwapRedAndBlue = effect.swapsRedAndBlue();
|
||||
fPMConversion = effect.pmConversion();
|
||||
}
|
||||
|
||||
virtual void emitVS(GrGLShaderBuilder* builder,
|
||||
|
@ -59,8 +59,8 @@ public:
|
|||
}
|
||||
|
||||
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);
|
||||
const GrConfigConversionEffect& effect = static_cast<const GrConfigConversionEffect&>(s);
|
||||
return static_cast<int>(effect.swapsRedAndBlue()) | (effect.pmConversion() << 1);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -177,24 +177,24 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
|
|||
|
||||
GrPaint paint;
|
||||
|
||||
SkAutoTUnref<GrEffect> pmToUPMStage1(SkNEW_ARGS(GrConfigConversionEffect,
|
||||
SkAutoTUnref<GrEffect> pmToUPMEffect1(SkNEW_ARGS(GrConfigConversionEffect,
|
||||
(dataTex, false, *pmToUPMRule)));
|
||||
SkAutoTUnref<GrEffect> upmToPMStage(SkNEW_ARGS(GrConfigConversionEffect,
|
||||
SkAutoTUnref<GrEffect> upmToPMEffect(SkNEW_ARGS(GrConfigConversionEffect,
|
||||
(readTex, false, *upmToPMRule)));
|
||||
SkAutoTUnref<GrEffect> pmToUPMStage2(SkNEW_ARGS(GrConfigConversionEffect,
|
||||
SkAutoTUnref<GrEffect> pmToUPMEffect2(SkNEW_ARGS(GrConfigConversionEffect,
|
||||
(tempTex, false, *pmToUPMRule)));
|
||||
|
||||
context->setRenderTarget(readTex->asRenderTarget());
|
||||
paint.colorSampler(0)->setEffect(pmToUPMStage1);
|
||||
paint.colorSampler(0)->setEffect(pmToUPMEffect1);
|
||||
context->drawRectToRect(paint, kDstRect, kSrcRect);
|
||||
|
||||
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead);
|
||||
|
||||
context->setRenderTarget(tempTex->asRenderTarget());
|
||||
paint.colorSampler(0)->setEffect(upmToPMStage);
|
||||
paint.colorSampler(0)->setEffect(upmToPMEffect);
|
||||
context->drawRectToRect(paint, kDstRect, kSrcRect);
|
||||
context->setRenderTarget(readTex->asRenderTarget());
|
||||
paint.colorSampler(0)->setEffect(pmToUPMStage2);
|
||||
paint.colorSampler(0)->setEffect(pmToUPMEffect2);
|
||||
context->drawRectToRect(paint, kDstRect, kSrcRect);
|
||||
|
||||
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead);
|
||||
|
|
|
@ -17,8 +17,7 @@ static const UniformHandle kInvalidUniformHandle = GrGLUniformManager::kInvalidU
|
|||
|
||||
class GrGLConvolutionEffect : public GrGLLegacyProgramStage {
|
||||
public:
|
||||
GrGLConvolutionEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage);
|
||||
GrGLConvolutionEffect(const GrProgramStageFactory&, const GrEffect&);
|
||||
|
||||
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
|
||||
virtual void emitVS(GrGLShaderBuilder* builder,
|
||||
|
@ -43,12 +42,12 @@ private:
|
|||
};
|
||||
|
||||
GrGLConvolutionEffect::GrGLConvolutionEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory)
|
||||
, fKernelUni(kInvalidUniformHandle)
|
||||
, fImageIncrementUni(kInvalidUniformHandle) {
|
||||
const GrConvolutionEffect& c =
|
||||
static_cast<const GrConvolutionEffect&>(stage);
|
||||
static_cast<const GrConvolutionEffect&>(effect);
|
||||
fRadius = c.radius();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
|
||||
class GrGLSingleTextureEffect : public GrGLLegacyProgramStage {
|
||||
public:
|
||||
GrGLSingleTextureEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage) : INHERITED (factory) { }
|
||||
GrGLSingleTextureEffect(const GrProgramStageFactory& factory, const GrEffect&)
|
||||
: INHERITED (factory) {
|
||||
}
|
||||
|
||||
virtual void emitVS(GrGLShaderBuilder* builder,
|
||||
const char* vertexCoords) SK_OVERRIDE { }
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
|
||||
class GrGLTextureDomainEffect : public GrGLLegacyProgramStage {
|
||||
public:
|
||||
GrGLTextureDomainEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage);
|
||||
GrGLTextureDomainEffect(const GrProgramStageFactory&, const GrEffect&);
|
||||
|
||||
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
|
||||
virtual void emitVS(GrGLShaderBuilder* builder,
|
||||
|
@ -33,7 +32,7 @@ private:
|
|||
};
|
||||
|
||||
GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrProgramStageFactory& factory,
|
||||
const GrEffect& stage)
|
||||
const GrEffect&)
|
||||
: INHERITED(factory)
|
||||
, fNameUni(GrGLUniformManager::kInvalidUniformHandle) {
|
||||
}
|
||||
|
|
|
@ -896,7 +896,7 @@ void GrGLProgram::initSamplerUniforms() {
|
|||
// Stage code generation
|
||||
|
||||
// TODO: Move this function to GrGLShaderBuilder
|
||||
GrGLProgramStage* GrGLProgram::GenStageCode(const GrEffect* stage,
|
||||
GrGLProgramStage* GrGLProgram::GenStageCode(const GrEffect* effect,
|
||||
const StageDesc& desc,
|
||||
StageUniforms* uniforms,
|
||||
const char* fsInColor, // NULL means no incoming color
|
||||
|
@ -904,7 +904,7 @@ GrGLProgramStage* GrGLProgram::GenStageCode(const GrEffect* stage,
|
|||
const char* vsInCoord,
|
||||
GrGLShaderBuilder* builder) {
|
||||
|
||||
GrGLProgramStage* glStage = stage->getFactory().createGLInstance(*stage);
|
||||
GrGLProgramStage* glStage = effect->getFactory().createGLInstance(*effect);
|
||||
|
||||
/// Vertex Shader Stuff
|
||||
|
||||
|
@ -932,13 +932,13 @@ GrGLProgramStage* GrGLProgram::GenStageCode(const GrEffect* stage,
|
|||
&varyingFSName);
|
||||
builder->setupTextureAccess(varyingFSName, texCoordVaryingType);
|
||||
|
||||
int numTextures = stage->numTextures();
|
||||
int numTextures = effect->numTextures();
|
||||
SkSTArray<8, GrGLShaderBuilder::TextureSampler> textureSamplers;
|
||||
|
||||
textureSamplers.push_back_n(numTextures);
|
||||
|
||||
for (int i = 0; i < numTextures; ++i) {
|
||||
textureSamplers[i].init(builder, &stage->textureAccess(i));
|
||||
textureSamplers[i].init(builder, &effect->textureAccess(i));
|
||||
uniforms->fSamplerUniforms.push_back(textureSamplers[i].fSamplerUniform);
|
||||
}
|
||||
|
||||
|
@ -956,7 +956,7 @@ GrGLProgramStage* GrGLProgram::GenStageCode(const GrEffect* stage,
|
|||
builder->fVSCode.appendf("\t{ // %s\n", glStage->name());
|
||||
builder->fFSCode.appendf("\t{ // %s \n", glStage->name());
|
||||
glStage->emitCode(builder,
|
||||
*stage,
|
||||
*effect,
|
||||
desc.fCustomStageKey,
|
||||
varyingVSName,
|
||||
fsOutColor,
|
||||
|
|
|
@ -175,7 +175,7 @@ private:
|
|||
|
||||
void genInputColor(GrGLShaderBuilder* builder, SkString* inColor);
|
||||
|
||||
static GrGLProgramStage* GenStageCode(const GrEffect* stage,
|
||||
static GrGLProgramStage* GenStageCode(const GrEffect* effect,
|
||||
const StageDesc& desc, // TODO: Eliminate this
|
||||
StageUniforms* stageUniforms, // TODO: Eliminate this
|
||||
const char* fsInColor, // NULL means no incoming color
|
||||
|
|
|
@ -20,11 +20,11 @@ GrGLProgramStage::~GrGLProgramStage() {
|
|||
void GrGLProgramStage::setData(const GrGLUniformManager&, const GrEffect&) {
|
||||
}
|
||||
|
||||
GrGLProgramStage::StageKey GrGLProgramStage::GenTextureKey(const GrEffect& stage,
|
||||
GrGLProgramStage::StageKey GrGLProgramStage::GenTextureKey(const GrEffect& effect,
|
||||
const GrGLCaps& caps) {
|
||||
StageKey key = 0;
|
||||
for (int index = 0; index < stage.numTextures(); ++index) {
|
||||
const GrTextureAccess& access = stage.textureAccess(index);
|
||||
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;
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
/** 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& stage);
|
||||
virtual void setData(const GrGLUniformManager&, const GrEffect&);
|
||||
|
||||
const char* name() const { return fFactory.name(); }
|
||||
|
||||
|
|
|
@ -199,11 +199,11 @@ void GrGpuGL::flushTextureMatrix(int s) {
|
|||
const GrDrawState& drawState = this->getDrawState();
|
||||
|
||||
// FIXME: Still assuming only a single texture per effect
|
||||
const GrEffect* stage = drawState.getSampler(s).getEffect();
|
||||
if (0 == stage->numTextures()) {
|
||||
const GrEffect* effect = drawState.getSampler(s).getEffect();
|
||||
if (0 == effect->numTextures()) {
|
||||
return;
|
||||
}
|
||||
const GrGLTexture* texture = static_cast<const GrGLTexture*>(stage->texture(0));
|
||||
const GrGLTexture* texture = static_cast<const GrGLTexture*>(effect->texture(0));
|
||||
if (NULL != texture) {
|
||||
|
||||
bool orientationChange = fCurrentProgram->fTextureOrientation[s] !=
|
||||
|
|
|
@ -44,9 +44,9 @@ const GrEffect* create_random_effect(StageDesc* stageDesc,
|
|||
// TODO: Remove GrRandom.
|
||||
SkRandom sk_random;
|
||||
sk_random.setSeed(random->nextU());
|
||||
GrEffect* stage = GrEffectTestFactory::CreateStage(&sk_random, context, dummyTextures);
|
||||
GrAssert(stage);
|
||||
return stage;
|
||||
GrEffect* effect = GrEffectTestFactory::CreateStage(&sk_random, context, dummyTextures);
|
||||
GrAssert(effect);
|
||||
return effect;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче