/** 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 GrEffect* asNewCustomStage(GrContext*) const;
+ virtual GrEffect* asNewEffect(GrContext*) const;
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
protected:
* in it. The caller assumes ownership of the stage, and it is up to the
* caller to unref it.
*/
- virtual bool asNewCustomStage(GrEffect** stage, GrTexture*) const;
+ virtual bool asNewEffect(GrEffect** stage, GrTexture*) const;
/**
* Returns true if the filter can be processed on the GPU. This is most
* often used for multi-pass effects, where intermediate results must be
- * rendered to textures. For single-pass effects, use asNewCustomStage().
+ * rendered to textures. For single-pass effects, use asNewEffect().
* The default implementation returns false.
*/
virtual bool canFilterImageGPU() const;
/**
* If the shader subclass has a GrEffect implementation, this installs
- * a custom stage on the sampler. A GrContext pointer is required since custom
+ * an effect 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
* GrEffect factory.
*/
- virtual bool asNewCustomStage(GrContext* context, GrSamplerState* sampler) const;
+ virtual bool asNewEffect(GrContext* context, GrSamplerState* sampler) const;
//////////////////////////////////////////////////////////////////////////
// Factory methods for stock shaders
virtual uint32_t getFlags() SK_OVERRIDE;
virtual bool asColorMatrix(SkScalar matrix[20]) SK_OVERRIDE;
#if SK_SUPPORT_GPU
- virtual GrEffect* asNewCustomStage(GrContext*) const SK_OVERRIDE;
+ virtual GrEffect* asNewEffect(GrContext*) const SK_OVERRIDE;
#endif
struct State {
public:
SkMagnifierImageFilter(SkRect srcRect, SkScalar inset);
- virtual bool asNewCustomStage(GrEffect** stage,
- GrTexture* texture) const SK_OVERRIDE;
+ virtual bool asNewEffect(GrEffect** stage,
+ GrTexture* texture) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMagnifierImageFilter)
SkBitmap* result, SkIPoint* loc) SK_OVERRIDE;
#if SK_SUPPORT_GPU
- virtual bool asNewCustomStage(GrEffect** stage, GrTexture*) const SK_OVERRIDE;
+ virtual bool asNewEffect(GrEffect** stage, GrTexture*) const SK_OVERRIDE;
#endif
private:
* found in the LICENSE file.
*/
-#ifndef GrCustomStage_DEFINED
-#define GrCustomStage_DEFINED
+#ifndef GrEffect_DEFINED
+#define GrEffect_DEFINED
#include "GrRefCnt.h"
#include "GrNoncopyable.h"
GrGLProgramStage created by the factory.
Example:
- class MyCustomStage : public GrEffect {
+ class MyCustomEffect : public GrEffect {
...
virtual const GrProgramStageFactory& getFactory() const
SK_OVERRIDE {
- return GrTProgramStageFactory<MyCustomStage>::getInstance();
+ return GrTProgramStageFactory<MyCustomEffect>::getInstance();
}
...
};
/** Returns a value that idenitifes the GLSL shader code generated by
a GrEffect. This enables caching of generated shaders. Part of the
- id identifies the GrCustomShader subclass. The remainder is based
+ 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,
return SkUnPreMultiply::PMColorToColor(dst);
}
-GrEffect* SkColorFilter::asNewCustomStage(GrContext*) const {
+GrEffect* SkColorFilter::asNewEffect(GrContext*) const {
return NULL;
}
return true;
}
-bool SkImageFilter::asNewCustomStage(GrEffect**, GrTexture*) const {
+bool SkImageFilter::asNewEffect(GrEffect**, GrTexture*) const {
return false;
}
return kNone_GradientType;
}
-bool SkShader::asNewCustomStage(GrContext*, GrSamplerState*) const {
+bool SkShader::asNewEffect(GrContext*, GrSamplerState*) const {
return false;
}
return SkNEW_ARGS(ColorMatrixEffect, (colorMatrix));
}
-GrEffect* SkColorMatrixFilter::asNewCustomStage(GrContext*) const {
+GrEffect* SkColorMatrixFilter::asNewEffect(GrContext*) const {
return SkNEW_ARGS(ColorMatrixEffect, (fMatrix));
}
SkScalar kd, SkImageFilter* input);
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiffuseLightingImageFilter)
- virtual bool asNewCustomStage(GrEffect** stage, GrTexture*) const SK_OVERRIDE;
+ virtual bool asNewEffect(GrEffect** stage, GrTexture*) const SK_OVERRIDE;
SkScalar kd() const { return fKD; }
protected:
SkSpecularLightingImageFilter(SkLight* light, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, SkImageFilter* input);
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSpecularLightingImageFilter)
- virtual bool asNewCustomStage(GrEffect** stage, GrTexture*) const SK_OVERRIDE;
+ virtual bool asNewEffect(GrEffect** stage, GrTexture*) const SK_OVERRIDE;
SkScalar ks() const { return fKS; }
SkScalar shininess() const { return fShininess; }
return true;
}
-bool SkDiffuseLightingImageFilter::asNewCustomStage(GrEffect** stage,
- GrTexture* texture) const {
+bool SkDiffuseLightingImageFilter::asNewEffect(GrEffect** stage,
+ GrTexture* texture) const {
#if SK_SUPPORT_GPU
if (stage) {
SkScalar scale = SkScalarMul(surfaceScale(), SkIntToScalar(255));
return true;
}
-bool SkSpecularLightingImageFilter::asNewCustomStage(GrEffect** stage,
- GrTexture* texture) const {
+bool SkSpecularLightingImageFilter::asNewEffect(GrEffect** stage,
+ GrTexture* texture) const {
#if SK_SUPPORT_GPU
if (stage) {
SkScalar scale = SkScalarMul(surfaceScale(), SkIntToScalar(255));
inset));
GrSamplerState sampler;
GrEffect* stage;
- filter->asNewCustomStage(&stage, textures[0]);
+ filter->asNewEffect(&stage, textures[0]);
GrAssert(NULL != stage);
return stage;
}
SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0);
}
-bool SkMagnifierImageFilter::asNewCustomStage(GrEffect** stage,
- GrTexture* texture) const {
+bool SkMagnifierImageFilter::asNewEffect(GrEffect** stage,
+ GrTexture* texture) const {
#if SK_SUPPORT_GPU
if (stage) {
*stage =
}
-bool SkMatrixConvolutionImageFilter::asNewCustomStage(GrEffect** stage,
- GrTexture* texture) const {
+bool SkMatrixConvolutionImageFilter::asNewEffect(GrEffect** stage,
+ GrTexture* texture) const {
bool ok = fKernelSize.width() * fKernelSize.height() <= MAX_KERNEL_SIZE;
if (ok && stage) {
*stage = SkNEW_ARGS(GrMatrixConvolutionEffect, (texture,
virtual bool asComponentTable(SkBitmap* table) const SK_OVERRIDE;
#if SK_SUPPORT_GPU
- virtual GrEffect* asNewCustomStage(GrContext* context) const SK_OVERRIDE;
+ virtual GrEffect* asNewEffect(GrContext* context) const SK_OVERRIDE;
#endif
virtual void filterSpan(const SkPMColor src[], int count,
return SkNEW_ARGS(ColorTableEffect, (textures[GrEffectUnitTest::kAlphaTextureIdx]));
}
-GrEffect* SkTable_ColorFilter::asNewCustomStage(GrContext* context) const {
+GrEffect* SkTable_ColorFilter::asNewEffect(GrContext* context) const {
SkBitmap bitmap;
this->asComponentTable(&bitmap);
- // passing NULL because this custom effect does no tiling or filtering.
+ // passing NULL because this effect does no tiling or filtering.
GrTexture* texture = GrLockCachedBitmapTexture(context, bitmap, NULL);
GrEffect* stage = SkNEW_ARGS(ColorTableEffect, (texture));
///////////////////////////////////////////////////////////////////////////////
-// Base class for GL gradient custom stages
+// Base class for GL gradient effects
class GrGLGradientStage : public GrGLLegacyProgramStage {
public:
colors, stops, colorCount,
tm));
GrSamplerState sampler;
- shader->asNewCustomStage(context, &sampler);
+ shader->asNewEffect(context, &sampler);
GrAssert(NULL != sampler.getEffect());
- // const_cast and ref is a hack! Will remove when asNewCustomStage returns GrEffect*
+ // const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
sampler.getEffect()->ref();
return const_cast<GrEffect*>(sampler.getEffect());
}
/////////////////////////////////////////////////////////////////////
-bool SkLinearGradient::asNewCustomStage(GrContext* context, GrSamplerState* sampler) const {
+bool SkLinearGradient::asNewEffect(GrContext* context, GrSamplerState* sampler) const {
SkASSERT(NULL != context && NULL != sampler);
SkAutoTUnref<GrEffect> stage(SkNEW_ARGS(GrLinearGradient, (context, *this, fTileMode)));
#else
-bool SkLinearGradient::asNewCustomStage(GrContext*, GrSamplerState*) const {
+bool SkLinearGradient::asNewEffect(GrContext*, GrSamplerState*) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count) SK_OVERRIDE;
virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const SK_OVERRIDE;
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewCustomStage(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
+ virtual bool asNewEffect(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLinearGradient)
colors, stops, colorCount,
tm));
GrSamplerState sampler;
- shader->asNewCustomStage(context, &sampler);
+ shader->asNewEffect(context, &sampler);
GrAssert(NULL != sampler.getEffect());
- // const_cast and ref is a hack! Will remove when asNewCustomStage returns GrEffect*
+ // const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
sampler.getEffect()->ref();
return const_cast<GrEffect*>(sampler.getEffect());
}
/////////////////////////////////////////////////////////////////////
-bool SkRadialGradient::asNewCustomStage(GrContext* context, GrSamplerState* sampler) const {
+bool SkRadialGradient::asNewEffect(GrContext* context, GrSamplerState* sampler) const {
SkASSERT(NULL != context && NULL != sampler);
SkAutoTUnref<GrEffect> stage(SkNEW_ARGS(GrRadialGradient, (context, *this, fTileMode)));
#else
-bool SkRadialGradient::asNewCustomStage(GrContext*, GrSamplerState*) const {
+bool SkRadialGradient::asNewEffect(GrContext*, GrSamplerState*) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
SkMatrix* matrix,
TileMode* xy) const SK_OVERRIDE;
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewCustomStage(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
+ virtual bool asNewEffect(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRadialGradient)
SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, center.fY,
colors, stops, colorCount));
GrSamplerState sampler;
- shader->asNewCustomStage(context, &sampler);
+ shader->asNewEffect(context, &sampler);
GrAssert(NULL != sampler.getEffect());
- // const_cast and ref is a hack! Will remove when asNewCustomStage returns GrEffect*
+ // const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
sampler.getEffect()->ref();
return const_cast<GrEffect*>(sampler.getEffect());
}
/////////////////////////////////////////////////////////////////////
-bool SkSweepGradient::asNewCustomStage(GrContext* context, GrSamplerState* sampler) const {
+bool SkSweepGradient::asNewEffect(GrContext* context, GrSamplerState* sampler) const {
SkAutoTUnref<GrEffect> stage(SkNEW_ARGS(GrSweepGradient, (context, *this)));
#else
-bool SkSweepGradient::asNewCustomStage(GrContext*, GrSamplerState*) const {
+bool SkSweepGradient::asNewEffect(GrContext*, GrSamplerState*) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewCustomStage(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
+ virtual bool asNewEffect(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSweepGradient)
colors, stops, colorCount,
tm));
GrSamplerState sampler;
- shader->asNewCustomStage(context, &sampler);
+ shader->asNewEffect(context, &sampler);
GrAssert(NULL != sampler.getEffect());
- // const_cast and ref is a hack! Will remove when asNewCustomStage returns GrEffect*
+ // const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
sampler.getEffect()->ref();
return const_cast<GrEffect*>(sampler.getEffect());
}
/////////////////////////////////////////////////////////////////////
-bool SkTwoPointConicalGradient::asNewCustomStage(GrContext* context,
- GrSamplerState* sampler) const {
+bool SkTwoPointConicalGradient::asNewEffect(GrContext* context,
+ GrSamplerState* sampler) const {
SkASSERT(NULL != context && NULL != sampler);
SkMatrix matrix;
#else
-bool SkTwoPointConicalGradient::asNewCustomStage(GrContext*, GrSamplerState*) const {
+bool SkTwoPointConicalGradient::asNewEffect(GrContext*, GrSamplerState*) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
SkMatrix* matrix,
TileMode* xy) const;
virtual SkShader::GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewCustomStage(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
+ virtual bool asNewEffect(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
SkScalar getCenterX1() const { return SkPoint::Distance(fCenter1, fCenter2); }
SkScalar getStartRadius() const { return fRadius1; }
colors, stops, colorCount,
tm));
GrSamplerState sampler;
- shader->asNewCustomStage(context, &sampler);
+ shader->asNewEffect(context, &sampler);
GrAssert(NULL != sampler.getEffect());
- // const_cast and ref is a hack! Will remove when asNewCustomStage returns GrEffect*
+ // const_cast and ref is a hack! Will remove when asNewEffect returns GrEffect*
sampler.getEffect()->ref();
return const_cast<GrEffect*>(sampler.getEffect());
}
/////////////////////////////////////////////////////////////////////
-bool SkTwoPointRadialGradient::asNewCustomStage(GrContext* context,
- GrSamplerState* sampler) const {
+bool SkTwoPointRadialGradient::asNewEffect(GrContext* context,
+ GrSamplerState* sampler) const {
SkASSERT(NULL != context && NULL != sampler);
SkScalar diffLen = fDiff.length();
SkMatrix matrix;
#else
-bool SkTwoPointRadialGradient::asNewCustomStage(GrContext*, GrSamplerState*) const {
+bool SkTwoPointRadialGradient::asNewEffect(GrContext*, GrSamplerState*) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
SkMatrix* matrix,
TileMode* xy) const SK_OVERRIDE;
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewCustomStage(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
+ virtual bool asNewEffect(GrContext* context, GrSamplerState* sampler) const SK_OVERRIDE;
virtual void shadeSpan(int x, int y, SkPMColor* dstCParam,
int count) SK_OVERRIDE;
}
#endif
-class GrCustomStage_Globals {
+class GrEffect_Globals {
public:
static GrMemoryPool* GetTLS() {
return (GrMemoryPool*)SkTLS::Get(CreateTLS, DeleteTLS);
}
void * GrEffect::operator new(size_t size) {
- return GrCustomStage_Globals::GetTLS()->allocate(size);
+ return GrEffect_Globals::GetTLS()->allocate(size);
}
void GrEffect::operator delete(void* target) {
- GrCustomStage_Globals::GetTLS()->release(target);
+ GrEffect_Globals::GetTLS()->release(target);
}
SkColor filtered = colorFilter->filterColor(skPaint.getColor());
grPaint->setColor(SkColor2GrColor(filtered));
} else {
- SkAutoTUnref<GrEffect> stage(colorFilter->asNewCustomStage(dev->context()));
+ SkAutoTUnref<GrEffect> stage(colorFilter->asNewEffect(dev->context()));
if (NULL != stage.get()) {
grPaint->colorSampler(kColorFilterTextureIdx)->setEffect(stage);
} else {
- // TODO: rewrite this using asNewCustomStage()
+ // TODO: rewrite this using asNewEffect()
SkColor color;
SkXfermode::Mode filterMode;
if (colorFilter->asColorMode(&color, &filterMode)) {
}
GrSamplerState* sampler = grPaint->colorSampler(kShaderTextureIdx);
- if (shader->asNewCustomStage(dev->context(), sampler)) {
+ if (shader->asNewEffect(dev->context(), sampler)) {
return true;
}
// 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->asNewCustomStage(&stage, texture)) {
+ } else if (filter->asNewEffect(&stage, texture)) {
GrAutoScratchTexture dst(context, desc);
apply_effect(context, texture, dst.texture(), rect, stage);
texture = dst.detach();
}
bool SkGpuDevice::canHandleImageFilter(SkImageFilter* filter) {
- if (!filter->asNewCustomStage(NULL, NULL) &&
+ if (!filter->asNewEffect(NULL, NULL) &&
!filter->canFilterImageGPU()) {
return false;
}
* found in the LICENSE file.
*/
-#ifndef GrGLCustomStage_DEFINED
-#define GrGLCustomStage_DEFINED
+#ifndef GrGLProgramStage_DEFINED
+#define GrGLProgramStage_DEFINED
#include "GrAllocator.h"
#include "GrEffect.h"
GLSL code that implements a GrEffect and for uploading uniforms at draw time. They also
must have a function:
static inline StageKey GenKey(const GrEffect&, const GrGLCaps&)
- that is used to implement a program cache. When two GrCustomEffects produce the same key this
- means that their GrGLProgramStages would emit the same GLSL code.
+ that is used to implement a program cache. When two GrEffects produce the same key this means
+ that their GrGLProgramStages would emit the same GLSL code.
These objects are created by the factory object returned by the GrEffect::getFactory().
*/
void GrGLShaderBuilder::setupTextureAccess(const char* varyingFSName, GrSLType varyingType) {
// FIXME: We don't know how the effect will manipulate the coords. So we give up on using
- // projective texturing and always give the stage 2D coords. This will be fixed when custom
- // stages are responsible for setting up their own tex coords / tex matrices.
+ // projective texturing and always give the stage 2D coords. This will be fixed when effects
+ // are responsible for setting up their own tex coords / tex matrices.
switch (varyingType) {
case kVec2f_GrSLType:
fDefaultTexCoordsName = varyingFSName;
const Uniform& uni = fUniforms[handle_to_index(u)];
GrAssert(uni.fType == kMat33f_GrSLType);
GrAssert(GrGLShaderVar::kNonArray == uni.fArrayCount);
- // TODO: Re-enable this assert once texture matrices aren't forced on all custom effects
+ // TODO: Re-enable this assert once texture matrices aren't forced on all effects
// GrAssert(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation);
if (kUnusedUniform != uni.fFSLocation) {
GR_GL_CALL(fContext.interface(), UniformMatrix3fv(uni.fFSLocation, 1, false, matrix));