aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoshualitt <joshualitt@chromium.org>2014-09-23 09:50:21 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-23 09:50:21 -0700
commitb0a8a377f832c59cee939ad721e1f87d378b7142 (patch)
tree7edeac33c817af28d73f3fbe1b31776ac34e8773
parente51ac563de24ed4b25fde97c225580a30a55e9ca (diff)
downloadskia-b0a8a377f832c59cee939ad721e1f87d378b7142.tar.gz
Patch to create a distinct geometry processor. The vast majority of this patch
is just a rename. The meat is in GrGeometryProcessor, GrProcessor, GrGL*Processor, GrProcessorStage, Gr*BackendProcessorFactory, GrProcessUnitTestFactory, and the builders BUG=skia: R=bsalomon@google.com Author: joshualitt@chromium.org Review URL: https://codereview.chromium.org/582963002
-rw-r--r--gm/beziereffects.cpp38
-rw-r--r--gm/convexpolyeffect.cpp22
-rw-r--r--gm/rrects.cpp11
-rw-r--r--gm/texdata.cpp2
-rw-r--r--gm/texturedomaineffect.cpp6
-rw-r--r--gm/yuvtorgbeffect.cpp6
-rw-r--r--gyp/gpu.gypi14
-rw-r--r--include/core/SkColorFilter.h4
-rw-r--r--include/core/SkColorShader.h5
-rw-r--r--include/core/SkImageFilter.h20
-rw-r--r--include/core/SkMaskFilter.h18
-rw-r--r--include/core/SkShader.h7
-rw-r--r--include/core/SkXfermode.h18
-rw-r--r--include/effects/SkColorMatrixFilter.h2
-rw-r--r--include/effects/SkLumaColorFilter.h2
-rw-r--r--include/effects/SkMagnifierImageFilter.h4
-rw-r--r--include/effects/SkMatrixConvolutionImageFilter.h6
-rw-r--r--include/effects/SkPerlinNoiseShader.h4
-rw-r--r--include/gpu/GrBackendProcessorFactory.h (renamed from include/gpu/GrBackendEffectFactory.h)86
-rw-r--r--include/gpu/GrContext.h12
-rw-r--r--include/gpu/GrCoordTransform.h10
-rw-r--r--include/gpu/GrEffectUnitTest.h101
-rw-r--r--include/gpu/GrGeometryProcessor.h66
-rw-r--r--include/gpu/GrPaint.h53
-rw-r--r--include/gpu/GrProcessor.h (renamed from include/gpu/GrEffect.h)134
-rw-r--r--include/gpu/GrProcessorStage.h (renamed from include/gpu/GrEffectStage.h)65
-rw-r--r--include/gpu/GrProcessorUnitTest.h128
-rw-r--r--include/gpu/GrProgramElement.h4
-rw-r--r--include/gpu/GrProgramElementRef.h6
-rw-r--r--include/gpu/GrTBackendEffectFactory.h76
-rw-r--r--include/gpu/GrTBackendProcessorFactory.h101
-rw-r--r--include/gpu/GrTextureAccess.h8
-rw-r--r--include/gpu/GrTypesPriv.h68
-rw-r--r--include/gpu/SkGr.h2
-rw-r--r--src/core/SkBitmapProcShader.cpp15
-rw-r--r--src/core/SkBitmapProcShader.h3
-rw-r--r--src/core/SkColorFilter.cpp2
-rw-r--r--src/core/SkImageFilter.cpp13
-rw-r--r--src/core/SkLocalMatrixShader.h11
-rw-r--r--src/core/SkMaskFilter.cpp2
-rw-r--r--src/core/SkPictureShader.cpp13
-rw-r--r--src/core/SkPictureShader.h4
-rw-r--r--src/core/SkShader.cpp17
-rw-r--r--src/core/SkXfermode.cpp78
-rw-r--r--src/core/SkXfermode_proccoeff.h4
-rw-r--r--src/effects/SkAlphaThresholdFilter.cpp84
-rw-r--r--src/effects/SkArithmeticMode.cpp91
-rw-r--r--src/effects/SkBlurMaskFilter.cpp136
-rw-r--r--src/effects/SkColorFilters.cpp64
-rw-r--r--src/effects/SkColorMatrixFilter.cpp50
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp83
-rw-r--r--src/effects/SkGpuBlurUtils.cpp16
-rw-r--r--src/effects/SkLightingImageFilter.cpp220
-rw-r--r--src/effects/SkLumaColorFilter.cpp32
-rw-r--r--src/effects/SkMagnifierImageFilter.cpp85
-rw-r--r--src/effects/SkMatrixConvolutionImageFilter.cpp28
-rw-r--r--src/effects/SkMorphologyImageFilter.cpp77
-rw-r--r--src/effects/SkPerlinNoiseShader.cpp114
-rw-r--r--src/effects/SkTableColorFilter.cpp68
-rw-r--r--src/effects/SkXfermodeImageFilter.cpp10
-rw-r--r--src/effects/gradients/SkGradientShader.cpp16
-rw-r--r--src/effects/gradients/SkGradientShaderPriv.h22
-rw-r--r--src/effects/gradients/SkLinearGradient.cpp61
-rw-r--r--src/effects/gradients/SkLinearGradient.h4
-rw-r--r--src/effects/gradients/SkRadialGradient.cpp63
-rw-r--r--src/effects/gradients/SkRadialGradient.h3
-rw-r--r--src/effects/gradients/SkSweepGradient.cpp56
-rw-r--r--src/effects/gradients/SkSweepGradient.h4
-rw-r--r--src/effects/gradients/SkTwoPointConicalGradient.cpp15
-rw-r--r--src/effects/gradients/SkTwoPointConicalGradient.h4
-rw-r--r--src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp354
-rw-r--r--src/effects/gradients/SkTwoPointConicalGradient_gpu.h6
-rw-r--r--src/effects/gradients/SkTwoPointRadialGradient.cpp83
-rw-r--r--src/effects/gradients/SkTwoPointRadialGradient.h8
-rw-r--r--src/gpu/GrAAConvexPathRenderer.cpp54
-rw-r--r--src/gpu/GrAAHairLinePathRenderer.cpp22
-rw-r--r--src/gpu/GrAARectRenderer.cpp96
-rwxr-xr-xsrc/gpu/GrBitmapTextContext.cpp9
-rw-r--r--src/gpu/GrBitmapTextContext.h15
-rw-r--r--src/gpu/GrClipMaskManager.cpp28
-rwxr-xr-xsrc/gpu/GrContext.cpp52
-rwxr-xr-xsrc/gpu/GrDistanceFieldTextContext.cpp36
-rw-r--r--src/gpu/GrDistanceFieldTextContext.h11
-rw-r--r--src/gpu/GrDrawState.cpp6
-rw-r--r--src/gpu/GrDrawState.h61
-rw-r--r--src/gpu/GrDrawTarget.cpp12
-rw-r--r--src/gpu/GrOptDrawState.cpp27
-rw-r--r--src/gpu/GrOvalRenderer.cpp190
-rw-r--r--src/gpu/GrPaint.cpp20
-rw-r--r--src/gpu/GrPathRenderer.h6
-rw-r--r--src/gpu/GrProcessor.cpp (renamed from src/gpu/GrEffect.cpp)36
-rw-r--r--src/gpu/GrRODrawState.cpp49
-rw-r--r--src/gpu/GrRODrawState.h20
-rw-r--r--src/gpu/GrSWMaskHelper.cpp2
-rw-r--r--src/gpu/SkGpuDevice.cpp18
-rw-r--r--src/gpu/SkGr.cpp41
-rw-r--r--src/gpu/effects/GrBezierEffect.cpp204
-rw-r--r--src/gpu/effects/GrBezierEffect.h110
-rw-r--r--src/gpu/effects/GrBicubicEffect.cpp50
-rw-r--r--src/gpu/effects/GrBicubicEffect.h24
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.cpp74
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.h18
-rw-r--r--src/gpu/effects/GrConvexPolyEffect.cpp170
-rw-r--r--src/gpu/effects/GrConvexPolyEffect.h34
-rw-r--r--src/gpu/effects/GrConvolutionEffect.cpp58
-rw-r--r--src/gpu/effects/GrConvolutionEffect.h32
-rw-r--r--src/gpu/effects/GrCustomCoordsTextureEffect.cpp38
-rw-r--r--src/gpu/effects/GrCustomCoordsTextureEffect.h12
-rw-r--r--src/gpu/effects/GrDashingEffect.cpp197
-rw-r--r--src/gpu/effects/GrDashingEffect.h7
-rwxr-xr-xsrc/gpu/effects/GrDistanceFieldTextureEffect.cpp98
-rw-r--r--src/gpu/effects/GrDistanceFieldTextureEffect.h38
-rw-r--r--src/gpu/effects/GrDitherEffect.cpp52
-rw-r--r--src/gpu/effects/GrDitherEffect.h4
-rw-r--r--src/gpu/effects/GrGeometryProcessor.h41
-rw-r--r--src/gpu/effects/GrMatrixConvolutionEffect.cpp83
-rw-r--r--src/gpu/effects/GrMatrixConvolutionEffect.h46
-rw-r--r--src/gpu/effects/GrOvalEffect.cpp190
-rw-r--r--src/gpu/effects/GrOvalEffect.h4
-rw-r--r--src/gpu/effects/GrRRectEffect.cpp193
-rw-r--r--src/gpu/effects/GrRRectEffect.h4
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.cpp34
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.h30
-rw-r--r--src/gpu/effects/GrSingleTextureEffect.h6
-rw-r--r--src/gpu/effects/GrTextureDomain.cpp76
-rw-r--r--src/gpu/effects/GrTextureDomain.h37
-rw-r--r--src/gpu/effects/GrYUVtoRGBEffect.cpp47
-rw-r--r--src/gpu/effects/GrYUVtoRGBEffect.h6
-rw-r--r--src/gpu/gl/GrGLGeometryProcessor.h27
-rw-r--r--src/gpu/gl/GrGLProcessor.h (renamed from src/gpu/gl/GrGLEffect.h)101
-rw-r--r--src/gpu/gl/GrGLProgram.cpp20
-rw-r--r--src/gpu/gl/GrGLProgram.h18
-rw-r--r--src/gpu/gl/GrGLProgramDesc.cpp171
-rw-r--r--src/gpu/gl/GrGLProgramDesc.h41
-rw-r--r--src/gpu/gl/GrGLProgramEffects.cpp82
-rw-r--r--src/gpu/gl/GrGLProgramEffects.h49
-rw-r--r--src/gpu/gl/GrGpuGL.h6
-rw-r--r--src/gpu/gl/GrGpuGL_program.cpp16
-rw-r--r--src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp40
-rw-r--r--src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.h14
-rw-r--r--src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp17
-rw-r--r--src/gpu/gl/builders/GrGLFragmentShaderBuilder.h81
-rw-r--r--src/gpu/gl/builders/GrGLFullProgramBuilder.cpp52
-rw-r--r--src/gpu/gl/builders/GrGLFullProgramBuilder.h61
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.cpp24
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.h89
-rw-r--r--src/gpu/gl/builders/GrGLShaderBuilder.h12
-rw-r--r--src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp8
-rw-r--r--src/gpu/gl/builders/GrGLVertexShaderBuilder.h2
-rw-r--r--tests/GLProgramsTest.cpp68
-rw-r--r--tests/GpuColorFilterTest.cpp4
151 files changed, 3645 insertions, 3314 deletions
diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp
index 924f2a5c4..ec7e83e76 100644
--- a/gm/beziereffects.cpp
+++ b/gm/beziereffects.cpp
@@ -26,7 +26,7 @@
namespace {
extern const GrVertexAttrib kAttribs[] = {
{kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
- {kVec4f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding}
+ {kVec4f_GrVertexAttribType, sizeof(SkPoint), kGeometryProcessor_GrVertexAttribBinding}
};
}
@@ -92,17 +92,17 @@ protected:
{rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)},
{rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}
};
- for(int edgeType = 0; edgeType < kGrEffectEdgeTypeCnt; ++edgeType) {
- SkAutoTUnref<GrEffect> effect;
+ for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType) {
+ SkAutoTUnref<GrGeometryProcessor> gp;
{ // scope to contain GrTestTarget
GrTestTarget tt;
context->getTestTarget(&tt);
if (NULL == tt.target()) {
continue;
}
- GrEffectEdgeType et = (GrEffectEdgeType)edgeType;
- effect.reset(GrCubicEffect::Create(et, *tt.target()->caps()));
- if (!effect) {
+ GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType;
+ gp.reset(GrCubicEffect::Create(et, *tt.target()->caps()));
+ if (!gp) {
continue;
}
}
@@ -170,7 +170,7 @@ protected:
GrDrawState* drawState = tt.target()->drawState();
drawState->setVertexAttribs<kAttribs>(2, sizeof(Vertex));
- drawState->setGeometryProcessor(effect);
+ drawState->setGeometryProcessor(gp);
drawState->setRenderTarget(rt);
drawState->setColor(0xff000000);
@@ -250,17 +250,17 @@ protected:
{rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}
};
SkScalar weight = rand.nextRangeF(0.f, 2.f);
- for(int edgeType = 0; edgeType < kGrEffectEdgeTypeCnt; ++edgeType) {
- SkAutoTUnref<GrEffect> effect;
+ for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType) {
+ SkAutoTUnref<GrGeometryProcessor> gp;
{ // scope to contain GrTestTarget
GrTestTarget tt;
context->getTestTarget(&tt);
if (NULL == tt.target()) {
continue;
}
- GrEffectEdgeType et = (GrEffectEdgeType)edgeType;
- effect.reset(GrConicEffect::Create(et, *tt.target()->caps()));
- if (!effect) {
+ GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType;
+ gp.reset(GrConicEffect::Create(et, *tt.target()->caps()));
+ if (!gp) {
continue;
}
}
@@ -325,7 +325,7 @@ protected:
GrDrawState* drawState = tt.target()->drawState();
drawState->setVertexAttribs<kAttribs>(2, sizeof(Vertex));
- drawState->setGeometryProcessor(effect);
+ drawState->setGeometryProcessor(gp);
drawState->setRenderTarget(rt);
drawState->setColor(0xff000000);
@@ -439,17 +439,17 @@ protected:
{rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)},
{rand.nextRangeF(0.f, w), rand.nextRangeF(0.f, h)}
};
- for(int edgeType = 0; edgeType < kGrEffectEdgeTypeCnt; ++edgeType) {
- SkAutoTUnref<GrEffect> effect;
+ for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType) {
+ SkAutoTUnref<GrGeometryProcessor> gp;
{ // scope to contain GrTestTarget
GrTestTarget tt;
context->getTestTarget(&tt);
if (NULL == tt.target()) {
continue;
}
- GrEffectEdgeType et = (GrEffectEdgeType)edgeType;
- effect.reset(GrQuadEffect::Create(et, *tt.target()->caps()));
- if (!effect) {
+ GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType;
+ gp.reset(GrQuadEffect::Create(et, *tt.target()->caps()));
+ if (!gp) {
continue;
}
}
@@ -509,7 +509,7 @@ protected:
GrDrawState* drawState = tt.target()->drawState();
drawState->setVertexAttribs<kAttribs>(2, sizeof(Vertex));
- drawState->setGeometryProcessor(effect);
+ drawState->setGeometryProcessor(gp);
drawState->setRenderTarget(rt);
drawState->setColor(0xff000000);
diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp
index 4f84c615d..e567208c1 100644
--- a/gm/convexpolyeffect.cpp
+++ b/gm/convexpolyeffect.cpp
@@ -24,7 +24,7 @@
namespace skiagm {
/**
- * This GM directly exercises a GrEffect that draws convex polygons.
+ * This GM directly exercises a GrProcessor that draws convex polygons.
*/
class ConvexPolyEffect : public GM {
public:
@@ -113,7 +113,7 @@ protected:
const SkPath* path = iter.get();
SkScalar x = 0;
- for (int et = 0; et < kGrEffectEdgeTypeCnt; ++et) {
+ for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) {
GrTestTarget tt;
context->getTestTarget(&tt);
if (NULL == tt.target()) {
@@ -127,12 +127,12 @@ protected:
m.setTranslate(x, y);
path->transform(m, &p);
- GrEffectEdgeType edgeType = (GrEffectEdgeType) et;
- SkAutoTUnref<GrEffect> effect(GrConvexPolyEffect::Create(edgeType, p));
- if (!effect) {
+ GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
+ SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(edgeType, p));
+ if (!fp) {
continue;
}
- drawState->addCoverageEffect(effect);
+ drawState->addCoverageProcessor(fp);
drawState->setIdentityViewMatrix();
drawState->setRenderTarget(rt);
drawState->setColor(0xff000000);
@@ -170,7 +170,7 @@ protected:
SkScalar x = 0;
- for (int et = 0; et < kGrEffectEdgeTypeCnt; ++et) {
+ for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) {
GrTestTarget tt;
context->getTestTarget(&tt);
if (NULL == tt.target()) {
@@ -179,14 +179,14 @@ protected:
}
SkRect rect = *iter.get();
rect.offset(x, y);
- GrEffectEdgeType edgeType = (GrEffectEdgeType) et;
- SkAutoTUnref<GrEffect> effect(GrConvexPolyEffect::Create(edgeType, rect));
- if (!effect) {
+ GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
+ SkAutoTUnref<GrFragmentProcessor> fp(GrConvexPolyEffect::Create(edgeType, rect));
+ if (!fp) {
continue;
}
GrDrawState* drawState = tt.target()->drawState();
- drawState->addCoverageEffect(effect);
+ drawState->addCoverageProcessor(fp);
drawState->setIdentityViewMatrix();
drawState->setRenderTarget(rt);
drawState->setColor(0xff000000);
diff --git a/gm/rrects.cpp b/gm/rrects.cpp
index 8f4cb3a8e..b0496e3d7 100644
--- a/gm/rrects.cpp
+++ b/gm/rrects.cpp
@@ -86,7 +86,7 @@ protected:
#endif
#if SK_SUPPORT_GPU
- int lastEdgeType = (kEffect_Type == fType) ? kLast_GrEffectEdgeType: 0;
+ int lastEdgeType = (kEffect_Type == fType) ? kLast_GrProcessorEdgeType: 0;
#else
int lastEdgeType = 0;
#endif
@@ -116,10 +116,11 @@ protected:
SkRRect rrect = fRRects[curRRect];
rrect.offset(SkIntToScalar(x), SkIntToScalar(y));
- GrEffectEdgeType edgeType = (GrEffectEdgeType) et;
- SkAutoTUnref<GrEffect> effect(GrRRectEffect::Create(edgeType, rrect));
- if (effect) {
- drawState->addCoverageEffect(effect);
+ GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
+ SkAutoTUnref<GrFragmentProcessor> fp(GrRRectEffect::Create(edgeType,
+ rrect));
+ if (fp) {
+ drawState->addCoverageProcessor(fp);
drawState->setIdentityViewMatrix();
drawState->setRenderTarget(rt);
drawState->setColor(0xff000000);
diff --git a/gm/texdata.cpp b/gm/texdata.cpp
index 8f7114168..b979df72f 100644
--- a/gm/texdata.cpp
+++ b/gm/texdata.cpp
@@ -111,7 +111,7 @@ protected:
SkMatrix tm;
tm = vm;
tm.postIDiv(2*S, 2*S);
- paint.addColorTextureEffect(texture, tm);
+ paint.addColorTextureProcessor(texture, tm);
ctx->drawRect(paint, SkRect::MakeWH(2*S, 2*S));
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index b310253e8..6534b0c1d 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -122,13 +122,13 @@ protected:
SkScalar x = kDrawPad + kTestPad;
for (int m = 0; m < GrTextureDomain::kModeCount; ++m) {
GrTextureDomain::Mode mode = (GrTextureDomain::Mode) m;
- SkAutoTUnref<GrEffect> effect(
+ SkAutoTUnref<GrFragmentProcessor> fp(
GrTextureDomainEffect::Create(texture, textureMatrices[tm],
GrTextureDomain::MakeTexelDomain(texture,
texelDomains[d]),
mode, GrTextureParams::kNone_FilterMode));
- if (!effect) {
+ if (!fp) {
continue;
}
SkMatrix viewMatrix;
@@ -136,7 +136,7 @@ protected:
drawState->reset(viewMatrix);
drawState->setRenderTarget(rt);
drawState->setColor(0xffffffff);
- drawState->addColorEffect(effect);
+ drawState->addColorProcessor(fp);
tt.target()->drawSimpleRect(renderRect);
x += renderRect.width() + kTestPad;
diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp
index d0b511f73..026823e8e 100644
--- a/gm/yuvtorgbeffect.cpp
+++ b/gm/yuvtorgbeffect.cpp
@@ -107,18 +107,18 @@ protected:
const int indices[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 0, 1}, {2, 1, 0}};
for (int i = 0; i < 6; ++i) {
- SkAutoTUnref<GrEffect> effect(
+ SkAutoTUnref<GrFragmentProcessor> fp(
GrYUVtoRGBEffect::Create(texture[indices[i][0]],
texture[indices[i][1]],
texture[indices[i][2]],
static_cast<SkYUVColorSpace>(space)));
- if (effect) {
+ if (fp) {
SkMatrix viewMatrix;
viewMatrix.setTranslate(x, y);
drawState->reset(viewMatrix);
drawState->setRenderTarget(rt);
drawState->setColor(0xffffffff);
- drawState->addColorEffect(effect);
+ drawState->addColorProcessor(fp);
tt.target()->drawSimpleRect(renderRect);
}
x += renderRect.width() + kTestPad;
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi
index 1de2ab406..ebc07b264 100644
--- a/gyp/gpu.gypi
+++ b/gyp/gpu.gypi
@@ -8,7 +8,7 @@
{
'variables': {
'skgpu_sources': [
- '<(skia_include_path)/gpu/GrBackendEffectFactory.h',
+ '<(skia_include_path)/gpu/GrBackendProcessorFactory.h',
'<(skia_include_path)/gpu/GrBinHashKey.h',
'<(skia_include_path)/gpu/GrClipData.h',
'<(skia_include_path)/gpu/GrColor.h',
@@ -16,14 +16,14 @@
'<(skia_include_path)/gpu/GrContext.h',
'<(skia_include_path)/gpu/GrContextFactory.h',
'<(skia_include_path)/gpu/GrCoordTransform.h',
- '<(skia_include_path)/gpu/GrEffect.h',
- '<(skia_include_path)/gpu/GrEffectStage.h',
- '<(skia_include_path)/gpu/GrEffectUnitTest.h',
'<(skia_include_path)/gpu/GrFontScaler.h',
'<(skia_include_path)/gpu/GrGlyph.h',
'<(skia_include_path)/gpu/GrGpuResource.h',
'<(skia_include_path)/gpu/GrPaint.h',
'<(skia_include_path)/gpu/GrPathRendererChain.h',
+ '<(skia_include_path)/gpu/GrProcessor.h',
+ '<(skia_include_path)/gpu/GrProcessorStage.h',
+ '<(skia_include_path)/gpu/GrProcessorUnitTest.h',
'<(skia_include_path)/gpu/GrProgramElement.h',
'<(skia_include_path)/gpu/GrProgramElementRef.h',
'<(skia_include_path)/gpu/GrGpuResourceRef.h',
@@ -32,7 +32,7 @@
'<(skia_include_path)/gpu/GrResourceKey.h',
'<(skia_include_path)/gpu/GrSurface.h',
'<(skia_include_path)/gpu/GrShaderVar.h',
- '<(skia_include_path)/gpu/GrTBackendEffectFactory.h',
+ '<(skia_include_path)/gpu/GrTBackendProcessorFactory.h',
'<(skia_include_path)/gpu/GrTexture.h',
'<(skia_include_path)/gpu/GrTextureAccess.h',
'<(skia_include_path)/gpu/GrTypes.h',
@@ -78,7 +78,6 @@
'<(skia_src_path)/gpu/GrDrawTarget.cpp',
'<(skia_src_path)/gpu/GrDrawTarget.h',
'<(skia_src_path)/gpu/GrDrawTargetCaps.h',
- '<(skia_src_path)/gpu/GrEffect.cpp',
'<(skia_src_path)/gpu/GrFontScaler.cpp',
'<(skia_src_path)/gpu/GrGeometryBuffer.h',
'<(skia_src_path)/gpu/GrGpu.cpp',
@@ -113,6 +112,7 @@
'<(skia_src_path)/gpu/GrPathUtils.cpp',
'<(skia_src_path)/gpu/GrPathUtils.h',
'<(skia_src_path)/gpu/GrProgramElement.cpp',
+ '<(skia_src_path)/gpu/GrProcessor.cpp',
'<(skia_src_path)/gpu/GrGpuResourceRef.cpp',
'<(skia_src_path)/gpu/GrPictureUtils.h',
'<(skia_src_path)/gpu/GrPictureUtils.cpp',
@@ -209,7 +209,6 @@
'<(skia_src_path)/gpu/gl/GrGLCreateNativeInterface_none.cpp',
'<(skia_src_path)/gpu/gl/GrGLDefaultInterface_none.cpp',
'<(skia_src_path)/gpu/gl/GrGLDefines.h',
- '<(skia_src_path)/gpu/gl/GrGLEffect.h',
'<(skia_src_path)/gpu/gl/GrGLGeometryProcessor.h',
'<(skia_src_path)/gpu/gl/GrGLExtensions.cpp',
'<(skia_src_path)/gpu/gl/GrGLIndexBuffer.cpp',
@@ -226,6 +225,7 @@
'<(skia_src_path)/gpu/gl/GrGLPathRange.h',
'<(skia_src_path)/gpu/gl/GrGLPathRendering.cpp',
'<(skia_src_path)/gpu/gl/GrGLPathRendering.h',
+ '<(skia_src_path)/gpu/gl/GrGLProcessor.h',
'<(skia_src_path)/gpu/gl/GrGLProgram.cpp',
'<(skia_src_path)/gpu/gl/GrGLProgram.h',
'<(skia_src_path)/gpu/gl/GrGLProgramDesc.cpp',
diff --git a/include/core/SkColorFilter.h b/include/core/SkColorFilter.h
index 5ddd6af08..31d4a01ee 100644
--- a/include/core/SkColorFilter.h
+++ b/include/core/SkColorFilter.h
@@ -15,7 +15,7 @@
#include "SkXfermode.h"
class SkBitmap;
-class GrEffect;
+class GrProcessor;
class GrContext;
/**
@@ -126,7 +126,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 GrEffect* asNewEffect(GrContext*) const;
+ virtual GrFragmentProcessor* asFragmentProcessor(GrContext*) const;
SK_TO_STRING_PUREVIRT()
diff --git a/include/core/SkColorShader.h b/include/core/SkColorShader.h
index 55d980b64..dc45f2d6c 100644
--- a/include/core/SkColorShader.h
+++ b/include/core/SkColorShader.h
@@ -54,9 +54,8 @@ public:
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* paintColor,
- GrEffect** effect) const SK_OVERRIDE;
+ virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*,
+ GrFragmentProcessor**) const SK_OVERRIDE;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader)
diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h
index adddf9387..9f17f814d 100644
--- a/include/core/SkImageFilter.h
+++ b/include/core/SkImageFilter.h
@@ -17,7 +17,7 @@ class SkBitmap;
class SkColorFilter;
class SkBaseDevice;
struct SkIPoint;
-class GrEffect;
+class GrFragmentProcessor;
class GrTexture;
/**
@@ -114,8 +114,8 @@ public:
/**
* 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 asNewEffect().
- * The default implementation returns asNewEffect(NULL, NULL, SkMatrix::I(),
+ * rendered to textures. For single-pass effects, use asFragmentProcessor().
+ * The default implementation returns asFragmentProcessor(NULL, NULL, SkMatrix::I(),
* SkIRect()).
*/
virtual bool canFilterImageGPU() const;
@@ -123,12 +123,12 @@ public:
/**
* Process this image filter 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 asNewEffect(). src is the
+ * textures. For single-pass effects, use asFragmentProcessor(). src is the
* source image for processing, as a texture-backed bitmap. result is
* the destination bitmap, which should contain a texture-backed pixelref
* on success. offset is the amount to translate the resulting image
* relative to the src when it is drawn. The default implementation does
- * single-pass processing using asNewEffect().
+ * single-pass processing using asFragmentProcessor().
*/
virtual bool filterImageGPU(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const;
@@ -290,10 +290,10 @@ protected:
/**
* Returns true if the filter can be expressed a single-pass
- * GrEffect, used to process this filter on the GPU, or false if
+ * GrProcessor, used to process this filter on the GPU, or false if
* not.
*
- * If effect is non-NULL, a new GrEffect instance is stored
+ * If effect is non-NULL, a new GrProcessor instance is stored
* in it. The caller assumes ownership of the stage, and it is up to the
* caller to unref it.
*
@@ -303,10 +303,8 @@ protected:
* will be called with (NULL, NULL, SkMatrix::I()) to query for support,
* so returning "true" indicates support for all possible matrices.
*/
- virtual bool asNewEffect(GrEffect** effect,
- GrTexture*,
- const SkMatrix& matrix,
- const SkIRect& bounds) const;
+ virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&,
+ const SkIRect& bounds) const;
private:
bool usesSrcInput() const { return fUsesSrcInput; }
diff --git a/include/core/SkMaskFilter.h b/include/core/SkMaskFilter.h
index 51ede4b0a..026ef40cb 100644
--- a/include/core/SkMaskFilter.h
+++ b/include/core/SkMaskFilter.h
@@ -63,24 +63,22 @@ public:
#if SK_SUPPORT_GPU
/**
- * Returns true if the filter can be expressed a single-pass GrEffect without requiring an
+ * Returns true if the filter can be expressed a single-pass GrProcessor without requiring an
* explicit input mask. Per-pixel, the effect receives the incoming mask's coverage as
* the input color and outputs the filtered covereage value. This means that each pixel's
* filtered coverage must only depend on the unfiltered mask value for that pixel and not on
* surrounding values.
*
- * If effect is non-NULL, a new GrEffect instance is stored in it. The caller assumes ownership
- * of the effect and must unref it.
+ * If effect is non-NULL, a new GrProcessor instance is stored in it. The caller assumes
+ * ownership of the effect and must unref it.
*/
- virtual bool asNewEffect(GrEffect** effect,
- GrTexture*,
- const SkMatrix& ctm) const;
+ virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix& ctm) const;
/**
- * If asNewEffect() fails the filter may be implemented on the GPU by a subclass overriding
- * filterMaskGPU (declared below). That code path requires constructing a src mask as input.
- * Since that is a potentially expensive operation, the subclass must also override this
- * function to indicate whether filterTextureMaskGPU would succeeed if the mask were to be
+ * If asFragmentProcessor() fails the filter may be implemented on the GPU by a subclass
+ * overriding filterMaskGPU (declared below). That code path requires constructing a src mask
+ * as input. Since that is a potentially expensive operation, the subclass must also override
+ * this function to indicate whether filterTextureMaskGPU would succeeed if the mask were to be
* created.
*
* 'maskRect' returns the device space portion of the mask that the filter needs. The mask
diff --git a/include/core/SkShader.h b/include/core/SkShader.h
index 6effe797f..0fbc1b8bd 100644
--- a/include/core/SkShader.h
+++ b/include/core/SkShader.h
@@ -20,7 +20,7 @@ class SkPath;
class SkPicture;
class SkXfermode;
class GrContext;
-class GrEffect;
+class GrFragmentProcessor;
/** \class SkShader
*
@@ -385,9 +385,8 @@ public:
* The GrContext may be used by the effect to create textures. The GPU device does not
* call createContext. Instead we pass the SkPaint here in case the shader needs paint info.
*/
- virtual bool asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrixOrNull, GrColor* paintColor,
- GrEffect** effect) const;
+ virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*,
+ GrFragmentProcessor**) const;
/**
* If the shader can represent its "average" luminance in a single color, return true and
diff --git a/include/core/SkXfermode.h b/include/core/SkXfermode.h
index 3fb3ab59a..bedcc2456 100644
--- a/include/core/SkXfermode.h
+++ b/include/core/SkXfermode.h
@@ -13,7 +13,7 @@
#include "SkFlattenable.h"
#include "SkColor.h"
-class GrEffect;
+class GrFragmentProcessor;
class GrTexture;
class SkString;
@@ -198,18 +198,16 @@ public:
fragment shader. If NULL, the effect should request access to destination color
(setWillReadDstColor()), and use that in the fragment shader (builder->dstColor()).
*/
- virtual bool asNewEffect(GrEffect** effect, GrTexture* background = NULL) const;
+ virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture* background = NULL) const;
/** Returns true if the xfermode can be expressed as coeffs (src, dst), or as an effect
- (effect). This helper calls the asCoeff() and asNewEffect() virtuals. If the xfermode is
- NULL, it is treated as kSrcOver_Mode. It is legal to call this with all params NULL to
- simply test the return value. effect, src, and dst must all be NULL or all non-NULL.
+ (effect). This helper calls the asCoeff() and asFragmentProcessor() virtuals. If the
+ xfermode is NULL, it is treated as kSrcOver_Mode. It is legal to call this with all params
+ NULL to simply test the return value. effect, src, and dst must all be NULL or all
+ non-NULL.
*/
- static bool AsNewEffectOrCoeff(SkXfermode*,
- GrEffect** effect,
- Coeff* src,
- Coeff* dst,
- GrTexture* background = NULL);
+ static bool asFragmentProcessorOrCoeff(SkXfermode*, GrFragmentProcessor**, Coeff* src,
+ Coeff* dst, GrTexture* background = NULL);
SK_TO_STRING_PUREVIRT()
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
diff --git a/include/effects/SkColorMatrixFilter.h b/include/effects/SkColorMatrixFilter.h
index b8464632b..dad40623f 100644
--- a/include/effects/SkColorMatrixFilter.h
+++ b/include/effects/SkColorMatrixFilter.h
@@ -26,7 +26,7 @@ public:
virtual uint32_t getFlags() const SK_OVERRIDE;
virtual bool asColorMatrix(SkScalar matrix[20]) const SK_OVERRIDE;
#if SK_SUPPORT_GPU
- virtual GrEffect* asNewEffect(GrContext*) const SK_OVERRIDE;
+ virtual GrFragmentProcessor* asFragmentProcessor(GrContext*) const SK_OVERRIDE;
#endif
struct State {
diff --git a/include/effects/SkLumaColorFilter.h b/include/effects/SkLumaColorFilter.h
index 38bab92ce..420999f2e 100644
--- a/include/effects/SkLumaColorFilter.h
+++ b/include/effects/SkLumaColorFilter.h
@@ -28,7 +28,7 @@ public:
virtual void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const SK_OVERRIDE;
#if SK_SUPPORT_GPU
- virtual GrEffect* asNewEffect(GrContext*) const SK_OVERRIDE;
+ virtual GrFragmentProcessor* asFragmentProcessor(GrContext*) const SK_OVERRIDE;
#endif
SK_TO_STRING_OVERRIDE()
diff --git a/include/effects/SkMagnifierImageFilter.h b/include/effects/SkMagnifierImageFilter.h
index 9ea4b3748..4dd47ef7b 100644
--- a/include/effects/SkMagnifierImageFilter.h
+++ b/include/effects/SkMagnifierImageFilter.h
@@ -28,8 +28,8 @@ protected:
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
#if SK_SUPPORT_GPU
- virtual bool asNewEffect(GrEffect** effect, GrTexture* texture, const SkMatrix& matrix,
- const SkIRect& bounds) const SK_OVERRIDE;
+ virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&,
+ const SkIRect& bounds) const SK_OVERRIDE;
#endif
private:
diff --git a/include/effects/SkMatrixConvolutionImageFilter.h b/include/effects/SkMatrixConvolutionImageFilter.h
index e24d82329..c14d6f99f 100644
--- a/include/effects/SkMatrixConvolutionImageFilter.h
+++ b/include/effects/SkMatrixConvolutionImageFilter.h
@@ -91,10 +91,8 @@ protected:
#if SK_SUPPORT_GPU
- virtual bool asNewEffect(GrEffect** effect,
- GrTexture*,
- const SkMatrix& ctm,
- const SkIRect& bounds) const SK_OVERRIDE;
+ virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&,
+ const SkIRect& bounds) const SK_OVERRIDE;
#endif
private:
diff --git a/include/effects/SkPerlinNoiseShader.h b/include/effects/SkPerlinNoiseShader.h
index f5f1af01c..2937926cd 100644
--- a/include/effects/SkPerlinNoiseShader.h
+++ b/include/effects/SkPerlinNoiseShader.h
@@ -96,8 +96,8 @@ public:
typedef SkShader::Context INHERITED;
};
- virtual bool asNewEffect(GrContext* context, const SkPaint&, const SkMatrix*, GrColor*,
- GrEffect**) const SK_OVERRIDE;
+ virtual bool asFragmentProcessor(GrContext* context, const SkPaint&, const SkMatrix*, GrColor*,
+ GrFragmentProcessor**) const SK_OVERRIDE;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPerlinNoiseShader)
diff --git a/include/gpu/GrBackendEffectFactory.h b/include/gpu/GrBackendProcessorFactory.h
index 936d632a7..b51a47473 100644
--- a/include/gpu/GrBackendEffectFactory.h
+++ b/include/gpu/GrBackendProcessorFactory.h
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
-#ifndef GrBackendEffectFactory_DEFINED
-#define GrBackendEffectFactory_DEFINED
+#ifndef GrBackendProcessorFactory_DEFINED
+#define GrBackendProcessorFactory_DEFINED
#include "GrTypes.h"
#include "SkTemplates.h"
@@ -14,16 +14,17 @@
#include "SkTypes.h"
#include "SkTArray.h"
-class GrGLEffect;
+class GrGLProcessor;
class GrGLCaps;
-class GrEffect;
+class GrProcessor;
/**
- * Used by effects to build their keys. It incorporates each per-effect key into a larger shader key.
+ * Used by effects to build their keys. It incorporates each per-processor key into a larger shader
+ * key.
*/
-class GrEffectKeyBuilder {
+class GrProcessorKeyBuilder {
public:
- GrEffectKeyBuilder(SkTArray<unsigned char, true>* data) : fData(data), fCount(0) {
+ GrProcessorKeyBuilder(SkTArray<unsigned char, true>* data) : fData(data), fCount(0) {
SkASSERT(0 == fData->count() % sizeof(uint32_t));
}
@@ -48,13 +49,13 @@ private:
};
/**
- * This class is used to pass the key that was created for a GrGLEffect back to it
+ * This class is used to pass the key that was created for a GrGLProcessor back to it
* when it emits code. It may allow the emit step to skip calculations that were
* performed when computing the key.
*/
-class GrEffectKey {
+class GrProcessorKey {
public:
- GrEffectKey(const uint32_t* key, int count) : fKey(key), fCount(count) {
+ GrProcessorKey(const uint32_t* key, int count) : fKey(key), fCount(count) {
SkASSERT(0 == reinterpret_cast<intptr_t>(key) % sizeof(uint32_t));
}
@@ -73,14 +74,14 @@ private:
};
/**
- * Given a GrEffect of a particular type, creates the corresponding graphics-backend-specific
+ * Given a GrProcessor of a particular type, creates the corresponding graphics-backend-specific
* effect object. It also tracks equivalence of shaders generated via a key. The factory for an
- * effect is accessed via GrEffect::getFactory(). Each factory instance is assigned an ID at
- * construction. The ID of GrEffect::getFactory() is used as a type identifier. Thus, a GrEffect
- * subclass must always return the same object from getFactory() and that factory object must be
- * unique to the GrEffect subclass (and unique from any further derived subclasses).
+ * effect is accessed via GrProcessor::getFactory(). Each factory instance is assigned an ID at
+ * construction. The ID of GrProcessor::getFactory() is used as a type identifier. Thus, a
+ * GrProcessor subclass must always return the same object from getFactory() and that factory object
+ * must be unique to the GrProcessor subclass (and unique from any further derived subclasses).
*
- * Rather than subclassing this class themselves, it is recommended that GrEffect authors use
+ * Rather than subclassing this class themselves, it is recommended that GrProcessor authors use
* the templated subclass GrTBackendEffectFactory by writing their getFactory() method as:
*
* const GrBackendEffectFactory& MyEffect::getFactory() const {
@@ -89,20 +90,15 @@ private:
*
* Using GrTBackendEffectFactory places a few constraints on the effect. See that class's comments.
*/
-class GrBackendEffectFactory : SkNoncopyable {
+class GrBackendProcessorFactory : SkNoncopyable {
public:
/**
- * Generates an effect's key. The key is based on the aspects of the GrEffect object's
- * configuration that affect GLSL code generation. Two GrEffect instances that would cause
+ * Generates an effect's key. The key is based on the aspects of the GrProcessor object's
+ * configuration that affect GLSL code generation. Two GrProcessor instances that would cause
* this->createGLInstance()->emitCode() to produce different code must produce different keys.
*/
- virtual void getGLEffectKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*) const = 0;
-
- /**
- * Creates a GrGLEffect instance that is used both to generate code for the GrEffect in a GLSL
- * program and to manage updating uniforms for the program when it is used.
- */
- virtual GrGLEffect* createGLInstance(const GrEffect&) const = 0;
+ virtual void getGLProcessorKey(const GrProcessor&, const GrGLCaps&,
+ GrProcessorKeyBuilder*) const = 0;
/**
* Produces a human-reable name for the effect.
@@ -111,14 +107,14 @@ public:
/**
* A unique value for every instance of this factory. It is automatically incorporated into the
- * effect's key. This allows keys generated by getGLEffectKey() to only be unique within a
- * GrEffect subclass and not necessarily across subclasses.
+ * effect's key. This allows keys generated by getGLProcessorKey() to only be unique within a
+ * GrProcessor subclass and not necessarily across subclasses.
*/
uint32_t effectClassID() const { return fEffectClassID; }
protected:
- GrBackendEffectFactory() : fEffectClassID(GenID()) {}
- virtual ~GrBackendEffectFactory() {}
+ GrBackendProcessorFactory() : fEffectClassID(GenID()) {}
+ virtual ~GrBackendProcessorFactory() {}
private:
enum {
@@ -131,7 +127,7 @@ private:
// 1 to the returned value.
uint32_t id = static_cast<uint32_t>(sk_atomic_inc(&fCurrEffectClassID)) + 1;
if (!id) {
- SkFAIL("This should never wrap as it should only be called once for each GrEffect "
+ SkFAIL("This should never wrap as it should only be called once for each GrProcessor "
"subclass.");
}
return id;
@@ -141,4 +137,32 @@ private:
static int32_t fCurrEffectClassID;
};
+class GrFragmentProcessor;
+class GrGeometryProcessor;
+class GrGLFragmentProcessor;
+class GrGLGeometryProcessor;
+
+/**
+ * Backend processor factory cannot actually create anything, it is up to subclasses to implement
+ * a create binding which matches Gr to GL in a type safe way
+ */
+
+class GrBackendFragmentProcessorFactory : public GrBackendProcessorFactory {
+public:
+ /**
+ * Creates a GrGLProcessor instance that is used both to generate code for the GrProcessor in a
+ * GLSL program and to manage updating uniforms for the program when it is used.
+ */
+ virtual GrGLFragmentProcessor* createGLInstance(const GrFragmentProcessor&) const = 0;
+};
+
+class GrBackendGeometryProcessorFactory : public GrBackendProcessorFactory {
+public:
+ /**
+ * Creates a GrGLProcessor instance that is used both to generate code for the GrProcessor in a
+ * GLSL program and to manage updating uniforms for the program when it is used.
+ */
+ virtual GrGLGeometryProcessor* createGLInstance(const GrGeometryProcessor&) const = 0;
+};
+
#endif
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index f9c78ffbe..45cd59913 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -22,8 +22,8 @@ class GrAARectRenderer;
class GrAutoScratchTexture;
class GrDrawState;
class GrDrawTarget;
-class GrEffect;
class GrFontCache;
+class GrFragmentProcessor;
class GrGpu;
class GrGpuTraceMarker;
class GrIndexBuffer;
@@ -759,7 +759,7 @@ public:
* Save/restore the view-matrix in the context. It can optionally adjust a paint to account
* for a coordinate system change. Here is an example of how the paint param can be used:
*
- * A GrPaint is setup with GrEffects. The stages will have access to the pre-matrix source
+ * A GrPaint is setup with GrProcessors. The stages will have access to the pre-matrix source
* geometry positions when the draw is executed. Later on a decision is made to transform the
* geometry to device space on the CPU. The effects now need to know that the space in which
* the geometry will be specified has changed.
@@ -1066,12 +1066,8 @@ private:
* of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. Otherwise, they
* return NULL.
*/
- const GrEffect* createPMToUPMEffect(GrTexture* texture,
- bool swapRAndB,
- const SkMatrix& matrix);
- const GrEffect* createUPMToPMEffect(GrTexture* texture,
- bool swapRAndB,
- const SkMatrix& matrix);
+ const GrFragmentProcessor* createPMToUPMEffect(GrTexture*, bool swapRAndB, const SkMatrix&);
+ const GrFragmentProcessor* createUPMToPMEffect(GrTexture*, bool swapRAndB, const SkMatrix&);
/**
* This callback allows the resource cache to callback into the GrContext
diff --git a/include/gpu/GrCoordTransform.h b/include/gpu/GrCoordTransform.h
index 734c26fae..718bbe774 100644
--- a/include/gpu/GrCoordTransform.h
+++ b/include/gpu/GrCoordTransform.h
@@ -8,13 +8,13 @@
#ifndef GrCoordTransform_DEFINED
#define GrCoordTransform_DEFINED
-#include "GrEffect.h"
+#include "GrProcessor.h"
#include "SkMatrix.h"
#include "GrTexture.h"
#include "GrTypes.h"
/**
- * Coordinates available to GrEffect subclasses for requesting transformations. Transformed
+ * Coordinates available to GrProcessor subclasses for requesting transformations. Transformed
* coordinates are made available in the the portion of fragment shader emitted by the effect.
*/
enum GrCoordSet {
@@ -22,21 +22,21 @@ enum GrCoordSet {
* The user-space coordinates that map to the fragment being rendered. These coords account for
* any change of coordinate system done on the CPU by GrContext before rendering, and also are
* correct for draws that take explicit local coords rather than inferring them from the
- * primitive's positions (e.g. drawVertices). These are usually the coords a GrEffect wants.
+ * primitive's positions (e.g. drawVertices). These are usually the coords a GrProcessor wants.
*/
kLocal_GrCoordSet,
/**
* The actual vertex position. Note that GrContext may not draw using the original view matrix
* specified by the caller, as it may have transformed vertices into another space. These are
- * usually not the coordinates a GrEffect wants.
+ * usually not the coordinates a GrProcessor wants.
*/
kPosition_GrCoordSet
};
/**
* A class representing a linear transformation from one of the built-in coordinate sets (local or
- * position). GrEffects just define these transformations, and the framework does the rest of the
+ * position). GrProcessors just define these transformations, and the framework does the rest of the
* work to make the transformed coordinates available in their fragment shader.
*/
class GrCoordTransform : SkNoncopyable {
diff --git a/include/gpu/GrEffectUnitTest.h b/include/gpu/GrEffectUnitTest.h
deleted file mode 100644
index ffc64f2b8..000000000
--- a/include/gpu/GrEffectUnitTest.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrEffectUnitTest_DEFINED
-#define GrEffectUnitTest_DEFINED
-
-#include "SkRandom.h"
-#include "SkTArray.h"
-#include "SkTypes.h"
-
-class SkMatrix;
-class GrDrawTargetCaps;
-
-namespace GrEffectUnitTest {
-// Used to access the dummy textures in TestCreate procs.
-enum {
- kSkiaPMTextureIdx = 0,
- kAlphaTextureIdx = 1,
-};
-
-/**
- * A helper for use in GrEffect::TestCreate functions.
- */
-const SkMatrix& TestMatrix(SkRandom*);
-
-}
-
-#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
-
-class GrContext;
-class GrEffect;
-class GrTexture;
-
-class GrEffectTestFactory : SkNoncopyable {
-public:
-
- typedef GrEffect* (*CreateProc)(SkRandom*,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture* dummyTextures[]);
-
- GrEffectTestFactory(CreateProc createProc) {
- fCreateProc = createProc;
- GetFactories()->push_back(this);
- }
-
- static GrEffect* CreateStage(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps& caps,
- GrTexture* dummyTextures[]) {
- uint32_t idx = random->nextRangeU(0, GetFactories()->count() - 1);
- GrEffectTestFactory* factory = (*GetFactories())[idx];
- return factory->fCreateProc(random, context, caps, dummyTextures);
- }
-
-private:
- CreateProc fCreateProc;
- static SkTArray<GrEffectTestFactory*, true>* GetFactories();
-};
-
-/** GrEffect subclasses should insert this macro in their declaration to be included in the
- * program generation unit test.
- */
-#define GR_DECLARE_EFFECT_TEST \
- static GrEffectTestFactory gTestFactory; \
- static GrEffect* TestCreate(SkRandom*, \
- GrContext*, \
- const GrDrawTargetCaps&, \
- GrTexture* dummyTextures[2])
-
-/** GrEffect subclasses should insert this macro in their implementation file. They must then
- * also implement this static function:
- * GrEffect* TestCreate(SkRandom*,
- * GrContext*,
- * const GrDrawTargetCaps&,
- * GrTexture* dummyTextures[2]);
- * dummyTextures[] are valid textures that can optionally be used to construct GrTextureAccesses.
- * The first texture has config kSkia8888_GrPixelConfig and the second has
- * kAlpha_8_GrPixelConfig. TestCreate functions are also free to create additional textures using
- * the GrContext.
- */
-#define GR_DEFINE_EFFECT_TEST(Effect) \
- GrEffectTestFactory Effect :: gTestFactory(Effect :: 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_EFFECT_TEST \
- static GrEffect* TestCreate(SkRandom*, \
- GrContext*, \
- const GrDrawTargetCaps&, \
- GrTexture* dummyTextures[2])
-#define GR_DEFINE_EFFECT_TEST(X)
-
-#endif // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
-#endif
diff --git a/include/gpu/GrGeometryProcessor.h b/include/gpu/GrGeometryProcessor.h
new file mode 100644
index 000000000..61659cf17
--- /dev/null
+++ b/include/gpu/GrGeometryProcessor.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrGeometryProcessor_DEFINED
+#define GrGeometryProcessor_DEFINED
+
+#include "GrProcessor.h"
+class GrBackendGeometryProcessorFactory;
+
+/**
+ * A GrGeomteryProcessor is used to perform computation in the vertex shader and
+ * add support for custom vertex attributes. A GrGemeotryProcessor is typically
+ * tied to the code that does a specific type of high-level primitive rendering
+ * (e.g. anti-aliased circle rendering). The GrGeometryProcessor used for a draw is
+ * specified using GrDrawState. There can only be one geometry processor active for
+ * a draw. The custom vertex attributes required by the geometry processor must be
+ * added to the vertex attribute array specified on the GrDrawState.
+ * GrGeometryProcessor subclasses should be immutable after construction.
+ */
+class GrGeometryProcessor : public GrProcessor {
+public:
+ GrGeometryProcessor() {}
+
+ virtual const GrBackendGeometryProcessorFactory& getFactory() const = 0;
+
+ /*
+ * This only has a max because GLProgramsTest needs to generate test arrays, and these have to
+ * be static
+ * TODO make this truly dynamic
+ */
+ static const int kMaxVertexAttribs = 2;
+ typedef SkTArray<GrShaderVar, true> VertexAttribArray;
+
+ const VertexAttribArray& getVertexAttribs() const { return fVertexAttribs; }
+
+protected:
+ /**
+ * Subclasses call this from their constructor to register vertex attributes (at most
+ * kMaxVertexAttribs). This must only be called from the constructor because GrProcessors are
+ * immutable.
+ */
+ const GrShaderVar& addVertexAttrib(const GrShaderVar& var) {
+ SkASSERT(fVertexAttribs.count() < kMaxVertexAttribs);
+ return fVertexAttribs.push_back(var);
+ }
+
+private:
+ SkSTArray<kMaxVertexAttribs, GrShaderVar, true> fVertexAttribs;
+
+ typedef GrProcessor INHERITED;
+};
+
+/**
+ * This creates an effect outside of the effect memory pool. The effect's destructor will be called
+ * at global destruction time. NAME will be the name of the created GrProcessor.
+ */
+#define GR_CREATE_STATIC_GEOMETRY_PROCESSOR(NAME, GP_CLASS, ARGS) \
+static SkAlignedSStorage<sizeof(GP_CLASS)> g_##NAME##_Storage; \
+static GrGeometryProcessor* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), GP_CLASS, ARGS); \
+static SkAutoTDestroy<GrGeometryProcessor> NAME##_ad(NAME);
+
+#endif
diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h
index 07b526f73..d0531a302 100644
--- a/include/gpu/GrPaint.h
+++ b/include/gpu/GrPaint.h
@@ -11,7 +11,7 @@
#define GrPaint_DEFINED
#include "GrColor.h"
-#include "GrEffectStage.h"
+#include "GrProcessorStage.h"
#include "SkXfermode.h"
@@ -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 GrEffect.
+ * created by subclassing GrProcessor.
*
* 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 GrEffect and remove from GrPaint.
+ * TODO: Encapsulate setXfermodeColorFilter in a GrProcessor and remove from GrPaint.
*/
class GrPaint {
public:
@@ -85,51 +85,44 @@ public:
bool isDither() const { return fDither; }
/**
- * Appends an additional color effect to the color computation.
+ * Appends an additional color processor to the color computation.
*/
- const GrEffect* addColorEffect(const GrEffect* effect) {
- SkASSERT(effect);
- SkASSERT(!effect->requiresVertexShader());
- if (!effect->willUseInputColor()) {
+ const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* fp) {
+ SkASSERT(fp);
+ if (!fp->willUseInputColor()) {
fColorStages.reset();
}
- SkNEW_APPEND_TO_TARRAY(&fColorStages, GrEffectStage, (effect));
- return effect;
+ SkNEW_APPEND_TO_TARRAY(&fColorStages, GrProcessorStage, (fp));
+ return fp;
}
/**
- * Appends an additional coverage effect to the coverage computation.
+ * Appends an additional coverage processor to the coverage computation.
*/
- const GrEffect* addCoverageEffect(const GrEffect* effect) {
- SkASSERT(effect);
- SkASSERT(!effect->requiresVertexShader());
- if (!effect->willUseInputColor()) {
+ const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* fp) {
+ SkASSERT(fp);
+ if (!fp->willUseInputColor()) {
fCoverageStages.reset();
}
- SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrEffectStage, (effect));
- return effect;
+ SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrProcessorStage, (fp));
+ return fp;
}
/**
* Helpers for adding color or coverage effects that sample a texture. The matrix is applied
* to the src space position to compute texture coordinates.
*/
- void addColorTextureEffect(GrTexture* texture, const SkMatrix& matrix);
- void addCoverageTextureEffect(GrTexture* texture, const SkMatrix& matrix);
-
- void addColorTextureEffect(GrTexture* texture,
- const SkMatrix& matrix,
- const GrTextureParams& params);
- void addCoverageTextureEffect(GrTexture* texture,
- const SkMatrix& matrix,
- const GrTextureParams& params);
+ void addColorTextureProcessor(GrTexture*, const SkMatrix&);
+ void addCoverageTextureProcessor(GrTexture*, const SkMatrix&);
+ void addColorTextureProcessor(GrTexture*, const SkMatrix&, const GrTextureParams&);
+ void addCoverageTextureProcessor(GrTexture*, const SkMatrix&, const GrTextureParams&);
int numColorStages() const { return fColorStages.count(); }
int numCoverageStages() const { return fCoverageStages.count(); }
int numTotalStages() const { return this->numColorStages() + this->numCoverageStages(); }
- const GrEffectStage& getColorStage(int s) const { return fColorStages[s]; }
- const GrEffectStage& getCoverageStage(int s) const { return fCoverageStages[s]; }
+ const GrFragmentStage& getColorStage(int s) const { return fColorStages[s]; }
+ const GrFragmentStage& getCoverageStage(int s) const { return fCoverageStages[s]; }
GrPaint& operator=(const GrPaint& paint) {
fSrcBlendCoeff = paint.fSrcBlendCoeff;
@@ -218,8 +211,8 @@ private:
friend class GrContext; // To access above two functions
friend class GrStencilAndCoverTextContext; // To access above two functions
- SkSTArray<4, GrEffectStage> fColorStages;
- SkSTArray<2, GrEffectStage> fCoverageStages;
+ SkSTArray<4, GrFragmentStage> fColorStages;
+ SkSTArray<2, GrFragmentStage> fCoverageStages;
GrBlendCoeff fSrcBlendCoeff;
GrBlendCoeff fDstBlendCoeff;
diff --git a/include/gpu/GrEffect.h b/include/gpu/GrProcessor.h
index e9259979f..7053872bb 100644
--- a/include/gpu/GrEffect.h
+++ b/include/gpu/GrProcessor.h
@@ -5,18 +5,19 @@
* found in the LICENSE file.
*/
-#ifndef GrEffect_DEFINED
-#define GrEffect_DEFINED
+#ifndef GrProcessor_DEFINED
+#define GrProcessor_DEFINED
+#include "GrBackendProcessorFactory.h"
#include "GrColor.h"
-#include "GrEffectUnitTest.h"
+#include "GrProcessorUnitTest.h"
#include "GrProgramElement.h"
#include "GrShaderVar.h"
#include "GrTextureAccess.h"
#include "GrTypesPriv.h"
#include "SkString.h"
-class GrBackendEffectFactory;
+class GrBackendProcessorFactory;
class GrContext;
class GrCoordTransform;
@@ -24,17 +25,17 @@ class GrCoordTransform;
Ganesh shading pipeline.
Subclasses must have a function that produces a human-readable name:
static const char* Name();
- GrEffect objects *must* be immutable: after being constructed, their fields may not change.
+ GrProcessor objects *must* be immutable: after being constructed, their fields may not change.
- Dynamically allocated GrEffects are managed by a per-thread memory pool. The ref count of an
+ Dynamically allocated GrProcessors are managed by a per-thread memory pool. The ref count of an
effect must reach 0 before the thread terminates and the pool is destroyed. To create a static
effect use the macro GR_CREATE_STATIC_EFFECT declared below.
*/
-class GrEffect : public GrProgramElement {
+class GrProcessor : public GrProgramElement {
public:
- SK_DECLARE_INST_COUNT(GrEffect)
+ SK_DECLARE_INST_COUNT(GrProcessor)
- virtual ~GrEffect();
+ virtual ~GrProcessor();
/**
* This function is used to perform optimizations. When called the color and validFlags params
@@ -45,17 +46,14 @@ public:
*/
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const = 0;
- /** Will this effect read the source color value? */
- bool willUseInputColor() const { return fWillUseInputColor; }
-
/** 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,
- GrTBackendEffectFactory. It is templated on the subclass of GrEffect. The subclass must have
- a nested type (or typedef) named GLEffect which will be the subclass of GrGLEffect created
- by the factory.
+ GrTBackendEffectFactory. It is templated on the subclass of GrProcessor. The subclass must
+ have a nested type (or typedef) named GLProcessor which will be the subclass of
+ GrGLProcessor created by the factory.
Example:
- class MyCustomEffect : public GrEffect {
+ class MyCustomEffect : public GrProcessor {
...
virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
return GrTBackendEffectFactory<MyCustomEffect>::getInstance();
@@ -63,7 +61,7 @@ public:
...
};
*/
- virtual const GrBackendEffectFactory& getFactory() const = 0;
+ virtual const GrBackendProcessorFactory& getFactory() const = 0;
/** Returns true if this and other effect conservatively draw identically. It can only return
true when the two effects are of the same subclass (i.e. they return the same object from
@@ -73,7 +71,7 @@ public:
generate the same shader code. To test for identical code generation use the effects' keys
computed by the GrBackendEffectFactory.
*/
- bool isEqual(const GrEffect& other) const {
+ bool isEqual(const GrProcessor& other) const {
if (&this->getFactory() != &other.getFactory()) {
return false;
}
@@ -105,21 +103,9 @@ public:
/** Shortcut for textureAccess(index).texture(); */
GrTexture* texture(int index) const { return this->textureAccess(index).getTexture(); }
- /** Will this effect read the destination pixel value? */
- bool willReadDstColor() const { return fWillReadDstColor; }
-
/** Will this effect read the fragment position? */
bool willReadFragmentPosition() const { return fWillReadFragmentPosition; }
- /** Will this effect emit custom vertex shader code?
- (To set this value the effect must inherit from GrEffect.) */
- bool requiresVertexShader() const { return fRequiresVertexShader; }
-
- static const int kMaxVertexAttribs = 2;
- typedef SkSTArray<kMaxVertexAttribs, GrShaderVar, true> VertexAttribArray;
-
- const VertexAttribArray& getVertexAttribs() const { return fVertexAttribs; }
-
void* operator new(size_t size);
void operator delete(void* target);
@@ -131,7 +117,7 @@ public:
}
/**
- * Helper for down-casting to a GrEffect subclass
+ * Helper for down-casting to a GrProcessor subclass
*/
template <typename T> const T& cast() const { return *static_cast<const T*>(this); }
@@ -139,32 +125,23 @@ protected:
/**
* Subclasses call this from their constructor to register coordinate transformations. The
* effect subclass manages the lifetime of the transformations (this function only stores a
- * pointer). The GrCoordTransform is typically a member field of the GrEffect subclass. When the
- * matrix has perspective, the transformed coordinates will have 3 components. Otherwise they'll
- * have 2. This must only be called from the constructor because GrEffects are immutable.
+ * pointer). The GrCoordTransform is typically a member field of the GrProcessor subclass. When
+ * the matrix has perspective, the transformed coordinates will have 3 components. Otherwise
+ * they'll have 2. This must only be called from the constructor because GrProcessors are
+ * immutable.
*/
void addCoordTransform(const GrCoordTransform* coordTransform);
/**
* Subclasses call this from their constructor to register GrTextureAccesses. The effect
* subclass manages the lifetime of the accesses (this function only stores a pointer). The
- * GrTextureAccess is typically a member field of the GrEffect subclass. This must only be
- * called from the constructor because GrEffects are immutable.
+ * GrTextureAccess is typically a member field of the GrProcessor subclass. This must only be
+ * called from the constructor because GrProcessors are immutable.
*/
void addTextureAccess(const GrTextureAccess* textureAccess);
- GrEffect()
- : fWillReadDstColor(false)
- , fWillReadFragmentPosition(false)
- , fWillUseInputColor(true)
- , fRequiresVertexShader(false) {}
-
- /**
- * If the effect subclass will read the destination pixel value then it must call this function
- * from its constructor. Otherwise, when its generated backend-specific effect class attempts
- * to generate code that reads the destination pixel it will fail.
- */
- void setWillReadDstColor() { fWillReadDstColor = true; }
+ GrProcessor()
+ : fWillReadFragmentPosition(false) {}
/**
* If the effect will generate a backend-specific effect that will read the fragment position
@@ -173,41 +150,68 @@ protected:
*/
void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; }
- /**
- * If the effect will generate a result that does not depend on the input color value then it must
- * call this function from its constructor. Otherwise, when its generated backend-specific code
- * might fail during variable binding due to unused variables.
- */
- void setWillNotUseInputColor() { fWillUseInputColor = false; }
-
private:
- SkDEBUGCODE(void assertEquality(const GrEffect& other) const;)
+ SkDEBUGCODE(void assertEquality(const GrProcessor& other) const;)
/** Subclass implements this to support isEqual(). It will only be called if it is known that
the two effects are of the same subclass (i.e. they return the same object from
getFactory()).*/
- virtual bool onIsEqual(const GrEffect& other) const = 0;
+ virtual bool onIsEqual(const GrProcessor& other) const = 0;
friend class GrGeometryProcessor; // to set fRequiresVertexShader and build fVertexAttribTypes.
SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms;
SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses;
- VertexAttribArray fVertexAttribs;
- bool fWillReadDstColor;
bool fWillReadFragmentPosition;
- bool fWillUseInputColor;
- bool fRequiresVertexShader;
typedef GrProgramElement INHERITED;
};
+class GrFragmentProcessor : public GrProcessor {
+public:
+ GrFragmentProcessor()
+ : INHERITED()
+ , fWillReadDstColor(false)
+ , fWillUseInputColor(true) {}
+
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const = 0;
+
+ /** Will this effect read the destination pixel value? */
+ bool willReadDstColor() const { return fWillReadDstColor; }
+
+ /** Will this effect read the source color value? */
+ bool willUseInputColor() const { return fWillUseInputColor; }
+
+protected:
+ /**
+ * If the effect subclass will read the destination pixel value then it must call this function
+ * from its constructor. Otherwise, when its generated backend-specific effect class attempts
+ * to generate code that reads the destination pixel it will fail.
+ */
+ void setWillReadDstColor() { fWillReadDstColor = true; }
+
+ /**
+ * If the effect will generate a result that does not depend on the input color value then it
+ * must call this function from its constructor. Otherwise, when its generated backend-specific
+ * code might fail during variable binding due to unused variables.
+ */
+ void setWillNotUseInputColor() { fWillUseInputColor = false; }
+
+private:
+ bool fWillReadDstColor;
+ bool fWillUseInputColor;
+
+ typedef GrProcessor INHERITED;
+};
+
/**
* This creates an effect outside of the effect memory pool. The effect's destructor will be called
- * at global destruction time. NAME will be the name of the created GrEffect.
+ * at global destruction time. NAME will be the name of the created GrProcessor.
*/
-#define GR_CREATE_STATIC_EFFECT(NAME, EFFECT_CLASS, ARGS) \
+#define GR_CREATE_STATIC_FRAGMENT_PROCESSOR(NAME, EFFECT_CLASS, ARGS) \
static SkAlignedSStorage<sizeof(EFFECT_CLASS)> g_##NAME##_Storage; \
-static GrEffect* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EFFECT_CLASS, ARGS); \
-static SkAutoTDestroy<GrEffect> NAME##_ad(NAME);
+static GrFragmentProcessor* \
+NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EFFECT_CLASS, ARGS); \
+static SkAutoTDestroy<GrFragmentProcessor> NAME##_ad(NAME);
#endif
diff --git a/include/gpu/GrEffectStage.h b/include/gpu/GrProcessorStage.h
index b42d309d4..1485ca7cd 100644
--- a/include/gpu/GrEffectStage.h
+++ b/include/gpu/GrProcessorStage.h
@@ -8,12 +8,13 @@
-#ifndef GrEffectStage_DEFINED
-#define GrEffectStage_DEFINED
+#ifndef GrProcessorStage_DEFINED
+#define GrProcessorStage_DEFINED
-#include "GrBackendEffectFactory.h"
+#include "GrBackendProcessorFactory.h"
#include "GrCoordTransform.h"
-#include "GrEffect.h"
+#include "GrProcessor.h"
+#include "GrGeometryProcessor.h"
#include "GrProgramElementRef.h"
#include "SkMatrix.h"
#include "SkShader.h"
@@ -23,27 +24,27 @@
// is immutable, and only owns pending execution refs. This requries removing the common base
// class from GrDrawState and GrOptDrawState called GrRODrawState and converting to GrOptDrawState
// when draws are enqueued in the GrInOrderDrawBuffer.
-class GrEffectStage {
+class GrProcessorStage {
public:
- explicit GrEffectStage(const GrEffect* effect)
- : fEffect(SkRef(effect)) {
+ explicit GrProcessorStage(const GrProcessor* proc)
+ : fProc(SkRef(proc)) {
fCoordChangeMatrixSet = false;
}
- GrEffectStage(const GrEffectStage& other) {
+ GrProcessorStage(const GrProcessorStage& other) {
fCoordChangeMatrixSet = other.fCoordChangeMatrixSet;
if (other.fCoordChangeMatrixSet) {
fCoordChangeMatrix = other.fCoordChangeMatrix;
}
- fEffect.initAndRef(other.fEffect);
+ fProc.initAndRef(other.fProc);
}
- static bool AreCompatible(const GrEffectStage& a, const GrEffectStage& b,
+ static bool AreCompatible(const GrProcessorStage& a, const GrProcessorStage& b,
bool usingExplicitLocalCoords) {
- SkASSERT(a.fEffect.get());
- SkASSERT(b.fEffect.get());
+ SkASSERT(a.fProc.get());
+ SkASSERT(b.fProc.get());
- if (!a.getEffect()->isEqual(*b.getEffect())) {
+ if (!a.getProcessor()->isEqual(*b.getProcessor())) {
return false;
}
@@ -87,7 +88,7 @@ public:
SkMatrix fCoordChangeMatrix;
SkDEBUGCODE(mutable uint32_t fEffectUniqueID;)
- friend class GrEffectStage;
+ friend class GrProcessorStage;
};
/**
@@ -102,7 +103,7 @@ public:
savedCoordChange->fCoordChangeMatrix = fCoordChangeMatrix;
}
SkASSERT(SK_InvalidUniqueID == savedCoordChange->fEffectUniqueID);
- SkDEBUGCODE(savedCoordChange->fEffectUniqueID = fEffect->getUniqueID();)
+ SkDEBUGCODE(savedCoordChange->fEffectUniqueID = fProc->getUniqueID();)
}
/**
@@ -113,12 +114,12 @@ public:
if (fCoordChangeMatrixSet) {
fCoordChangeMatrix = savedCoordChange.fCoordChangeMatrix;
}
- SkASSERT(savedCoordChange.fEffectUniqueID == fEffect->getUniqueID());
+ SkASSERT(savedCoordChange.fEffectUniqueID == fProc->getUniqueID());
SkDEBUGCODE(savedCoordChange.fEffectUniqueID = SK_InvalidUniqueID);
}
/**
- * Gets the matrix representing all changes of coordinate system since the GrEffect was
+ * Gets the matrix representing all changes of coordinate system since the GrProcessor was
* installed in the stage.
*/
const SkMatrix& getCoordChangeMatrix() const {
@@ -130,7 +131,7 @@ public:
}
bool isPerspectiveCoordTransform(int matrixIndex, bool useExplicitLocalCoords) const {
- const GrCoordTransform& coordTransform = this->getEffect()->coordTransform(matrixIndex);
+ const GrCoordTransform& coordTransform = this->getProcessor()->coordTransform(matrixIndex);
SkMatrix::TypeMask type0 = coordTransform.getMatrix().getType();
SkMatrix::TypeMask type1 = SkMatrix::kIdentity_Mask;
if (kLocal_GrCoordSet == coordTransform.sourceCoords()) {
@@ -146,14 +147,32 @@ public:
}
}
- const GrEffect* getEffect() const { return fEffect.get(); }
+ const GrProcessor* getProcessor() const { return fProc.get(); }
- void convertToPendingExec() { fEffect.convertToPendingExec(); }
+ void convertToPendingExec() { fProc.convertToPendingExec(); }
private:
- bool fCoordChangeMatrixSet;
- SkMatrix fCoordChangeMatrix;
- GrProgramElementRef<const GrEffect> fEffect;
+ bool fCoordChangeMatrixSet;
+ SkMatrix fCoordChangeMatrix;
+ GrProgramElementRef<const GrProcessor> fProc;
+};
+
+class GrFragmentStage : public GrProcessorStage {
+public:
+ GrFragmentStage(const GrFragmentProcessor* fp) : GrProcessorStage(fp) {}
+
+ const GrFragmentProcessor* getFragmentProcessor() const {
+ return static_cast<const GrFragmentProcessor*>(this->getProcessor());
+ }
+};
+
+class GrGeometryStage : public GrProcessorStage {
+public:
+ GrGeometryStage(const GrGeometryProcessor* gp) : GrProcessorStage(gp) {}
+
+ const GrGeometryProcessor* getGeometryProcessor() const {
+ return static_cast<const GrGeometryProcessor*>(this->getProcessor());
+ }
};
#endif
diff --git a/include/gpu/GrProcessorUnitTest.h b/include/gpu/GrProcessorUnitTest.h
new file mode 100644
index 000000000..04ab2d15e
--- /dev/null
+++ b/include/gpu/GrProcessorUnitTest.h
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrProcessorUnitTest_DEFINED
+#define GrProcessorUnitTest_DEFINED
+
+#include "SkRandom.h"
+#include "SkTArray.h"
+#include "SkTypes.h"
+
+class SkMatrix;
+class GrDrawTargetCaps;
+
+namespace GrProcessorUnitTest {
+// Used to access the dummy textures in TestCreate procs.
+enum {
+ kSkiaPMTextureIdx = 0,
+ kAlphaTextureIdx = 1,
+};
+
+/**
+ * A helper for use in GrProcessor::TestCreate functions.
+ */
+const SkMatrix& TestMatrix(SkRandom*);
+
+}
+
+#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
+
+class GrContext;
+class GrProcessor;
+class GrTexture;
+
+template <class Processor>
+class GrProcessorTestFactory : SkNoncopyable {
+public:
+
+ typedef Processor* (*CreateProc)(SkRandom*,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture* dummyTextures[]);
+
+ GrProcessorTestFactory(CreateProc createProc) {
+ fCreateProc = createProc;
+ GetFactories()->push_back(this);
+ }
+
+ static Processor* CreateStage(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps& caps,
+ GrTexture* dummyTextures[]) {
+ uint32_t idx = random->nextRangeU(0, GetFactories()->count() - 1);
+ GrProcessorTestFactory<Processor>* factory = (*GetFactories())[idx];
+ return factory->fCreateProc(random, context, caps, dummyTextures);
+ }
+
+private:
+ CreateProc fCreateProc;
+
+ #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
+ static SkTArray<GrProcessorTestFactory<Processor>*, true>* GetFactories() {
+ static SkTArray<GrProcessorTestFactory<Processor>*, true> gFactories;
+ return &gFactories;
+ }
+ #endif
+};
+
+/** GrProcessor subclasses should insert this macro in their declaration to be included in the
+ * program generation unit test.
+ */
+
+#define GR_DECLARE_GEOMETRY_PROCESSOR_TEST \
+ static GrProcessorTestFactory<GrGeometryProcessor> gTestFactory; \
+ static GrGeometryProcessor* TestCreate(SkRandom*, \
+ GrContext*, \
+ const GrDrawTargetCaps&, \
+ GrTexture* dummyTextures[2])
+
+#define GR_DECLARE_FRAGMENT_PROCESSOR_TEST \
+ static GrProcessorTestFactory<GrFragmentProcessor> gTestFactory; \
+ static GrFragmentProcessor* TestCreate(SkRandom*, \
+ GrContext*, \
+ const GrDrawTargetCaps&, \
+ GrTexture* dummyTextures[2])
+
+/** GrProcessor subclasses should insert this macro in their implementation file. They must then
+ * also implement this static function:
+ * GrProcessor* TestCreate(SkRandom*,
+ * GrContext*,
+ * const GrDrawTargetCaps&,
+ * GrTexture* dummyTextures[2]);
+ * dummyTextures[] are valid textures that can optionally be used to construct GrTextureAccesses.
+ * The first texture has config kSkia8888_GrPixelConfig and the second has
+ * kAlpha_8_GrPixelConfig. TestCreate functions are also free to create additional textures using
+ * the GrContext.
+ */
+#define GR_DEFINE_FRAGMENT_PROCESSOR_TEST(Effect) \
+ GrProcessorTestFactory<GrFragmentProcessor> Effect :: gTestFactory(Effect :: TestCreate)
+
+#define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(Effect) \
+ GrProcessorTestFactory<GrGeometryProcessor> Effect :: gTestFactory(Effect :: 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_FRAGMENT_PROCESSOR_TEST \
+ static GrFragmentProcessor* TestCreate(SkRandom*, \
+ GrContext*, \
+ const GrDrawTargetCaps&, \
+ GrTexture* dummyTextures[2])
+#define GR_DEFINE_FRAGMENT_PROCESSOR_TEST(X)
+
+// The unit test relies on static initializers. Just declare the TestCreate function so that
+// its definitions will compile.
+#define GR_DECLARE_GEOMETRY_PROCESSOR_TEST \
+ static GrGeometryProcessor* TestCreate(SkRandom*, \
+ GrContext*, \
+ const GrDrawTargetCaps&, \
+ GrTexture* dummyTextures[2])
+#define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(X)
+
+#endif // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
+#endif
diff --git a/include/gpu/GrProgramElement.h b/include/gpu/GrProgramElement.h
index 8d23ba203..245dcd5fb 100644
--- a/include/gpu/GrProgramElement.h
+++ b/include/gpu/GrProgramElement.h
@@ -14,8 +14,8 @@
class GrGpuResourceRef;
/**
- * Base class for GrEffect (and future GrGeometryProcessor). GrDrawState uses this to manage
- * transitioning a GrEffect from being owned by a client to being scheduled for execution. It
+ * Base class for GrProcessor. GrDrawState uses this to manage
+ * transitioning a GrProcessor from being owned by a client to being scheduled for execution. It
* converts resources owned by the effect from being ref'ed to having pending reads/writes.
*
* All GrGpuResource objects owned by a GrProgramElement or derived classes (either directly or
diff --git a/include/gpu/GrProgramElementRef.h b/include/gpu/GrProgramElementRef.h
index df083c073..ecc802317 100644
--- a/include/gpu/GrProgramElementRef.h
+++ b/include/gpu/GrProgramElementRef.h
@@ -38,12 +38,12 @@ public:
fOwnPendingExec = true;
}
- // In the short term we need to support copying a GrEffectStage and making the copy own
+ // In the short term we need to support copying a GrProcessorStage and making the copy own
// the same type of ref as the source. This function exists to support this. TODO: Once
// GrDrawState and GrOptDrawState no longer share a base class they won't have to share
- // GrEffectStage and we can have GrOptDrawState always own pending executions rather than
+ // GrProcessorStage and we can have GrOptDrawState always own pending executions rather than
// refs on GrProgramElements. At that point we should be able to delete this function.
- // This function makes assumptions that are valid in the GrEffectStage use case and should
+ // This function makes assumptions that are valid in the GrProcessorStage use case and should
// not be used elsewhere.
void initAndRef(const GrProgramElementRef& that) {
SkASSERT(!fObj);
diff --git a/include/gpu/GrTBackendEffectFactory.h b/include/gpu/GrTBackendEffectFactory.h
deleted file mode 100644
index a45aeacb7..000000000
--- a/include/gpu/GrTBackendEffectFactory.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrTBackendEffectFactory_DEFINED
-#define GrTBackendEffectFactory_DEFINED
-
-#include "GrBackendEffectFactory.h"
-#include "gl/GrGLProgramEffects.h"
-
-/**
- * Implements GrBackendEffectFactory for a GrEffect subclass as a singleton. This can be used by
- * most GrEffect subclasses to implement the GrEffect::getFactory() method:
- *
- * const GrBackendEffectFactory& MyEffect::getFactory() const {
- * return GrTBackendEffectFactory<MyEffect>::getInstance();
- * }
- *
- * Using this class requires that the GrEffect subclass always produces the same GrGLEffect
- * subclass. Additionally, It adds the following requirements to the GrEffect and GrGLEffect
- * subclasses:
- *
- * 1. The GrGLEffect used by GrEffect subclass MyEffect must be named or typedef'ed to
- * MyEffect::GLEffect.
- * 2. MyEffect::GLEffect must have a static function:
- * EffectKey GenKey(const GrEffect, const GrGLCaps&)
- * which generates a key that maps 1 to 1 with code variations emitted by
- * MyEffect::GLEffect::emitCode().
- * 3. MyEffect must have a static function:
- * const char* Name()
- * which returns a human-readable name for the effect.
- */
-template <typename EffectClass>
-class GrTBackendEffectFactory : public GrBackendEffectFactory {
-
-public:
- typedef typename EffectClass::GLEffect GLEffect;
-
- /** Returns a human-readable name for the effect. Implemented using GLEffect::Name as described
- * in this class's comment. */
- virtual const char* name() const SK_OVERRIDE { return EffectClass::Name(); }
-
-
- /** Implemented using GLEffect::GenKey as described in this class's comment. */
- virtual void getGLEffectKey(const GrEffect& effect,
- const GrGLCaps& caps,
- GrEffectKeyBuilder* b) const SK_OVERRIDE {
- GLEffect::GenKey(effect, caps, b);
- }
-
- /** Returns a new instance of the appropriate *GL* implementation class
- for the given GrEffect; caller is responsible for deleting
- the object. */
- virtual GrGLEffect* createGLInstance(const GrEffect& effect) const SK_OVERRIDE {
- return SkNEW_ARGS(GLEffect, (*this, effect));
- }
-
- /** This class is a singleton. This function returns the single instance. */
- static const GrBackendEffectFactory& getInstance() {
- static SkAlignedSTStorage<1, GrTBackendEffectFactory> gInstanceMem;
- static const GrTBackendEffectFactory* gInstance;
- if (!gInstance) {
- gInstance = SkNEW_PLACEMENT(gInstanceMem.get(),
- GrTBackendEffectFactory);
- }
- return *gInstance;
- }
-
-protected:
- GrTBackendEffectFactory() {}
-};
-
-#endif
diff --git a/include/gpu/GrTBackendProcessorFactory.h b/include/gpu/GrTBackendProcessorFactory.h
new file mode 100644
index 000000000..c67f508f5
--- /dev/null
+++ b/include/gpu/GrTBackendProcessorFactory.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrTBackendProcessorFactory_DEFINED
+#define GrTBackendProcessorFactory_DEFINED
+
+#include "GrBackendProcessorFactory.h"
+#include "gl/GrGLProgramEffects.h"
+
+/**
+ * Implements GrBackendEffectFactory for a GrProcessor subclass as a singleton. This can be used by
+ * most GrProcessor subclasses to implement the GrProcessor::getFactory() method:
+ *
+ * const GrBackendEffectFactory& MyEffect::getFactory() const {
+ * return GrTBackendEffectFactory<MyEffect>::getInstance();
+ * }
+ *
+ * Using this class requires that the GrProcessor subclass always produces the same GrGLProcessor
+ * subclass. Additionally, it adds the following requirements to the GrProcessor and GrGLProcessor
+ * subclasses:
+ *
+ * 1. The GrGLProcessor used by GrProcessor subclass MyEffect must be named or typedef'ed to
+ * MyEffect::GLProcessor.
+ * 2. MyEffect::GLProcessor must have a static function:
+ * EffectKey GenKey(const GrProcessor, const GrGLCaps&)
+ * which generates a key that maps 1 to 1 with code variations emitted by
+ * MyEffect::GLProcessor::emitCode().
+ * 3. MyEffect must have a static function:
+ * const char* Name()
+ * which returns a human-readable name for the effect.
+ */
+template <class ProcessorClass, class BackEnd, class ProcessorBase, class GLProcessorBase>
+class GrTBackendProcessorFactory : public BackEnd {
+public:
+ typedef typename ProcessorClass::GLProcessor GLProcessor;
+
+ /** Returns a human-readable name for the effect. Implemented using GLProcessor::Name as
+ * described in this class's comment. */
+ virtual const char* name() const SK_OVERRIDE { return ProcessorClass::Name(); }
+
+
+ /** Implemented using GLProcessor::GenKey as described in this class's comment. */
+ virtual void getGLProcessorKey(const GrProcessor& effect,
+ const GrGLCaps& caps,
+ GrProcessorKeyBuilder* b) const SK_OVERRIDE {
+ GLProcessor::GenKey(effect, caps, b);
+ }
+
+ /** Returns a new instance of the appropriate *GL* implementation class
+ for the given GrProcessor; caller is responsible for deleting
+ the object. */
+ virtual GLProcessorBase* createGLInstance(const ProcessorBase& effect) const SK_OVERRIDE {
+ return SkNEW_ARGS(GLProcessor, (*this, effect));
+ }
+
+ /** This class is a singleton. This function returns the single instance. */
+ static const BackEnd& getInstance() {
+ static SkAlignedSTStorage<1, GrTBackendProcessorFactory> gInstanceMem;
+ static const GrTBackendProcessorFactory* gInstance;
+ if (!gInstance) {
+ gInstance = SkNEW_PLACEMENT(gInstanceMem.get(),
+ GrTBackendProcessorFactory);
+ }
+ return *gInstance;
+ }
+
+protected:
+ GrTBackendProcessorFactory() {}
+};
+
+/*
+ * Every effect so far derives from one of the following subclasses of GrTBackendProcessorFactory.
+ * All of this machinery is necessary to ensure that creatGLInstace is typesafe and does not
+ * require any casting
+ */
+template <class ProcessorClass>
+class GrTBackendGeometryProcessorFactory
+ : public GrTBackendProcessorFactory<ProcessorClass,
+ GrBackendGeometryProcessorFactory,
+ GrGeometryProcessor,
+ GrGLGeometryProcessor> {
+protected:
+ GrTBackendGeometryProcessorFactory() {}
+};
+
+template <class ProcessorClass>
+class GrTBackendFragmentProcessorFactory
+ : public GrTBackendProcessorFactory<ProcessorClass,
+ GrBackendFragmentProcessorFactory,
+ GrFragmentProcessor,
+ GrGLFragmentProcessor> {
+protected:
+ GrTBackendFragmentProcessorFactory() {}
+};
+
+
+#endif
diff --git a/include/gpu/GrTextureAccess.h b/include/gpu/GrTextureAccess.h
index d552e440c..5055e103f 100644
--- a/include/gpu/GrTextureAccess.h
+++ b/include/gpu/GrTextureAccess.h
@@ -108,7 +108,7 @@ 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 GrEffect uses different swizzles based on its input then it must
+ * key. However, if a GrProcessor uses different swizzles based on its input then it must
* consider that variation in its key-generation.
*/
class GrTextureAccess : public SkNoncopyable {
@@ -116,8 +116,8 @@ public:
SK_DECLARE_INST_COUNT_ROOT(GrTextureAccess);
/**
- * A default GrTextureAccess must have reset() called on it in a GrEffect subclass's
- * constructor if it will be accessible via GrEffect::textureAccess().
+ * A default GrTextureAccess must have reset() called on it in a GrProcessor subclass's
+ * constructor if it will be accessible via GrProcessor::textureAccess().
*/
GrTextureAccess();
@@ -165,7 +165,7 @@ public:
GrTexture* getTexture() const { return fTexture.get(); }
/**
- * For internal use by GrEffect.
+ * For internal use by GrProcessor.
*/
const GrGpuResourceRef* getProgramTexture() const { return &fTexture; }
diff --git a/include/gpu/GrTypesPriv.h b/include/gpu/GrTypesPriv.h
index dfe415345..94ec1d7cf 100644
--- a/include/gpu/GrTypesPriv.h
+++ b/include/gpu/GrTypesPriv.h
@@ -115,9 +115,9 @@ static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) {
}
/**
- * Semantic bindings for vertex attributes. kEffect means that the attribute is input to a GrEffect.
- * Each binding other than kEffect may not appear more than once in the current set of attributes.
- * kPosition must be appear for exactly one attribute.
+ * Semantic bindings for vertex attributes. kEffect means that the attribute is input to a
+ * GrProcessor. Each binding other than kEffect may not appear more than once in the current set of
+ * attributes. kPosition must be appear for exactly one attribute.
*/
enum GrVertexAttribBinding {
kPosition_GrVertexAttribBinding, // required, must have vector count of 2
@@ -127,10 +127,10 @@ enum GrVertexAttribBinding {
kLastFixedFunction_GrVertexAttribBinding = kCoverage_GrVertexAttribBinding,
- kEffect_GrVertexAttribBinding, // vector length must agree with
- // GrEffect::vertexAttribType() for each effect input to
+ kGeometryProcessor_GrVertexAttribBinding, // vector length must agree with
+ // GrProcessor::vertexAttribType() for each effect input to
// which the attribute is mapped by GrDrawState::setEffect()
- kLast_GrVertexAttribBinding = kEffect_GrVertexAttribBinding
+ kLast_GrVertexAttribBinding = kGeometryProcessor_GrVertexAttribBinding
};
static const int kGrVertexAttribBindingCnt = kLast_GrVertexAttribBinding + 1;
@@ -173,48 +173,48 @@ template <int N> class GrVertexAttribArray : public SkSTArray<N, GrVertexAttrib,
/**
* We have coverage effects that clip rendering to the edge of some geometric primitive.
* This enum specifies how that clipping is performed. Not all factories that take a
-* GrEffectEdgeType will succeed with all values and it is up to the caller to check for
+* GrProcessorEdgeType will succeed with all values and it is up to the caller to check for
* a NULL return.
*/
-enum GrEffectEdgeType {
- kFillBW_GrEffectEdgeType,
- kFillAA_GrEffectEdgeType,
- kInverseFillBW_GrEffectEdgeType,
- kInverseFillAA_GrEffectEdgeType,
- kHairlineAA_GrEffectEdgeType,
-
- kLast_GrEffectEdgeType = kHairlineAA_GrEffectEdgeType
+enum GrPrimitiveEdgeType {
+ kFillBW_GrProcessorEdgeType,
+ kFillAA_GrProcessorEdgeType,
+ kInverseFillBW_GrProcessorEdgeType,
+ kInverseFillAA_GrProcessorEdgeType,
+ kHairlineAA_GrProcessorEdgeType,
+
+ kLast_GrProcessorEdgeType = kHairlineAA_GrProcessorEdgeType
};
-static const int kGrEffectEdgeTypeCnt = kLast_GrEffectEdgeType + 1;
+static const int kGrProcessorEdgeTypeCnt = kLast_GrProcessorEdgeType + 1;
-static inline bool GrEffectEdgeTypeIsFill(const GrEffectEdgeType edgeType) {
- return (kFillAA_GrEffectEdgeType == edgeType || kFillBW_GrEffectEdgeType == edgeType);
+static inline bool GrProcessorEdgeTypeIsFill(const GrPrimitiveEdgeType edgeType) {
+ return (kFillAA_GrProcessorEdgeType == edgeType || kFillBW_GrProcessorEdgeType == edgeType);
}
-static inline bool GrEffectEdgeTypeIsInverseFill(const GrEffectEdgeType edgeType) {
- return (kInverseFillAA_GrEffectEdgeType == edgeType ||
- kInverseFillBW_GrEffectEdgeType == edgeType);
+static inline bool GrProcessorEdgeTypeIsInverseFill(const GrPrimitiveEdgeType edgeType) {
+ return (kInverseFillAA_GrProcessorEdgeType == edgeType ||
+ kInverseFillBW_GrProcessorEdgeType == edgeType);
}
-static inline bool GrEffectEdgeTypeIsAA(const GrEffectEdgeType edgeType) {
- return (kFillBW_GrEffectEdgeType != edgeType && kInverseFillBW_GrEffectEdgeType != edgeType);
+static inline bool GrProcessorEdgeTypeIsAA(const GrPrimitiveEdgeType edgeType) {
+ return (kFillBW_GrProcessorEdgeType != edgeType && kInverseFillBW_GrProcessorEdgeType != edgeType);
}
-static inline GrEffectEdgeType GrInvertEffectEdgeType(const GrEffectEdgeType edgeType) {
+static inline GrPrimitiveEdgeType GrInvertProcessorEdgeType(const GrPrimitiveEdgeType edgeType) {
switch (edgeType) {
- case kFillBW_GrEffectEdgeType:
- return kInverseFillBW_GrEffectEdgeType;
- case kFillAA_GrEffectEdgeType:
- return kInverseFillAA_GrEffectEdgeType;
- case kInverseFillBW_GrEffectEdgeType:
- return kFillBW_GrEffectEdgeType;
- case kInverseFillAA_GrEffectEdgeType:
- return kFillAA_GrEffectEdgeType;
- case kHairlineAA_GrEffectEdgeType:
+ case kFillBW_GrProcessorEdgeType:
+ return kInverseFillBW_GrProcessorEdgeType;
+ case kFillAA_GrProcessorEdgeType:
+ return kInverseFillAA_GrProcessorEdgeType;
+ case kInverseFillBW_GrProcessorEdgeType:
+ return kFillBW_GrProcessorEdgeType;
+ case kInverseFillAA_GrProcessorEdgeType:
+ return kFillAA_GrProcessorEdgeType;
+ case kHairlineAA_GrProcessorEdgeType:
SkFAIL("Hairline fill isn't invertible.");
}
- return kFillAA_GrEffectEdgeType; // suppress warning.
+ return kFillAA_GrProcessorEdgeType; // suppress warning.
}
#endif
diff --git a/include/gpu/SkGr.h b/include/gpu/SkGr.h
index cd5fabfde..df2ae5a32 100644
--- a/include/gpu/SkGr.h
+++ b/include/gpu/SkGr.h
@@ -86,7 +86,7 @@ void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor
bool constantColor, GrPaint* grPaint);
// This function is similar to skPaint2GrPaintNoShader but also converts
-// skPaint's shader to a GrTexture/GrEffectStage if possible.
+// skPaint's shader to a GrTexture/GrProcessorStage if possible.
// constantColor has the same meaning as in skPaint2GrPaintNoShader.
void SkPaint2GrPaintShader(GrContext* context, const SkPaint& skPaint,
bool constantColor, GrPaint* grPaint);
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index 6e2a7ca65..9c900d35f 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -395,9 +395,9 @@ void SkBitmapProcShader::toString(SkString* str) const {
#include "effects/GrSimpleTextureEffect.h"
#include "SkGr.h"
-bool SkBitmapProcShader::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* paintColor,
- GrEffect** effect) const {
+bool SkBitmapProcShader::asFragmentProcessor(GrContext* context, const SkPaint& paint,
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrFragmentProcessor** fp) const {
SkMatrix matrix;
matrix.setIDiv(fRawBitmap.width(), fRawBitmap.height());
@@ -472,9 +472,9 @@ bool SkBitmapProcShader::asNewEffect(GrContext* context, const SkPaint& paint,
SkColor2GrColorJustAlpha(paint.getColor());
if (useBicubic) {
- *effect = GrBicubicEffect::Create(texture, matrix, tm);
+ *fp = GrBicubicEffect::Create(texture, matrix, tm);
} else {
- *effect = GrSimpleTextureEffect::Create(texture, matrix, params);
+ *fp = GrSimpleTextureEffect::Create(texture, matrix, params);
}
GrUnlockAndUnrefCachedBitmapTexture(texture);
@@ -483,9 +483,8 @@ bool SkBitmapProcShader::asNewEffect(GrContext* context, const SkPaint& paint,
#else
-bool SkBitmapProcShader::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* paintColor,
- GrEffect** effect) const {
+bool SkBitmapProcShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*,
+ GrFragmentProcessor**) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
diff --git a/src/core/SkBitmapProcShader.h b/src/core/SkBitmapProcShader.h
index d293c5030..cd52d9954 100644
--- a/src/core/SkBitmapProcShader.h
+++ b/src/core/SkBitmapProcShader.h
@@ -31,7 +31,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader)
- bool asNewEffect(GrContext*, const SkPaint&, const SkMatrix*, GrColor*, GrEffect**)
+ bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*,
+ GrFragmentProcessor**)
const SK_OVERRIDE;
class BitmapProcShaderContext : public SkShader::Context {
diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp
index a686f4c41..aadb29cb2 100644
--- a/src/core/SkColorFilter.cpp
+++ b/src/core/SkColorFilter.cpp
@@ -40,6 +40,6 @@ SkColor SkColorFilter::filterColor(SkColor c) const {
return SkUnPreMultiply::PMColorToColor(dst);
}
-GrEffect* SkColorFilter::asNewEffect(GrContext*) const {
+GrFragmentProcessor* SkColorFilter::asFragmentProcessor(GrContext*) const {
return NULL;
}
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index e5be085f2..56c310d37 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -227,7 +227,7 @@ bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const Context&,
}
bool SkImageFilter::canFilterImageGPU() const {
- return this->asNewEffect(NULL, NULL, SkMatrix::I(), SkIRect());
+ return this->asFragmentProcessor(NULL, NULL, SkMatrix::I(), SkIRect());
}
bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
@@ -263,16 +263,16 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont
am.setIdentity(context);
GrContext::AutoRenderTarget art(context, dst.texture()->asRenderTarget());
GrContext::AutoClip acs(context, dstRect);
- GrEffect* effect;
+ GrFragmentProcessor* fp;
offset->fX = bounds.left();
offset->fY = bounds.top();
bounds.offset(-srcOffset);
SkMatrix matrix(ctx.ctm());
matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
- this->asNewEffect(&effect, srcTexture, matrix, bounds);
- SkASSERT(effect);
+ this->asFragmentProcessor(&fp, srcTexture, matrix, bounds);
+ SkASSERT(fp);
GrPaint paint;
- paint.addColorEffect(effect)->unref();
+ paint.addColorProcessor(fp)->unref();
context->drawRectToRect(paint, dstRect, srcRect);
SkAutoTUnref<GrTexture> resultTex(dst.detach());
@@ -365,7 +365,8 @@ bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
return true;
}
-bool SkImageFilter::asNewEffect(GrEffect**, GrTexture*, const SkMatrix&, const SkIRect&) const {
+bool SkImageFilter::asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&,
+ const SkIRect&) const {
return false;
}
diff --git a/src/core/SkLocalMatrixShader.h b/src/core/SkLocalMatrixShader.h
index 352c1e31b..b8e471461 100644
--- a/src/core/SkLocalMatrixShader.h
+++ b/src/core/SkLocalMatrixShader.h
@@ -34,19 +34,20 @@ public:
#if SK_SUPPORT_GPU
- virtual bool asNewEffect(GrContext* context, const SkPaint& paint, const SkMatrix* localMatrix,
- GrColor* grColor, GrEffect** grEffect) const SK_OVERRIDE {
+ virtual bool asFragmentProcessor(GrContext* context, const SkPaint& paint,
+ const SkMatrix* localMatrix, GrColor* grColor,
+ GrFragmentProcessor** fp) const SK_OVERRIDE {
SkMatrix tmp = this->getLocalMatrix();
if (localMatrix) {
tmp.preConcat(*localMatrix);
}
- return fProxyShader->asNewEffect(context, paint, &tmp, grColor, grEffect);
+ return fProxyShader->asFragmentProcessor(context, paint, &tmp, grColor, fp);
}
#else
- virtual bool asNewEffect(GrContext* context, const SkPaint& paint, const SkMatrix* localMatrix,
- GrColor* grColor, GrEffect** grEffect) const SK_OVERRIDE {
+ virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*,
+ GrFragmentProcessor**) const SK_OVERRIDE {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
diff --git a/src/core/SkMaskFilter.cpp b/src/core/SkMaskFilter.cpp
index a2adc7c32..86f303c56 100644
--- a/src/core/SkMaskFilter.cpp
+++ b/src/core/SkMaskFilter.cpp
@@ -298,7 +298,7 @@ SkMaskFilter::filterRectsToNine(const SkRect[], int count, const SkMatrix&,
}
#if SK_SUPPORT_GPU
-bool SkMaskFilter::asNewEffect(GrEffect** effect, GrTexture*, const SkMatrix&) const {
+bool SkMaskFilter::asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&) const {
return false;
}
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
index 03eeb74c5..8a16ea3b0 100644
--- a/src/core/SkPictureShader.cpp
+++ b/src/core/SkPictureShader.cpp
@@ -212,19 +212,18 @@ void SkPictureShader::toString(SkString* str) const {
#endif
#if SK_SUPPORT_GPU
-bool SkPictureShader::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* paintColor,
- GrEffect** effect) const {
+bool SkPictureShader::asFragmentProcessor(GrContext* context, const SkPaint& paint,
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrFragmentProcessor** fp) const {
SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(context->getMatrix(), localMatrix));
if (!bitmapShader) {
return false;
}
- return bitmapShader->asNewEffect(context, paint, NULL, paintColor, effect);
+ return bitmapShader->asFragmentProcessor(context, paint, NULL, paintColor, fp);
}
#else
-bool SkPictureShader::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* paintColor,
- GrEffect** effect) const {
+bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*,
+ GrFragmentProcessor**) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
diff --git a/src/core/SkPictureShader.h b/src/core/SkPictureShader.h
index 99c70c946..24aa7803c 100644
--- a/src/core/SkPictureShader.h
+++ b/src/core/SkPictureShader.h
@@ -30,8 +30,8 @@ public:
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureShader)
- bool asNewEffect(GrContext*, const SkPaint&, const SkMatrix*, GrColor*, GrEffect**)
- const SK_OVERRIDE;
+ bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*,
+ GrFragmentProcessor**) const SK_OVERRIDE;
protected:
SkPictureShader(SkReadBuffer&);
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index 67fa12273..d8e408516 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -223,9 +223,8 @@ SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const {
return kNone_GradientType;
}
-bool SkShader::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrixOrNull, GrColor* paintColor,
- GrEffect** effect) const {
+bool SkShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*,
+ GrFragmentProcessor**) const {
return false;
}
@@ -370,10 +369,9 @@ SkShader::GradientType SkColorShader::asAGradient(GradientInfo* info) const {
#include "SkGr.h"
-bool SkColorShader::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* paintColor,
- GrEffect** effect) const {
- *effect = NULL;
+bool SkColorShader::asFragmentProcessor(GrContext*, const SkPaint& paint, const SkMatrix*,
+ GrColor* paintColor, GrFragmentProcessor** fp) const {
+ *fp = NULL;
SkColor skColor = fColor;
U8CPU newA = SkMulDiv255Round(SkColorGetA(fColor), paint.getAlpha());
*paintColor = SkColor2GrColor(SkColorSetA(skColor, newA));
@@ -382,9 +380,8 @@ bool SkColorShader::asNewEffect(GrContext* context, const SkPaint& paint,
#else
-bool SkColorShader::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* paintColor,
- GrEffect** effect) const {
+bool SkColorShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*,
+ GrFragmentProcessor**) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp
index d7f5a7c22..443aa1940 100644
--- a/src/core/SkXfermode.cpp
+++ b/src/core/SkXfermode.cpp
@@ -676,21 +676,18 @@ bool SkXfermode::asMode(Mode* mode) const {
return false;
}
-bool SkXfermode::asNewEffect(GrEffect** effect, GrTexture* background) const {
+bool SkXfermode::asFragmentProcessor(GrFragmentProcessor**, GrTexture*) const {
return false;
}
-bool SkXfermode::AsNewEffectOrCoeff(SkXfermode* xfermode,
- GrEffect** effect,
- Coeff* src,
- Coeff* dst,
- GrTexture* background) {
+bool SkXfermode::asFragmentProcessorOrCoeff(SkXfermode* xfermode, GrFragmentProcessor** fp,
+ Coeff* src, Coeff* dst, GrTexture* background) {
if (NULL == xfermode) {
return ModeAsCoeff(kSrcOver_Mode, src, dst);
} else if (xfermode->asCoeff(src, dst)) {
return true;
} else {
- return xfermode->asNewEffect(effect, background);
+ return xfermode->asFragmentProcessor(fp, background);
}
}
@@ -778,23 +775,23 @@ void SkXfermode::xferA8(SkAlpha* SK_RESTRICT dst,
#if SK_SUPPORT_GPU
-#include "GrEffect.h"
+#include "GrProcessor.h"
#include "GrCoordTransform.h"
-#include "GrEffectUnitTest.h"
-#include "GrTBackendEffectFactory.h"
-#include "gl/GrGLEffect.h"
+#include "GrProcessorUnitTest.h"
+#include "GrTBackendProcessorFactory.h"
+#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
/**
- * GrEffect that implements the all the separable xfer modes that cannot be expressed as Coeffs.
+ * GrProcessor that implements the all the separable xfer modes that cannot be expressed as Coeffs.
*/
-class XferEffect : public GrEffect {
+class XferEffect : public GrFragmentProcessor {
public:
static bool IsSupportedMode(SkXfermode::Mode mode) {
return mode > SkXfermode::kLastCoeffMode && mode <= SkXfermode::kLastMode;
}
- static GrEffect* Create(SkXfermode::Mode mode, GrTexture* background) {
+ static GrFragmentProcessor* Create(SkXfermode::Mode mode, GrTexture* background) {
if (!IsSupportedMode(mode)) {
return NULL;
} else {
@@ -807,8 +804,8 @@ public:
*validFlags = 0;
}
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
- return GrTBackendEffectFactory<XferEffect>::getInstance();
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
+ return GrTBackendFragmentProcessorFactory<XferEffect>::getInstance();
}
static const char* Name() { return "XferEffect"; }
@@ -816,21 +813,21 @@ public:
SkXfermode::Mode mode() const { return fMode; }
const GrTextureAccess& backgroundAccess() const { return fBackgroundAccess; }
- class GLEffect : public GrGLEffect {
+ class GLProcessor : public GrGLFragmentProcessor {
public:
- GLEffect(const GrBackendEffectFactory& factory, const GrEffect&)
- : GrGLEffect(factory) {
+ GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
+ : INHERITED(factory) {
}
virtual void emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& fp,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
const TextureSamplerArray& samplers) SK_OVERRIDE {
- SkXfermode::Mode mode = effect.cast<XferEffect>().mode();
+ SkXfermode::Mode mode = fp.cast<XferEffect>().mode();
const GrTexture* backgroundTex =
- effect.cast<XferEffect>().backgroundAccess().getTexture();
+ fp.cast<XferEffect>().backgroundAccess().getTexture();
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
const char* dstColor;
if (backgroundTex) {
@@ -971,12 +968,12 @@ public:
}
}
- static inline void GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
+ static inline void GenKey(const GrProcessor& proc, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
// The background may come from the dst or from a texture.
- uint32_t key = effect.numTextures();
+ uint32_t key = proc.numTextures();
SkASSERT(key <= 1);
- key |= effect.cast<XferEffect>().mode() << 1;
+ key |= proc.cast<XferEffect>().mode() << 1;
b->add32(key);
}
@@ -1197,10 +1194,10 @@ public:
}
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
private:
XferEffect(SkXfermode::Mode mode, GrTexture* background)
@@ -1214,7 +1211,7 @@ private:
this->setWillReadDstColor();
}
}
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE {
const XferEffect& s = other.cast<XferEffect>();
return fMode == s.fMode &&
fBackgroundAccess.getTexture() == s.fBackgroundAccess.getTexture();
@@ -1224,14 +1221,14 @@ private:
GrCoordTransform fBackgroundTransform;
GrTextureAccess fBackgroundAccess;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
-GR_DEFINE_EFFECT_TEST(XferEffect);
-GrEffect* XferEffect::TestCreate(SkRandom* rand,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture*[]) {
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(XferEffect);
+GrFragmentProcessor* XferEffect::TestCreate(SkRandom* rand,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture*[]) {
int mode = rand->nextRangeU(SkXfermode::kLastCoeffMode + 1, SkXfermode::kLastSeparableMode);
return SkNEW_ARGS(XferEffect, (static_cast<SkXfermode::Mode>(mode), NULL));
@@ -1380,11 +1377,12 @@ void SkProcCoeffXfermode::xferA8(SkAlpha* SK_RESTRICT dst,
}
#if SK_SUPPORT_GPU
-bool SkProcCoeffXfermode::asNewEffect(GrEffect** effect, GrTexture* background) const {
+bool SkProcCoeffXfermode::asFragmentProcessor(GrFragmentProcessor** fp,
+ GrTexture* background) const {
if (XferEffect::IsSupportedMode(fMode)) {
- if (effect) {
- *effect = XferEffect::Create(fMode, background);
- SkASSERT(*effect);
+ if (fp) {
+ *fp = XferEffect::Create(fMode, background);
+ SkASSERT(*fp);
}
return true;
}
diff --git a/src/core/SkXfermode_proccoeff.h b/src/core/SkXfermode_proccoeff.h
index 47472e683..f3b9b2491 100644
--- a/src/core/SkXfermode_proccoeff.h
+++ b/src/core/SkXfermode_proccoeff.h
@@ -35,8 +35,8 @@ public:
virtual bool asCoeff(Coeff* sc, Coeff* dc) const SK_OVERRIDE;
#if SK_SUPPORT_GPU
- virtual bool asNewEffect(GrEffect** effect,
- GrTexture* background) const SK_OVERRIDE;
+ virtual bool asFragmentProcessor(GrFragmentProcessor**,
+ GrTexture* background) const SK_OVERRIDE;
#endif
SK_TO_STRING_OVERRIDE()
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index 44752501e..09cc61851 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -27,8 +27,8 @@ protected:
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
#if SK_SUPPORT_GPU
- virtual bool asNewEffect(GrEffect** effect, GrTexture* texture,
- const SkMatrix& matrix, const SkIRect& bounds) const SK_OVERRIDE;
+ virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&,
+ const SkIRect& bounds) const SK_OVERRIDE;
#endif
private:
@@ -48,23 +48,23 @@ SkImageFilter* SkAlphaThresholdFilter::Create(const SkRegion& region,
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrCoordTransform.h"
-#include "GrEffect.h"
-#include "gl/GrGLEffect.h"
+#include "GrProcessor.h"
+#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "GrTextureAccess.h"
#include "SkGr.h"
class GrGLAlphaThresholdEffect;
-class AlphaThresholdEffect : public GrEffect {
+class AlphaThresholdEffect : public GrFragmentProcessor {
public:
- static GrEffect* Create(GrTexture* texture,
- GrTexture* maskTexture,
- float innerThreshold,
- float outerThreshold) {
+ static GrFragmentProcessor* Create(GrTexture* texture,
+ GrTexture* maskTexture,
+ float innerThreshold,
+ float outerThreshold) {
return SkNEW_ARGS(AlphaThresholdEffect, (texture,
maskTexture,
innerThreshold,
@@ -75,13 +75,13 @@ public:
static const char* Name() { return "Alpha Threshold"; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
float innerThreshold() const { return fInnerThreshold; }
float outerThreshold() const { return fOuterThreshold; }
- typedef GrGLAlphaThresholdEffect GLEffect;
+ typedef GrGLAlphaThresholdEffect GLProcessor;
private:
AlphaThresholdEffect(GrTexture* texture,
@@ -102,9 +102,9 @@ private:
this->addTextureAccess(&fMaskTextureAccess);
}
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
float fInnerThreshold;
float fOuterThreshold;
@@ -113,39 +113,39 @@ private:
GrCoordTransform fMaskCoordTransform;
GrTextureAccess fMaskTextureAccess;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
-class GrGLAlphaThresholdEffect : public GrGLEffect {
+class GrGLAlphaThresholdEffect : public GrGLFragmentProcessor {
public:
- GrGLAlphaThresholdEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GrGLAlphaThresholdEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
private:
GrGLProgramDataManager::UniformHandle fInnerThresholdVar;
GrGLProgramDataManager::UniformHandle fOuterThresholdVar;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
-GrGLAlphaThresholdEffect::GrGLAlphaThresholdEffect(const GrBackendEffectFactory& factory,
- const GrEffect&)
+GrGLAlphaThresholdEffect::GrGLAlphaThresholdEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor&)
: INHERITED(factory) {
}
void GrGLAlphaThresholdEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey& key,
+ const GrFragmentProcessor&,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -194,22 +194,22 @@ void GrGLAlphaThresholdEffect::emitCode(GrGLProgramBuilder* builder,
}
void GrGLAlphaThresholdEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
- const AlphaThresholdEffect& alpha_threshold = effect.cast<AlphaThresholdEffect>();
+ const GrProcessor& proc) {
+ const AlphaThresholdEffect& alpha_threshold = proc.cast<AlphaThresholdEffect>();
pdman.set1f(fInnerThresholdVar, alpha_threshold.innerThreshold());
pdman.set1f(fOuterThresholdVar, alpha_threshold.outerThreshold());
}
/////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(AlphaThresholdEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(AlphaThresholdEffect);
-GrEffect* AlphaThresholdEffect::TestCreate(SkRandom* random,
+GrFragmentProcessor* AlphaThresholdEffect::TestCreate(SkRandom* random,
GrContext* context,
const GrDrawTargetCaps&,
GrTexture** textures) {
- GrTexture* bmpTex = textures[GrEffectUnitTest::kSkiaPMTextureIdx];
- GrTexture* maskTex = textures[GrEffectUnitTest::kAlphaTextureIdx];
+ GrTexture* bmpTex = textures[GrProcessorUnitTest::kSkiaPMTextureIdx];
+ GrTexture* maskTex = textures[GrProcessorUnitTest::kAlphaTextureIdx];
float inner_thresh = random->nextUScalar1();
float outer_thresh = random->nextUScalar1();
return AlphaThresholdEffect::Create(bmpTex, maskTex, inner_thresh, outer_thresh);
@@ -217,11 +217,11 @@ GrEffect* AlphaThresholdEffect::TestCreate(SkRandom* random,
///////////////////////////////////////////////////////////////////////////////
-const GrBackendEffectFactory& AlphaThresholdEffect::getFactory() const {
- return GrTBackendEffectFactory<AlphaThresholdEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& AlphaThresholdEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<AlphaThresholdEffect>::getInstance();
}
-bool AlphaThresholdEffect::onIsEqual(const GrEffect& sBase) const {
+bool AlphaThresholdEffect::onIsEqual(const GrProcessor& sBase) const {
const AlphaThresholdEffect& s = sBase.cast<AlphaThresholdEffect>();
return (this->texture(0) == s.texture(0) &&
this->fInnerThreshold == s.fInnerThreshold &&
@@ -268,9 +268,11 @@ SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(const SkRegion& region,
}
#if SK_SUPPORT_GPU
-bool SkAlphaThresholdFilterImpl::asNewEffect(GrEffect** effect, GrTexture* texture,
- const SkMatrix& in_matrix, const SkIRect&) const {
- if (effect) {
+bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp,
+ GrTexture* texture,
+ const SkMatrix& in_matrix,
+ const SkIRect&) const {
+ if (fp) {
GrContext* context = texture->getContext();
GrTextureDesc maskDesc;
if (context->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) {
@@ -307,10 +309,10 @@ bool SkAlphaThresholdFilterImpl::asNewEffect(GrEffect** effect, GrTexture* textu
context->setMatrix(old_matrix);
}
- *effect = AlphaThresholdEffect::Create(texture,
- maskTexture,
- fInnerThreshold,
- fOuterThreshold);
+ *fp = AlphaThresholdEffect::Create(texture,
+ maskTexture,
+ fInnerThreshold,
+ fOuterThreshold);
}
return true;
}
diff --git a/src/effects/SkArithmeticMode.cpp b/src/effects/SkArithmeticMode.cpp
index 7ee2a70f6..85af19cf5 100644
--- a/src/effects/SkArithmeticMode.cpp
+++ b/src/effects/SkArithmeticMode.cpp
@@ -14,9 +14,9 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrCoordTransform.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#endif
static const bool gUseUnpremul = false;
@@ -35,7 +35,8 @@ public:
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkArithmeticMode_scalar)
#if SK_SUPPORT_GPU
- virtual bool asNewEffect(GrEffect** effect, GrTexture* background) const SK_OVERRIDE;
+ virtual bool asFragmentProcessor(GrFragmentProcessor**,
+ GrTexture* background) const SK_OVERRIDE;
#endif
private:
@@ -247,44 +248,44 @@ SkXfermode* SkArithmeticMode::Create(SkScalar k1, SkScalar k2,
#if SK_SUPPORT_GPU
-class GrGLArithmeticEffect : public GrGLEffect {
+class GrGLArithmeticEffect : public GrGLFragmentProcessor {
public:
- GrGLArithmeticEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GrGLArithmeticEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual ~GrGLArithmeticEffect();
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
- static void GenKey(const GrEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
+ static void GenKey(const GrProcessor&, const GrGLCaps& caps, GrProcessorKeyBuilder* b);
private:
GrGLProgramDataManager::UniformHandle fKUni;
bool fEnforcePMColor;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
-class GrArithmeticEffect : public GrEffect {
+class GrArithmeticEffect : public GrFragmentProcessor {
public:
- static GrEffect* Create(float k1, float k2, float k3, float k4, bool enforcePMColor,
+ static GrFragmentProcessor* Create(float k1, float k2, float k3, float k4, bool enforcePMColor,
GrTexture* background) {
return SkNEW_ARGS(GrArithmeticEffect, (k1, k2, k3, k4, enforcePMColor, background));
}
virtual ~GrArithmeticEffect();
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
- typedef GrGLArithmeticEffect GLEffect;
+ typedef GrGLArithmeticEffect GLProcessor;
static const char* Name() { return "Arithmetic"; }
GrTexture* backgroundTexture() const { return fBackgroundAccess.getTexture(); }
@@ -297,7 +298,7 @@ public:
bool enforcePMColor() const { return fEnforcePMColor; }
private:
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
GrArithmeticEffect(float k1, float k2, float k3, float k4, bool enforcePMColor,
GrTexture* background);
@@ -306,8 +307,8 @@ private:
GrCoordTransform fBackgroundTransform;
GrTextureAccess fBackgroundAccess;
- GR_DECLARE_EFFECT_TEST;
- typedef GrEffect INHERITED;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
+ typedef GrFragmentProcessor INHERITED;
};
@@ -329,7 +330,7 @@ GrArithmeticEffect::GrArithmeticEffect(float k1, float k2, float k3, float k4,
GrArithmeticEffect::~GrArithmeticEffect() {
}
-bool GrArithmeticEffect::onIsEqual(const GrEffect& sBase) const {
+bool GrArithmeticEffect::onIsEqual(const GrProcessor& sBase) const {
const GrArithmeticEffect& s = sBase.cast<GrArithmeticEffect>();
return fK1 == s.fK1 &&
fK2 == s.fK2 &&
@@ -339,8 +340,8 @@ bool GrArithmeticEffect::onIsEqual(const GrEffect& sBase) const {
backgroundTexture() == s.backgroundTexture();
}
-const GrBackendEffectFactory& GrArithmeticEffect::getFactory() const {
- return GrTBackendEffectFactory<GrArithmeticEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& GrArithmeticEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<GrArithmeticEffect>::getInstance();
}
void GrArithmeticEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const {
@@ -350,8 +351,8 @@ void GrArithmeticEffect::getConstantColorComponents(GrColor* color, uint32_t* va
///////////////////////////////////////////////////////////////////////////////
-GrGLArithmeticEffect::GrGLArithmeticEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GrGLArithmeticEffect::GrGLArithmeticEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor&)
: INHERITED(factory),
fEnforcePMColor(true) {
}
@@ -360,14 +361,14 @@ GrGLArithmeticEffect::~GrGLArithmeticEffect() {
}
void GrGLArithmeticEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& fp,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
const TextureSamplerArray& samplers) {
- GrTexture* backgroundTex = effect.cast<GrArithmeticEffect>().backgroundTexture();
+ GrTexture* backgroundTex = fp.cast<GrArithmeticEffect>().backgroundTexture();
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
const char* dstColor;
if (backgroundTex) {
@@ -408,15 +409,16 @@ void GrGLArithmeticEffect::emitCode(GrGLProgramBuilder* builder,
}
}
-void GrGLArithmeticEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect& effect) {
- const GrArithmeticEffect& arith = effect.cast<GrArithmeticEffect>();
+void GrGLArithmeticEffect::setData(const GrGLProgramDataManager& pdman,
+ const GrProcessor& processor) {
+ const GrArithmeticEffect& arith = processor.cast<GrArithmeticEffect>();
pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4());
fEnforcePMColor = arith.enforcePMColor();
}
-void GrGLArithmeticEffect::GenKey(const GrEffect& effect,
- const GrGLCaps&, GrEffectKeyBuilder* b) {
- const GrArithmeticEffect& arith = effect.cast<GrArithmeticEffect>();
+void GrGLArithmeticEffect::GenKey(const GrProcessor& processor,
+ const GrGLCaps&, GrProcessorKeyBuilder* b) {
+ const GrArithmeticEffect& arith = processor.cast<GrArithmeticEffect>();
uint32_t key = arith.enforcePMColor() ? 1 : 0;
if (arith.backgroundTexture()) {
key |= 2;
@@ -424,10 +426,10 @@ void GrGLArithmeticEffect::GenKey(const GrEffect& effect,
b->add32(key);
}
-GrEffect* GrArithmeticEffect::TestCreate(SkRandom* rand,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture*[]) {
+GrFragmentProcessor* GrArithmeticEffect::TestCreate(SkRandom* rand,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture*[]) {
float k1 = rand->nextF();
float k2 = rand->nextF();
float k3 = rand->nextF();
@@ -437,16 +439,17 @@ GrEffect* GrArithmeticEffect::TestCreate(SkRandom* rand,
return SkNEW_ARGS(GrArithmeticEffect, (k1, k2, k3, k4, enforcePMColor, NULL));
}
-GR_DEFINE_EFFECT_TEST(GrArithmeticEffect);
-
-bool SkArithmeticMode_scalar::asNewEffect(GrEffect** effect, GrTexture* background) const {
- if (effect) {
- *effect = GrArithmeticEffect::Create(SkScalarToFloat(fK[0]),
- SkScalarToFloat(fK[1]),
- SkScalarToFloat(fK[2]),
- SkScalarToFloat(fK[3]),
- fEnforcePMColor,
- background);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticEffect);
+
+bool SkArithmeticMode_scalar::asFragmentProcessor(GrFragmentProcessor** fp,
+ GrTexture* background) const {
+ if (fp) {
+ *fp = GrArithmeticEffect::Create(SkScalarToFloat(fK[0]),
+ SkScalarToFloat(fK[1]),
+ SkScalarToFloat(fK[2]),
+ SkScalarToFloat(fK[3]),
+ fEnforcePMColor,
+ background);
}
return true;
}
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 2bf4475c0..123b9d28e 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -20,11 +20,11 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrTexture.h"
-#include "GrEffect.h"
-#include "gl/GrGLEffect.h"
+#include "GrProcessor.h"
+#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "effects/GrSimpleTextureEffect.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "SkGrPixelRef.h"
#include "SkDraw.h"
#endif
@@ -554,21 +554,21 @@ void SkBlurMaskFilterImpl::flatten(SkWriteBuffer& buffer) const {
class GrGLRectBlurEffect;
-class GrRectBlurEffect : public GrEffect {
+class GrRectBlurEffect : public GrFragmentProcessor {
public:
virtual ~GrRectBlurEffect();
static const char* Name() { return "RectBlur"; }
- typedef GrGLRectBlurEffect GLEffect;
+ typedef GrGLRectBlurEffect GLProcessor;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
/**
* Create a simple filter effect with custom bicubic coefficients.
*/
- static GrEffect* Create(GrContext *context, const SkRect& rect, float sigma) {
+ static GrFragmentProcessor* Create(GrContext *context, const SkRect& rect, float sigma) {
GrTexture *blurProfileTexture = NULL;
int doubleProfileSize = SkScalarCeilToInt(12*sigma);
@@ -592,7 +592,7 @@ public:
private:
GrRectBlurEffect(const SkRect& rect, float sigma, GrTexture *blur_profile);
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
static bool CreateBlurProfileTexture(GrContext *context, float sigma,
GrTexture **blurProfileTexture);
@@ -601,24 +601,24 @@ private:
float fSigma;
GrTextureAccess fBlurProfileAccess;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
-class GrGLRectBlurEffect : public GrGLEffect {
+class GrGLRectBlurEffect : public GrGLFragmentProcessor {
public:
- GrGLRectBlurEffect(const GrBackendEffectFactory& factory,
- const GrEffect&);
+ GrGLRectBlurEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor&);
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
private:
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
@@ -626,12 +626,12 @@ private:
UniformHandle fProxyRectUniform;
UniformHandle fProfileSizeUniform;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
-GrGLRectBlurEffect::GrGLRectBlurEffect(const GrBackendEffectFactory& factory, const GrEffect&)
+GrGLRectBlurEffect::GrGLRectBlurEffect(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED(factory) {
}
@@ -652,8 +652,8 @@ void OutputRectBlurProfileLookup(GrGLFragmentShaderBuilder* fsBuilder,
}
void GrGLRectBlurEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey& key,
+ const GrFragmentProcessor&,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -696,8 +696,8 @@ void GrGLRectBlurEffect::emitCode(GrGLProgramBuilder* builder,
}
void GrGLRectBlurEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
- const GrRectBlurEffect& rbe = effect.cast<GrRectBlurEffect>();
+ const GrProcessor& proc) {
+ const GrRectBlurEffect& rbe = proc.cast<GrRectBlurEffect>();
SkRect rect = rbe.getRect();
pdman.set4f(fProxyRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
@@ -756,11 +756,11 @@ GrRectBlurEffect::GrRectBlurEffect(const SkRect& rect, float sigma,
GrRectBlurEffect::~GrRectBlurEffect() {
}
-const GrBackendEffectFactory& GrRectBlurEffect::getFactory() const {
- return GrTBackendEffectFactory<GrRectBlurEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& GrRectBlurEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<GrRectBlurEffect>::getInstance();
}
-bool GrRectBlurEffect::onIsEqual(const GrEffect& sBase) const {
+bool GrRectBlurEffect::onIsEqual(const GrProcessor& sBase) const {
const GrRectBlurEffect& s = sBase.cast<GrRectBlurEffect>();
return this->getSigma() == s.getSigma() && this->getRect() == s.getRect();
}
@@ -770,12 +770,12 @@ void GrRectBlurEffect::getConstantColorComponents(GrColor* color, uint32_t* vali
return;
}
-GR_DEFINE_EFFECT_TEST(GrRectBlurEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect);
-GrEffect* GrRectBlurEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrFragmentProcessor* GrRectBlurEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
float sigma = random->nextRangeF(3,8);
float width = random->nextRangeF(200,300);
float height = random->nextRangeF(200,300);
@@ -806,8 +806,8 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
int pad=SkScalarCeilToInt(6*xformedSigma)/2;
rect.outset(SkIntToScalar(pad), SkIntToScalar(pad));
- SkAutoTUnref<GrEffect> effect(GrRectBlurEffect::Create(context, rect, xformedSigma));
- if (!effect) {
+ SkAutoTUnref<GrFragmentProcessor> fp(GrRectBlurEffect::Create(context, rect, xformedSigma));
+ if (!fp) {
return false;
}
@@ -816,7 +816,7 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
return false;
}
- grp->addCoverageEffect(effect);
+ grp->addCoverageProcessor(fp);
context->drawRect(*grp, rect);
return true;
@@ -824,10 +824,10 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
class GrGLRRectBlurEffect;
-class GrRRectBlurEffect : public GrEffect {
+class GrRRectBlurEffect : public GrFragmentProcessor {
public:
- static GrEffect* Create(GrContext* context, float sigma, const SkRRect&);
+ static GrFragmentProcessor* Create(GrContext* context, float sigma, const SkRRect&);
virtual ~GrRRectBlurEffect() {};
static const char* Name() { return "GrRRectBlur"; }
@@ -835,28 +835,29 @@ public:
const SkRRect& getRRect() const { return fRRect; }
float getSigma() const { return fSigma; }
- typedef GrGLRRectBlurEffect GLEffect;
+ typedef GrGLRRectBlurEffect GLProcessor;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
private:
GrRRectBlurEffect(float sigma, const SkRRect&, GrTexture* profileTexture);
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE;
SkRRect fRRect;
float fSigma;
GrTextureAccess fNinePatchAccess;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
-GrEffect* GrRRectBlurEffect::Create(GrContext* context, float sigma, const SkRRect& rrect) {
+GrFragmentProcessor* GrRRectBlurEffect::Create(GrContext* context, float sigma,
+ const SkRRect& rrect) {
if (!rrect.isSimpleCircular()) {
return NULL;
}
@@ -932,8 +933,8 @@ void GrRRectBlurEffect::getConstantColorComponents(GrColor* color, uint32_t* val
*validFlags = 0;
}
-const GrBackendEffectFactory& GrRRectBlurEffect::getFactory() const {
- return GrTBackendEffectFactory<GrRRectBlurEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& GrRRectBlurEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<GrRRectBlurEffect>::getInstance();
}
GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTexture *ninePatchTexture)
@@ -944,16 +945,16 @@ GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur
this->setWillReadFragmentPosition();
}
-bool GrRRectBlurEffect::onIsEqual(const GrEffect& other) const {
+bool GrRRectBlurEffect::onIsEqual(const GrProcessor& other) const {
const GrRRectBlurEffect& rrbe = other.cast<GrRRectBlurEffect>();
return fRRect.getSimpleRadii().fX == rrbe.fRRect.getSimpleRadii().fX && fSigma == rrbe.fSigma;
}
//////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrRRectBlurEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRRectBlurEffect);
-GrEffect* GrRRectBlurEffect::TestCreate(SkRandom* random,
+GrFragmentProcessor* GrRRectBlurEffect::TestCreate(SkRandom* random,
GrContext* context,
const GrDrawTargetCaps& caps,
GrTexture*[]) {
@@ -968,39 +969,39 @@ GrEffect* GrRRectBlurEffect::TestCreate(SkRandom* random,
//////////////////////////////////////////////////////////////////////////////
-class GrGLRRectBlurEffect : public GrGLEffect {
+class GrGLRRectBlurEffect : public GrGLFragmentProcessor {
public:
- GrGLRRectBlurEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GrGLRRectBlurEffect(const GrBackendProcessorFactory&, const GrProcessor&);
- virtual void emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ virtual void emitCode(GrGLProgramBuilder*,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
private:
GrGLProgramDataManager::UniformHandle fProxyRectUniform;
GrGLProgramDataManager::UniformHandle fCornerRadiusUniform;
GrGLProgramDataManager::UniformHandle fBlurRadiusUniform;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
-GrGLRRectBlurEffect::GrGLRRectBlurEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GrGLRRectBlurEffect::GrGLRRectBlurEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor&)
: INHERITED (factory) {
}
void GrGLRRectBlurEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
- const char* outputColor,
- const char* inputColor,
- const TransformedCoordsArray&,
- const TextureSamplerArray& samplers) {
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
+ const char* outputColor,
+ const char* inputColor,
+ const TransformedCoordsArray&,
+ const TextureSamplerArray& samplers) {
const char *rectName;
const char *cornerRadiusName;
const char *blurRadiusName;
@@ -1052,8 +1053,8 @@ void GrGLRRectBlurEffect::emitCode(GrGLProgramBuilder* builder,
}
void GrGLRRectBlurEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
- const GrRRectBlurEffect& brre = effect.cast<GrRRectBlurEffect>();
+ const GrProcessor& proc) {
+ const GrRRectBlurEffect& brre = proc.cast<GrRRectBlurEffect>();
SkRRect rrect = brre.getRRect();
float blurRadius = 3.f*SkScalarCeilToScalar(brre.getSigma()-1/6.0f);
@@ -1088,9 +1089,8 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
float extra=3.f*SkScalarCeilToScalar(xformedSigma-1/6.0f);
proxy_rect.outset(extra, extra);
- SkAutoTUnref<GrEffect> effect(GrRRectBlurEffect::Create(
- context, xformedSigma, rrect));
- if (!effect) {
+ SkAutoTUnref<GrFragmentProcessor> fp(GrRRectBlurEffect::Create(context, xformedSigma, rrect));
+ if (!fp) {
return false;
}
@@ -1099,7 +1099,7 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
return false;
}
- grp->addCoverageEffect(effect);
+ grp->addCoverageProcessor(fp);
context->drawRect(*grp, proxy_rect);
return true;
@@ -1172,7 +1172,7 @@ bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src,
matrix.setIDiv(src->width(), src->height());
// Blend pathTexture over blurTexture.
GrContext::AutoRenderTarget art(context, (*result)->asRenderTarget());
- paint.addColorEffect(GrSimpleTextureEffect::Create(src, matrix))->unref();
+ paint.addColorProcessor(GrSimpleTextureEffect::Create(src, matrix))->unref();
if (kInner_SkBlurStyle == fBlurStyle) {
// inner: dst = dst * src
paint.setBlendFunc(kDC_GrBlendCoeff, kZero_GrBlendCoeff);
diff --git a/src/effects/SkColorFilters.cpp b/src/effects/SkColorFilters.cpp
index 3d89d0b52..bd0d2aa6c 100644
--- a/src/effects/SkColorFilters.cpp
+++ b/src/effects/SkColorFilters.cpp
@@ -74,7 +74,7 @@ public:
#endif
#if SK_SUPPORT_GPU
- virtual GrEffect* asNewEffect(GrContext*) const SK_OVERRIDE;
+ virtual GrFragmentProcessor* asFragmentProcessor(GrContext*) const SK_OVERRIDE;
#endif
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkModeColorFilter)
@@ -123,10 +123,10 @@ SkFlattenable* SkModeColorFilter::CreateProc(SkReadBuffer& buffer) {
///////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
#include "GrBlend.h"
-#include "GrEffect.h"
-#include "GrEffectUnitTest.h"
-#include "GrTBackendEffectFactory.h"
-#include "gl/GrGLEffect.h"
+#include "GrProcessor.h"
+#include "GrProcessorUnitTest.h"
+#include "GrTBackendProcessorFactory.h"
+#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "SkGr.h"
@@ -182,9 +182,9 @@ static inline ColorExpr color_filter_expression(const SkXfermode::Mode& mode,
}
-class ModeColorFilterEffect : public GrEffect {
+class ModeColorFilterEffect : public GrFragmentProcessor {
public:
- static GrEffect* Create(const GrColor& c, SkXfermode::Mode mode) {
+ static GrFragmentProcessor* Create(const GrColor& c, SkXfermode::Mode mode) {
// TODO: Make the effect take the coeffs rather than mode since we already do the
// conversion here.
SkXfermode::Coeff srcCoeff, dstCoeff;
@@ -207,8 +207,8 @@ public:
return true;
}
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
- return GrTBackendEffectFactory<ModeColorFilterEffect>::getInstance();
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
+ return GrTBackendFragmentProcessorFactory<ModeColorFilterEffect>::getInstance();
}
static const char* Name() { return "ModeColorFilterEffect"; }
@@ -216,24 +216,24 @@ public:
SkXfermode::Mode mode() const { return fMode; }
GrColor color() const { return fColor; }
- class GLEffect : public GrGLEffect {
+ class GLProcessor : public GrGLFragmentProcessor {
public:
- GLEffect(const GrBackendEffectFactory& factory, const GrEffect&)
+ GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED(factory) {
}
virtual void emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& fp,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
- const TransformedCoordsArray& coords,
- const TextureSamplerArray& samplers) SK_OVERRIDE {
- SkXfermode::Mode mode = effect.cast<ModeColorFilterEffect>().mode();
+ const TransformedCoordsArray&,
+ const TextureSamplerArray&) SK_OVERRIDE {
+ SkXfermode::Mode mode = fp.cast<ModeColorFilterEffect>().mode();
SkASSERT(SkXfermode::kDst_Mode != mode);
const char* colorFilterColorUniName = NULL;
- if (effect.cast<ModeColorFilterEffect>().willUseFilterColor()) {
+ if (fp.cast<ModeColorFilterEffect>().willUseFilterColor()) {
fFilterColorUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec4f_GrSLType, "FilterColor",
&colorFilterColorUniName);
@@ -247,18 +247,18 @@ public:
codeAppendf("\t%s = %s;\n", outputColor, filter.c_str());
}
- static void GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
- const ModeColorFilterEffect& colorModeFilter = effect.cast<ModeColorFilterEffect>();
+ static void GenKey(const GrProcessor& fp, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
+ const ModeColorFilterEffect& colorModeFilter = fp.cast<ModeColorFilterEffect>();
// The SL code does not depend on filter color at the moment, so no need to represent it
// in the key.
b->add32(colorModeFilter.mode());
}
virtual void setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) SK_OVERRIDE {
+ const GrProcessor& fp) SK_OVERRIDE {
if (fFilterColorUni.isValid()) {
- const ModeColorFilterEffect& colorModeFilter = effect.cast<ModeColorFilterEffect>();
+ const ModeColorFilterEffect& colorModeFilter = fp.cast<ModeColorFilterEffect>();
GrGLfloat c[4];
GrColorToRGBAFloat(colorModeFilter.color(), c);
pdman.set4fv(fFilterColorUni, 1, c);
@@ -268,10 +268,10 @@ public:
private:
GrGLProgramDataManager::UniformHandle fFilterColorUni;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
private:
ModeColorFilterEffect(GrColor color, SkXfermode::Mode mode)
@@ -288,7 +288,7 @@ private:
}
}
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE {
const ModeColorFilterEffect& s = other.cast<ModeColorFilterEffect>();
return fMode == s.fMode && fColor == s.fColor;
}
@@ -296,7 +296,7 @@ private:
SkXfermode::Mode fMode;
GrColor fColor;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
namespace {
@@ -396,11 +396,11 @@ void ModeColorFilterEffect::getConstantColorComponents(GrColor* color, uint32_t*
*validFlags = result.getValidComponents();
}
-GR_DEFINE_EFFECT_TEST(ModeColorFilterEffect);
-GrEffect* ModeColorFilterEffect::TestCreate(SkRandom* rand,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture*[]) {
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ModeColorFilterEffect);
+GrFragmentProcessor* ModeColorFilterEffect::TestCreate(SkRandom* rand,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture*[]) {
SkXfermode::Mode mode = SkXfermode::kDst_Mode;
while (SkXfermode::kDst_Mode == mode) {
mode = static_cast<SkXfermode::Mode>(rand->nextRangeU(0, SkXfermode::kLastCoeffMode));
@@ -409,7 +409,7 @@ GrEffect* ModeColorFilterEffect::TestCreate(SkRandom* rand,
return ModeColorFilterEffect::Create(color, mode);
}
-GrEffect* SkModeColorFilter::asNewEffect(GrContext*) const {
+GrFragmentProcessor* SkModeColorFilter::asFragmentProcessor(GrContext*) const {
if (SkXfermode::kDst_Mode != fMode) {
return ModeColorFilterEffect::Create(SkColor2GrColor(fColor), fMode);
}
diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp
index bf098c840..5ac455253 100644
--- a/src/effects/SkColorMatrixFilter.cpp
+++ b/src/effects/SkColorMatrixFilter.cpp
@@ -332,21 +332,21 @@ bool SkColorMatrixFilter::asColorMatrix(SkScalar matrix[20]) const {
}
#if SK_SUPPORT_GPU
-#include "GrEffect.h"
-#include "GrTBackendEffectFactory.h"
-#include "gl/GrGLEffect.h"
+#include "GrProcessor.h"
+#include "GrTBackendProcessorFactory.h"
+#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
-class ColorMatrixEffect : public GrEffect {
+class ColorMatrixEffect : public GrFragmentProcessor {
public:
- static GrEffect* Create(const SkColorMatrix& matrix) {
+ static GrFragmentProcessor* Create(const SkColorMatrix& matrix) {
return SkNEW_ARGS(ColorMatrixEffect, (matrix));
}
static const char* Name() { return "Color Matrix"; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
- return GrTBackendEffectFactory<ColorMatrixEffect>::getInstance();
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
+ return GrTBackendFragmentProcessorFactory<ColorMatrixEffect>::getInstance();
}
virtual void getConstantColorComponents(GrColor* color,
@@ -394,21 +394,21 @@ public:
*color = static_cast<uint8_t>(SkScalarPin(outputA, 0, 255)) << GrColor_SHIFT_A;
}
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
- class GLEffect : public GrGLEffect {
+ class GLProcessor : public GrGLFragmentProcessor {
public:
// this class always generates the same code.
- static void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder* b) {}
+ static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder* b) {}
- GLEffect(const GrBackendEffectFactory& factory,
- const GrEffect&)
+ GLProcessor(const GrBackendProcessorFactory& factory,
+ const GrProcessor&)
: INHERITED(factory) {
}
virtual void emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
@@ -438,8 +438,8 @@ public:
}
virtual void setData(const GrGLProgramDataManager& uniManager,
- const GrEffect& effect) SK_OVERRIDE {
- const ColorMatrixEffect& cme = effect.cast<ColorMatrixEffect>();
+ const GrProcessor& proc) SK_OVERRIDE {
+ const ColorMatrixEffect& cme = proc.cast<ColorMatrixEffect>();
const float* m = cme.fMatrix.fMat;
// The GL matrix is transposed from SkColorMatrix.
GrGLfloat mt[] = {
@@ -460,28 +460,28 @@ public:
GrGLProgramDataManager::UniformHandle fMatrixHandle;
GrGLProgramDataManager::UniformHandle fVectorHandle;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
private:
ColorMatrixEffect(const SkColorMatrix& matrix) : fMatrix(matrix) {}
- virtual bool onIsEqual(const GrEffect& s) const {
+ virtual bool onIsEqual(const GrProcessor& s) const {
const ColorMatrixEffect& cme = s.cast<ColorMatrixEffect>();
return cme.fMatrix == fMatrix;
}
SkColorMatrix fMatrix;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
-GR_DEFINE_EFFECT_TEST(ColorMatrixEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorMatrixEffect);
-GrEffect* ColorMatrixEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* dummyTextures[2]) {
+GrFragmentProcessor* ColorMatrixEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* dummyTextures[2]) {
SkColorMatrix colorMatrix;
for (size_t i = 0; i < SK_ARRAY_COUNT(colorMatrix.fMat); ++i) {
colorMatrix.fMat[i] = random->nextSScalar1();
@@ -489,7 +489,7 @@ GrEffect* ColorMatrixEffect::TestCreate(SkRandom* random,
return ColorMatrixEffect::Create(colorMatrix);
}
-GrEffect* SkColorMatrixFilter::asNewEffect(GrContext*) const {
+GrFragmentProcessor* SkColorMatrixFilter::asFragmentProcessor(GrContext*) const {
return ColorMatrixEffect::Create(fMatrix);
}
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 6f23dae8c..474d9a7dc 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -13,9 +13,9 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrCoordTransform.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#endif
namespace {
@@ -297,41 +297,40 @@ bool SkDisplacementMapEffect::onFilterBounds(const SkIRect& src, const SkMatrix&
///////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
-class GrGLDisplacementMapEffect : public GrGLEffect {
+class GrGLDisplacementMapEffect : public GrGLFragmentProcessor {
public:
- GrGLDisplacementMapEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect);
+ GrGLDisplacementMapEffect(const GrBackendProcessorFactory&,
+ const GrProcessor&);
virtual ~GrGLDisplacementMapEffect();
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
private:
SkDisplacementMapEffect::ChannelSelectorType fXChannelSelector;
SkDisplacementMapEffect::ChannelSelectorType fYChannelSelector;
GrGLProgramDataManager::UniformHandle fScaleUni;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
-class GrDisplacementMapEffect : public GrEffect {
+class GrDisplacementMapEffect : public GrFragmentProcessor {
public:
- static GrEffect* Create(SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
- SkDisplacementMapEffect::ChannelSelectorType yChannelSelector,
- SkVector scale,
- GrTexture* displacement, const SkMatrix& offsetMatrix,
- GrTexture* color) {
+ static GrFragmentProcessor* Create(
+ SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
+ SkDisplacementMapEffect::ChannelSelectorType yChannelSelector, SkVector scale,
+ GrTexture* displacement, const SkMatrix& offsetMatrix, GrTexture* color) {
return SkNEW_ARGS(GrDisplacementMapEffect, (xChannelSelector,
yChannelSelector,
scale,
@@ -342,20 +341,20 @@ public:
virtual ~GrDisplacementMapEffect();
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
SkDisplacementMapEffect::ChannelSelectorType xChannelSelector() const
{ return fXChannelSelector; }
SkDisplacementMapEffect::ChannelSelectorType yChannelSelector() const
{ return fYChannelSelector; }
const SkVector& scale() const { return fScale; }
- typedef GrGLDisplacementMapEffect GLEffect;
+ typedef GrGLDisplacementMapEffect GLProcessor;
static const char* Name() { return "DisplacementMap"; }
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
private:
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
GrDisplacementMapEffect(SkDisplacementMapEffect::ChannelSelectorType xChannelSelector,
SkDisplacementMapEffect::ChannelSelectorType yChannelSelector,
@@ -363,7 +362,7 @@ private:
GrTexture* displacement, const SkMatrix& offsetMatrix,
GrTexture* color);
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
GrCoordTransform fDisplacementTransform;
GrTextureAccess fDisplacementAccess;
@@ -373,7 +372,7 @@ private:
SkDisplacementMapEffect::ChannelSelectorType fYChannelSelector;
SkVector fScale;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
@@ -431,7 +430,7 @@ bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src,
offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset.fX),
SkIntToScalar(colorOffset.fY - displacementOffset.fY));
- paint.addColorEffect(
+ paint.addColorProcessor(
GrDisplacementMapEffect::Create(fXChannelSelector,
fYChannelSelector,
scale,
@@ -479,7 +478,7 @@ GrDisplacementMapEffect::GrDisplacementMapEffect(
GrDisplacementMapEffect::~GrDisplacementMapEffect() {
}
-bool GrDisplacementMapEffect::onIsEqual(const GrEffect& sBase) const {
+bool GrDisplacementMapEffect::onIsEqual(const GrProcessor& sBase) const {
const GrDisplacementMapEffect& s = sBase.cast<GrDisplacementMapEffect>();
return fDisplacementAccess.getTexture() == s.fDisplacementAccess.getTexture() &&
fColorAccess.getTexture() == s.fColorAccess.getTexture() &&
@@ -488,8 +487,8 @@ bool GrDisplacementMapEffect::onIsEqual(const GrEffect& sBase) const {
fScale == s.fScale;
}
-const GrBackendEffectFactory& GrDisplacementMapEffect::getFactory() const {
- return GrTBackendEffectFactory<GrDisplacementMapEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& GrDisplacementMapEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<GrDisplacementMapEffect>::getInstance();
}
void GrDisplacementMapEffect::getConstantColorComponents(GrColor*,
@@ -504,16 +503,16 @@ void GrDisplacementMapEffect::getConstantColorComponents(GrColor*,
///////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrDisplacementMapEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDisplacementMapEffect);
-GrEffect* GrDisplacementMapEffect::TestCreate(SkRandom* random,
+GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(SkRandom* random,
GrContext*,
const GrDrawTargetCaps&,
GrTexture* textures[]) {
- int texIdxDispl = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
- GrEffectUnitTest::kAlphaTextureIdx;
- int texIdxColor = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
- GrEffectUnitTest::kAlphaTextureIdx;
+ int texIdxDispl = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
+ GrProcessorUnitTest::kAlphaTextureIdx;
+ int texIdxColor = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
+ GrProcessorUnitTest::kAlphaTextureIdx;
static const int kMaxComponent = 4;
SkDisplacementMapEffect::ChannelSelectorType xChannelSelector =
static_cast<SkDisplacementMapEffect::ChannelSelectorType>(
@@ -531,19 +530,19 @@ GrEffect* GrDisplacementMapEffect::TestCreate(SkRandom* random,
///////////////////////////////////////////////////////////////////////////////
-GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor& proc)
: INHERITED(factory)
- , fXChannelSelector(effect.cast<GrDisplacementMapEffect>().xChannelSelector())
- , fYChannelSelector(effect.cast<GrDisplacementMapEffect>().yChannelSelector()) {
+ , fXChannelSelector(proc.cast<GrDisplacementMapEffect>().xChannelSelector())
+ , fYChannelSelector(proc.cast<GrDisplacementMapEffect>().yChannelSelector()) {
}
GrGLDisplacementMapEffect::~GrGLDisplacementMapEffect() {
}
void GrGLDisplacementMapEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey& key,
+ const GrFragmentProcessor&,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -620,8 +619,8 @@ void GrGLDisplacementMapEffect::emitCode(GrGLProgramBuilder* builder,
}
void GrGLDisplacementMapEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
- const GrDisplacementMapEffect& displacementMap = effect.cast<GrDisplacementMapEffect>();
+ const GrProcessor& proc) {
+ const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMapEffect>();
GrTexture* colorTex = displacementMap.texture(1);
SkScalar scaleX = SkScalarDiv(displacementMap.scale().fX, SkIntToScalar(colorTex->width()));
SkScalar scaleY = SkScalarDiv(displacementMap.scale().fY, SkIntToScalar(colorTex->height()));
@@ -630,9 +629,9 @@ void GrGLDisplacementMapEffect::setData(const GrGLProgramDataManager& pdman,
SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY));
}
-void GrGLDisplacementMapEffect::GenKey(const GrEffect& effect,
- const GrGLCaps&, GrEffectKeyBuilder* b) {
- const GrDisplacementMapEffect& displacementMap = effect.cast<GrDisplacementMapEffect>();
+void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc,
+ const GrGLCaps&, GrProcessorKeyBuilder* b) {
+ const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMapEffect>();
uint32_t xKey = displacementMap.xChannelSelector();
uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBits;
diff --git a/src/effects/SkGpuBlurUtils.cpp b/src/effects/SkGpuBlurUtils.cpp
index a9a53f2ac..76c3b3bb7 100644
--- a/src/effects/SkGpuBlurUtils.cpp
+++ b/src/effects/SkGpuBlurUtils.cpp
@@ -54,10 +54,10 @@ static void convolve_gaussian_1d(GrContext* context,
float bounds[2]) {
GrPaint paint;
paint.reset();
- SkAutoTUnref<GrEffect> conv(GrConvolutionEffect::CreateGaussian(
+ SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian(
texture, direction, radius, sigma, useBounds, bounds));
paint.reset();
- paint.addColorEffect(conv);
+ paint.addColorProcessor(conv);
context->drawRectToRect(paint, dstRect, srcRect);
}
@@ -75,12 +75,12 @@ static void convolve_gaussian_2d(GrContext* context,
SkIPoint kernelOffset = SkIPoint::Make(radiusX, radiusY);
GrPaint paint;
paint.reset();
- SkAutoTUnref<GrEffect> conv(GrMatrixConvolutionEffect::CreateGaussian(
+ SkAutoTUnref<GrFragmentProcessor> conv(GrMatrixConvolutionEffect::CreateGaussian(
texture, bounds, size, 1.0, 0.0, kernelOffset,
useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_Mode,
true, sigmaX, sigmaY));
paint.reset();
- paint.addColorEffect(conv);
+ paint.addColorProcessor(conv);
context->drawRectToRect(paint, dstRect, srcRect);
}
@@ -197,16 +197,16 @@ GrTexture* GaussianBlur(GrContext* context,
matrix.mapRect(&domain, rect);
domain.inset(i < scaleFactorX ? SK_ScalarHalf / srcTexture->width() : 0.0f,
i < scaleFactorY ? SK_ScalarHalf / srcTexture->height() : 0.0f);
- SkAutoTUnref<GrEffect> effect(GrTextureDomainEffect::Create(
+ SkAutoTUnref<GrFragmentProcessor> fp(GrTextureDomainEffect::Create(
srcTexture,
matrix,
domain,
GrTextureDomain::kDecal_Mode,
GrTextureParams::kBilerp_FilterMode));
- paint.addColorEffect(effect);
+ paint.addColorProcessor(fp);
} else {
GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBilerp_FilterMode);
- paint.addColorTextureEffect(srcTexture, matrix, params);
+ paint.addColorTextureProcessor(srcTexture, matrix, params);
}
scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f,
i < scaleFactorY ? 0.5f : 1.0f);
@@ -286,7 +286,7 @@ GrTexture* GaussianBlur(GrContext* context,
GrPaint paint;
// FIXME: this should be mitchell, not bilinear.
GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBilerp_FilterMode);
- paint.addColorTextureEffect(srcTexture, matrix, params);
+ paint.addColorTextureProcessor(srcTexture, matrix, params);
SkRect dstRect(srcRect);
scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY);
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 95e9965f2..f76656212 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -16,10 +16,10 @@
#if SK_SUPPORT_GPU
#include "effects/GrSingleTextureEffect.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
-#include "GrEffect.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrProcessor.h"
+#include "GrTBackendProcessorFactory.h"
class GrGLDiffuseLightingEffect;
class GrGLSpecularLightingEffect;
@@ -36,12 +36,14 @@ const SkScalar gOneHalf = 0.5f;
const SkScalar gOneQuarter = 0.25f;
#if SK_SUPPORT_GPU
-void setUniformPoint3(const GrGLProgramDataManager& pdman, UniformHandle uni, const SkPoint3& point) {
+void setUniformPoint3(const GrGLProgramDataManager& pdman, UniformHandle uni,
+ const SkPoint3& point) {
GR_STATIC_ASSERT(sizeof(SkPoint3) == 3 * sizeof(GrGLfloat));
pdman.set3fv(uni, 1, &point.fX);
}
-void setUniformNormal3(const GrGLProgramDataManager& pdman, UniformHandle uni, const SkPoint3& point) {
+void setUniformNormal3(const GrGLProgramDataManager& pdman, UniformHandle uni,
+ const SkPoint3& point) {
setUniformPoint3(pdman, uni, SkPoint3(point.fX, point.fY, point.fZ));
}
#endif
@@ -60,7 +62,8 @@ class DiffuseLightingType {
public:
DiffuseLightingType(SkScalar kd)
: fKD(kd) {}
- SkPMColor light(const SkPoint3& normal, const SkPoint3& surfaceTolight, const SkPoint3& lightColor) const {
+ SkPMColor light(const SkPoint3& normal, const SkPoint3& surfaceTolight,
+ const SkPoint3& lightColor) const {
SkScalar colorScale = SkScalarMul(fKD, normal.dot(surfaceTolight));
colorScale = SkScalarClampMax(colorScale, SK_Scalar1);
SkPoint3 color(lightColor * colorScale);
@@ -77,7 +80,8 @@ class SpecularLightingType {
public:
SpecularLightingType(SkScalar ks, SkScalar shininess)
: fKS(ks), fShininess(shininess) {}
- SkPMColor light(const SkPoint3& normal, const SkPoint3& surfaceTolight, const SkPoint3& lightColor) const {
+ SkPMColor light(const SkPoint3& normal, const SkPoint3& surfaceTolight,
+ const SkPoint3& lightColor) const {
SkPoint3 halfDir(surfaceTolight);
halfDir.fZ += SK_Scalar1; // eye position is always (0, 0, 1)
halfDir.normalize();
@@ -162,7 +166,9 @@ inline SkPoint3 bottomRightNormal(int m[9], SkScalar surfaceScale) {
surfaceScale);
}
-template <class LightingType, class LightType> void lightBitmap(const LightingType& lightingType, const SkLight* light, const SkBitmap& src, SkBitmap* dst, SkScalar surfaceScale, const SkIRect& bounds) {
+template <class LightingType, class LightType> void lightBitmap(
+ const LightingType& lightingType, const SkLight* light, const SkBitmap& src, SkBitmap* dst,
+ SkScalar surfaceScale, const SkIRect& bounds) {
SkASSERT(dst->width() == bounds.width() && dst->height() == bounds.height());
const LightType* l = static_cast<const LightType*>(light);
int left = bounds.left(), right = bounds.right();
@@ -179,18 +185,21 @@ template <class LightingType, class LightType> void lightBitmap(const LightingTy
m[7] = SkGetPackedA32(*row2++);
m[8] = SkGetPackedA32(*row2++);
SkPoint3 surfaceToLight = l->surfaceToLight(x, y, m[4], surfaceScale);
- *dptr++ = lightingType.light(topLeftNormal(m, surfaceScale), surfaceToLight, l->lightColor(surfaceToLight));
+ *dptr++ = lightingType.light(topLeftNormal(m, surfaceScale), surfaceToLight,
+ l->lightColor(surfaceToLight));
for (++x; x < right - 1; ++x)
{
shiftMatrixLeft(m);
m[5] = SkGetPackedA32(*row1++);
m[8] = SkGetPackedA32(*row2++);
surfaceToLight = l->surfaceToLight(x, y, m[4], surfaceScale);
- *dptr++ = lightingType.light(topNormal(m, surfaceScale), surfaceToLight, l->lightColor(surfaceToLight));
+ *dptr++ = lightingType.light(topNormal(m, surfaceScale), surfaceToLight,
+ l->lightColor(surfaceToLight));
}
shiftMatrixLeft(m);
surfaceToLight = l->surfaceToLight(x, y, m[4], surfaceScale);
- *dptr++ = lightingType.light(topRightNormal(m, surfaceScale), surfaceToLight, l->lightColor(surfaceToLight));
+ *dptr++ = lightingType.light(topRightNormal(m, surfaceScale), surfaceToLight,
+ l->lightColor(surfaceToLight));
}
for (++y; y < bottom - 1; ++y) {
@@ -206,18 +215,21 @@ template <class LightingType, class LightType> void lightBitmap(const LightingTy
m[7] = SkGetPackedA32(*row2++);
m[8] = SkGetPackedA32(*row2++);
SkPoint3 surfaceToLight = l->surfaceToLight(x, y, m[4], surfaceScale);
- *dptr++ = lightingType.light(leftNormal(m, surfaceScale), surfaceToLight, l->lightColor(surfaceToLight));
+ *dptr++ = lightingType.light(leftNormal(m, surfaceScale), surfaceToLight,
+ l->lightColor(surfaceToLight));
for (++x; x < right - 1; ++x) {
shiftMatrixLeft(m);
m[2] = SkGetPackedA32(*row0++);
m[5] = SkGetPackedA32(*row1++);
m[8] = SkGetPackedA32(*row2++);
surfaceToLight = l->surfaceToLight(x, y, m[4], surfaceScale);
- *dptr++ = lightingType.light(interiorNormal(m, surfaceScale), surfaceToLight, l->lightColor(surfaceToLight));
+ *dptr++ = lightingType.light(interiorNormal(m, surfaceScale), surfaceToLight,
+ l->lightColor(surfaceToLight));
}
shiftMatrixLeft(m);
surfaceToLight = l->surfaceToLight(x, y, m[4], surfaceScale);
- *dptr++ = lightingType.light(rightNormal(m, surfaceScale), surfaceToLight, l->lightColor(surfaceToLight));
+ *dptr++ = lightingType.light(rightNormal(m, surfaceScale), surfaceToLight,
+ l->lightColor(surfaceToLight));
}
{
@@ -230,18 +242,21 @@ template <class LightingType, class LightType> void lightBitmap(const LightingTy
m[4] = SkGetPackedA32(*row1++);
m[5] = SkGetPackedA32(*row1++);
SkPoint3 surfaceToLight = l->surfaceToLight(x, y, m[4], surfaceScale);
- *dptr++ = lightingType.light(bottomLeftNormal(m, surfaceScale), surfaceToLight, l->lightColor(surfaceToLight));
+ *dptr++ = lightingType.light(bottomLeftNormal(m, surfaceScale), surfaceToLight,
+ l->lightColor(surfaceToLight));
for (++x; x < right - 1; ++x)
{
shiftMatrixLeft(m);
m[2] = SkGetPackedA32(*row0++);
m[5] = SkGetPackedA32(*row1++);
surfaceToLight = l->surfaceToLight(x, y, m[4], surfaceScale);
- *dptr++ = lightingType.light(bottomNormal(m, surfaceScale), surfaceToLight, l->lightColor(surfaceToLight));
+ *dptr++ = lightingType.light(bottomNormal(m, surfaceScale), surfaceToLight,
+ l->lightColor(surfaceToLight));
}
shiftMatrixLeft(m);
surfaceToLight = l->surfaceToLight(x, y, m[4], surfaceScale);
- *dptr++ = lightingType.light(bottomRightNormal(m, surfaceScale), surfaceToLight, l->lightColor(surfaceToLight));
+ *dptr++ = lightingType.light(bottomRightNormal(m, surfaceScale), surfaceToLight,
+ l->lightColor(surfaceToLight));
}
}
@@ -281,8 +296,8 @@ protected:
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
#if SK_SUPPORT_GPU
- virtual bool asNewEffect(GrEffect** effect, GrTexture*, const SkMatrix& matrix,
- const SkIRect& bounds) const SK_OVERRIDE;
+ virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&,
+ const SkIRect& bounds) const SK_OVERRIDE;
#endif
private:
@@ -294,7 +309,8 @@ private:
class SkSpecularLightingImageFilter : public SkLightingImageFilter {
public:
static SkImageFilter* Create(SkLight* light, SkScalar surfaceScale,
- SkScalar ks, SkScalar shininess, SkImageFilter*, const CropRect*, uint32_t uniqueID = 0);
+ SkScalar ks, SkScalar shininess, SkImageFilter*, const CropRect*,
+ uint32_t uniqueID = 0);
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSpecularLightingImageFilter)
@@ -312,8 +328,8 @@ protected:
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
#if SK_SUPPORT_GPU
- virtual bool asNewEffect(GrEffect** effect, GrTexture*, const SkMatrix& matrix,
- const SkIRect& bounds) const SK_OVERRIDE;
+ virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&,
+ const SkIRect& bounds) const SK_OVERRIDE;
#endif
private:
@@ -341,7 +357,7 @@ public:
}
protected:
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
private:
typedef GrSingleTextureEffect INHERITED;
@@ -352,11 +368,11 @@ private:
class GrDiffuseLightingEffect : public GrLightingEffect {
public:
- static GrEffect* Create(GrTexture* texture,
- const SkLight* light,
- SkScalar surfaceScale,
- const SkMatrix& matrix,
- SkScalar kd) {
+ static GrFragmentProcessor* Create(GrTexture* texture,
+ const SkLight* light,
+ SkScalar surfaceScale,
+ const SkMatrix& matrix,
+ SkScalar kd) {
return SkNEW_ARGS(GrDiffuseLightingEffect, (texture,
light,
surfaceScale,
@@ -366,13 +382,13 @@ public:
static const char* Name() { return "DiffuseLighting"; }
- typedef GrGLDiffuseLightingEffect GLEffect;
+ typedef GrGLDiffuseLightingEffect GLProcessor;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
SkScalar kd() const { return fKD; }
private:
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
GrDiffuseLightingEffect(GrTexture* texture,
const SkLight* light,
@@ -380,19 +396,19 @@ private:
const SkMatrix& matrix,
SkScalar kd);
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
typedef GrLightingEffect INHERITED;
SkScalar fKD;
};
class GrSpecularLightingEffect : public GrLightingEffect {
public:
- static GrEffect* Create(GrTexture* texture,
- const SkLight* light,
- SkScalar surfaceScale,
- const SkMatrix& matrix,
- SkScalar ks,
- SkScalar shininess) {
+ static GrFragmentProcessor* Create(GrTexture* texture,
+ const SkLight* light,
+ SkScalar surfaceScale,
+ const SkMatrix& matrix,
+ SkScalar ks,
+ SkScalar shininess) {
return SkNEW_ARGS(GrSpecularLightingEffect, (texture,
light,
surfaceScale,
@@ -402,14 +418,14 @@ public:
}
static const char* Name() { return "SpecularLighting"; }
- typedef GrGLSpecularLightingEffect GLEffect;
+ typedef GrGLSpecularLightingEffect GLProcessor;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
SkScalar ks() const { return fKS; }
SkScalar shininess() const { return fShininess; }
private:
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
GrSpecularLightingEffect(GrTexture* texture,
const SkLight* light,
@@ -418,7 +434,7 @@ private:
SkScalar ks,
SkScalar shininess);
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
typedef GrLightingEffect INHERITED;
SkScalar fKS;
SkScalar fShininess;
@@ -1042,11 +1058,13 @@ bool SkDiffuseLightingImageFilter::onFilterImage(Proxy* proxy,
}
#if SK_SUPPORT_GPU
-bool SkDiffuseLightingImageFilter::asNewEffect(GrEffect** effect, GrTexture* texture,
- const SkMatrix& matrix, const SkIRect&) const {
- if (effect) {
+bool SkDiffuseLightingImageFilter::asFragmentProcessor(GrFragmentProcessor** fp,
+ GrTexture* texture,
+ const SkMatrix& matrix,
+ const SkIRect&) const {
+ if (fp) {
SkScalar scale = SkScalarMul(surfaceScale(), SkIntToScalar(255));
- *effect = GrDiffuseLightingEffect::Create(texture, light(), scale, matrix, kd());
+ *fp = GrDiffuseLightingEffect::Create(texture, light(), scale, matrix, kd());
}
return true;
}
@@ -1158,11 +1176,13 @@ bool SkSpecularLightingImageFilter::onFilterImage(Proxy* proxy,
}
#if SK_SUPPORT_GPU
-bool SkSpecularLightingImageFilter::asNewEffect(GrEffect** effect, GrTexture* texture,
- const SkMatrix& matrix, const SkIRect&) const {
- if (effect) {
+bool SkSpecularLightingImageFilter::asFragmentProcessor(GrFragmentProcessor** fp,
+ GrTexture* texture,
+ const SkMatrix& matrix,
+ const SkIRect&) const {
+ if (fp) {
SkScalar scale = SkScalarMul(surfaceScale(), SkIntToScalar(255));
- *effect = GrSpecularLightingEffect::Create(texture, light(), scale, matrix, ks(), shininess());
+ *fp = GrSpecularLightingEffect::Create(texture, light(), scale, matrix, ks(), shininess());
}
return true;
}
@@ -1203,32 +1223,31 @@ SkLight* create_random_light(SkRandom* random) {
}
-class GrGLLightingEffect : public GrGLEffect {
+class GrGLLightingEffect : public GrGLFragmentProcessor {
public:
- GrGLLightingEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect);
+ GrGLLightingEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual ~GrGLLightingEffect();
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder* b);
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder* b);
/**
* Subclasses of GrGLLightingEffect must call INHERITED::setData();
*/
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
protected:
virtual void emitLightFunc(GrGLProgramBuilder*, SkString* funcName) = 0;
private:
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
UniformHandle fImageIncrementUni;
UniformHandle fSurfaceScaleUni;
@@ -1239,10 +1258,9 @@ private:
class GrGLDiffuseLightingEffect : public GrGLLightingEffect {
public:
- GrGLDiffuseLightingEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect);
+ GrGLDiffuseLightingEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitLightFunc(GrGLProgramBuilder*, SkString* funcName) SK_OVERRIDE;
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
private:
typedef GrGLLightingEffect INHERITED;
@@ -1254,10 +1272,9 @@ private:
class GrGLSpecularLightingEffect : public GrGLLightingEffect {
public:
- GrGLSpecularLightingEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect);
+ GrGLSpecularLightingEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitLightFunc(GrGLProgramBuilder*, SkString* funcName) SK_OVERRIDE;
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
private:
typedef GrGLLightingEffect INHERITED;
@@ -1286,7 +1303,7 @@ GrLightingEffect::~GrLightingEffect() {
fLight->unref();
}
-bool GrLightingEffect::onIsEqual(const GrEffect& sBase) const {
+bool GrLightingEffect::onIsEqual(const GrProcessor& sBase) const {
const GrLightingEffect& s = sBase.cast<GrLightingEffect>();
return this->texture(0) == s.texture(0) &&
fLight->isEqual(*s.fLight) &&
@@ -1303,19 +1320,19 @@ GrDiffuseLightingEffect::GrDiffuseLightingEffect(GrTexture* texture,
: INHERITED(texture, light, surfaceScale, matrix), fKD(kd) {
}
-const GrBackendEffectFactory& GrDiffuseLightingEffect::getFactory() const {
- return GrTBackendEffectFactory<GrDiffuseLightingEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& GrDiffuseLightingEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<GrDiffuseLightingEffect>::getInstance();
}
-bool GrDiffuseLightingEffect::onIsEqual(const GrEffect& sBase) const {
+bool GrDiffuseLightingEffect::onIsEqual(const GrProcessor& sBase) const {
const GrDiffuseLightingEffect& s = sBase.cast<GrDiffuseLightingEffect>();
return INHERITED::onIsEqual(sBase) &&
this->kd() == s.kd();
}
-GR_DEFINE_EFFECT_TEST(GrDiffuseLightingEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDiffuseLightingEffect);
-GrEffect* GrDiffuseLightingEffect::TestCreate(SkRandom* random,
+GrFragmentProcessor* GrDiffuseLightingEffect::TestCreate(SkRandom* random,
GrContext* context,
const GrDrawTargetCaps&,
GrTexture* textures[]) {
@@ -1326,17 +1343,17 @@ GrEffect* GrDiffuseLightingEffect::TestCreate(SkRandom* random,
for (int i = 0; i < 9; i++) {
matrix[i] = random->nextUScalar1();
}
- return GrDiffuseLightingEffect::Create(textures[GrEffectUnitTest::kAlphaTextureIdx],
+ return GrDiffuseLightingEffect::Create(textures[GrProcessorUnitTest::kAlphaTextureIdx],
light, surfaceScale, matrix, kd);
}
///////////////////////////////////////////////////////////////////////////////
-GrGLLightingEffect::GrGLLightingEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GrGLLightingEffect::GrGLLightingEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor& fp)
: INHERITED(factory) {
- const GrLightingEffect& m = effect.cast<GrLightingEffect>();
+ const GrLightingEffect& m = fp.cast<GrLightingEffect>();
fLight = m.light()->createGLLight();
}
@@ -1345,8 +1362,8 @@ GrGLLightingEffect::~GrGLLightingEffect() {
}
void GrGLLightingEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey& key,
+ const GrFragmentProcessor&,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -1441,14 +1458,14 @@ void GrGLLightingEffect::emitCode(GrGLProgramBuilder* builder,
fsBuilder->codeAppend(modulate.c_str());
}
-void GrGLLightingEffect::GenKey(const GrEffect& effect,
- const GrGLCaps& caps, GrEffectKeyBuilder* b) {
- b->add32(effect.cast<GrLightingEffect>().light()->type());
+void GrGLLightingEffect::GenKey(const GrProcessor& proc,
+ const GrGLCaps& caps, GrProcessorKeyBuilder* b) {
+ b->add32(proc.cast<GrLightingEffect>().light()->type());
}
void GrGLLightingEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
- const GrLightingEffect& lighting = effect.cast<GrLightingEffect>();
+ const GrProcessor& proc) {
+ const GrLightingEffect& lighting = proc.cast<GrLightingEffect>();
GrTexture* texture = lighting.texture(0);
float ySign = texture->origin() == kTopLeft_GrSurfaceOrigin ? -1.0f : 1.0f;
pdman.set2f(fImageIncrementUni, 1.0f / texture->width(), ySign / texture->height());
@@ -1461,9 +1478,9 @@ void GrGLLightingEffect::setData(const GrGLProgramDataManager& pdman,
///////////////////////////////////////////////////////////////////////////////
-GrGLDiffuseLightingEffect::GrGLDiffuseLightingEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
- : INHERITED(factory, effect) {
+GrGLDiffuseLightingEffect::GrGLDiffuseLightingEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor& proc)
+ : INHERITED(factory, proc) {
}
void GrGLDiffuseLightingEffect::emitLightFunc(GrGLProgramBuilder* builder, SkString* funcName) {
@@ -1490,9 +1507,9 @@ void GrGLDiffuseLightingEffect::emitLightFunc(GrGLProgramBuilder* builder, SkStr
}
void GrGLDiffuseLightingEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
- INHERITED::setData(pdman, effect);
- const GrDiffuseLightingEffect& diffuse = effect.cast<GrDiffuseLightingEffect>();
+ const GrProcessor& proc) {
+ INHERITED::setData(pdman, proc);
+ const GrDiffuseLightingEffect& diffuse = proc.cast<GrDiffuseLightingEffect>();
pdman.set1f(fKDUni, diffuse.kd());
}
@@ -1509,23 +1526,23 @@ GrSpecularLightingEffect::GrSpecularLightingEffect(GrTexture* texture,
fShininess(shininess) {
}
-const GrBackendEffectFactory& GrSpecularLightingEffect::getFactory() const {
- return GrTBackendEffectFactory<GrSpecularLightingEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& GrSpecularLightingEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<GrSpecularLightingEffect>::getInstance();
}
-bool GrSpecularLightingEffect::onIsEqual(const GrEffect& sBase) const {
+bool GrSpecularLightingEffect::onIsEqual(const GrProcessor& sBase) const {
const GrSpecularLightingEffect& s = sBase.cast<GrSpecularLightingEffect>();
return INHERITED::onIsEqual(sBase) &&
this->ks() == s.ks() &&
this->shininess() == s.shininess();
}
-GR_DEFINE_EFFECT_TEST(GrSpecularLightingEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSpecularLightingEffect);
-GrEffect* GrSpecularLightingEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrFragmentProcessor* GrSpecularLightingEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
SkScalar surfaceScale = random->nextSScalar1();
SkScalar ks = random->nextUScalar1();
SkScalar shininess = random->nextUScalar1();
@@ -1534,15 +1551,15 @@ GrEffect* GrSpecularLightingEffect::TestCreate(SkRandom* random,
for (int i = 0; i < 9; i++) {
matrix[i] = random->nextUScalar1();
}
- return GrSpecularLightingEffect::Create(textures[GrEffectUnitTest::kAlphaTextureIdx],
+ return GrSpecularLightingEffect::Create(textures[GrProcessorUnitTest::kAlphaTextureIdx],
light, surfaceScale, matrix, ks, shininess);
}
///////////////////////////////////////////////////////////////////////////////
-GrGLSpecularLightingEffect::GrGLSpecularLightingEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
- : INHERITED(factory, effect) {
+GrGLSpecularLightingEffect::GrGLSpecularLightingEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor& proc)
+ : INHERITED(factory, proc) {
}
void GrGLSpecularLightingEffect::emitLightFunc(GrGLProgramBuilder* builder, SkString* funcName) {
@@ -1573,7 +1590,7 @@ void GrGLSpecularLightingEffect::emitLightFunc(GrGLProgramBuilder* builder, SkSt
}
void GrGLSpecularLightingEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
+ const GrProcessor& effect) {
INHERITED::setData(pdman, effect);
const GrSpecularLightingEffect& spec = effect.cast<GrSpecularLightingEffect>();
pdman.set1f(fKSUni, spec.ks());
@@ -1588,8 +1605,7 @@ void GrGLLight::emitLightColorUniform(GrGLProgramBuilder* builder) {
void GrGLLight::emitLightColor(GrGLProgramBuilder* builder,
const char *surfaceToLight) {
- builder->getFragmentShaderBuilder()->
- codeAppend(builder->getUniformCStr(this->lightColorUni()));
+ builder->getFragmentShaderBuilder()->codeAppend(builder->getUniformCStr(this->lightColorUni()));
}
void GrGLLight::setData(const GrGLProgramDataManager& pdman,
diff --git a/src/effects/SkLumaColorFilter.cpp b/src/effects/SkLumaColorFilter.cpp
index 2619719cf..ee2bfa654 100644
--- a/src/effects/SkLumaColorFilter.cpp
+++ b/src/effects/SkLumaColorFilter.cpp
@@ -11,10 +11,10 @@
#include "SkString.h"
#if SK_SUPPORT_GPU
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrContext.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#endif
void SkLumaColorFilter::filterSpan(const SkPMColor src[], int count,
@@ -60,17 +60,17 @@ void SkLumaColorFilter::toString(SkString* str) const {
#endif
#if SK_SUPPORT_GPU
-class LumaColorFilterEffect : public GrEffect {
+class LumaColorFilterEffect : public GrFragmentProcessor {
public:
- static GrEffect* Create() {
- GR_CREATE_STATIC_EFFECT(gLumaEffect, LumaColorFilterEffect, ());
+ static GrFragmentProcessor* Create() {
+ GR_CREATE_STATIC_FRAGMENT_PROCESSOR(gLumaEffect, LumaColorFilterEffect, ());
return SkRef(gLumaEffect);
}
static const char* Name() { return "Luminance-to-Alpha"; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
- return GrTBackendEffectFactory<LumaColorFilterEffect>::getInstance();
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
+ return GrTBackendFragmentProcessorFactory<LumaColorFilterEffect>::getInstance();
}
virtual void getConstantColorComponents(GrColor* color,
@@ -80,18 +80,18 @@ public:
*validFlags = kRGB_GrColorComponentFlags;
}
- class GLEffect : public GrGLEffect {
+ class GLProcessor : public GrGLFragmentProcessor {
public:
- GLEffect(const GrBackendEffectFactory& factory,
- const GrEffect&)
+ GLProcessor(const GrBackendProcessorFactory& factory,
+ const GrProcessor&)
: INHERITED(factory) {
}
- static void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder* b) {}
+ static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder* b) {}
virtual void emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
@@ -112,16 +112,16 @@ public:
}
private:
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
private:
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE {
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE {
return true;
}
};
-GrEffect* SkLumaColorFilter::asNewEffect(GrContext*) const {
+GrFragmentProcessor* SkLumaColorFilter::asFragmentProcessor(GrContext*) const {
return LumaColorFilterEffect::Create();
}
#endif
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index 349ddac10..9d7b91836 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -15,24 +15,24 @@
////////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
#include "effects/GrSingleTextureEffect.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "gl/GrGLSL.h"
#include "gl/GrGLTexture.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
class GrGLMagnifierEffect;
class GrMagnifierEffect : public GrSingleTextureEffect {
public:
- static GrEffect* Create(GrTexture* texture,
- float xOffset,
- float yOffset,
- float xInvZoom,
- float yInvZoom,
- float xInvInset,
- float yInvInset) {
+ static GrFragmentProcessor* Create(GrTexture* texture,
+ float xOffset,
+ float yOffset,
+ float xInvZoom,
+ float yInvZoom,
+ float xInvInset,
+ float yInvInset) {
return SkNEW_ARGS(GrMagnifierEffect, (texture,
xOffset,
yOffset,
@@ -46,7 +46,7 @@ public:
static const char* Name() { return "Magnifier"; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
float x_offset() const { return fXOffset; }
@@ -56,7 +56,7 @@ public:
float x_inv_inset() const { return fXInvInset; }
float y_inv_inset() const { return fYInvInset; }
- typedef GrGLMagnifierEffect GLEffect;
+ typedef GrGLMagnifierEffect GLProcessor;
private:
GrMagnifierEffect(GrTexture* texture,
@@ -74,9 +74,9 @@ private:
, fXInvInset(xInvInset)
, fYInvInset(yInvInset) {}
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
float fXOffset;
float fYOffset;
@@ -91,35 +91,36 @@ private:
// For brevity
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
-class GrGLMagnifierEffect : public GrGLEffect {
+class GrGLMagnifierEffect : public GrGLFragmentProcessor {
public:
- GrGLMagnifierEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GrGLMagnifierEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
private:
UniformHandle fOffsetVar;
UniformHandle fInvZoomVar;
UniformHandle fInvInsetVar;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
-GrGLMagnifierEffect::GrGLMagnifierEffect(const GrBackendEffectFactory& factory, const GrEffect&)
+GrGLMagnifierEffect::GrGLMagnifierEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor&)
: INHERITED(factory) {
}
void GrGLMagnifierEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey& key,
+ const GrFragmentProcessor&,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -172,7 +173,7 @@ void GrGLMagnifierEffect::emitCode(GrGLProgramBuilder* builder,
}
void GrGLMagnifierEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
+ const GrProcessor& effect) {
const GrMagnifierEffect& zoom = effect.cast<GrMagnifierEffect>();
pdman.set2f(fOffsetVar, zoom.x_offset(), zoom.y_offset());
pdman.set2f(fInvZoomVar, zoom.x_inv_zoom(), zoom.y_inv_zoom());
@@ -181,12 +182,12 @@ void GrGLMagnifierEffect::setData(const GrGLProgramDataManager& pdman,
/////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrMagnifierEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect);
-GrEffect* GrMagnifierEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture** textures) {
+GrFragmentProcessor* GrMagnifierEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture** textures) {
GrTexture* texture = textures[0];
const int kMaxWidth = 200;
const int kMaxHeight = 200;
@@ -197,7 +198,7 @@ GrEffect* GrMagnifierEffect::TestCreate(SkRandom* random,
uint32_t y = random->nextULessThan(kMaxHeight - height);
uint32_t inset = random->nextULessThan(kMaxInset);
- GrEffect* effect = GrMagnifierEffect::Create(
+ GrFragmentProcessor* effect = GrMagnifierEffect::Create(
texture,
(float) width / texture->width(),
(float) height / texture->height(),
@@ -211,11 +212,11 @@ GrEffect* GrMagnifierEffect::TestCreate(SkRandom* random,
///////////////////////////////////////////////////////////////////////////////
-const GrBackendEffectFactory& GrMagnifierEffect::getFactory() const {
- return GrTBackendEffectFactory<GrMagnifierEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& GrMagnifierEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<GrMagnifierEffect>::getInstance();
}
-bool GrMagnifierEffect::onIsEqual(const GrEffect& sBase) const {
+bool GrMagnifierEffect::onIsEqual(const GrProcessor& sBase) const {
const GrMagnifierEffect& s = sBase.cast<GrMagnifierEffect>();
return (this->texture(0) == s.texture(0) &&
this->fXOffset == s.fXOffset &&
@@ -271,19 +272,19 @@ SkMagnifierImageFilter::SkMagnifierImageFilter(const SkRect& srcRect, SkScalar i
}
#if SK_SUPPORT_GPU
-bool SkMagnifierImageFilter::asNewEffect(GrEffect** effect, GrTexture* texture, const SkMatrix&,
- const SkIRect&) const {
- if (effect) {
+bool SkMagnifierImageFilter::asFragmentProcessor(GrFragmentProcessor** fp, GrTexture* texture,
+ const SkMatrix&, const SkIRect&) const {
+ if (fp) {
SkScalar yOffset = (texture->origin() == kTopLeft_GrSurfaceOrigin) ? fSrcRect.y() :
(texture->height() - (fSrcRect.y() + fSrcRect.height()));
SkScalar invInset = fInset > 0 ? SkScalarInvert(fInset) : SK_Scalar1;
- *effect = GrMagnifierEffect::Create(texture,
- fSrcRect.x() / texture->width(),
- yOffset / texture->height(),
- fSrcRect.width() / texture->width(),
- fSrcRect.height() / texture->height(),
- texture->width() * invInset,
- texture->height() * invInset);
+ *fp = GrMagnifierEffect::Create(texture,
+ fSrcRect.x() / texture->width(),
+ yOffset / texture->height(),
+ fSrcRect.width() / texture->width(),
+ fSrcRect.height() / texture->height(),
+ texture->width() * invInset,
+ texture->height() * invInset);
}
return true;
}
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp
index c8959eecf..75e3f7a90 100644
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp
@@ -363,23 +363,23 @@ static GrTextureDomain::Mode convert_tilemodes(
return GrTextureDomain::kIgnore_Mode;
}
-bool SkMatrixConvolutionImageFilter::asNewEffect(GrEffect** effect,
- GrTexture* texture,
- const SkMatrix&,
- const SkIRect& bounds) const {
- if (!effect) {
+bool SkMatrixConvolutionImageFilter::asFragmentProcessor(GrFragmentProcessor** fp,
+ GrTexture* texture,
+ const SkMatrix&,
+ const SkIRect& bounds) const {
+ if (!fp) {
return fKernelSize.width() * fKernelSize.height() <= MAX_KERNEL_SIZE;
}
SkASSERT(fKernelSize.width() * fKernelSize.height() <= MAX_KERNEL_SIZE);
- *effect = GrMatrixConvolutionEffect::Create(texture,
- bounds,
- fKernelSize,
- fKernel,
- fGain,
- fBias,
- fKernelOffset,
- convert_tilemodes(fTileMode),
- fConvolveAlpha);
+ *fp = GrMatrixConvolutionEffect::Create(texture,
+ bounds,
+ fKernelSize,
+ fKernel,
+ fGain,
+ fBias,
+ fKernelOffset,
+ convert_tilemodes(fTileMode),
+ fConvolveAlpha);
return true;
}
#endif
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 02c0be167..397e43193 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -15,8 +15,8 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrTexture.h"
-#include "GrTBackendEffectFactory.h"
-#include "gl/GrGLEffect.h"
+#include "GrTBackendProcessorFactory.h"
+#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "effects/Gr1DKernelEffect.h"
#endif
@@ -295,7 +295,8 @@ public:
kDilate_MorphologyType,
};
- static GrEffect* Create(GrTexture* tex, Direction dir, int radius, MorphologyType type) {
+ static GrFragmentProcessor* Create(GrTexture* tex, Direction dir, int radius,
+ MorphologyType type) {
return SkNEW_ARGS(GrMorphologyEffect, (tex, dir, radius, type));
}
@@ -305,9 +306,9 @@ public:
static const char* Name() { return "Morphology"; }
- typedef GrGLMorphologyEffect GLEffect;
+ typedef GrGLMorphologyEffect GLProcessor;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
protected:
@@ -315,32 +316,32 @@ protected:
MorphologyType fType;
private:
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
GrMorphologyEffect(GrTexture*, Direction, int radius, MorphologyType);
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
typedef Gr1DKernelEffect INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
-class GrGLMorphologyEffect : public GrGLEffect {
+class GrGLMorphologyEffect : public GrGLFragmentProcessor {
public:
- GrGLMorphologyEffect (const GrBackendEffectFactory&, const GrEffect&);
+ GrGLMorphologyEffect (const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder* b);
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder* b);
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
private:
int width() const { return GrMorphologyEffect::WidthFromRadius(fRadius); }
@@ -349,20 +350,20 @@ private:
GrMorphologyEffect::MorphologyType fType;
GrGLProgramDataManager::UniformHandle fImageIncrementUni;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
-GrGLMorphologyEffect::GrGLMorphologyEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GrGLMorphologyEffect::GrGLMorphologyEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor& proc)
: INHERITED(factory) {
- const GrMorphologyEffect& m = effect.cast<GrMorphologyEffect>();
+ const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>();
fRadius = m.radius();
fType = m.type();
}
void GrGLMorphologyEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey& key,
+ const GrFragmentProcessor&,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -401,17 +402,17 @@ void GrGLMorphologyEffect::emitCode(GrGLProgramBuilder* builder,
fsBuilder->codeAppend(modulate.c_str());
}
-void GrGLMorphologyEffect::GenKey(const GrEffect& effect,
- const GrGLCaps&, GrEffectKeyBuilder* b) {
- const GrMorphologyEffect& m = effect.cast<GrMorphologyEffect>();
+void GrGLMorphologyEffect::GenKey(const GrProcessor& proc,
+ const GrGLCaps&, GrProcessorKeyBuilder* b) {
+ const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>();
uint32_t key = static_cast<uint32_t>(m.radius());
key |= (m.type() << 8);
b->add32(key);
}
void GrGLMorphologyEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
- const Gr1DKernelEffect& kern = effect.cast<Gr1DKernelEffect>();
+ const GrProcessor& proc) {
+ const Gr1DKernelEffect& kern = proc.cast<Gr1DKernelEffect>();
GrTexture& texture = *kern.texture(0);
// the code we generated was for a specific kernel radius
SkASSERT(kern.radius() == fRadius);
@@ -442,11 +443,11 @@ GrMorphologyEffect::GrMorphologyEffect(GrTexture* texture,
GrMorphologyEffect::~GrMorphologyEffect() {
}
-const GrBackendEffectFactory& GrMorphologyEffect::getFactory() const {
- return GrTBackendEffectFactory<GrMorphologyEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& GrMorphologyEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<GrMorphologyEffect>::getInstance();
}
-bool GrMorphologyEffect::onIsEqual(const GrEffect& sBase) const {
+bool GrMorphologyEffect::onIsEqual(const GrProcessor& sBase) const {
const GrMorphologyEffect& s = sBase.cast<GrMorphologyEffect>();
return (this->texture(0) == s.texture(0) &&
this->radius() == s.radius() &&
@@ -462,14 +463,14 @@ void GrMorphologyEffect::getConstantColorComponents(GrColor* color, uint32_t* va
///////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrMorphologyEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMorphologyEffect);
-GrEffect* GrMorphologyEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
- int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
- GrEffectUnitTest::kAlphaTextureIdx;
+GrFragmentProcessor* GrMorphologyEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
+ int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
+ GrProcessorUnitTest::kAlphaTextureIdx;
Direction dir = random->nextBool() ? kX_Direction : kY_Direction;
static const int kMaxRadius = 10;
int radius = random->nextRangeU(1, kMaxRadius);
@@ -489,10 +490,10 @@ void apply_morphology_pass(GrContext* context,
GrMorphologyEffect::MorphologyType morphType,
Gr1DKernelEffect::Direction direction) {
GrPaint paint;
- paint.addColorEffect(GrMorphologyEffect::Create(texture,
- direction,
- radius,
- morphType))->unref();
+ paint.addColorProcessor(GrMorphologyEffect::Create(texture,
+ direction,
+ radius,
+ morphType))->unref();
context->drawRectToRect(paint, SkRect::Make(dstRect), SkRect::Make(srcRect));
}
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp
index aba5ddb72..88e6caddb 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -17,9 +17,9 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrCoordTransform.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "SkGr.h"
#endif
@@ -507,25 +507,25 @@ void SkPerlinNoiseShader::PerlinNoiseShaderContext::shadeSpan16(
#if SK_SUPPORT_GPU
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
-class GrGLPerlinNoise : public GrGLEffect {
+class GrGLPerlinNoise : public GrGLFragmentProcessor {
public:
- GrGLPerlinNoise(const GrBackendEffectFactory& factory,
- const GrEffect& effect);
+ GrGLPerlinNoise(const GrBackendProcessorFactory&,
+ const GrProcessor&);
virtual ~GrGLPerlinNoise() {}
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder* b);
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder* b);
private:
@@ -537,18 +537,18 @@ private:
GrGLProgramDataManager::UniformHandle fAlphaUni;
private:
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
/////////////////////////////////////////////////////////////////////
-class GrPerlinNoiseEffect : public GrEffect {
+class GrPerlinNoiseEffect : public GrFragmentProcessor {
public:
- static GrEffect* Create(SkPerlinNoiseShader::Type type,
- int numOctaves, bool stitchTiles,
- SkPerlinNoiseShader::PaintingData* paintingData,
- GrTexture* permutationsTexture, GrTexture* noiseTexture,
- const SkMatrix& matrix, uint8_t alpha) {
+ static GrFragmentProcessor* Create(SkPerlinNoiseShader::Type type,
+ int numOctaves, bool stitchTiles,
+ SkPerlinNoiseShader::PaintingData* paintingData,
+ GrTexture* permutationsTexture, GrTexture* noiseTexture,
+ const SkMatrix& matrix, uint8_t alpha) {
return SkNEW_ARGS(GrPerlinNoiseEffect, (type, numOctaves, stitchTiles, paintingData,
permutationsTexture, noiseTexture, matrix, alpha));
}
@@ -558,8 +558,8 @@ public:
}
static const char* Name() { return "PerlinNoise"; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
- return GrTBackendEffectFactory<GrPerlinNoiseEffect>::getInstance();
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
+ return GrTBackendFragmentProcessorFactory<GrPerlinNoiseEffect>::getInstance();
}
const SkPerlinNoiseShader::StitchData& stitchData() const { return fPaintingData->fStitchDataInit; }
@@ -570,10 +570,10 @@ public:
const SkMatrix& matrix() const { return fCoordTransform.getMatrix(); }
uint8_t alpha() const { return fAlpha; }
- typedef GrGLPerlinNoise GLEffect;
+ typedef GrGLPerlinNoise GLProcessor;
private:
- virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE {
+ virtual bool onIsEqual(const GrProcessor& sBase) const SK_OVERRIDE {
const GrPerlinNoiseEffect& s = sBase.cast<GrPerlinNoiseEffect>();
return fType == s.fType &&
fPaintingData->fBaseFrequency == s.fPaintingData->fBaseFrequency &&
@@ -605,7 +605,7 @@ private:
this->setWillNotUseInputColor();
}
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
SkPerlinNoiseShader::Type fType;
GrCoordTransform fCoordTransform;
@@ -621,16 +621,16 @@ private:
}
private:
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
/////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrPerlinNoiseEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrPerlinNoiseEffect);
-GrEffect* GrPerlinNoiseEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrFragmentProcessor* GrPerlinNoiseEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
int numOctaves = random->nextRangeU(2, 10);
bool stitchTiles = random->nextBool();
SkScalar seed = SkIntToScalar(random->nextU());
@@ -648,24 +648,25 @@ GrEffect* GrPerlinNoiseEffect::TestCreate(SkRandom* random,
SkPaint paint;
GrColor paintColor;
- GrEffect* effect;
- SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
+ GrFragmentProcessor* effect;
+ SkAssertResult(shader->asFragmentProcessor(context, paint, NULL, &paintColor, &effect));
SkDELETE(shader);
return effect;
}
-GrGLPerlinNoise::GrGLPerlinNoise(const GrBackendEffectFactory& factory, const GrEffect& effect)
+GrGLPerlinNoise::GrGLPerlinNoise(const GrBackendProcessorFactory& factory,
+ const GrProcessor& processor)
: INHERITED (factory)
- , fType(effect.cast<GrPerlinNoiseEffect>().type())
- , fStitchTiles(effect.cast<GrPerlinNoiseEffect>().stitchTiles())
- , fNumOctaves(effect.cast<GrPerlinNoiseEffect>().numOctaves()) {
+ , fType(processor.cast<GrPerlinNoiseEffect>().type())
+ , fStitchTiles(processor.cast<GrPerlinNoiseEffect>().stitchTiles())
+ , fNumOctaves(processor.cast<GrPerlinNoiseEffect>().numOctaves()) {
}
void GrGLPerlinNoise::emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey& key,
+ const GrFragmentProcessor&,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -919,8 +920,9 @@ void GrGLPerlinNoise::emitCode(GrGLProgramBuilder* builder,
outputColor, outputColor, outputColor, outputColor);
}
-void GrGLPerlinNoise::GenKey(const GrEffect& effect, const GrGLCaps&, GrEffectKeyBuilder* b) {
- const GrPerlinNoiseEffect& turbulence = effect.cast<GrPerlinNoiseEffect>();
+void GrGLPerlinNoise::GenKey(const GrProcessor& processor, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
+ const GrPerlinNoiseEffect& turbulence = processor.cast<GrPerlinNoiseEffect>();
uint32_t key = turbulence.numOctaves();
@@ -945,10 +947,10 @@ void GrGLPerlinNoise::GenKey(const GrEffect& effect, const GrGLCaps&, GrEffectKe
b->add32(key);
}
-void GrGLPerlinNoise::setData(const GrGLProgramDataManager& pdman, const GrEffect& effect) {
- INHERITED::setData(pdman, effect);
+void GrGLPerlinNoise::setData(const GrGLProgramDataManager& pdman, const GrProcessor& processor) {
+ INHERITED::setData(pdman, processor);
- const GrPerlinNoiseEffect& turbulence = effect.cast<GrPerlinNoiseEffect>();
+ const GrPerlinNoiseEffect& turbulence = processor.cast<GrPerlinNoiseEffect>();
const SkVector& baseFrequency = turbulence.baseFrequency();
pdman.set2f(fBaseFrequencyUni, baseFrequency.fX, baseFrequency.fY);
@@ -963,9 +965,9 @@ void GrGLPerlinNoise::setData(const GrGLProgramDataManager& pdman, const GrEffec
/////////////////////////////////////////////////////////////////////
-bool SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* externalLocalMatrix, GrColor* paintColor,
- GrEffect** effect) const {
+bool SkPerlinNoiseShader::asFragmentProcessor(GrContext* context, const SkPaint& paint,
+ const SkMatrix* externalLocalMatrix,
+ GrColor* paintColor, GrFragmentProcessor** fp) const {
SkASSERT(context);
*paintColor = SkColor2GrColorJustAlpha(paint.getColor());
@@ -985,14 +987,15 @@ bool SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint& paint,
}
SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(
clearColor, SkXfermode::kSrc_Mode));
- *effect = cf->asNewEffect(context);
+ *fp = cf->asFragmentProcessor(context);
return true;
}
// Either we don't stitch tiles, either we have a valid tile size
SkASSERT(!fStitchTiles || !fTileSize.isEmpty());
- SkPerlinNoiseShader::PaintingData* paintingData = SkNEW_ARGS(PaintingData, (fTileSize, fSeed, fBaseFrequencyX, fBaseFrequencyY, matrix));
+ SkPerlinNoiseShader::PaintingData* paintingData =
+ SkNEW_ARGS(PaintingData, (fTileSize, fSeed, fBaseFrequencyX, fBaseFrequencyY, matrix));
GrTexture* permutationsTexture = GrLockAndRefCachedBitmapTexture(
context, paintingData->getPermutationsBitmap(), NULL);
GrTexture* noiseTexture = GrLockAndRefCachedBitmapTexture(
@@ -1002,15 +1005,15 @@ bool SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint& paint,
m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1);
if ((permutationsTexture) && (noiseTexture)) {
- *effect = GrPerlinNoiseEffect::Create(fType,
- fNumOctaves,
- fStitchTiles,
- paintingData,
- permutationsTexture, noiseTexture,
- m, paint.getAlpha());
+ *fp = GrPerlinNoiseEffect::Create(fType,
+ fNumOctaves,
+ fStitchTiles,
+ paintingData,
+ permutationsTexture, noiseTexture,
+ m, paint.getAlpha());
} else {
SkDELETE(paintingData);
- *effect = NULL;
+ *fp = NULL;
}
// Unlock immediately, this is not great, but we don't have a way of
@@ -1028,9 +1031,8 @@ bool SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint& paint,
#else
-bool SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* externalLocalMatrix, GrColor* paintColor,
- GrEffect** effect) const {
+bool SkPerlinNoiseShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*,
+ GrFragmentProcessor**) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index 548a92894..88b4a4bf4 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -43,7 +43,7 @@ public:
virtual bool asComponentTable(SkBitmap* table) const SK_OVERRIDE;
#if SK_SUPPORT_GPU
- virtual GrEffect* asNewEffect(GrContext* context) const SK_OVERRIDE;
+ virtual GrFragmentProcessor* asFragmentProcessor(GrContext* context) const SK_OVERRIDE;
#endif
virtual void filterSpan(const SkPMColor src[], int count,
@@ -275,71 +275,71 @@ bool SkTable_ColorFilter::asComponentTable(SkBitmap* table) const {
#if SK_SUPPORT_GPU
-#include "GrEffect.h"
-#include "GrTBackendEffectFactory.h"
-#include "gl/GrGLEffect.h"
+#include "GrProcessor.h"
+#include "GrTBackendProcessorFactory.h"
+#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "SkGr.h"
class GLColorTableEffect;
-class ColorTableEffect : public GrEffect {
+class ColorTableEffect : public GrFragmentProcessor {
public:
- static GrEffect* Create(GrTexture* texture, unsigned flags) {
+ static GrFragmentProcessor* Create(GrTexture* texture, unsigned flags) {
return SkNEW_ARGS(ColorTableEffect, (texture, flags));
}
virtual ~ColorTableEffect();
static const char* Name() { return "ColorTable"; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
- typedef GLColorTableEffect GLEffect;
+ typedef GLColorTableEffect GLProcessor;
private:
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
explicit ColorTableEffect(GrTexture* texture, unsigned flags);
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
GrTextureAccess fTextureAccess;
unsigned fFlags; // currently not used in shader code, just to assist
// getConstantColorComponents().
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
-class GLColorTableEffect : public GrGLEffect {
+class GLColorTableEffect : public GrGLFragmentProcessor {
public:
- GLColorTableEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GLColorTableEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE {}
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {}
- static void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder* b) {}
+ static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder* b) {}
private:
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
-GLColorTableEffect::GLColorTableEffect(const GrBackendEffectFactory& factory, const GrEffect&)
+GLColorTableEffect::GLColorTableEffect(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED(factory) {
}
void GLColorTableEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
@@ -393,11 +393,11 @@ ColorTableEffect::ColorTableEffect(GrTexture* texture, unsigned flags)
ColorTableEffect::~ColorTableEffect() {
}
-const GrBackendEffectFactory& ColorTableEffect::getFactory() const {
- return GrTBackendEffectFactory<ColorTableEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& ColorTableEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<ColorTableEffect>::getInstance();
}
-bool ColorTableEffect::onIsEqual(const GrEffect& sBase) const {
+bool ColorTableEffect::onIsEqual(const GrProcessor& sBase) const {
return this->texture(0) == sBase.texture(0);
}
@@ -421,32 +421,32 @@ void ColorTableEffect::getConstantColorComponents(GrColor* color, uint32_t* vali
///////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(ColorTableEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorTableEffect);
-GrEffect* ColorTableEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrFragmentProcessor* ColorTableEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
static unsigned kAllFlags = SkTable_ColorFilter::kR_Flag | SkTable_ColorFilter::kG_Flag |
SkTable_ColorFilter::kB_Flag | SkTable_ColorFilter::kA_Flag;
- return ColorTableEffect::Create(textures[GrEffectUnitTest::kAlphaTextureIdx], kAllFlags);
+ return ColorTableEffect::Create(textures[GrProcessorUnitTest::kAlphaTextureIdx], kAllFlags);
}
-GrEffect* SkTable_ColorFilter::asNewEffect(GrContext* context) const {
+GrFragmentProcessor* SkTable_ColorFilter::asFragmentProcessor(GrContext* context) const {
SkBitmap bitmap;
- GrEffect* effect = NULL;
+ GrFragmentProcessor* fp = NULL;
this->asComponentTable(&bitmap);
// passing NULL because this effect does no tiling or filtering.
GrTexture* texture = GrLockAndRefCachedBitmapTexture(context, bitmap, NULL);
if (texture) {
- effect = ColorTableEffect::Create(texture, fFlags);
+ fp = ColorTableEffect::Create(texture, fFlags);
// 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.
GrUnlockAndUnrefCachedBitmapTexture(texture);
}
- return effect;
+ return fp;
}
#endif // SK_SUPPORT_GPU
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index 98936f71e..bca5223db 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -108,7 +108,7 @@ bool SkXfermodeImageFilter::onFilterImage(Proxy* proxy,
#if SK_SUPPORT_GPU
bool SkXfermodeImageFilter::canFilterImageGPU() const {
- return fMode && fMode->asNewEffect(NULL, NULL) && !cropRectIsSet();
+ return fMode && fMode->asFragmentProcessor(NULL, NULL) && !cropRectIsSet();
}
bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
@@ -132,7 +132,7 @@ bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
GrTexture* foregroundTex = foreground.getTexture();
GrContext* context = foregroundTex->getContext();
- GrEffect* xferEffect = NULL;
+ GrFragmentProcessor* xferProcessor = NULL;
GrTextureDesc desc;
desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
@@ -148,7 +148,7 @@ bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
GrContext::AutoRenderTarget art(context, dst->asRenderTarget());
- if (!fMode || !fMode->asNewEffect(&xferEffect, backgroundTex)) {
+ if (!fMode || !fMode->asFragmentProcessor(&xferProcessor, backgroundTex)) {
// canFilterImageGPU() should've taken care of this
SkASSERT(false);
return false;
@@ -163,8 +163,8 @@ bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
src.getBounds(&srcRect);
GrPaint paint;
- paint.addColorTextureEffect(foregroundTex, foregroundMatrix);
- paint.addColorEffect(xferEffect)->unref();
+ paint.addColorTextureProcessor(foregroundTex, foregroundMatrix);
+ paint.addColorProcessor(xferProcessor)->unref();
context->drawRect(paint, srcRect);
offset->fX = backgroundOffset.fX;
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 6413f4fe5..d25873b43 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -945,11 +945,11 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
#if SK_SUPPORT_GPU
#include "effects/GrTextureStripAtlas.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "SkGr.h"
-GrGLGradientEffect::GrGLGradientEffect(const GrBackendEffectFactory& factory)
+GrGLGradientEffect::GrGLGradientEffect(const GrBackendProcessorFactory& factory)
: INHERITED(factory)
, fCachedYCoord(SK_ScalarMax) {
}
@@ -1001,9 +1001,9 @@ static inline void set_mul_color_uni(const GrGLProgramDataManager& pdman,
}
void GrGLGradientEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
+ const GrProcessor& processor) {
- const GrGradientEffect& e = effect.cast<GrGradientEffect>();
+ const GrGradientEffect& e = processor.cast<GrGradientEffect>();
if (SkGradientShaderBase::kTwo_GpuColorType == e.getColorType()){
@@ -1038,8 +1038,8 @@ void GrGLGradientEffect::setData(const GrGLProgramDataManager& pdman,
}
-uint32_t GrGLGradientEffect::GenBaseGradientKey(const GrEffect& effect) {
- const GrGradientEffect& e = effect.cast<GrGradientEffect>();
+uint32_t GrGLGradientEffect::GenBaseGradientKey(const GrProcessor& processor) {
+ const GrGradientEffect& e = processor.cast<GrGradientEffect>();
uint32_t key = 0;
@@ -1185,8 +1185,8 @@ GrGradientEffect::~GrGradientEffect() {
}
}
-bool GrGradientEffect::onIsEqual(const GrEffect& effect) const {
- const GrGradientEffect& s = effect.cast<GrGradientEffect>();
+bool GrGradientEffect::onIsEqual(const GrProcessor& processor) const {
+ const GrGradientEffect& s = processor.cast<GrGradientEffect>();
if (this->fColorType == s.getColorType()){
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
index cc5b2e9a2..b81b5626b 100644
--- a/src/effects/gradients/SkGradientShaderPriv.h
+++ b/src/effects/gradients/SkGradientShaderPriv.h
@@ -298,10 +298,10 @@ static inline int next_dither_toggle16(int toggle) {
#if SK_SUPPORT_GPU
#include "GrCoordTransform.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
-class GrEffectStage;
-class GrBackendEffectFactory;
+class GrProcessorStage;
+class GrBackendProcessorFactory;
/*
* The interpretation of the texture matrix depends on the sample mode. The
@@ -329,7 +329,7 @@ class GrBackendEffectFactory;
class GrTextureStripAtlas;
// Base class for Gr gradient effects
-class GrGradientEffect : public GrEffect {
+class GrGradientEffect : public GrFragmentProcessor {
public:
GrGradientEffect(GrContext* ctx,
@@ -374,7 +374,7 @@ protected:
SkScalar** stops,
SkShader::TileMode* tm);
- virtual bool onIsEqual(const GrEffect& effect) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
const GrCoordTransform& getCoordTransform() const { return fCoordTransform; }
@@ -391,19 +391,19 @@ private:
SkColor fColors[3]; // More than 3 colors we use texture
PremulType fPremulType; // This only changes behavior for two and three color special cases.
// It is already baked into to the table for texture gradients.
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
// Base class for GL gradient effects
-class GrGLGradientEffect : public GrGLEffect {
+class GrGLGradientEffect : public GrGLFragmentProcessor {
public:
- GrGLGradientEffect(const GrBackendEffectFactory& factory);
+ GrGLGradientEffect(const GrBackendProcessorFactory& factory);
virtual ~GrGLGradientEffect();
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
protected:
/**
@@ -411,7 +411,7 @@ protected:
* by the base class. The subclasses must stick it in their key and then pass it to the below
* emit* functions from their emitCode function.
*/
- static uint32_t GenBaseGradientKey(const GrEffect&);
+ static uint32_t GenBaseGradientKey(const GrProcessor&);
// Emits the uniform used as the y-coord to texture samples in derived classes. Subclasses
// should call this method from their emitCode().
@@ -467,7 +467,7 @@ private:
GrGLProgramDataManager::UniformHandle fColorMidUni;
GrGLProgramDataManager::UniformHandle fColorEndUni;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
#endif
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index d978e5ada..058e61cb8 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -459,7 +459,7 @@ void SkLinearGradient::LinearGradientContext::shadeSpan16(int x, int y,
#if SK_SUPPORT_GPU
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "SkGr.h"
@@ -468,21 +468,21 @@ void SkLinearGradient::LinearGradientContext::shadeSpan16(int x, int y,
class GrGLLinearGradient : public GrGLGradientEffect {
public:
- GrGLLinearGradient(const GrBackendEffectFactory& factory, const GrEffect&)
+ GrGLLinearGradient(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED (factory) { }
virtual ~GrGLLinearGradient() { }
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- static void GenKey(const GrEffect& effect, const GrGLCaps&, GrEffectKeyBuilder* b) {
- b->add32(GenBaseGradientKey(effect));
+ static void GenKey(const GrProcessor& processor, const GrGLCaps&, GrProcessorKeyBuilder* b) {
+ b->add32(GenBaseGradientKey(processor));
}
private:
@@ -495,21 +495,21 @@ private:
class GrLinearGradient : public GrGradientEffect {
public:
- static GrEffect* Create(GrContext* ctx,
- const SkLinearGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm) {
+ static GrFragmentProcessor* Create(GrContext* ctx,
+ const SkLinearGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm) {
return SkNEW_ARGS(GrLinearGradient, (ctx, shader, matrix, tm));
}
virtual ~GrLinearGradient() { }
static const char* Name() { return "Linear Gradient"; }
- const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
- return GrTBackendEffectFactory<GrLinearGradient>::getInstance();
+ const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
+ return GrTBackendFragmentProcessorFactory<GrLinearGradient>::getInstance();
}
- typedef GrGLLinearGradient GLEffect;
+ typedef GrGLLinearGradient GLProcessor;
private:
GrLinearGradient(GrContext* ctx,
@@ -517,19 +517,19 @@ private:
const SkMatrix& matrix,
SkShader::TileMode tm)
: INHERITED(ctx, shader, matrix, tm) { }
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
typedef GrGradientEffect INHERITED;
};
/////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrLinearGradient);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrLinearGradient);
-GrEffect* GrLinearGradient::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrFragmentProcessor* GrLinearGradient::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
SkPoint points[] = {{random->nextUScalar1(), random->nextUScalar1()},
{random->nextUScalar1(), random->nextUScalar1()}};
@@ -543,16 +543,16 @@ GrEffect* GrLinearGradient::TestCreate(SkRandom* random,
tm));
SkPaint paint;
GrColor paintColor;
- GrEffect* effect;
- SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
- return effect;
+ GrFragmentProcessor* fp;
+ SkAssertResult(shader->asFragmentProcessor(context, paint, NULL, &paintColor, &fp));
+ return fp;
}
/////////////////////////////////////////////////////////////////////
void GrGLLinearGradient::emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey& key,
+ const GrFragmentProcessor&,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -566,9 +566,9 @@ void GrGLLinearGradient::emitCode(GrGLProgramBuilder* builder,
/////////////////////////////////////////////////////////////////////
-bool SkLinearGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* paintColor,
- GrEffect** effect) const {
+bool SkLinearGradient::asFragmentProcessor(GrContext* context, const SkPaint& paint,
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrFragmentProcessor** fp) const {
SkASSERT(context);
SkMatrix matrix;
@@ -585,16 +585,15 @@ bool SkLinearGradient::asNewEffect(GrContext* context, const SkPaint& paint,
matrix.postConcat(fPtsToUnit);
*paintColor = SkColor2GrColorJustAlpha(paint.getColor());
- *effect = GrLinearGradient::Create(context, *this, matrix, fTileMode);
+ *fp = GrLinearGradient::Create(context, *this, matrix, fTileMode);
return true;
}
#else
-bool SkLinearGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* paintColor,
- GrEffect** effect) const {
+bool SkLinearGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*,
+ GrFragmentProcessor**) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
diff --git a/src/effects/gradients/SkLinearGradient.h b/src/effects/gradients/SkLinearGradient.h
index 68901064d..eb6c76e2e 100644
--- a/src/effects/gradients/SkLinearGradient.h
+++ b/src/effects/gradients/SkLinearGradient.h
@@ -30,8 +30,8 @@ public:
virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const SK_OVERRIDE;
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewEffect(GrContext* context, const SkPaint& paint, const SkMatrix* localMatrix,
- GrColor* paintColor, GrEffect** effect) const SK_OVERRIDE;
+ virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*,
+ GrColor*, GrFragmentProcessor**) const SK_OVERRIDE;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLinearGradient)
diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp
index 90d945839..b4ced5e6a 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -469,27 +469,27 @@ void SkRadialGradient::RadialGradientContext::shadeSpan(int x, int y,
#if SK_SUPPORT_GPU
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "SkGr.h"
class GrGLRadialGradient : public GrGLGradientEffect {
public:
- GrGLRadialGradient(const GrBackendEffectFactory& factory,
- const GrEffect&) : INHERITED (factory) { }
+ GrGLRadialGradient(const GrBackendProcessorFactory& factory,
+ const GrProcessor&) : INHERITED (factory) { }
virtual ~GrGLRadialGradient() { }
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- static void GenKey(const GrEffect& effect, const GrGLCaps&, GrEffectKeyBuilder* b) {
- b->add32(GenBaseGradientKey(effect));
+ static void GenKey(const GrProcessor& processor, const GrGLCaps&, GrProcessorKeyBuilder* b) {
+ b->add32(GenBaseGradientKey(processor));
}
private:
@@ -502,21 +502,21 @@ private:
class GrRadialGradient : public GrGradientEffect {
public:
- static GrEffect* Create(GrContext* ctx,
- const SkRadialGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm) {
+ static GrFragmentProcessor* Create(GrContext* ctx,
+ const SkRadialGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm) {
return SkNEW_ARGS(GrRadialGradient, (ctx, shader, matrix, tm));
}
virtual ~GrRadialGradient() { }
static const char* Name() { return "Radial Gradient"; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
- return GrTBackendEffectFactory<GrRadialGradient>::getInstance();
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
+ return GrTBackendFragmentProcessorFactory<GrRadialGradient>::getInstance();
}
- typedef GrGLRadialGradient GLEffect;
+ typedef GrGLRadialGradient GLProcessor;
private:
GrRadialGradient(GrContext* ctx,
@@ -526,19 +526,19 @@ private:
: INHERITED(ctx, shader, matrix, tm) {
}
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
typedef GrGradientEffect INHERITED;
};
/////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrRadialGradient);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRadialGradient);
-GrEffect* GrRadialGradient::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrFragmentProcessor* GrRadialGradient::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
SkPoint center = {random->nextUScalar1(), random->nextUScalar1()};
SkScalar radius = random->nextUScalar1();
@@ -552,16 +552,16 @@ GrEffect* GrRadialGradient::TestCreate(SkRandom* random,
tm));
SkPaint paint;
GrColor paintColor;
- GrEffect* effect;
- SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
- return effect;
+ GrFragmentProcessor* fp;
+ SkAssertResult(shader->asFragmentProcessor(context, paint, NULL, &paintColor, &fp));
+ return fp;
}
/////////////////////////////////////////////////////////////////////
void GrGLRadialGradient::emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey& key,
+ const GrFragmentProcessor&,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -576,9 +576,9 @@ void GrGLRadialGradient::emitCode(GrGLProgramBuilder* builder,
/////////////////////////////////////////////////////////////////////
-bool SkRadialGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* paintColor,
- GrEffect** effect) const {
+bool SkRadialGradient::asFragmentProcessor(GrContext* context, const SkPaint& paint,
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrFragmentProcessor** fp) const {
SkASSERT(context);
SkMatrix matrix;
@@ -595,16 +595,15 @@ bool SkRadialGradient::asNewEffect(GrContext* context, const SkPaint& paint,
matrix.postConcat(fPtsToUnit);
*paintColor = SkColor2GrColorJustAlpha(paint.getColor());
- *effect = GrRadialGradient::Create(context, *this, matrix, fTileMode);
+ *fp = GrRadialGradient::Create(context, *this, matrix, fTileMode);
return true;
}
#else
-bool SkRadialGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* paintColor,
- GrEffect** effect) const {
+bool SkRadialGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*,
+ GrFragmentProcessor**) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
diff --git a/src/effects/gradients/SkRadialGradient.h b/src/effects/gradients/SkRadialGradient.h
index 7709c380b..633b39f91 100644
--- a/src/effects/gradients/SkRadialGradient.h
+++ b/src/effects/gradients/SkRadialGradient.h
@@ -32,7 +32,8 @@ public:
SkMatrix* matrix,
TileMode* xy) const SK_OVERRIDE;
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewEffect(GrContext*, const SkPaint&, const SkMatrix*, GrColor*, GrEffect**) const SK_OVERRIDE;
+ virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*,
+ GrFragmentProcessor**) const SK_OVERRIDE;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRadialGradient)
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index 6aaa92fc3..750e80a6d 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -184,27 +184,27 @@ void SkSweepGradient::SweepGradientContext::shadeSpan16(int x, int y, uint16_t*
#if SK_SUPPORT_GPU
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "SkGr.h"
class GrGLSweepGradient : public GrGLGradientEffect {
public:
- GrGLSweepGradient(const GrBackendEffectFactory& factory,
- const GrEffect&) : INHERITED (factory) { }
+ GrGLSweepGradient(const GrBackendProcessorFactory& factory,
+ const GrProcessor&) : INHERITED (factory) { }
virtual ~GrGLSweepGradient() { }
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- static void GenKey(const GrEffect& effect, const GrGLCaps&, GrEffectKeyBuilder* b) {
- b->add32(GenBaseGradientKey(effect));
+ static void GenKey(const GrProcessor& processor, const GrGLCaps&, GrProcessorKeyBuilder* b) {
+ b->add32(GenBaseGradientKey(processor));
}
private:
@@ -217,36 +217,37 @@ private:
class GrSweepGradient : public GrGradientEffect {
public:
- static GrEffect* Create(GrContext* ctx, const SkSweepGradient& shader, const SkMatrix& m) {
+ static GrFragmentProcessor* Create(GrContext* ctx, const SkSweepGradient& shader,
+ const SkMatrix& m) {
return SkNEW_ARGS(GrSweepGradient, (ctx, shader, m));
}
virtual ~GrSweepGradient() { }
static const char* Name() { return "Sweep Gradient"; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
- return GrTBackendEffectFactory<GrSweepGradient>::getInstance();
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
+ return GrTBackendFragmentProcessorFactory<GrSweepGradient>::getInstance();
}
- typedef GrGLSweepGradient GLEffect;
+ typedef GrGLSweepGradient GLProcessor;
private:
GrSweepGradient(GrContext* ctx,
const SkSweepGradient& shader,
const SkMatrix& matrix)
: INHERITED(ctx, shader, matrix, SkShader::kClamp_TileMode) { }
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
typedef GrGradientEffect INHERITED;
};
/////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrSweepGradient);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSweepGradient);
-GrEffect* GrSweepGradient::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrFragmentProcessor* GrSweepGradient::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
SkPoint center = {random->nextUScalar1(), random->nextUScalar1()};
SkColor colors[kMaxRandomGradientColors];
@@ -257,17 +258,17 @@ GrEffect* GrSweepGradient::TestCreate(SkRandom* random,
SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, center.fY,
colors, stops, colorCount));
SkPaint paint;
- GrEffect* effect;
+ GrFragmentProcessor* fp;
GrColor paintColor;
- SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
- return effect;
+ SkAssertResult(shader->asFragmentProcessor(context, paint, NULL, &paintColor, &fp));
+ return fp;
}
/////////////////////////////////////////////////////////////////////
void GrGLSweepGradient::emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey& key,
+ const GrFragmentProcessor&,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -292,9 +293,9 @@ void GrGLSweepGradient::emitCode(GrGLProgramBuilder* builder,
/////////////////////////////////////////////////////////////////////
-bool SkSweepGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* paintColor,
- GrEffect** effect) const {
+bool SkSweepGradient::asFragmentProcessor(GrContext* context, const SkPaint& paint,
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrFragmentProcessor** effect) const {
SkMatrix matrix;
if (!this->getLocalMatrix().invert(&matrix)) {
@@ -317,9 +318,8 @@ bool SkSweepGradient::asNewEffect(GrContext* context, const SkPaint& paint,
#else
-bool SkSweepGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* paintColor,
- GrEffect** effect) const {
+bool SkSweepGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*,
+ GrFragmentProcessor**) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
diff --git a/src/effects/gradients/SkSweepGradient.h b/src/effects/gradients/SkSweepGradient.h
index 640079ad6..d81629507 100644
--- a/src/effects/gradients/SkSweepGradient.h
+++ b/src/effects/gradients/SkSweepGradient.h
@@ -34,8 +34,8 @@ public:
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewEffect(GrContext*, const SkPaint&, const SkMatrix*, GrColor*, GrEffect**)
- const SK_OVERRIDE;
+ virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*,
+ GrFragmentProcessor**) const SK_OVERRIDE;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSweepGradient)
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp
index 0ecad3a05..bb3b9b371 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp
@@ -420,22 +420,23 @@ void SkTwoPointConicalGradient::flatten(SkWriteBuffer& buffer) const {
#include "SkGr.h"
-bool SkTwoPointConicalGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* paintColor,
- GrEffect** effect) const {
+bool SkTwoPointConicalGradient::asFragmentProcessor(GrContext* context,
+ const SkPaint& paint,
+ const SkMatrix* localMatrix,
+ GrColor* paintColor,
+ GrFragmentProcessor** fp) const {
SkASSERT(context);
SkASSERT(fPtsToUnit.isIdentity());
- *effect = Gr2PtConicalGradientEffect::Create(context, *this, fTileMode, localMatrix);
+ *fp = Gr2PtConicalGradientEffect::Create(context, *this, fTileMode, localMatrix);
*paintColor = SkColor2GrColorJustAlpha(paint.getColor());
return true;
}
#else
-bool SkTwoPointConicalGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* paintColor,
- GrEffect** effect) const {
+bool SkTwoPointConicalGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*,
+ GrColor*, GrFragmentProcessor**) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.h b/src/effects/gradients/SkTwoPointConicalGradient.h
index 608ea7671..c43f682c5 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.h
+++ b/src/effects/gradients/SkTwoPointConicalGradient.h
@@ -64,8 +64,8 @@ public:
SkMatrix* matrix,
TileMode* xy) const;
virtual SkShader::GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewEffect(GrContext*, const SkPaint&, const SkMatrix*, GrColor* paintColor,
- GrEffect**) const SK_OVERRIDE;
+ virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*, GrColor*,
+ GrFragmentProcessor**) const SK_OVERRIDE;
virtual bool isOpaque() const SK_OVERRIDE;
SkScalar getCenterX1() const { return SkPoint::Distance(fCenter1, fCenter2); }
diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
index c02e71eb9..206d2d968 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
@@ -11,7 +11,7 @@
#include "SkTwoPointConicalGradient.h"
#if SK_SUPPORT_GPU
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "gl/builders/GrGLProgramBuilder.h"
// For brevity
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
@@ -60,27 +60,27 @@ class GLEdge2PtConicalEffect;
class Edge2PtConicalEffect : public GrGradientEffect {
public:
- static GrEffect* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm) {
+ static GrFragmentProcessor* Create(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm) {
return SkNEW_ARGS(Edge2PtConicalEffect, (ctx, shader, matrix, tm));
}
virtual ~Edge2PtConicalEffect() {}
static const char* Name() { return "Two-Point Conical Gradient Edge Touching"; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
// The radial gradient parameters can collapse to a linear (instead of quadratic) equation.
SkScalar center() const { return fCenterX1; }
SkScalar diffRadius() const { return fDiffRadius; }
SkScalar radius() const { return fRadius0; }
- typedef GLEdge2PtConicalEffect GLEffect;
+ typedef GLEdge2PtConicalEffect GLProcessor;
private:
- virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE {
+ virtual bool onIsEqual(const GrProcessor& sBase) const SK_OVERRIDE {
const Edge2PtConicalEffect& s = sBase.cast<Edge2PtConicalEffect>();
return (INHERITED::onIsEqual(sBase) &&
this->fCenterX1 == s.fCenterX1 &&
@@ -119,7 +119,7 @@ private:
this->addCoordTransform(&fBTransform);
}
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
// @{
// Cache of values - these can change arbitrarily, EXCEPT
@@ -137,19 +137,19 @@ private:
class GLEdge2PtConicalEffect : public GrGLGradientEffect {
public:
- GLEdge2PtConicalEffect(const GrBackendEffectFactory& factory, const GrEffect&);
+ GLEdge2PtConicalEffect(const GrBackendProcessorFactory& factory, const GrProcessor&);
virtual ~GLEdge2PtConicalEffect() { }
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
- static void GenKey(const GrEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
+ static void GenKey(const GrProcessor&, const GrGLCaps& caps, GrProcessorKeyBuilder* b);
protected:
UniformHandle fParamUni;
@@ -170,19 +170,19 @@ private:
};
-const GrBackendEffectFactory& Edge2PtConicalEffect::getFactory() const {
- return GrTBackendEffectFactory<Edge2PtConicalEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& Edge2PtConicalEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<Edge2PtConicalEffect>::getInstance();
}
-GR_DEFINE_EFFECT_TEST(Edge2PtConicalEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(Edge2PtConicalEffect);
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-GrEffect* Edge2PtConicalEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrFragmentProcessor* Edge2PtConicalEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()};
SkScalar radius1 = random->nextUScalar1();
SkPoint center2;
@@ -209,14 +209,14 @@ GrEffect* Edge2PtConicalEffect::TestCreate(SkRandom* random,
colors, stops, colorCount,
tm));
SkPaint paint;
- GrEffect* effect;
+ GrFragmentProcessor* fp;
GrColor paintColor;
- SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
- return effect;
+ SkAssertResult(shader->asFragmentProcessor(context, paint, NULL, &paintColor, &fp));
+ return fp;
}
-GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor&)
: INHERITED(factory)
, fVSVaryingName(NULL)
, fFSVaryingName(NULL)
@@ -224,8 +224,8 @@ GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrBackendEffectFactory& fac
, fCachedDiffRadius(-SK_ScalarMax) {}
void GLEdge2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey& key,
+ const GrFragmentProcessor&,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -282,9 +282,9 @@ void GLEdge2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
}
void GLEdge2PtConicalEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
- INHERITED::setData(pdman, effect);
- const Edge2PtConicalEffect& data = effect.cast<Edge2PtConicalEffect>();
+ const GrProcessor& processor) {
+ INHERITED::setData(pdman, processor);
+ const Edge2PtConicalEffect& data = processor.cast<Edge2PtConicalEffect>();
SkScalar radius0 = data.radius();
SkScalar diffRadius = data.diffRadius();
@@ -303,9 +303,9 @@ void GLEdge2PtConicalEffect::setData(const GrGLProgramDataManager& pdman,
}
}
-void GLEdge2PtConicalEffect::GenKey(const GrEffect& effect,
- const GrGLCaps&, GrEffectKeyBuilder* b) {
- b->add32(GenBaseGradientKey(effect));
+void GLEdge2PtConicalEffect::GenKey(const GrProcessor& processor,
+ const GrGLCaps&, GrProcessorKeyBuilder* b) {
+ b->add32(GenBaseGradientKey(processor));
}
//////////////////////////////////////////////////////////////////////////////
@@ -375,26 +375,26 @@ class GLFocalOutside2PtConicalEffect;
class FocalOutside2PtConicalEffect : public GrGradientEffect {
public:
- static GrEffect* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- SkScalar focalX) {
+ static GrFragmentProcessor* Create(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ SkScalar focalX) {
return SkNEW_ARGS(FocalOutside2PtConicalEffect, (ctx, shader, matrix, tm, focalX));
}
virtual ~FocalOutside2PtConicalEffect() { }
static const char* Name() { return "Two-Point Conical Gradient Focal Outside"; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
bool isFlipped() const { return fIsFlipped; }
SkScalar focal() const { return fFocalX; }
- typedef GLFocalOutside2PtConicalEffect GLEffect;
+ typedef GLFocalOutside2PtConicalEffect GLProcessor;
private:
- virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE {
+ virtual bool onIsEqual(const GrProcessor& sBase) const SK_OVERRIDE {
const FocalOutside2PtConicalEffect& s = sBase.cast<FocalOutside2PtConicalEffect>();
return (INHERITED::onIsEqual(sBase) &&
this->fFocalX == s.fFocalX &&
@@ -408,7 +408,7 @@ private:
SkScalar focalX)
: INHERITED(ctx, shader, matrix, tm), fFocalX(focalX), fIsFlipped(shader.isFlippedGrad()) {}
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
SkScalar fFocalX;
bool fIsFlipped;
@@ -418,19 +418,19 @@ private:
class GLFocalOutside2PtConicalEffect : public GrGLGradientEffect {
public:
- GLFocalOutside2PtConicalEffect(const GrBackendEffectFactory& factory, const GrEffect&);
+ GLFocalOutside2PtConicalEffect(const GrBackendProcessorFactory& factory, const GrProcessor&);
virtual ~GLFocalOutside2PtConicalEffect() { }
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
- static void GenKey(const GrEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
+ static void GenKey(const GrProcessor&, const GrGLCaps& caps, GrProcessorKeyBuilder* b);
protected:
UniformHandle fParamUni;
@@ -452,19 +452,19 @@ private:
};
-const GrBackendEffectFactory& FocalOutside2PtConicalEffect::getFactory() const {
- return GrTBackendEffectFactory<FocalOutside2PtConicalEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& FocalOutside2PtConicalEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<FocalOutside2PtConicalEffect>::getInstance();
}
-GR_DEFINE_EFFECT_TEST(FocalOutside2PtConicalEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalOutside2PtConicalEffect);
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-GrEffect* FocalOutside2PtConicalEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrFragmentProcessor* FocalOutside2PtConicalEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()};
SkScalar radius1 = 0.f;
SkPoint center2;
@@ -488,25 +488,25 @@ GrEffect* FocalOutside2PtConicalEffect::TestCreate(SkRandom* random,
colors, stops, colorCount,
tm));
SkPaint paint;
- GrEffect* effect;
+ GrFragmentProcessor* effect;
GrColor paintColor;
- SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
+ SkAssertResult(shader->asFragmentProcessor(context, paint, NULL, &paintColor, &effect));
return effect;
}
-GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor& processor)
: INHERITED(factory)
, fVSVaryingName(NULL)
, fFSVaryingName(NULL)
, fCachedFocal(SK_ScalarMax) {
- const FocalOutside2PtConicalEffect& data = effect.cast<FocalOutside2PtConicalEffect>();
+ const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtConicalEffect>();
fIsFlipped = data.isFlipped();
}
void GLFocalOutside2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey& key,
+ const GrFragmentProcessor&,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -554,9 +554,9 @@ void GLFocalOutside2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
}
void GLFocalOutside2PtConicalEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
- INHERITED::setData(pdman, effect);
- const FocalOutside2PtConicalEffect& data = effect.cast<FocalOutside2PtConicalEffect>();
+ const GrProcessor& processor) {
+ INHERITED::setData(pdman, processor);
+ const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtConicalEffect>();
SkASSERT(data.isFlipped() == fIsFlipped);
SkScalar focal = data.focal();
@@ -573,11 +573,11 @@ void GLFocalOutside2PtConicalEffect::setData(const GrGLProgramDataManager& pdman
}
}
-void GLFocalOutside2PtConicalEffect::GenKey(const GrEffect& effect,
- const GrGLCaps&, GrEffectKeyBuilder* b) {
+void GLFocalOutside2PtConicalEffect::GenKey(const GrProcessor& processor,
+ const GrGLCaps&, GrProcessorKeyBuilder* b) {
uint32_t* key = b->add32n(2);
- key[0] = GenBaseGradientKey(effect);
- key[1] = effect.cast<FocalOutside2PtConicalEffect>().isFlipped();
+ key[0] = GenBaseGradientKey(processor);
+ key[1] = processor.cast<FocalOutside2PtConicalEffect>().isFlipped();
}
//////////////////////////////////////////////////////////////////////////////
@@ -587,25 +587,25 @@ class GLFocalInside2PtConicalEffect;
class FocalInside2PtConicalEffect : public GrGradientEffect {
public:
- static GrEffect* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- SkScalar focalX) {
+ static GrFragmentProcessor* Create(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ SkScalar focalX) {
return SkNEW_ARGS(FocalInside2PtConicalEffect, (ctx, shader, matrix, tm, focalX));
}
virtual ~FocalInside2PtConicalEffect() {}
static const char* Name() { return "Two-Point Conical Gradient Focal Inside"; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
SkScalar focal() const { return fFocalX; }
- typedef GLFocalInside2PtConicalEffect GLEffect;
+ typedef GLFocalInside2PtConicalEffect GLProcessor;
private:
- virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE {
+ virtual bool onIsEqual(const GrProcessor& sBase) const SK_OVERRIDE {
const FocalInside2PtConicalEffect& s = sBase.cast<FocalInside2PtConicalEffect>();
return (INHERITED::onIsEqual(sBase) &&
this->fFocalX == s.fFocalX);
@@ -618,7 +618,7 @@ private:
SkScalar focalX)
: INHERITED(ctx, shader, matrix, tm), fFocalX(focalX) {}
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
SkScalar fFocalX;
@@ -627,19 +627,19 @@ private:
class GLFocalInside2PtConicalEffect : public GrGLGradientEffect {
public:
- GLFocalInside2PtConicalEffect(const GrBackendEffectFactory& factory, const GrEffect&);
+ GLFocalInside2PtConicalEffect(const GrBackendProcessorFactory& factory, const GrProcessor&);
virtual ~GLFocalInside2PtConicalEffect() {}
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
- static void GenKey(const GrEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
+ static void GenKey(const GrProcessor&, const GrGLCaps& caps, GrProcessorKeyBuilder* b);
protected:
UniformHandle fFocalUni;
@@ -659,19 +659,19 @@ private:
};
-const GrBackendEffectFactory& FocalInside2PtConicalEffect::getFactory() const {
- return GrTBackendEffectFactory<FocalInside2PtConicalEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& FocalInside2PtConicalEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<FocalInside2PtConicalEffect>::getInstance();
}
-GR_DEFINE_EFFECT_TEST(FocalInside2PtConicalEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalInside2PtConicalEffect);
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-GrEffect* FocalInside2PtConicalEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrFragmentProcessor* FocalInside2PtConicalEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()};
SkScalar radius1 = 0.f;
SkPoint center2;
@@ -698,21 +698,21 @@ GrEffect* FocalInside2PtConicalEffect::TestCreate(SkRandom* random,
tm));
SkPaint paint;
GrColor paintColor;
- GrEffect* effect;
- SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
- return effect;
+ GrFragmentProcessor* fp;
+ SkAssertResult(shader->asFragmentProcessor(context, paint, NULL, &paintColor, &fp));
+ return fp;
}
-GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor&)
: INHERITED(factory)
, fVSVaryingName(NULL)
, fFSVaryingName(NULL)
, fCachedFocal(SK_ScalarMax) {}
void GLFocalInside2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey& key,
+ const GrFragmentProcessor&,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -740,9 +740,9 @@ void GLFocalInside2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
}
void GLFocalInside2PtConicalEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
- INHERITED::setData(pdman, effect);
- const FocalInside2PtConicalEffect& data = effect.cast<FocalInside2PtConicalEffect>();
+ const GrProcessor& processor) {
+ INHERITED::setData(pdman, processor);
+ const FocalInside2PtConicalEffect& data = processor.cast<FocalInside2PtConicalEffect>();
SkScalar focal = data.focal();
if (fCachedFocal != focal) {
@@ -751,9 +751,9 @@ void GLFocalInside2PtConicalEffect::setData(const GrGLProgramDataManager& pdman,
}
}
-void GLFocalInside2PtConicalEffect::GenKey(const GrEffect& effect,
- const GrGLCaps&, GrEffectKeyBuilder* b) {
- b->add32(GenBaseGradientKey(effect));
+void GLFocalInside2PtConicalEffect::GenKey(const GrProcessor& processor,
+ const GrGLCaps&, GrProcessorKeyBuilder* b) {
+ b->add32(GenBaseGradientKey(processor));
}
//////////////////////////////////////////////////////////////////////////////
@@ -825,18 +825,18 @@ class GLCircleInside2PtConicalEffect;
class CircleInside2PtConicalEffect : public GrGradientEffect {
public:
- static GrEffect* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- const CircleConicalInfo& info) {
+ static GrFragmentProcessor* Create(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ const CircleConicalInfo& info) {
return SkNEW_ARGS(CircleInside2PtConicalEffect, (ctx, shader, matrix, tm, info));
}
virtual ~CircleInside2PtConicalEffect() {}
static const char* Name() { return "Two-Point Conical Gradient Inside"; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
SkScalar centerX() const { return fInfo.fCenterEnd.fX; }
SkScalar centerY() const { return fInfo.fCenterEnd.fY; }
@@ -844,10 +844,10 @@ public:
SkScalar B() const { return fInfo.fB; }
SkScalar C() const { return fInfo.fC; }
- typedef GLCircleInside2PtConicalEffect GLEffect;
+ typedef GLCircleInside2PtConicalEffect GLProcessor;
private:
- virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE {
+ virtual bool onIsEqual(const GrProcessor& sBase) const SK_OVERRIDE {
const CircleInside2PtConicalEffect& s = sBase.cast<CircleInside2PtConicalEffect>();
return (INHERITED::onIsEqual(sBase) &&
this->fInfo.fCenterEnd == s.fInfo.fCenterEnd &&
@@ -863,7 +863,7 @@ private:
const CircleConicalInfo& info)
: INHERITED(ctx, shader, matrix, tm), fInfo(info) {}
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
const CircleConicalInfo fInfo;
@@ -872,19 +872,19 @@ private:
class GLCircleInside2PtConicalEffect : public GrGLGradientEffect {
public:
- GLCircleInside2PtConicalEffect(const GrBackendEffectFactory& factory, const GrEffect&);
+ GLCircleInside2PtConicalEffect(const GrBackendProcessorFactory& factory, const GrProcessor&);
virtual ~GLCircleInside2PtConicalEffect() {}
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
- static void GenKey(const GrEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
+ static void GenKey(const GrProcessor&, const GrGLCaps& caps, GrProcessorKeyBuilder* b);
protected:
UniformHandle fCenterUni;
@@ -909,19 +909,19 @@ private:
};
-const GrBackendEffectFactory& CircleInside2PtConicalEffect::getFactory() const {
- return GrTBackendEffectFactory<CircleInside2PtConicalEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& CircleInside2PtConicalEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<CircleInside2PtConicalEffect>::getInstance();
}
-GR_DEFINE_EFFECT_TEST(CircleInside2PtConicalEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleInside2PtConicalEffect);
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-GrEffect* CircleInside2PtConicalEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrFragmentProcessor* CircleInside2PtConicalEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()};
SkScalar radius1 = random->nextUScalar1() + 0.0001f; // make sure radius1 != 0
SkPoint center2;
@@ -947,13 +947,13 @@ GrEffect* CircleInside2PtConicalEffect::TestCreate(SkRandom* random,
tm));
SkPaint paint;
GrColor paintColor;
- GrEffect* effect;
- SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
- return effect;
+ GrFragmentProcessor* processor;
+ SkAssertResult(shader->asFragmentProcessor(context, paint, NULL, &paintColor, &processor));
+ return processor;
}
-GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor& processor)
: INHERITED(factory)
, fVSVaryingName(NULL)
, fFSVaryingName(NULL)
@@ -964,8 +964,8 @@ GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrBackendEf
, fCachedC(SK_ScalarMax) {}
void GLCircleInside2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey& key,
+ const GrFragmentProcessor&,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -1007,9 +1007,9 @@ void GLCircleInside2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
}
void GLCircleInside2PtConicalEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
- INHERITED::setData(pdman, effect);
- const CircleInside2PtConicalEffect& data = effect.cast<CircleInside2PtConicalEffect>();
+ const GrProcessor& processor) {
+ INHERITED::setData(pdman, processor);
+ const CircleInside2PtConicalEffect& data = processor.cast<CircleInside2PtConicalEffect>();
SkScalar centerX = data.centerX();
SkScalar centerY = data.centerY();
SkScalar A = data.A();
@@ -1030,9 +1030,9 @@ void GLCircleInside2PtConicalEffect::setData(const GrGLProgramDataManager& pdman
}
}
-void GLCircleInside2PtConicalEffect::GenKey(const GrEffect& effect,
- const GrGLCaps&, GrEffectKeyBuilder* b) {
- b->add32(GenBaseGradientKey(effect));
+void GLCircleInside2PtConicalEffect::GenKey(const GrProcessor& processor,
+ const GrGLCaps&, GrProcessorKeyBuilder* b) {
+ b->add32(GenBaseGradientKey(processor));
}
//////////////////////////////////////////////////////////////////////////////
@@ -1042,18 +1042,18 @@ class GLCircleOutside2PtConicalEffect;
class CircleOutside2PtConicalEffect : public GrGradientEffect {
public:
- static GrEffect* Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm,
- const CircleConicalInfo& info) {
+ static GrFragmentProcessor* Create(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm,
+ const CircleConicalInfo& info) {
return SkNEW_ARGS(CircleOutside2PtConicalEffect, (ctx, shader, matrix, tm, info));
}
virtual ~CircleOutside2PtConicalEffect() {}
static const char* Name() { return "Two-Point Conical Gradient Outside"; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
SkScalar centerX() const { return fInfo.fCenterEnd.fX; }
SkScalar centerY() const { return fInfo.fCenterEnd.fY; }
@@ -1063,10 +1063,10 @@ public:
SkScalar tLimit() const { return fTLimit; }
bool isFlipped() const { return fIsFlipped; }
- typedef GLCircleOutside2PtConicalEffect GLEffect;
+ typedef GLCircleOutside2PtConicalEffect GLProcessor;
private:
- virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE {
+ virtual bool onIsEqual(const GrProcessor& sBase) const SK_OVERRIDE {
const CircleOutside2PtConicalEffect& s = sBase.cast<CircleOutside2PtConicalEffect>();
return (INHERITED::onIsEqual(sBase) &&
this->fInfo.fCenterEnd == s.fInfo.fCenterEnd &&
@@ -1093,7 +1093,7 @@ private:
fIsFlipped = shader.isFlippedGrad();
}
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
const CircleConicalInfo fInfo;
SkScalar fTLimit;
@@ -1104,19 +1104,19 @@ private:
class GLCircleOutside2PtConicalEffect : public GrGLGradientEffect {
public:
- GLCircleOutside2PtConicalEffect(const GrBackendEffectFactory& factory, const GrEffect&);
+ GLCircleOutside2PtConicalEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual ~GLCircleOutside2PtConicalEffect() {}
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
- static void GenKey(const GrEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
+ static void GenKey(const GrProcessor&, const GrGLCaps& caps, GrProcessorKeyBuilder* b);
protected:
UniformHandle fCenterUni;
@@ -1144,19 +1144,19 @@ private:
};
-const GrBackendEffectFactory& CircleOutside2PtConicalEffect::getFactory() const {
- return GrTBackendEffectFactory<CircleOutside2PtConicalEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& CircleOutside2PtConicalEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<CircleOutside2PtConicalEffect>::getInstance();
}
-GR_DEFINE_EFFECT_TEST(CircleOutside2PtConicalEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleOutside2PtConicalEffect);
/*
* All Two point conical gradient test create functions may occasionally create edge case shaders
*/
-GrEffect* CircleOutside2PtConicalEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrFragmentProcessor* CircleOutside2PtConicalEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()};
SkScalar radius1 = random->nextUScalar1() + 0.0001f; // make sure radius1 != 0
SkPoint center2;
@@ -1183,13 +1183,13 @@ GrEffect* CircleOutside2PtConicalEffect::TestCreate(SkRandom* random,
tm));
SkPaint paint;
GrColor paintColor;
- GrEffect* effect;
- SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
- return effect;
+ GrFragmentProcessor* processor;
+ SkAssertResult(shader->asFragmentProcessor(context, paint, NULL, &paintColor, &processor));
+ return processor;
}
-GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor& processor)
: INHERITED(factory)
, fVSVaryingName(NULL)
, fFSVaryingName(NULL)
@@ -1199,13 +1199,13 @@ GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrBackend
, fCachedB(SK_ScalarMax)
, fCachedC(SK_ScalarMax)
, fCachedTLimit(SK_ScalarMax) {
- const CircleOutside2PtConicalEffect& data = effect.cast<CircleOutside2PtConicalEffect>();
+ const CircleOutside2PtConicalEffect& data = processor.cast<CircleOutside2PtConicalEffect>();
fIsFlipped = data.isFlipped();
}
void GLCircleOutside2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey& key,
+ const GrFragmentProcessor&,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -1263,9 +1263,9 @@ void GLCircleOutside2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
}
void GLCircleOutside2PtConicalEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
- INHERITED::setData(pdman, effect);
- const CircleOutside2PtConicalEffect& data = effect.cast<CircleOutside2PtConicalEffect>();
+ const GrProcessor& processor) {
+ INHERITED::setData(pdman, processor);
+ const CircleOutside2PtConicalEffect& data = processor.cast<CircleOutside2PtConicalEffect>();
SkASSERT(data.isFlipped() == fIsFlipped);
SkScalar centerX = data.centerX();
SkScalar centerY = data.centerY();
@@ -1290,19 +1290,19 @@ void GLCircleOutside2PtConicalEffect::setData(const GrGLProgramDataManager& pdma
}
}
-void GLCircleOutside2PtConicalEffect::GenKey(const GrEffect& effect,
- const GrGLCaps&, GrEffectKeyBuilder* b) {
+void GLCircleOutside2PtConicalEffect::GenKey(const GrProcessor& processor,
+ const GrGLCaps&, GrProcessorKeyBuilder* b) {
uint32_t* key = b->add32n(2);
- key[0] = GenBaseGradientKey(effect);
- key[1] = effect.cast<CircleOutside2PtConicalEffect>().isFlipped();
+ key[0] = GenBaseGradientKey(processor);
+ key[1] = processor.cast<CircleOutside2PtConicalEffect>().isFlipped();
}
//////////////////////////////////////////////////////////////////////////////
-GrEffect* Gr2PtConicalGradientEffect::Create(GrContext* ctx,
- const SkTwoPointConicalGradient& shader,
- SkShader::TileMode tm,
- const SkMatrix* localMatrix) {
+GrFragmentProcessor* Gr2PtConicalGradientEffect::Create(GrContext* ctx,
+ const SkTwoPointConicalGradient& shader,
+ SkShader::TileMode tm,
+ const SkMatrix* localMatrix) {
SkMatrix matrix;
if (!shader.getLocalMatrix().invert(&matrix)) {
return NULL;
diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.h b/src/effects/gradients/SkTwoPointConicalGradient_gpu.h
index 4471ffc89..54937c6ff 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.h
+++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.h
@@ -10,7 +10,7 @@
#include "SkGradientShaderPriv.h"
-class GrEffect;
+class GrProcessor;
class SkTwoPointConicalGradient;
namespace Gr2PtConicalGradientEffect {
@@ -18,8 +18,8 @@ namespace Gr2PtConicalGradientEffect {
* Creates an effect that produces a two point conical gradient based on the
* shader passed in.
*/
- GrEffect* Create(GrContext* ctx, const SkTwoPointConicalGradient& shader,
- SkShader::TileMode tm, const SkMatrix* localMatrix);
+ GrFragmentProcessor* Create(GrContext* ctx, const SkTwoPointConicalGradient& shader,
+ SkShader::TileMode tm, const SkMatrix* localMatrix);
};
#endif
diff --git a/src/effects/gradients/SkTwoPointRadialGradient.cpp b/src/effects/gradients/SkTwoPointRadialGradient.cpp
index fe56c73fa..3b4be2d33 100644
--- a/src/effects/gradients/SkTwoPointRadialGradient.cpp
+++ b/src/effects/gradients/SkTwoPointRadialGradient.cpp
@@ -397,7 +397,7 @@ void SkTwoPointRadialGradient::init() {
#if SK_SUPPORT_GPU
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "SkGr.h"
@@ -408,19 +408,19 @@ class GrGLRadial2Gradient : public GrGLGradientEffect {
public:
- GrGLRadial2Gradient(const GrBackendEffectFactory& factory, const GrEffect&);
+ GrGLRadial2Gradient(const GrBackendProcessorFactory& factory, const GrProcessor&);
virtual ~GrGLRadial2Gradient() { }
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
- static void GenKey(const GrEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
+ static void GenKey(const GrProcessor&, const GrGLCaps& caps, GrProcessorKeyBuilder* b);
protected:
@@ -450,18 +450,18 @@ private:
class GrRadial2Gradient : public GrGradientEffect {
public:
- static GrEffect* Create(GrContext* ctx,
- const SkTwoPointRadialGradient& shader,
- const SkMatrix& matrix,
- SkShader::TileMode tm) {
+ static GrFragmentProcessor* Create(GrContext* ctx,
+ const SkTwoPointRadialGradient& shader,
+ const SkMatrix& matrix,
+ SkShader::TileMode tm) {
return SkNEW_ARGS(GrRadial2Gradient, (ctx, shader, matrix, tm));
}
virtual ~GrRadial2Gradient() { }
static const char* Name() { return "Two-Point Radial Gradient"; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
- return GrTBackendEffectFactory<GrRadial2Gradient>::getInstance();
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
+ return GrTBackendFragmentProcessorFactory<GrRadial2Gradient>::getInstance();
}
// The radial gradient parameters can collapse to a linear (instead of quadratic) equation.
@@ -470,10 +470,10 @@ public:
SkScalar radius() const { return fRadius0; }
bool isPosRoot() const { return SkToBool(fPosRoot); }
- typedef GrGLRadial2Gradient GLEffect;
+ typedef GrGLRadial2Gradient GLProcessor;
private:
- virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE {
+ virtual bool onIsEqual(const GrProcessor& sBase) const SK_OVERRIDE {
const GrRadial2Gradient& s = sBase.cast<GrRadial2Gradient>();
return (INHERITED::onIsEqual(sBase) &&
this->fCenterX1 == s.fCenterX1 &&
@@ -502,7 +502,7 @@ private:
this->addCoordTransform(&fBTransform);
}
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
// @{
// Cache of values - these can change arbitrarily, EXCEPT
@@ -520,12 +520,12 @@ private:
/////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrRadial2Gradient);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRadial2Gradient);
-GrEffect* GrRadial2Gradient::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture**) {
+GrFragmentProcessor* GrRadial2Gradient::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture**) {
SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()};
SkScalar radius1 = random->nextUScalar1();
SkPoint center2;
@@ -546,16 +546,16 @@ GrEffect* GrRadial2Gradient::TestCreate(SkRandom* random,
colors, stops, colorCount,
tm));
SkPaint paint;
- GrEffect* effect;
+ GrFragmentProcessor* fp;
GrColor paintColor;
- SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effect));
- return effect;
+ SkAssertResult(shader->asFragmentProcessor(context, paint, NULL, &paintColor, &fp));
+ return fp;
}
/////////////////////////////////////////////////////////////////////
-GrGLRadial2Gradient::GrGLRadial2Gradient(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GrGLRadial2Gradient::GrGLRadial2Gradient(const GrBackendProcessorFactory& factory,
+ const GrProcessor& processor)
: INHERITED(factory)
, fVSVaryingName(NULL)
, fFSVaryingName(NULL)
@@ -563,13 +563,13 @@ GrGLRadial2Gradient::GrGLRadial2Gradient(const GrBackendEffectFactory& factory,
, fCachedRadius(-SK_ScalarMax)
, fCachedPosRoot(0) {
- const GrRadial2Gradient& data = effect.cast<GrRadial2Gradient>();
+ const GrRadial2Gradient& data = processor.cast<GrRadial2Gradient>();
fIsDegenerate = data.isDegenerate();
}
void GrGLRadial2Gradient::emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor&,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -642,9 +642,9 @@ void GrGLRadial2Gradient::emitCode(GrGLProgramBuilder* builder,
}
void GrGLRadial2Gradient::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
- INHERITED::setData(pdman, effect);
- const GrRadial2Gradient& data = effect.cast<GrRadial2Gradient>();
+ const GrProcessor& processor) {
+ INHERITED::setData(pdman, processor);
+ const GrRadial2Gradient& data = processor.cast<GrRadial2Gradient>();
SkASSERT(data.isDegenerate() == fIsDegenerate);
SkScalar centerX1 = data.center();
SkScalar radius0 = data.radius();
@@ -675,18 +675,18 @@ void GrGLRadial2Gradient::setData(const GrGLProgramDataManager& pdman,
}
}
-void GrGLRadial2Gradient::GenKey(const GrEffect& effect,
- const GrGLCaps&, GrEffectKeyBuilder* b) {
+void GrGLRadial2Gradient::GenKey(const GrProcessor& processor,
+ const GrGLCaps&, GrProcessorKeyBuilder* b) {
uint32_t* key = b->add32n(2);
- key[0] = GenBaseGradientKey(effect);
- key[1] = effect.cast<GrRadial2Gradient>().isDegenerate();
+ key[0] = GenBaseGradientKey(processor);
+ key[1] = processor.cast<GrRadial2Gradient>().isDegenerate();
}
/////////////////////////////////////////////////////////////////////
-bool SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* paintColor,
- GrEffect** effect) const {
+bool SkTwoPointRadialGradient::asFragmentProcessor(GrContext* context, const SkPaint& paint,
+ const SkMatrix* localMatrix, GrColor* paintColor,
+ GrFragmentProcessor** fp) const {
SkASSERT(context);
// invert the localM, translate to center1 (fPtsToUni), rotate so center2 is on x axis.
@@ -713,16 +713,15 @@ bool SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkPaint& pa
}
*paintColor = SkColor2GrColorJustAlpha(paint.getColor());
- *effect = GrRadial2Gradient::Create(context, *this, matrix, fTileMode);
+ *fp = GrRadial2Gradient::Create(context, *this, matrix, fTileMode);
return true;
}
#else
-bool SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkPaint& paint,
- const SkMatrix* localMatrix, GrColor* paintColor,
- GrEffect** effect) const {
+bool SkTwoPointRadialGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix*,
+ GrColor*, GrFragmentProcessor**) const {
SkDEBUGFAIL("Should not call in GPU-less build");
return false;
}
diff --git a/src/effects/gradients/SkTwoPointRadialGradient.h b/src/effects/gradients/SkTwoPointRadialGradient.h
index bfeecc589..da9c5fc02 100644
--- a/src/effects/gradients/SkTwoPointRadialGradient.h
+++ b/src/effects/gradients/SkTwoPointRadialGradient.h
@@ -14,15 +14,15 @@
class SkTwoPointRadialGradient : public SkGradientShaderBase {
public:
SkTwoPointRadialGradient(const SkPoint& start, SkScalar startRadius,
- const SkPoint& end, SkScalar endRadius,
- const Descriptor&);
+ const SkPoint& end, SkScalar endRadius,
+ const Descriptor&);
virtual BitmapType asABitmap(SkBitmap* bitmap,
SkMatrix* matrix,
TileMode* xy) const SK_OVERRIDE;
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual bool asNewEffect(GrContext* context, const SkPaint&, const SkMatrix*, GrColor*,
- GrEffect**) const SK_OVERRIDE;
+ virtual bool asFragmentProcessor(GrContext* context, const SkPaint&, const SkMatrix*, GrColor*,
+ GrFragmentProcessor**) const SK_OVERRIDE;
virtual size_t contextSize() const SK_OVERRIDE;
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp
index a132e7de3..dc74459e3 100644
--- a/src/gpu/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/GrAAConvexPathRenderer.cpp
@@ -11,19 +11,19 @@
#include "GrContext.h"
#include "GrDrawState.h"
#include "GrDrawTargetCaps.h"
-#include "GrEffect.h"
+#include "GrProcessor.h"
#include "GrPathUtils.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "SkString.h"
#include "SkStrokeRec.h"
#include "SkTraceEvent.h"
#include "gl/builders/GrGLFullProgramBuilder.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
#include "gl/GrGLGeometryProcessor.h"
-#include "effects/GrGeometryProcessor.h"
+#include "GrGeometryProcessor.h"
GrAAConvexPathRenderer::GrAAConvexPathRenderer() {
}
@@ -507,8 +507,8 @@ static void create_vertices(const SegmentArray& segments,
class QuadEdgeEffect : public GrGeometryProcessor {
public:
- static GrEffect* Create() {
- GR_CREATE_STATIC_EFFECT(gQuadEdgeEffect, QuadEdgeEffect, ());
+ static GrGeometryProcessor* Create() {
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gQuadEdgeEffect, QuadEdgeEffect, ());
gQuadEdgeEffect->ref();
return gQuadEdgeEffect;
}
@@ -524,18 +524,18 @@ public:
const GrShaderVar& inQuadEdge() const { return fInQuadEdge; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
- return GrTBackendEffectFactory<QuadEdgeEffect>::getInstance();
+ virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE {
+ return GrTBackendGeometryProcessorFactory<QuadEdgeEffect>::getInstance();
}
- class GLEffect : public GrGLGeometryProcessor {
+ class GLProcessor : public GrGLGeometryProcessor {
public:
- GLEffect(const GrBackendEffectFactory& factory, const GrEffect&)
+ GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED (factory) {}
virtual void emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
@@ -543,7 +543,7 @@ public:
const char *vsName, *fsName;
builder->addVarying(kVec4f_GrSLType, "QuadEdge", &vsName, &fsName);
- GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+ GrGLProcessorFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
@@ -569,14 +569,14 @@ public:
fsBuilder->codeAppendf("\t%s = %s;\n", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
- const GrShaderVar& inQuadEdge = effect.cast<QuadEdgeEffect>().inQuadEdge();
+ const GrShaderVar& inQuadEdge = geometryProcessor.cast<QuadEdgeEffect>().inQuadEdge();
GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
vsBuilder->codeAppendf("\t%s = %s;\n", vsName, inQuadEdge.c_str());
}
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {}
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE {}
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {}
private:
typedef GrGLGeometryProcessor INHERITED;
@@ -589,23 +589,23 @@ private:
GrShaderVar::kAttribute_TypeModifier))) {
}
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE {
return true;
}
const GrShaderVar& fInQuadEdge;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
-GR_DEFINE_EFFECT_TEST(QuadEdgeEffect);
+GR_DEFINE_GEOMETRY_PROCESSOR_TEST(QuadEdgeEffect);
-GrEffect* QuadEdgeEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
+GrGeometryProcessor* QuadEdgeEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
// Doesn't work without derivative instructions.
return caps.shaderDerivativeSupport() ? QuadEdgeEffect::Create() : NULL;
}
@@ -625,7 +625,7 @@ namespace {
// position + edge
extern const GrVertexAttrib gPathAttribs[] = {
{kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
- {kVec4f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding}
+ {kVec4f_GrVertexAttribType, sizeof(SkPoint), kGeometryProcessor_GrVertexAttribBinding}
};
};
@@ -681,8 +681,8 @@ bool GrAAConvexPathRenderer::onDrawPath(const SkPath& origPath,
drawState->setVertexAttribs<gPathAttribs>(SK_ARRAY_COUNT(gPathAttribs), sizeof(QuadVertex));
- GrEffect* quadEffect = QuadEdgeEffect::Create();
- drawState->setGeometryProcessor(quadEffect)->unref();
+ GrGeometryProcessor* quadProcessor = QuadEdgeEffect::Create();
+ drawState->setGeometryProcessor(quadProcessor)->unref();
GrDrawTarget::AutoReleaseGeometry arg(target, vCount, iCount);
if (!arg.succeeded()) {
diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp
index 2b4689e4d..7347f9c25 100644
--- a/src/gpu/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/GrAAHairLinePathRenderer.cpp
@@ -10,11 +10,11 @@
#include "GrContext.h"
#include "GrDrawState.h"
#include "GrDrawTargetCaps.h"
-#include "GrEffect.h"
+#include "GrProcessor.h"
#include "GrGpu.h"
#include "GrIndexBuffer.h"
#include "GrPathUtils.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "SkGeometry.h"
#include "SkStroke.h"
#include "SkTemplates.h"
@@ -708,7 +708,7 @@ namespace {
// position + edge
extern const GrVertexAttrib gHairlineBezierAttribs[] = {
{kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
- {kVec4f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding}
+ {kVec4f_GrVertexAttribType, sizeof(SkPoint), kGeometryProcessor_GrVertexAttribBinding}
};
// position + coverage
@@ -995,12 +995,12 @@ bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path,
kVertsPerQuad * quadCnt + kVertsPerQuad * conicCnt));
if (quadCnt > 0) {
- GrEffect* hairQuadEffect = GrQuadEffect::Create(kHairlineAA_GrEffectEdgeType,
- *target->caps());
- SkASSERT(hairQuadEffect);
+ GrGeometryProcessor* hairQuadProcessor =
+ GrQuadEffect::Create(kHairlineAA_GrProcessorEdgeType, *target->caps());
+ SkASSERT(hairQuadProcessor);
GrDrawState::AutoRestoreEffects are(drawState);
target->setIndexSourceToBuffer(fQuadsIndexBuffer);
- drawState->setGeometryProcessor(hairQuadEffect)->unref();
+ drawState->setGeometryProcessor(hairQuadProcessor)->unref();
int quads = 0;
while (quads < quadCnt) {
int n = SkTMin(quadCnt - quads, kNumQuadsInIdxBuffer);
@@ -1016,10 +1016,10 @@ bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path,
if (conicCnt > 0) {
GrDrawState::AutoRestoreEffects are(drawState);
- GrEffect* hairConicEffect = GrConicEffect::Create(kHairlineAA_GrEffectEdgeType,
- *target->caps());
- SkASSERT(hairConicEffect);
- drawState->setGeometryProcessor(hairConicEffect)->unref();
+ GrGeometryProcessor* hairConicProcessor = GrConicEffect::Create(
+ kHairlineAA_GrProcessorEdgeType, *target->caps());
+ SkASSERT(hairConicProcessor);
+ drawState->setGeometryProcessor(hairConicProcessor)->unref();
int conics = 0;
while (conics < conicCnt) {
int n = SkTMin(conicCnt - conics, kNumQuadsInIdxBuffer);
diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp
index 45247ffd3..572098249 100644
--- a/src/gpu/GrAARectRenderer.cpp
+++ b/src/gpu/GrAARectRenderer.cpp
@@ -8,11 +8,11 @@
#include "GrAARectRenderer.h"
#include "GrGpu.h"
#include "gl/builders/GrGLFullProgramBuilder.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/GrGLGeometryProcessor.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "SkColorPriv.h"
-#include "effects/GrGeometryProcessor.h"
+#include "GrGeometryProcessor.h"
///////////////////////////////////////////////////////////////////////////////
class GrGLAlignedRectEffect;
@@ -20,8 +20,8 @@ class GrGLAlignedRectEffect;
// Axis Aligned special case
class GrAlignedRectEffect : public GrGeometryProcessor {
public:
- static GrEffect* Create() {
- GR_CREATE_STATIC_EFFECT(gAlignedRectEffect, GrAlignedRectEffect, ());
+ static GrGeometryProcessor* Create() {
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gAlignedRectEffect, GrAlignedRectEffect, ());
gAlignedRectEffect->ref();
return gAlignedRectEffect;
}
@@ -37,18 +37,18 @@ public:
const GrShaderVar& inRect() const { return fInRect; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
- return GrTBackendEffectFactory<GrAlignedRectEffect>::getInstance();
+ virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE {
+ return GrTBackendGeometryProcessorFactory<GrAlignedRectEffect>::getInstance();
}
- class GLEffect : public GrGLGeometryProcessor {
+ class GLProcessor : public GrGLGeometryProcessor {
public:
- GLEffect(const GrBackendEffectFactory& factory, const GrEffect&)
+ GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED (factory) {}
virtual void emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
@@ -59,11 +59,11 @@ public:
const char *vsRectName, *fsRectName;
builder->addVarying(kVec4f_GrSLType, "Rect", &vsRectName, &fsRectName);
- const GrShaderVar& inRect = effect.cast<GrAlignedRectEffect>().inRect();
+ const GrShaderVar& inRect = geometryProcessor.cast<GrAlignedRectEffect>().inRect();
GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
vsBuilder->codeAppendf("\t%s = %s;\n", vsRectName, inRect.c_str());
- GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+ GrGLProcessorFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
// TODO: compute all these offsets, spans, and scales in the VS
fsBuilder->codeAppendf("\tfloat insetW = min(1.0, %s.z) - 0.5;\n", fsRectName);
fsBuilder->codeAppendf("\tfloat insetH = min(1.0, %s.w) - 0.5;\n", fsRectName);
@@ -92,9 +92,9 @@ public:
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("coverage")).c_str());
}
- static void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
+ static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {}
- virtual void setData(const GrGLProgramDataManager& pdman, const GrEffect&) SK_OVERRIDE {}
+ virtual void setData(const GrGLProgramDataManager& pdman, const GrProcessor&) SK_OVERRIDE {}
private:
typedef GrGLGeometryProcessor INHERITED;
@@ -110,20 +110,20 @@ private:
const GrShaderVar& fInRect;
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE { return true; }
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE { return true; }
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
typedef GrGeometryProcessor INHERITED;
};
-GR_DEFINE_EFFECT_TEST(GrAlignedRectEffect);
+GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrAlignedRectEffect);
-GrEffect* GrAlignedRectEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrGeometryProcessor* GrAlignedRectEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
return GrAlignedRectEffect::Create();
}
@@ -145,8 +145,8 @@ class GrGLRectEffect;
class GrRectEffect : public GrGeometryProcessor {
public:
- static GrEffect* Create() {
- GR_CREATE_STATIC_EFFECT(gRectEffect, GrRectEffect, ());
+ static GrGeometryProcessor* Create() {
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gRectEffect, GrRectEffect, ());
gRectEffect->ref();
return gRectEffect;
}
@@ -163,18 +163,18 @@ public:
const GrShaderVar& inRectEdge() const { return fInRectEdge; }
const GrShaderVar& inWidthHeight() const { return fInWidthHeight; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
- return GrTBackendEffectFactory<GrRectEffect>::getInstance();
+ virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE {
+ return GrTBackendGeometryProcessorFactory<GrRectEffect>::getInstance();
}
- class GLEffect : public GrGLGeometryProcessor {
+ class GLProcessor : public GrGLGeometryProcessor {
public:
- GLEffect(const GrBackendEffectFactory& factory, const GrEffect&)
+ GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED (factory) {}
virtual void emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
@@ -185,7 +185,7 @@ public:
builder->addVarying(kVec4f_GrSLType, "RectEdge",
&vsRectEdgeName, &fsRectEdgeName);
- const GrRectEffect& rectEffect = effect.cast<GrRectEffect>();
+ const GrRectEffect& rectEffect = geometryProcessor.cast<GrRectEffect>();
GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
vsBuilder->codeAppendf("%s = %s;", vsRectEdgeName, rectEffect.inRectEdge().c_str());
@@ -197,7 +197,7 @@ public:
vsWidthHeightName,
rectEffect.inWidthHeight().c_str());
- GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+ GrGLProcessorFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
// TODO: compute all these offsets, spans, and scales in the VS
fsBuilder->codeAppendf("\tfloat insetW = min(1.0, %s.x) - 0.5;\n", fsWidthHeightName);
fsBuilder->codeAppendf("\tfloat insetH = min(1.0, %s.y) - 0.5;\n", fsWidthHeightName);
@@ -233,9 +233,9 @@ public:
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("coverage")).c_str());
}
- static void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
+ static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {}
- virtual void setData(const GrGLProgramDataManager& pdman, const GrEffect&) SK_OVERRIDE {}
+ virtual void setData(const GrGLProgramDataManager& pdman, const GrProcessor&) SK_OVERRIDE {}
private:
typedef GrGLGeometryProcessor INHERITED;
@@ -255,23 +255,23 @@ private:
this->setWillReadFragmentPosition();
}
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE { return true; }
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE { return true; }
const GrShaderVar& fInRectEdge;
const GrShaderVar& fInWidthHeight;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
typedef GrGeometryProcessor INHERITED;
};
-GR_DEFINE_EFFECT_TEST(GrRectEffect);
+GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrRectEffect);
-GrEffect* GrRectEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrGeometryProcessor* GrRectEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
return GrRectEffect::Create();
}
@@ -611,8 +611,8 @@ struct RectVertex {
// Rotated
extern const GrVertexAttrib gAARectVertexAttribs[] = {
{ kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding },
- { kVec4f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding },
- { kVec2f_GrVertexAttribType, 3*sizeof(SkPoint), kEffect_GrVertexAttribBinding }
+ { kVec4f_GrVertexAttribType, sizeof(SkPoint), kGeometryProcessor_GrVertexAttribBinding },
+ { kVec2f_GrVertexAttribType, 3*sizeof(SkPoint), kGeometryProcessor_GrVertexAttribBinding }
};
// Axis Aligned
@@ -625,7 +625,7 @@ struct AARectVertex {
// Axis Aligned
extern const GrVertexAttrib gAAAARectVertexAttribs[] = {
{ kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding },
- { kVec4f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding },
+ { kVec4f_GrVertexAttribType, sizeof(SkPoint), kGeometryProcessor_GrVertexAttribBinding },
};
};
@@ -662,8 +662,8 @@ void GrAARectRenderer::shaderFillAARect(GrGpu* gpu,
RectVertex* verts = reinterpret_cast<RectVertex*>(geo.vertices());
- GrEffect* effect = GrRectEffect::Create();
- drawState->setGeometryProcessor(effect)->unref();
+ GrGeometryProcessor* gp = GrRectEffect::Create();
+ drawState->setGeometryProcessor(gp)->unref();
for (int i = 0; i < 4; ++i) {
verts[i].fCenter = center;
@@ -710,8 +710,8 @@ void GrAARectRenderer::shaderFillAlignedAARect(GrGpu* gpu,
AARectVertex* verts = reinterpret_cast<AARectVertex*>(geo.vertices());
- GrEffect* effect = GrAlignedRectEffect::Create();
- drawState->setGeometryProcessor(effect)->unref();
+ GrGeometryProcessor* gp = GrAlignedRectEffect::Create();
+ drawState->setGeometryProcessor(gp)->unref();
SkRect devRect;
combinedMatrix.mapRect(&devRect, rect);
diff --git a/src/gpu/GrBitmapTextContext.cpp b/src/gpu/GrBitmapTextContext.cpp
index 421051752..82784bf0e 100755
--- a/src/gpu/GrBitmapTextContext.cpp
+++ b/src/gpu/GrBitmapTextContext.cpp
@@ -34,7 +34,7 @@ namespace {
// position + texture coord
extern const GrVertexAttrib gTextVertexAttribs[] = {
{kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
- {kVec2f_GrVertexAttribType, sizeof(SkPoint) , kEffect_GrVertexAttribBinding}
+ {kVec2f_GrVertexAttribType, sizeof(SkPoint), kGeometryProcessor_GrVertexAttribBinding}
};
static const size_t kTextVASize = 2 * sizeof(SkPoint);
@@ -43,7 +43,7 @@ static const size_t kTextVASize = 2 * sizeof(SkPoint);
extern const GrVertexAttrib gTextVertexWithColorAttribs[] = {
{kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
{kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVertexAttribBinding},
- {kVec2f_GrVertexAttribType, sizeof(SkPoint) + sizeof(GrColor), kEffect_GrVertexAttribBinding}
+ {kVec2f_GrVertexAttribType, sizeof(SkPoint) + sizeof(GrColor), kGeometryProcessor_GrVertexAttribBinding}
};
static const size_t kTextVAColorSize = 2 * sizeof(SkPoint) + sizeof(GrColor);
@@ -98,12 +98,13 @@ void GrBitmapTextContext::flushGlyphs() {
uint32_t textureUniqueID = fCurrTexture->getUniqueID();
if (textureUniqueID != fEffectTextureUniqueID) {
- fCachedEffect.reset(GrCustomCoordsTextureEffect::Create(fCurrTexture, params));
+ fCachedGeometryProcessor.reset(GrCustomCoordsTextureEffect::Create(fCurrTexture,
+ params));
fEffectTextureUniqueID = textureUniqueID;
}
// This effect could be stored with one of the cache objects (atlas?)
- drawState->setGeometryProcessor(fCachedEffect.get());
+ drawState->setGeometryProcessor(fCachedGeometryProcessor.get());
SkASSERT(fStrike);
switch (fStrike->getMaskFormat()) {
// Color bitmap text
diff --git a/src/gpu/GrBitmapTextContext.h b/src/gpu/GrBitmapTextContext.h
index 6d4ea6d52..80abf681f 100644
--- a/src/gpu/GrBitmapTextContext.h
+++ b/src/gpu/GrBitmapTextContext.h
@@ -10,6 +10,7 @@
#include "GrTextContext.h"
+class GrGeometryProcessor;
class GrTextStrike;
/*
@@ -44,14 +45,14 @@ private:
kDefaultRequestedVerts = kDefaultRequestedGlyphs * 4,
};
- void* fVertices;
- int32_t fMaxVertices;
- GrTexture* fCurrTexture;
- SkAutoTUnref<GrEffect> fCachedEffect;
+ void* fVertices;
+ int32_t fMaxVertices;
+ GrTexture* fCurrTexture;
+ SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor;
// Used to check whether fCachedEffect is still valid.
- uint32_t fEffectTextureUniqueID;
- int fCurrVertex;
- SkRect fVertexBounds;
+ uint32_t fEffectTextureUniqueID;
+ int fCurrVertex;
+ SkRect fVertexBounds;
};
#endif
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 2cc764f27..3ecc92299 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -51,7 +51,7 @@ void setup_drawstate_aaclip(GrGpu* gpu,
SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height());
// This could be a long-lived effect that is cached with the alpha-mask.
- drawState->addCoverageEffect(
+ drawState->addCoverageProcessor(
GrTextureDomainEffect::Create(result,
mat,
GrTextureDomain::MakeTexelDomain(result, domainTexels),
@@ -154,44 +154,46 @@ bool GrClipMaskManager::installClipEffects(const ElementList& elements,
}
if (!skip) {
- GrEffectEdgeType edgeType;
+ GrPrimitiveEdgeType edgeType;
if (GR_AA_CLIP && iter.get()->isAA()) {
if (rt->isMultisampled()) {
// Coverage based AA clips don't place nicely with MSAA.
failed = true;
break;
}
- edgeType = invert ? kInverseFillAA_GrEffectEdgeType : kFillAA_GrEffectEdgeType;
+ edgeType =
+ invert ? kInverseFillAA_GrProcessorEdgeType : kFillAA_GrProcessorEdgeType;
} else {
- edgeType = invert ? kInverseFillBW_GrEffectEdgeType : kFillBW_GrEffectEdgeType;
+ edgeType =
+ invert ? kInverseFillBW_GrProcessorEdgeType : kFillBW_GrProcessorEdgeType;
}
- SkAutoTUnref<GrEffect> effect;
+ SkAutoTUnref<GrFragmentProcessor> fp;
switch (iter.get()->getType()) {
case SkClipStack::Element::kPath_Type:
- effect.reset(GrConvexPolyEffect::Create(edgeType, iter.get()->getPath(),
+ fp.reset(GrConvexPolyEffect::Create(edgeType, iter.get()->getPath(),
&clipToRTOffset));
break;
case SkClipStack::Element::kRRect_Type: {
SkRRect rrect = iter.get()->getRRect();
rrect.offset(clipToRTOffset.fX, clipToRTOffset.fY);
- effect.reset(GrRRectEffect::Create(edgeType, rrect));
+ fp.reset(GrRRectEffect::Create(edgeType, rrect));
break;
}
case SkClipStack::Element::kRect_Type: {
SkRect rect = iter.get()->getRect();
rect.offset(clipToRTOffset.fX, clipToRTOffset.fY);
- effect.reset(GrConvexPolyEffect::Create(edgeType, rect));
+ fp.reset(GrConvexPolyEffect::Create(edgeType, rect));
break;
}
default:
break;
}
- if (effect) {
+ if (fp) {
if (!setARE) {
are->set(fGpu->drawState());
setARE = true;
}
- fGpu->drawState()->addCoverageEffect(effect);
+ fGpu->drawState()->addCoverageProcessor(fp);
} else {
failed = true;
break;
@@ -397,8 +399,8 @@ bool GrClipMaskManager::drawElement(GrTexture* target,
SkDEBUGFAIL("Should never get here with an empty element.");
break;
case Element::kRect_Type:
- // TODO: Do rects directly to the accumulator using a aa-rect GrEffect that covers the
- // entire mask bounds and writes 0 outside the rect.
+ // TODO: Do rects directly to the accumulator using a aa-rect GrProcessor that covers
+ // the entire mask bounds and writes 0 outside the rect.
if (element->isAA()) {
getContext()->getAARectRenderer()->fillAARect(fGpu,
fGpu,
@@ -474,7 +476,7 @@ void GrClipMaskManager::mergeMask(GrTexture* dstMask,
SkMatrix sampleM;
sampleM.setIDiv(srcMask->width(), srcMask->height());
- drawState->addColorEffect(
+ drawState->addColorProcessor(
GrTextureDomainEffect::Create(srcMask,
sampleM,
GrTextureDomain::MakeTexelDomain(srcMask, srcBound),
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index f18499c73..630aaebf5 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -363,7 +363,7 @@ GrTexture* GrContext::createResizedTexture(const GrTextureDesc& desc,
// the original.
GrTextureParams params(SkShader::kClamp_TileMode, filter ? GrTextureParams::kBilerp_FilterMode :
GrTextureParams::kNone_FilterMode);
- drawState->addColorTextureEffect(clampedTexture, SkMatrix::I(), params);
+ drawState->addColorTextureProcessor(clampedTexture, SkMatrix::I(), params);
drawState->setVertexAttribs<gVertexAttribs>(SK_ARRAY_COUNT(gVertexAttribs),
2 * sizeof(SkPoint));
@@ -1485,22 +1485,20 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
textureMatrix.setTranslate(SK_Scalar1 *left, SK_Scalar1 *top);
textureMatrix.postIDiv(src->width(), src->height());
- SkAutoTUnref<const GrEffect> effect;
+ SkAutoTUnref<const GrFragmentProcessor> fp;
if (unpremul) {
- effect.reset(this->createPMToUPMEffect(src, swapRAndB, textureMatrix));
- if (effect) {
+ fp.reset(this->createPMToUPMEffect(src, swapRAndB, textureMatrix));
+ if (fp) {
unpremul = false; // we no longer need to do this on CPU after the read back.
}
}
// 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 (effect || flipY || swapRAndB) {
- if (!effect) {
- effect.reset(GrConfigConversionEffect::Create(
- src,
- swapRAndB,
- GrConfigConversionEffect::kNone_PMConversion,
- textureMatrix));
+ if (fp || flipY || swapRAndB) {
+ if (!fp) {
+ fp.reset(GrConfigConversionEffect::Create(
+ src, swapRAndB, GrConfigConversionEffect::kNone_PMConversion,
+ textureMatrix));
}
swapRAndB = false; // we will handle the swap in the draw.
@@ -1509,8 +1507,8 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
// can be invoked in this method
GrDrawTarget::AutoGeometryAndStatePush agasp(fGpu, GrDrawTarget::kReset_ASRInit);
GrDrawState* drawState = fGpu->drawState();
- SkASSERT(effect);
- drawState->addColorEffect(effect);
+ SkASSERT(fp);
+ drawState->addColorProcessor(fp);
drawState->setRenderTarget(texture->asRenderTarget());
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
@@ -1602,7 +1600,7 @@ void GrContext::copyTexture(GrTexture* src, GrRenderTarget* dst, const SkIPoint*
return;
}
sampleM.preTranslate(SkIntToScalar(srcRect.fLeft), SkIntToScalar(srcRect.fTop));
- drawState->addColorTextureEffect(src, sampleM);
+ drawState->addColorTextureProcessor(src, sampleM);
SkRect dstR = SkRect::MakeWH(SkIntToScalar(srcRect.width()), SkIntToScalar(srcRect.height()));
target->drawSimpleRect(dstR);
@@ -1668,7 +1666,7 @@ bool GrContext::writeRenderTargetPixels(GrRenderTarget* target,
return false;
}
- SkAutoTUnref<const GrEffect> effect;
+ SkAutoTUnref<const GrFragmentProcessor> fp;
SkMatrix textureMatrix;
textureMatrix.setIDiv(texture->width(), texture->height());
@@ -1679,9 +1677,9 @@ bool GrContext::writeRenderTargetPixels(GrRenderTarget* target,
if (!GrPixelConfigIs8888(srcConfig)) {
return false;
}
- effect.reset(this->createUPMToPMEffect(texture, swapRAndB, textureMatrix));
+ fp.reset(this->createUPMToPMEffect(texture, swapRAndB, textureMatrix));
// handle the unpremul step on the CPU if we couldn't create an effect to do it.
- if (NULL == effect) {
+ if (NULL == fp) {
SkSrcPixelInfo srcPI;
if (!GrPixelConfig2ColorType(srcConfig, &srcPI.fColorType)) {
return false;
@@ -1706,8 +1704,8 @@ bool GrContext::writeRenderTargetPixels(GrRenderTarget* target,
rowBytes = 4 * width;
}
}
- if (NULL == effect) {
- effect.reset(GrConfigConversionEffect::Create(texture,
+ if (NULL == fp) {
+ fp.reset(GrConfigConversionEffect::Create(texture,
swapRAndB,
GrConfigConversionEffect::kNone_PMConversion,
textureMatrix));
@@ -1733,8 +1731,8 @@ bool GrContext::writeRenderTargetPixels(GrRenderTarget* target,
matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
GrDrawTarget::AutoGeometryAndStatePush agasp(fGpu, GrDrawTarget::kReset_ASRInit, &matrix);
GrDrawState* drawState = fGpu->drawState();
- SkASSERT(effect);
- drawState->addColorEffect(effect);
+ SkASSERT(fp);
+ drawState->addColorProcessor(fp);
drawState->setRenderTarget(target);
@@ -1889,9 +1887,9 @@ void test_pm_conversions(GrContext* ctx, int* pmToUPMValue, int* upmToPMValue) {
}
}
-const GrEffect* GrContext::createPMToUPMEffect(GrTexture* texture,
- bool swapRAndB,
- const SkMatrix& matrix) {
+const GrFragmentProcessor* GrContext::createPMToUPMEffect(GrTexture* texture,
+ bool swapRAndB,
+ const SkMatrix& matrix) {
if (!fDidTestPMConversions) {
test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion);
fDidTestPMConversions = true;
@@ -1905,9 +1903,9 @@ const GrEffect* GrContext::createPMToUPMEffect(GrTexture* texture,
}
}
-const GrEffect* GrContext::createUPMToPMEffect(GrTexture* texture,
- bool swapRAndB,
- const SkMatrix& matrix) {
+const GrFragmentProcessor* GrContext::createUPMToPMEffect(GrTexture* texture,
+ bool swapRAndB,
+ const SkMatrix& matrix) {
if (!fDidTestPMConversions) {
test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion);
fDidTestPMConversions = true;
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index 3b5bd304d..9fd024af9 100755
--- a/src/gpu/GrDistanceFieldTextContext.cpp
+++ b/src/gpu/GrDistanceFieldTextContext.cpp
@@ -38,7 +38,7 @@ namespace {
// position + texture coord
extern const GrVertexAttrib gTextVertexAttribs[] = {
{kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
- {kVec2f_GrVertexAttribType, sizeof(SkPoint) , kEffect_GrVertexAttribBinding}
+ {kVec2f_GrVertexAttribType, sizeof(SkPoint) , kGeometryProcessor_GrVertexAttribBinding}
};
static const size_t kTextVASize = 2 * sizeof(SkPoint);
@@ -47,7 +47,7 @@ static const size_t kTextVASize = 2 * sizeof(SkPoint);
extern const GrVertexAttrib gTextVertexWithColorAttribs[] = {
{kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
{kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVertexAttribBinding},
- {kVec2f_GrVertexAttribType, sizeof(SkPoint) + sizeof(GrColor), kEffect_GrVertexAttribBinding}
+ {kVec2f_GrVertexAttribType, sizeof(SkPoint) + sizeof(GrColor), kGeometryProcessor_GrVertexAttribBinding}
};
static const size_t kTextVAColorSize = 2 * sizeof(SkPoint) + sizeof(GrColor);
@@ -141,25 +141,27 @@ void GrDistanceFieldTextContext::setupCoverageEffect(const SkColor& filteredColo
flags != fEffectFlags) {
if (fUseLCDText) {
GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredColor);
- fCachedEffect.reset(GrDistanceFieldLCDTextureEffect::Create(fCurrTexture,
- params,
- fGammaTexture,
- gammaParams,
- colorNoPreMul,
- flags));
+ fCachedGeometryProcessor.reset(
+ GrDistanceFieldLCDTextureEffect::Create(fCurrTexture,
+ params,
+ fGammaTexture,
+ gammaParams,
+ colorNoPreMul,
+ flags));
} else {
#ifdef SK_GAMMA_APPLY_TO_A8
U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDeviceProperties.getGamma(),
filteredColor);
- fCachedEffect.reset(GrDistanceFieldTextureEffect::Create(fCurrTexture,
- params,
- fGammaTexture,
- gammaParams,
- lum/255.f,
- flags));
+ fCachedGeometryProcessor.reset(
+ GrDistanceFieldTextureEffect::Create(fCurrTexture,
+ params,
+ fGammaTexture,
+ gammaParams,
+ lum/255.f,
+ flags));
#else
- fCachedEffect.reset(GrDistanceFieldTextureEffect::Create(fCurrTexture,
- params, flags));
+ fCachedGeometryProcessor.reset(GrDistanceFieldTextureEffect::Create(fCurrTexture,
+ params, flags));
#endif
}
fEffectTextureUniqueID = textureUniqueID;
@@ -194,7 +196,7 @@ void GrDistanceFieldTextContext::flushGlyphs() {
this->setupCoverageEffect(filteredColor);
// Effects could be stored with one of the cache objects (atlas?)
- drawState->setGeometryProcessor(fCachedEffect.get());
+ drawState->setGeometryProcessor(fCachedGeometryProcessor.get());
// Set draw state
if (fUseLCDText) {
diff --git a/src/gpu/GrDistanceFieldTextContext.h b/src/gpu/GrDistanceFieldTextContext.h
index 75a13b385..85d9250e4 100644
--- a/src/gpu/GrDistanceFieldTextContext.h
+++ b/src/gpu/GrDistanceFieldTextContext.h
@@ -10,6 +10,7 @@
#include "GrTextContext.h"
+class GrGeometryProcessor;
class GrTextStrike;
/*
@@ -30,11 +31,11 @@ public:
virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;
private:
- GrTextStrike* fStrike;
- SkScalar fTextRatio;
- bool fUseLCDText;
- bool fEnableDFRendering;
- SkAutoTUnref<GrEffect> fCachedEffect;
+ GrTextStrike* fStrike;
+ SkScalar fTextRatio;
+ bool fUseLCDText;
+ bool fEnableDFRendering;
+ SkAutoTUnref<GrGeometryProcessor> fCachedGeometryProcessor;
// Used to check whether fCachedEffect is still valid.
uint32_t fEffectTextureUniqueID;
SkColor fEffectColor;
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index 872696581..168cf0b9c 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -108,7 +108,7 @@ GrDrawState& GrDrawState::operator=(const GrDrawState& that) {
fCoverage = that.fCoverage;
fDrawFace = that.fDrawFace;
if (that.hasGeometryProcessor()) {
- fGeometryProcessor.reset(SkNEW_ARGS(GrEffectStage, (*that.fGeometryProcessor.get())));
+ fGeometryProcessor.reset(SkNEW_ARGS(GrGeometryStage, (*that.fGeometryProcessor.get())));
} else {
fGeometryProcessor.reset(NULL);
}
@@ -329,7 +329,7 @@ void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) {
if (SK_InvalidUniqueID == fOriginalGPID) {
fDrawState->fGeometryProcessor.reset(NULL);
} else {
- SkASSERT(fDrawState->getGeometryProcessor()->getEffect()->getUniqueID() ==
+ SkASSERT(fDrawState->getGeometryProcessor()->getProcessor()->getUniqueID() ==
fOriginalGPID);
fOriginalGPID = SK_InvalidUniqueID;
}
@@ -350,7 +350,7 @@ void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) {
if (NULL != ds) {
SkASSERT(SK_InvalidUniqueID == fOriginalGPID);
if (NULL != ds->getGeometryProcessor()) {
- fOriginalGPID = ds->getGeometryProcessor()->getEffect()->getUniqueID();
+ fOriginalGPID = ds->getGeometryProcessor()->getProcessor()->getUniqueID();
}
fColorEffectCnt = ds->numColorStages();
fCoverageEffectCnt = ds->numCoverageStages();
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 5e4ed9b4c..19ea4df8c 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -52,7 +52,7 @@ public:
virtual ~GrDrawState();
/**
- * Resets to the default state. GrEffects will be removed from all stages.
+ * Resets to the default state. GrProcessors will be removed from all stages.
*/
void reset() { this->onReset(NULL); }
@@ -75,7 +75,7 @@ public:
* the type of the attribute, its offset, and semantic binding (see GrVertexAttrib in
* GrTypesPriv.h).
*
- * The mapping of attributes with kEffect bindings to GrEffect inputs is specified when
+ * The mapping of attributes with kEffect bindings to GrProcessor inputs is specified when
* setEffect is called.
*/
@@ -179,19 +179,18 @@ public:
* but is never put in the color processing pipeline.
*/
- const GrEffect* setGeometryProcessor(const GrEffect* effect) {
- SkASSERT(effect);
- SkASSERT(effect->requiresVertexShader());
+ const GrGeometryProcessor* setGeometryProcessor(const GrGeometryProcessor* geometryProcessor) {
+ SkASSERT(geometryProcessor);
SkASSERT(!this->hasGeometryProcessor());
- fGeometryProcessor.reset(new GrEffectStage(effect));
+ fGeometryProcessor.reset(new GrGeometryStage(geometryProcessor));
this->invalidateOptState();
- return effect;
+ return geometryProcessor;
}
///////////////////////////////////////////////////////////////////////////
/// @name Effect Stages
- /// Each stage hosts a GrEffect. The effect produces an output color or coverage in the fragment
- /// shader. Its inputs are the output from the previous stage as well as some variables
+ /// Each stage hosts a GrProcessor. The effect produces an output color or coverage in the
+ /// fragment shader. Its inputs are the output from the previous stage as well as some variables
/// available to it in the fragment and vertex shader (e.g. the vertex position, the dst color,
/// the fragment position, local coordinates).
///
@@ -208,18 +207,16 @@ public:
/// the color / coverage distinction.
////
- const GrEffect* addColorEffect(const GrEffect* effect) {
+ const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* effect) {
SkASSERT(effect);
- SkASSERT(!effect->requiresVertexShader());
- SkNEW_APPEND_TO_TARRAY(&fColorStages, GrEffectStage, (effect));
+ SkNEW_APPEND_TO_TARRAY(&fColorStages, GrFragmentStage, (effect));
this->invalidateOptState();
return effect;
}
- const GrEffect* addCoverageEffect(const GrEffect* effect) {
+ const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* effect) {
SkASSERT(effect);
- SkASSERT(!effect->requiresVertexShader());
- SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrEffectStage, (effect));
+ SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrFragmentStage, (effect));
this->invalidateOptState();
return effect;
}
@@ -227,24 +224,24 @@ public:
/**
* Creates a GrSimpleTextureEffect that uses local coords as texture coordinates.
*/
- void addColorTextureEffect(GrTexture* texture, const SkMatrix& matrix) {
- this->addColorEffect(GrSimpleTextureEffect::Create(texture, matrix))->unref();
- }
-
- void addCoverageTextureEffect(GrTexture* texture, const SkMatrix& matrix) {
- this->addCoverageEffect(GrSimpleTextureEffect::Create(texture, matrix))->unref();
+ void addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
+ this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref();
}
- void addColorTextureEffect(GrTexture* texture,
- const SkMatrix& matrix,
- const GrTextureParams& params) {
- this->addColorEffect(GrSimpleTextureEffect::Create(texture, matrix, params))->unref();
+ void addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
+ this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref();
}
- void addCoverageTextureEffect(GrTexture* texture,
+ void addColorTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addCoverageEffect(GrSimpleTextureEffect::Create(texture, matrix, params))->unref();
+ this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix, params))->unref();
+ }
+
+ void addCoverageTextureProcessor(GrTexture* texture,
+ const SkMatrix& matrix,
+ const GrTextureParams& params) {
+ this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix, params))->unref();
}
/**
@@ -387,11 +384,11 @@ public:
private:
void doEffectCoordChanges(const SkMatrix& coordChangeMatrix);
- GrDrawState* fDrawState;
- SkMatrix fViewMatrix;
- int fNumColorStages;
- bool fHasGeometryProcessor;
- SkAutoSTArray<8, GrEffectStage::SavedCoordChange> fSavedCoordChanges;
+ GrDrawState* fDrawState;
+ SkMatrix fViewMatrix;
+ int fNumColorStages;
+ bool fHasGeometryProcessor;
+ SkAutoSTArray<8, GrProcessorStage::SavedCoordChange> fSavedCoordChanges;
};
/// @}
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index e942d7cf3..eb8991519 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -390,16 +390,16 @@ bool GrDrawTarget::checkDraw(GrPrimitiveType type, int startVertex,
SkASSERT(drawState.getRenderTarget());
if (drawState.hasGeometryProcessor()) {
- const GrEffect* effect = drawState.getGeometryProcessor()->getEffect();
- int numTextures = effect->numTextures();
+ const GrGeometryProcessor* gp = drawState.getGeometryProcessor()->getGeometryProcessor();
+ int numTextures = gp->numTextures();
for (int t = 0; t < numTextures; ++t) {
- GrTexture* texture = effect->texture(t);
+ GrTexture* texture = gp->texture(t);
SkASSERT(texture->asRenderTarget() != drawState.getRenderTarget());
}
}
for (int s = 0; s < drawState.numColorStages(); ++s) {
- const GrEffect* effect = drawState.getColorStage(s).getEffect();
+ const GrProcessor* effect = drawState.getColorStage(s).getProcessor();
int numTextures = effect->numTextures();
for (int t = 0; t < numTextures; ++t) {
GrTexture* texture = effect->texture(t);
@@ -407,7 +407,7 @@ bool GrDrawTarget::checkDraw(GrPrimitiveType type, int startVertex,
}
}
for (int s = 0; s < drawState.numCoverageStages(); ++s) {
- const GrEffect* effect = drawState.getCoverageStage(s).getEffect();
+ const GrProcessor* effect = drawState.getCoverageStage(s).getProcessor();
int numTextures = effect->numTextures();
for (int t = 0; t < numTextures; ++t) {
GrTexture* texture = effect->texture(t);
@@ -984,7 +984,7 @@ bool GrDrawTarget::onCopySurface(GrSurface* dst,
matrix.setTranslate(SkIntToScalar(srcRect.fLeft - dstPoint.fX),
SkIntToScalar(srcRect.fTop - dstPoint.fY));
matrix.postIDiv(tex->width(), tex->height());
- this->drawState()->addColorTextureEffect(tex, matrix);
+ this->drawState()->addColorTextureProcessor(tex, matrix);
SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX,
dstPoint.fY,
srcRect.width(),
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp
index ac3031145..70209e175 100644
--- a/src/gpu/GrOptDrawState.cpp
+++ b/src/gpu/GrOptDrawState.cpp
@@ -39,7 +39,7 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
fInputCoverageIsUsed = true;
if (drawState.hasGeometryProcessor()) {
- fGeometryProcessor.reset(SkNEW_ARGS(GrEffectStage, (*drawState.getGeometryProcessor())));
+ fGeometryProcessor.reset(SkNEW_ARGS(GrGeometryStage, (*drawState.getGeometryProcessor())));
} else {
fGeometryProcessor.reset(NULL);
}
@@ -184,12 +184,12 @@ void GrOptDrawState::copyEffectiveColorStages(const GrDrawState& ds) {
}
for (int i = 0; i < ds.numColorStages(); ++i) {
- const GrEffect* effect = ds.getColorStage(i).getEffect();
- if (!effect->willUseInputColor()) {
+ const GrFragmentProcessor* fp = ds.getColorStage(i).getFragmentProcessor();
+ if (!fp->willUseInputColor()) {
firstColorStage = i;
fInputColorIsUsed = false;
}
- effect->getConstantColorComponents(&color, &validComponentFlags);
+ fp->getConstantColorComponents(&color, &validComponentFlags);
if (kRGBA_GrColorComponentFlags == validComponentFlags) {
firstColorStage = i + 1;
fColor = color;
@@ -216,8 +216,8 @@ void GrOptDrawState::copyEffectiveCoverageStages(const GrDrawState& ds) {
// input coverage in an effect
#ifdef OptCoverageStages
for (int i = 0; i < ds.numCoverageStages(); ++i) {
- const GrEffect* effect = ds.getCoverageStage(i).getEffect();
- if (!effect->willUseInputColor()) {
+ const GrProcessor* processor = ds.getCoverageStage(i).getProcessor();
+ if (!processor->willUseInputColor()) {
firstCoverageStage = i;
fInputCoverageIsUsed = false;
}
@@ -231,14 +231,15 @@ void GrOptDrawState::copyEffectiveCoverageStages(const GrDrawState& ds) {
}
}
-static void get_stage_stats(const GrEffectStage& stage, bool* readsDst, bool* readsFragPosition) {
- if (stage.getEffect()->willReadDstColor()) {
+static void get_stage_stats(const GrFragmentStage& stage, bool* readsDst, bool* readsFragPosition) {
+ if (stage.getFragmentProcessor()->willReadDstColor()) {
*readsDst = true;
}
- if (stage.getEffect()->willReadFragmentPosition()) {
+ if (stage.getFragmentProcessor()->willReadFragmentPosition()) {
*readsFragPosition = true;
}
}
+
void GrOptDrawState::getStageStats() {
// We will need a local coord attrib if there is one currently set on the optState and we are
// actually generating some effect code
@@ -252,16 +253,16 @@ void GrOptDrawState::getStageStats() {
fReadsFragPosition = false;
for (int s = 0; s < this->numColorStages(); ++s) {
- const GrEffectStage& stage = this->getColorStage(s);
+ const GrFragmentStage& stage = this->getColorStage(s);
get_stage_stats(stage, &fReadsDst, &fReadsFragPosition);
}
for (int s = 0; s < this->numCoverageStages(); ++s) {
- const GrEffectStage& stage = this->getCoverageStage(s);
+ const GrFragmentStage& stage = this->getCoverageStage(s);
get_stage_stats(stage, &fReadsDst, &fReadsFragPosition);
}
if (this->hasGeometryProcessor()) {
- const GrEffectStage& stage = *this->getGeometryProcessor();
- get_stage_stats(stage, &fReadsDst, &fReadsFragPosition);
+ const GrGeometryStage& stage = *this->getGeometryProcessor();
+ fReadsFragPosition = fReadsFragPosition || stage.getProcessor()->willReadFragmentPosition();
SkASSERT(fRequiresVertexShader);
}
}
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index ae992ec4f..4ae0ebc7e 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -8,11 +8,11 @@
#include "GrOvalRenderer.h"
#include "gl/builders/GrGLFullProgramBuilder.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
#include "gl/GrGLGeometryProcessor.h"
-#include "GrEffect.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrProcessor.h"
+#include "GrTBackendProcessorFactory.h"
#include "GrDrawState.h"
#include "GrDrawTarget.h"
@@ -22,7 +22,7 @@
#include "SkStrokeRec.h"
#include "SkTLazy.h"
-#include "effects/GrGeometryProcessor.h"
+#include "GrGeometryProcessor.h"
#include "effects/GrRRectEffect.h"
namespace {
@@ -62,9 +62,9 @@ inline bool circle_stays_circle(const SkMatrix& m) {
class CircleEdgeEffect : public GrGeometryProcessor {
public:
- static GrEffect* Create(bool stroke) {
- GR_CREATE_STATIC_EFFECT(gCircleStrokeEdge, CircleEdgeEffect, (true));
- GR_CREATE_STATIC_EFFECT(gCircleFillEdge, CircleEdgeEffect, (false));
+ static GrGeometryProcessor* Create(bool stroke) {
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gCircleStrokeEdge, CircleEdgeEffect, (true));
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gCircleFillEdge, CircleEdgeEffect, (false));
if (stroke) {
gCircleStrokeEdge->ref();
@@ -82,8 +82,8 @@ public:
const GrShaderVar& inCircleEdge() const { return fInCircleEdge; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
- return GrTBackendEffectFactory<CircleEdgeEffect>::getInstance();
+ virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE {
+ return GrTBackendGeometryProcessorFactory<CircleEdgeEffect>::getInstance();
}
virtual ~CircleEdgeEffect() {}
@@ -92,26 +92,26 @@ public:
inline bool isStroked() const { return fStroke; }
- class GLEffect : public GrGLGeometryProcessor {
+ class GLProcessor : public GrGLGeometryProcessor {
public:
- GLEffect(const GrBackendEffectFactory& factory, const GrEffect&)
+ GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED (factory) {}
virtual void emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) SK_OVERRIDE {
- const CircleEdgeEffect& circleEffect = effect.cast<CircleEdgeEffect>();
+ const CircleEdgeEffect& circleEffect = geometryProcessor.cast<CircleEdgeEffect>();
const char *vsName, *fsName;
builder->addVarying(kVec4f_GrSLType, "CircleEdge", &vsName, &fsName);
GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();;
vsBuilder->codeAppendf("\t%s = %s;\n", vsName, circleEffect.inCircleEdge().c_str());
- GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+ GrGLProcessorFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
fsBuilder->codeAppendf("\tfloat d = length(%s.xy);\n", fsName);
fsBuilder->codeAppendf("\tfloat edgeAlpha = clamp(%s.z - d, 0.0, 1.0);\n", fsName);
if (circleEffect.isStroked()) {
@@ -123,13 +123,13 @@ public:
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
}
- static void GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
- const CircleEdgeEffect& circleEffect = effect.cast<CircleEdgeEffect>();
+ static void GenKey(const GrProcessor& processor, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
+ const CircleEdgeEffect& circleEffect = processor.cast<CircleEdgeEffect>();
b->add32(circleEffect.isStroked());
}
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE {}
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {}
private:
typedef GrGLGeometryProcessor INHERITED;
@@ -145,7 +145,7 @@ private:
fStroke = stroke;
}
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE {
const CircleEdgeEffect& cee = other.cast<CircleEdgeEffect>();
return cee.fStroke == fStroke;
}
@@ -153,17 +153,17 @@ private:
const GrShaderVar& fInCircleEdge;
bool fStroke;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
typedef GrGeometryProcessor INHERITED;
};
-GR_DEFINE_EFFECT_TEST(CircleEdgeEffect);
+GR_DEFINE_GEOMETRY_PROCESSOR_TEST(CircleEdgeEffect);
-GrEffect* CircleEdgeEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrGeometryProcessor* CircleEdgeEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
return CircleEdgeEffect::Create(random->nextBool());
}
@@ -179,9 +179,9 @@ GrEffect* CircleEdgeEffect::TestCreate(SkRandom* random,
class EllipseEdgeEffect : public GrGeometryProcessor {
public:
- static GrEffect* Create(bool stroke) {
- GR_CREATE_STATIC_EFFECT(gEllipseStrokeEdge, EllipseEdgeEffect, (true));
- GR_CREATE_STATIC_EFFECT(gEllipseFillEdge, EllipseEdgeEffect, (false));
+ static GrGeometryProcessor* Create(bool stroke) {
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gEllipseStrokeEdge, EllipseEdgeEffect, (true));
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gEllipseFillEdge, EllipseEdgeEffect, (false));
if (stroke) {
gEllipseStrokeEdge->ref();
@@ -197,8 +197,8 @@ public:
*validFlags = 0;
}
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
- return GrTBackendEffectFactory<EllipseEdgeEffect>::getInstance();
+ virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE {
+ return GrTBackendGeometryProcessorFactory<EllipseEdgeEffect>::getInstance();
}
virtual ~EllipseEdgeEffect() {}
@@ -210,19 +210,19 @@ public:
inline bool isStroked() const { return fStroke; }
- class GLEffect : public GrGLGeometryProcessor {
+ class GLProcessor : public GrGLGeometryProcessor {
public:
- GLEffect(const GrBackendEffectFactory& factory, const GrEffect&)
+ GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED (factory) {}
virtual void emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) SK_OVERRIDE {
- const EllipseEdgeEffect& ellipseEffect = effect.cast<EllipseEdgeEffect>();
+ const EllipseEdgeEffect& ellipseEffect = geometryProcessor.cast<EllipseEdgeEffect>();
const char *vsOffsetName, *fsOffsetName;
const char *vsRadiiName, *fsRadiiName;
@@ -237,7 +237,7 @@ public:
vsBuilder->codeAppendf("%s = %s;", vsRadiiName, ellipseEffect.inEllipseRadii().c_str());
// for outer curve
- GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+ GrGLProcessorFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
fsBuilder->codeAppendf("\tvec2 scaledOffset = %s*%s.xy;\n", fsOffsetName, fsRadiiName);
fsBuilder->codeAppend("\tfloat test = dot(scaledOffset, scaledOffset) - 1.0;\n");
fsBuilder->codeAppendf("\tvec2 grad = 2.0*scaledOffset*%s.xy;\n", fsRadiiName);
@@ -260,13 +260,13 @@ public:
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
}
- static void GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
- const EllipseEdgeEffect& ellipseEffect = effect.cast<EllipseEdgeEffect>();
+ static void GenKey(const GrProcessor& processor, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
+ const EllipseEdgeEffect& ellipseEffect = processor.cast<EllipseEdgeEffect>();
b->add32(ellipseEffect.isStroked());
}
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE {
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {
}
private:
@@ -286,7 +286,7 @@ private:
fStroke = stroke;
}
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE {
const EllipseEdgeEffect& eee = other.cast<EllipseEdgeEffect>();
return eee.fStroke == fStroke;
}
@@ -295,17 +295,17 @@ private:
const GrShaderVar& fInEllipseRadii;
bool fStroke;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
typedef GrGeometryProcessor INHERITED;
};
-GR_DEFINE_EFFECT_TEST(EllipseEdgeEffect);
+GR_DEFINE_GEOMETRY_PROCESSOR_TEST(EllipseEdgeEffect);
-GrEffect* EllipseEdgeEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrGeometryProcessor* EllipseEdgeEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
return EllipseEdgeEffect::Create(random->nextBool());
}
@@ -324,10 +324,10 @@ class DIEllipseEdgeEffect : public GrGeometryProcessor {
public:
enum Mode { kStroke = 0, kHairline, kFill };
- static GrEffect* Create(Mode mode) {
- GR_CREATE_STATIC_EFFECT(gEllipseStrokeEdge, DIEllipseEdgeEffect, (kStroke));
- GR_CREATE_STATIC_EFFECT(gEllipseHairlineEdge, DIEllipseEdgeEffect, (kHairline));
- GR_CREATE_STATIC_EFFECT(gEllipseFillEdge, DIEllipseEdgeEffect, (kFill));
+ static GrGeometryProcessor* Create(Mode mode) {
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gEllipseStrokeEdge, DIEllipseEdgeEffect, (kStroke));
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gEllipseHairlineEdge, DIEllipseEdgeEffect, (kHairline));
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gEllipseFillEdge, DIEllipseEdgeEffect, (kFill));
if (kStroke == mode) {
gEllipseStrokeEdge->ref();
@@ -346,8 +346,8 @@ public:
*validFlags = 0;
}
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
- return GrTBackendEffectFactory<DIEllipseEdgeEffect>::getInstance();
+ virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE {
+ return GrTBackendGeometryProcessorFactory<DIEllipseEdgeEffect>::getInstance();
}
virtual ~DIEllipseEdgeEffect() {}
@@ -359,19 +359,20 @@ public:
inline Mode getMode() const { return fMode; }
- class GLEffect : public GrGLGeometryProcessor {
+ class GLProcessor : public GrGLGeometryProcessor {
public:
- GLEffect(const GrBackendEffectFactory& factory, const GrEffect&)
+ GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED (factory) {}
virtual void emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) SK_OVERRIDE {
- const DIEllipseEdgeEffect& ellipseEffect = effect.cast<DIEllipseEdgeEffect>();
+ const DIEllipseEdgeEffect& ellipseEffect =
+ geometryProcessor.cast<DIEllipseEdgeEffect>();
const char *vsOffsetName0, *fsOffsetName0;
builder->addVarying(kVec2f_GrSLType, "EllipseOffsets0",
@@ -386,7 +387,7 @@ public:
vsBuilder->codeAppendf("\t%s = %s;\n", vsOffsetName1,
ellipseEffect.inEllipseOffsets1().c_str());
- GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+ GrGLProcessorFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
// for outer curve
@@ -427,14 +428,14 @@ public:
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
}
- static void GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
- const DIEllipseEdgeEffect& ellipseEffect = effect.cast<DIEllipseEdgeEffect>();
+ static void GenKey(const GrProcessor& processor, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
+ const DIEllipseEdgeEffect& ellipseEffect = processor.cast<DIEllipseEdgeEffect>();
b->add32(ellipseEffect.getMode());
}
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE {
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {
}
private:
@@ -454,7 +455,7 @@ private:
fMode = mode;
}
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE {
const DIEllipseEdgeEffect& eee = other.cast<DIEllipseEdgeEffect>();
return eee.fMode == fMode;
}
@@ -463,17 +464,17 @@ private:
const GrShaderVar& fInEllipseOffsets1;
Mode fMode;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
typedef GrGeometryProcessor INHERITED;
};
-GR_DEFINE_EFFECT_TEST(DIEllipseEdgeEffect);
+GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DIEllipseEdgeEffect);
-GrEffect* DIEllipseEdgeEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrGeometryProcessor* DIEllipseEdgeEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
return DIEllipseEdgeEffect::Create((Mode)(random->nextRangeU(0,2)));
}
@@ -518,7 +519,7 @@ bool GrOvalRenderer::drawOval(GrDrawTarget* target, const GrContext* context, bo
// position + edge
extern const GrVertexAttrib gCircleVertexAttribs[] = {
{kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
- {kVec4f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding}
+ {kVec4f_GrVertexAttribType, sizeof(SkPoint), kGeometryProcessor_GrVertexAttribBinding}
};
void GrOvalRenderer::drawCircle(GrDrawTarget* target,
@@ -571,8 +572,8 @@ void GrOvalRenderer::drawCircle(GrDrawTarget* target,
}
}
- GrEffect* effect = CircleEdgeEffect::Create(isStrokeOnly && innerRadius > 0);
- drawState->setGeometryProcessor(effect)->unref();
+ GrGeometryProcessor* gp = CircleEdgeEffect::Create(isStrokeOnly && innerRadius > 0);
+ drawState->setGeometryProcessor(gp)->unref();
// The radii are outset for two reasons. First, it allows the shader to simply perform
// clamp(distance-to-center - radius, 0, 1). Second, the outer radius is used to compute the
@@ -616,15 +617,15 @@ void GrOvalRenderer::drawCircle(GrDrawTarget* target,
// position + offset + 1/radii
extern const GrVertexAttrib gEllipseVertexAttribs[] = {
{kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
- {kVec2f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding},
- {kVec4f_GrVertexAttribType, 2*sizeof(SkPoint), kEffect_GrVertexAttribBinding}
+ {kVec2f_GrVertexAttribType, sizeof(SkPoint), kGeometryProcessor_GrVertexAttribBinding},
+ {kVec4f_GrVertexAttribType, 2*sizeof(SkPoint), kGeometryProcessor_GrVertexAttribBinding}
};
// position + offsets
extern const GrVertexAttrib gDIEllipseVertexAttribs[] = {
{kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
- {kVec2f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding},
- {kVec2f_GrVertexAttribType, 2*sizeof(SkPoint), kEffect_GrVertexAttribBinding},
+ {kVec2f_GrVertexAttribType, sizeof(SkPoint), kGeometryProcessor_GrVertexAttribBinding},
+ {kVec2f_GrVertexAttribType, 2*sizeof(SkPoint), kGeometryProcessor_GrVertexAttribBinding},
};
bool GrOvalRenderer::drawEllipse(GrDrawTarget* target,
@@ -710,10 +711,10 @@ bool GrOvalRenderer::drawEllipse(GrDrawTarget* target,
EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices());
- GrEffect* effect = EllipseEdgeEffect::Create(isStrokeOnly &&
- innerXRadius > 0 && innerYRadius > 0);
+ GrGeometryProcessor* gp = EllipseEdgeEffect::Create(isStrokeOnly &&
+ innerXRadius > 0 && innerYRadius > 0);
- drawState->setGeometryProcessor(effect)->unref();
+ drawState->setGeometryProcessor(gp)->unref();
// Compute the reciprocals of the radii here to save time in the shader
SkScalar xRadRecip = SkScalarInvert(xRadius);
@@ -827,9 +828,9 @@ bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target,
DIEllipseVertex* verts = reinterpret_cast<DIEllipseVertex*>(geo.vertices());
- GrEffect* effect = DIEllipseEdgeEffect::Create(mode);
+ GrGeometryProcessor* gp = DIEllipseEdgeEffect::Create(mode);
- drawState->setGeometryProcessor(effect)->unref();
+ drawState->setGeometryProcessor(gp)->unref();
// This expands the outer rect so that after CTM we end up with a half-pixel border
SkScalar a = vm[SkMatrix::kMScaleX];
@@ -920,14 +921,15 @@ bool GrOvalRenderer::drawDRRect(GrDrawTarget* target, GrContext* context, bool u
return false;
}
}
- GrEffectEdgeType edgeType = applyAA ? kInverseFillAA_GrEffectEdgeType :
- kInverseFillBW_GrEffectEdgeType;
- GrEffect* effect = GrRRectEffect::Create(edgeType, *inner);
- if (NULL == effect) {
+ GrPrimitiveEdgeType edgeType = applyAA ?
+ kInverseFillAA_GrProcessorEdgeType :
+ kInverseFillBW_GrProcessorEdgeType;
+ GrFragmentProcessor* fp = GrRRectEffect::Create(edgeType, *inner);
+ if (NULL == fp) {
return false;
}
are.set(target->drawState());
- target->drawState()->addCoverageEffect(effect)->unref();
+ target->drawState()->addCoverageProcessor(fp)->unref();
}
SkStrokeRec fillRec(SkStrokeRec::kFill_InitStyle);
@@ -942,9 +944,9 @@ bool GrOvalRenderer::drawDRRect(GrDrawTarget* target, GrContext* context, bool u
return false;
}
}
- GrEffectEdgeType edgeType = applyAA ? kFillAA_GrEffectEdgeType :
- kFillBW_GrEffectEdgeType;
- GrEffect* effect = GrRRectEffect::Create(edgeType, *outer);
+ GrPrimitiveEdgeType edgeType = applyAA ? kFillAA_GrProcessorEdgeType :
+ kFillBW_GrProcessorEdgeType;
+ GrFragmentProcessor* effect = GrRRectEffect::Create(edgeType, *outer);
if (NULL == effect) {
return false;
}
@@ -955,7 +957,7 @@ bool GrOvalRenderer::drawDRRect(GrDrawTarget* target, GrContext* context, bool u
if (!avmr.setIdentity(target->drawState())) {
return false;
}
- target->drawState()->addCoverageEffect(effect)->unref();
+ target->drawState()->addCoverageProcessor(effect)->unref();
SkRect bounds = outer->getBounds();
if (applyAA) {
bounds.outset(SK_ScalarHalf, SK_ScalarHalf);
@@ -1075,7 +1077,7 @@ bool GrOvalRenderer::drawRRect(GrDrawTarget* target, GrContext* context, bool us
isStrokeOnly = (isStrokeOnly && innerRadius >= 0);
- GrEffect* effect = CircleEdgeEffect::Create(isStrokeOnly);
+ GrGeometryProcessor* effect = CircleEdgeEffect::Create(isStrokeOnly);
drawState->setGeometryProcessor(effect)->unref();
// The radii are outset for two reasons. First, it allows the shader to simply perform
@@ -1178,7 +1180,7 @@ bool GrOvalRenderer::drawRRect(GrDrawTarget* target, GrContext* context, bool us
}
EllipseVertex* verts = reinterpret_cast<EllipseVertex*>(geo.vertices());
- GrEffect* effect = EllipseEdgeEffect::Create(isStrokeOnly);
+ GrGeometryProcessor* effect = EllipseEdgeEffect::Create(isStrokeOnly);
drawState->setGeometryProcessor(effect)->unref();
// Compute the reciprocals of the radii here to save time in the shader
diff --git a/src/gpu/GrPaint.cpp b/src/gpu/GrPaint.cpp
index 0e5b2ccdd..84fdf420e 100644
--- a/src/gpu/GrPaint.cpp
+++ b/src/gpu/GrPaint.cpp
@@ -11,24 +11,24 @@
#include "GrBlend.h"
#include "effects/GrSimpleTextureEffect.h"
-void GrPaint::addColorTextureEffect(GrTexture* texture, const SkMatrix& matrix) {
- this->addColorEffect(GrSimpleTextureEffect::Create(texture, matrix))->unref();
+void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
+ this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref();
}
-void GrPaint::addCoverageTextureEffect(GrTexture* texture, const SkMatrix& matrix) {
- this->addCoverageEffect(GrSimpleTextureEffect::Create(texture, matrix))->unref();
+void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
+ this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref();
}
-void GrPaint::addColorTextureEffect(GrTexture* texture,
+void GrPaint::addColorTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addColorEffect(GrSimpleTextureEffect::Create(texture, matrix, params))->unref();
+ this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix, params))->unref();
}
-void GrPaint::addCoverageTextureEffect(GrTexture* texture,
+void GrPaint::addCoverageTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addCoverageEffect(GrSimpleTextureEffect::Create(texture, matrix, params))->unref();
+ this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix, params))->unref();
}
bool GrPaint::isOpaque() const {
@@ -56,7 +56,7 @@ bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor,
uint32_t coverageComps = kRGBA_GrColorComponentFlags;
int count = fCoverageStages.count();
for (int i = 0; i < count; ++i) {
- fCoverageStages[i].getEffect()->getConstantColorComponents(&coverage, &coverageComps);
+ fCoverageStages[i].getProcessor()->getConstantColorComponents(&coverage, &coverageComps);
}
if (kRGBA_GrColorComponentFlags != coverageComps || 0xffffffff != coverage) {
return false;
@@ -66,7 +66,7 @@ bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor,
uint32_t colorComps = kRGBA_GrColorComponentFlags;
count = fColorStages.count();
for (int i = 0; i < count; ++i) {
- fColorStages[i].getEffect()->getConstantColorComponents(&color, &colorComps);
+ fColorStages[i].getProcessor()->getConstantColorComponents(&color, &colorComps);
}
SkASSERT((NULL == solidColor) == (NULL == solidColorKnownComponents));
diff --git a/src/gpu/GrPathRenderer.h b/src/gpu/GrPathRenderer.h
index 1099b2be3..0720c3f86 100644
--- a/src/gpu/GrPathRenderer.h
+++ b/src/gpu/GrPathRenderer.h
@@ -49,9 +49,9 @@ public:
/**
* A caller may wish to use a path renderer to draw a path into the stencil buffer. However,
* the path renderer itself may require use of the stencil buffer. Also a path renderer may
- * use a GrEffect coverage stage that sets coverage to zero to eliminate pixels that are covered
- * by bounding geometry but outside the path. These exterior pixels would still be rendered into
- * the stencil.
+ * use a GrProcessor coverage stage that sets coverage to zero to eliminate pixels that are
+ * covered by bounding geometry but outside the path. These exterior pixels would still be
+ * rendered into the stencil.
*
* A GrPathRenderer can provide three levels of support for stenciling paths:
* 1) kNoRestriction: This is the most general. The caller sets up the GrDrawState on the target
diff --git a/src/gpu/GrEffect.cpp b/src/gpu/GrProcessor.cpp
index 28c23d7da..45298b522 100644
--- a/src/gpu/GrEffect.cpp
+++ b/src/gpu/GrProcessor.cpp
@@ -5,21 +5,14 @@
* found in the LICENSE file.
*/
-#include "GrEffect.h"
-#include "GrBackendEffectFactory.h"
+#include "GrProcessor.h"
+#include "GrBackendProcessorFactory.h"
#include "GrContext.h"
#include "GrCoordTransform.h"
#include "GrMemoryPool.h"
#include "SkTLS.h"
-#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
-SkTArray<GrEffectTestFactory*, true>* GrEffectTestFactory::GetFactories() {
- static SkTArray<GrEffectTestFactory*, true> gFactories;
- return &gFactories;
-}
-#endif
-
-namespace GrEffectUnitTest {
+namespace GrProcessorUnitTest {
const SkMatrix& TestMatrix(SkRandom* random) {
static SkMatrix gMatrices[5];
static bool gOnce;
@@ -39,7 +32,7 @@ const SkMatrix& TestMatrix(SkRandom* random) {
}
}
-class GrEffect_Globals {
+class GrProcessor_Globals {
public:
static GrMemoryPool* GetTLS() {
return (GrMemoryPool*)SkTLS::Get(CreateTLS, DeleteTLS);
@@ -55,36 +48,37 @@ private:
}
};
-int32_t GrBackendEffectFactory::fCurrEffectClassID = GrBackendEffectFactory::kIllegalEffectClassID;
+int32_t GrBackendProcessorFactory::fCurrEffectClassID =
+ GrBackendProcessorFactory::kIllegalEffectClassID;
///////////////////////////////////////////////////////////////////////////////
-GrEffect::~GrEffect() {}
+GrProcessor::~GrProcessor() {}
-const char* GrEffect::name() const {
+const char* GrProcessor::name() const {
return this->getFactory().name();
}
-void GrEffect::addCoordTransform(const GrCoordTransform* transform) {
+void GrProcessor::addCoordTransform(const GrCoordTransform* transform) {
fCoordTransforms.push_back(transform);
SkDEBUGCODE(transform->setInEffect();)
}
-void GrEffect::addTextureAccess(const GrTextureAccess* access) {
+void GrProcessor::addTextureAccess(const GrTextureAccess* access) {
fTextureAccesses.push_back(access);
this->addGpuResource(access->getProgramTexture());
}
-void* GrEffect::operator new(size_t size) {
- return GrEffect_Globals::GetTLS()->allocate(size);
+void* GrProcessor::operator new(size_t size) {
+ return GrProcessor_Globals::GetTLS()->allocate(size);
}
-void GrEffect::operator delete(void* target) {
- GrEffect_Globals::GetTLS()->release(target);
+void GrProcessor::operator delete(void* target) {
+ GrProcessor_Globals::GetTLS()->release(target);
}
#ifdef SK_DEBUG
-void GrEffect::assertEquality(const GrEffect& other) const {
+void GrProcessor::assertEquality(const GrProcessor& other) const {
SkASSERT(this->numTransforms() == other.numTransforms());
for (int i = 0; i < this->numTransforms(); ++i) {
SkASSERT(this->coordTransform(i) == other.coordTransform(i));
diff --git a/src/gpu/GrRODrawState.cpp b/src/gpu/GrRODrawState.cpp
index fb4db2d09..2a673f3e5 100644
--- a/src/gpu/GrRODrawState.cpp
+++ b/src/gpu/GrRODrawState.cpp
@@ -48,9 +48,9 @@ bool GrRODrawState::isEqual(const GrRODrawState& that) const {
if (this->hasGeometryProcessor()) {
if (!that.hasGeometryProcessor()) {
return false;
- } else if (!GrEffectStage::AreCompatible(*this->getGeometryProcessor(),
- *that.getGeometryProcessor(),
- explicitLocalCoords)) {
+ } else if (!GrProcessorStage::AreCompatible(*this->getGeometryProcessor(),
+ *that.getGeometryProcessor(),
+ explicitLocalCoords)) {
return false;
}
} else if (that.hasGeometryProcessor()) {
@@ -58,14 +58,14 @@ bool GrRODrawState::isEqual(const GrRODrawState& that) const {
}
for (int i = 0; i < this->numColorStages(); i++) {
- if (!GrEffectStage::AreCompatible(this->getColorStage(i), that.getColorStage(i),
- explicitLocalCoords)) {
+ if (!GrProcessorStage::AreCompatible(this->getColorStage(i), that.getColorStage(i),
+ explicitLocalCoords)) {
return false;
}
}
for (int i = 0; i < this->numCoverageStages(); i++) {
- if (!GrEffectStage::AreCompatible(this->getCoverageStage(i), that.getCoverageStage(i),
- explicitLocalCoords)) {
+ if (!GrProcessorStage::AreCompatible(this->getCoverageStage(i), that.getCoverageStage(i),
+ explicitLocalCoords)) {
return false;
}
}
@@ -87,17 +87,17 @@ bool GrRODrawState::validateVertexAttribs() const {
}
if (this->hasGeometryProcessor()) {
- const GrEffectStage& stage = *this->getGeometryProcessor();
- const GrEffect* effect = stage.getEffect();
- SkASSERT(effect);
+ const GrGeometryStage& stage = *this->getGeometryProcessor();
+ const GrGeometryProcessor* gp = stage.getGeometryProcessor();
+ SkASSERT(gp);
// make sure that any attribute indices have the correct binding type, that the attrib
// type and effect's shader lang type are compatible, and that attributes shared by
// multiple effects use the same shader lang type.
- const GrEffect::VertexAttribArray& s = effect->getVertexAttribs();
+ const GrGeometryProcessor::VertexAttribArray& s = gp->getVertexAttribs();
int effectIndex = 0;
for (int index = 0; index < fVACount; index++) {
- if (kEffect_GrVertexAttribBinding != fVAPtr[index].fBinding) {
+ if (kGeometryProcessor_GrVertexAttribBinding != fVAPtr[index].fBinding) {
// we only care about effect bindings
continue;
}
@@ -138,12 +138,12 @@ bool GrRODrawState::hasSolidCoverage() const {
// Run through the coverage stages and see if the coverage will be all ones at the end.
if (this->hasGeometryProcessor()) {
- const GrEffect* effect = fGeometryProcessor->getEffect();
- effect->getConstantColorComponents(&coverage, &validComponentFlags);
+ const GrGeometryProcessor* gp = fGeometryProcessor->getGeometryProcessor();
+ gp->getConstantColorComponents(&coverage, &validComponentFlags);
}
for (int s = 0; s < this->numCoverageStages(); ++s) {
- const GrEffect* effect = this->getCoverageStage(s).getEffect();
- effect->getConstantColorComponents(&coverage, &validComponentFlags);
+ const GrProcessor* processor = this->getCoverageStage(s).getProcessor();
+ processor->getConstantColorComponents(&coverage, &validComponentFlags);
}
return (kRGBA_GrColorComponentFlags == validComponentFlags) && (0xffffffff == coverage);
}
@@ -153,18 +153,13 @@ bool GrRODrawState::hasSolidCoverage() const {
bool GrRODrawState::willEffectReadDstColor() const {
if (!this->isColorWriteDisabled()) {
for (int s = 0; s < this->numColorStages(); ++s) {
- if (this->getColorStage(s).getEffect()->willReadDstColor()) {
+ if (this->getColorStage(s).getFragmentProcessor()->willReadDstColor()) {
return true;
}
}
}
for (int s = 0; s < this->numCoverageStages(); ++s) {
- if (this->getCoverageStage(s).getEffect()->willReadDstColor()) {
- return true;
- }
- }
- if (this->hasGeometryProcessor()) {
- if (fGeometryProcessor->getEffect()->willReadDstColor()) {
+ if (this->getCoverageStage(s).getFragmentProcessor()->willReadDstColor()) {
return true;
}
}
@@ -319,8 +314,8 @@ bool GrRODrawState::srcAlphaWillBeOne() const {
// Run through the color stages
for (int s = 0; s < this->numColorStages(); ++s) {
- const GrEffect* effect = this->getColorStage(s).getEffect();
- effect->getConstantColorComponents(&color, &validComponentFlags);
+ const GrProcessor* processor = this->getColorStage(s).getProcessor();
+ processor->getConstantColorComponents(&color, &validComponentFlags);
}
// Check whether coverage is treated as color. If so we run through the coverage computation.
@@ -339,8 +334,8 @@ bool GrRODrawState::srcAlphaWillBeOne() const {
// Run through the coverage stages
for (int s = 0; s < this->numCoverageStages(); ++s) {
- const GrEffect* effect = this->getCoverageStage(s).getEffect();
- effect->getConstantColorComponents(&coverage, &coverageComponentFlags);
+ const GrProcessor* processor = this->getCoverageStage(s).getProcessor();
+ processor->getConstantColorComponents(&coverage, &coverageComponentFlags);
}
// Since the shader will multiply coverage and color, the only way the final A==1 is if
diff --git a/src/gpu/GrRODrawState.h b/src/gpu/GrRODrawState.h
index 75e36a6ab..ac263ff81 100644
--- a/src/gpu/GrRODrawState.h
+++ b/src/gpu/GrRODrawState.h
@@ -8,7 +8,7 @@
#ifndef GrRODrawState_DEFINED
#define GrRODrawState_DEFINED
-#include "GrEffectStage.h"
+#include "GrProcessorStage.h"
#include "GrRenderTarget.h"
#include "GrStencil.h"
#include "SkMatrix.h"
@@ -110,8 +110,8 @@ public:
///////////////////////////////////////////////////////////////////////////
/// @name Effect Stages
- /// Each stage hosts a GrEffect. The effect produces an output color or coverage in the fragment
- /// shader. Its inputs are the output from the previous stage as well as some variables
+ /// Each stage hosts a GrProcessor. The effect produces an output color or coverage in the
+ /// fragment shader. Its inputs are the output from the previous stage as well as some variables
/// available to it in the fragment and vertex shader (e.g. the vertex position, the dst color,
/// the fragment position, local coordinates).
///
@@ -136,9 +136,9 @@ public:
}
bool hasGeometryProcessor() const { return SkToBool(fGeometryProcessor.get()); }
- const GrEffectStage* getGeometryProcessor() const { return fGeometryProcessor.get(); }
- const GrEffectStage& getColorStage(int stageIdx) const { return fColorStages[stageIdx]; }
- const GrEffectStage& getCoverageStage(int stageIdx) const { return fCoverageStages[stageIdx]; }
+ const GrGeometryStage* getGeometryProcessor() const { return fGeometryProcessor.get(); }
+ const GrFragmentStage& getColorStage(int stageIdx) const { return fColorStages[stageIdx]; }
+ const GrFragmentStage& getCoverageStage(int stageIdx) const { return fCoverageStages[stageIdx]; }
/**
* Checks whether any of the effects will read the dst pixel color.
@@ -413,10 +413,10 @@ protected:
GrBlendCoeff fSrcBlend;
GrBlendCoeff fDstBlend;
- typedef SkSTArray<4, GrEffectStage> EffectStageArray;
- SkAutoTDelete<GrEffectStage> fGeometryProcessor;
- EffectStageArray fColorStages;
- EffectStageArray fCoverageStages;
+ typedef SkSTArray<4, GrFragmentStage> FragmentStageArray;
+ SkAutoTDelete<GrGeometryStage> fGeometryProcessor;
+ FragmentStageArray fColorStages;
+ FragmentStageArray fCoverageStages;
uint32_t fHints;
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index d3d464883..c80a13ccd 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -361,7 +361,7 @@ void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture,
maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop));
maskMatrix.preConcat(drawState->getViewMatrix());
- drawState->addCoverageEffect(
+ drawState->addCoverageProcessor(
GrSimpleTextureEffect::Create(texture,
maskMatrix,
GrTextureParams::kNone_FilterMode,
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 7ce3446b7..bebc3980b 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -588,7 +588,7 @@ bool draw_mask(GrContext* context, const SkRect& maskRect,
matrix.setTranslate(-maskRect.fLeft, -maskRect.fTop);
matrix.postIDiv(mask->width(), mask->height());
- grp->addCoverageEffect(GrSimpleTextureEffect::Create(mask, matrix))->unref();
+ grp->addCoverageProcessor(GrSimpleTextureEffect::Create(mask, matrix))->unref();
context->drawRect(*grp, maskRect);
return true;
}
@@ -1308,7 +1308,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
SkScalarMul(srcRect.fBottom, hInv));
SkRect textureDomain = SkRect::MakeEmpty();
- SkAutoTUnref<GrEffect> effect;
+ SkAutoTUnref<GrFragmentProcessor> fp;
if (needsTextureDomain && !(flags & SkCanvas::kBleed_DrawBitmapRectFlag)) {
// Use a constrained texture domain to avoid color bleeding
SkScalar left, top, right, bottom;
@@ -1328,9 +1328,9 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
}
textureDomain.setLTRB(left, top, right, bottom);
if (bicubic) {
- effect.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), textureDomain));
+ fp.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), textureDomain));
} else {
- effect.reset(GrTextureDomainEffect::Create(texture,
+ fp.reset(GrTextureDomainEffect::Create(texture,
SkMatrix::I(),
textureDomain,
GrTextureDomain::kClamp_Mode,
@@ -1339,15 +1339,15 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
} else if (bicubic) {
SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode());
SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTileModeY() };
- effect.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), tileModes));
+ fp.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), tileModes));
} else {
- effect.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), params));
+ fp.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), params));
}
// Construct a GrPaint by setting the bitmap texture as the first effect and then configuring
// the rest from the SkPaint.
GrPaint grPaint;
- grPaint.addColorEffect(effect);
+ grPaint.addColorProcessor(fp);
bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType());
GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor()) :
SkColor2GrColor(paint.getColor());
@@ -1416,7 +1416,7 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
}
GrPaint grPaint;
- grPaint.addColorTextureEffect(texture, SkMatrix::I());
+ grPaint.addColorTextureProcessor(texture, SkMatrix::I());
SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColorJustAlpha(paint.getColor()),
false, &grPaint);
@@ -1527,7 +1527,7 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
}
GrPaint grPaint;
- grPaint.addColorTextureEffect(devTex, SkMatrix::I());
+ grPaint.addColorTextureProcessor(devTex, SkMatrix::I());
SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColorJustAlpha(paint.getColor()),
false, &grPaint);
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 56f3a16b6..e81abdbae 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -270,11 +270,11 @@ static GrTexture *load_yuv_texture(GrContext* ctx, bool cache, const GrTexturePa
GrRenderTarget* renderTarget = result ? result->asRenderTarget() : NULL;
if (renderTarget) {
- SkAutoTUnref<GrEffect> yuvToRgbEffect(GrYUVtoRGBEffect::Create(
+ SkAutoTUnref<GrFragmentProcessor> yuvToRgbProcessor(GrYUVtoRGBEffect::Create(
yuvTextures[0].texture(), yuvTextures[1].texture(), yuvTextures[2].texture(),
colorSpace));
GrPaint paint;
- paint.addColorEffect(yuvToRgbEffect);
+ paint.addColorProcessor(yuvToRgbProcessor);
SkRect r = SkRect::MakeWH(SkIntToScalar(yuvSizes[0].fWidth),
SkIntToScalar(yuvSizes[0].fHeight));
GrContext::AutoRenderTarget autoRT(ctx, renderTarget);
@@ -471,10 +471,10 @@ void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor
SkXfermode::Coeff dm;
SkXfermode* mode = skPaint.getXfermode();
- GrEffect* xferEffect = NULL;
- if (SkXfermode::AsNewEffectOrCoeff(mode, &xferEffect, &sm, &dm)) {
- if (xferEffect) {
- grPaint->addColorEffect(xferEffect)->unref();
+ GrFragmentProcessor* xferProcessor = NULL;
+ if (SkXfermode::asFragmentProcessorOrCoeff(mode, &xferProcessor, &sm, &dm)) {
+ if (xferProcessor) {
+ grPaint->addColorProcessor(xferProcessor)->unref();
sm = SkXfermode::kOne_Coeff;
dm = SkXfermode::kZero_Coeff;
}
@@ -497,9 +497,9 @@ void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor
SkColor filtered = colorFilter->filterColor(skPaint.getColor());
grPaint->setColor(SkColor2GrColor(filtered));
} else {
- SkAutoTUnref<GrEffect> effect(colorFilter->asNewEffect(context));
- if (effect.get()) {
- grPaint->addColorEffect(effect);
+ SkAutoTUnref<GrFragmentProcessor> fp(colorFilter->asFragmentProcessor(context));
+ if (fp.get()) {
+ grPaint->addColorProcessor(fp);
}
}
}
@@ -518,9 +518,9 @@ void SkPaint2GrPaintNoShader(GrContext* context, const SkPaint& skPaint, GrColor
target->config() == kBGRA_8888_GrPixelConfig) {
// The dither flag is set and the target is likely
// not going to be dithered by the GPU.
- SkAutoTUnref<GrEffect> effect(GrDitherEffect::Create());
- if (effect.get()) {
- grPaint->addColorEffect(effect);
+ SkAutoTUnref<GrFragmentProcessor> fp(GrDitherEffect::Create());
+ if (fp.get()) {
+ grPaint->addColorProcessor(fp);
grPaint->setDither(false);
}
}
@@ -560,26 +560,27 @@ void SkPaint2GrPaintShader(GrContext* context, const SkPaint& skPaint,
GrColor paintColor = SkColor2GrColor(skPaint.getColor());
// Start a new block here in order to preserve our context state after calling
- // asNewEffect(). Since these calls get passed back to the client, we don't really
+ // asFragmentProcessor(). Since these calls get passed back to the client, we don't really
// want them messing around with the context.
{
- // SkShader::asNewEffect() may do offscreen rendering. Save off the current RT, clip, and
- // matrix. We don't reset the matrix on the context because SkShader::asNewEffect may use
- // GrContext::getMatrix() to know the transformation from local coords to device space.
+ // SkShader::asFragmentProcessor() may do offscreen rendering. Save off the current RT,
+ // clip, and matrix. We don't reset the matrix on the context because
+ // SkShader::asFragmentProcessor may use GrContext::getMatrix() to know the transformation
+ // from local coords to device space.
GrContext::AutoRenderTarget art(context, NULL);
GrContext::AutoClip ac(context, GrContext::AutoClip::kWideOpen_InitialClip);
AutoMatrix am(context);
// Allow the shader to modify paintColor and also create an effect to be installed as
// the first color effect on the GrPaint.
- GrEffect* effect = NULL;
- if (shader->asNewEffect(context, skPaint, NULL, &paintColor, &effect) && effect) {
- grPaint->addColorEffect(effect)->unref();
+ GrFragmentProcessor* fp = NULL;
+ if (shader->asFragmentProcessor(context, skPaint, NULL, &paintColor, &fp) && fp) {
+ grPaint->addColorProcessor(fp)->unref();
constantColor = false;
}
}
- // The grcolor is automatically set when calling asneweffect.
+ // The grcolor is automatically set when calling asFragmentProcessor.
// If the shader can be seen as an effect it returns true and adds its effect to the grpaint.
SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint);
}
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index c34229152..fe509b60a 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -8,43 +8,43 @@
#include "GrBezierEffect.h"
#include "gl/builders/GrGLFullProgramBuilder.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
#include "gl/GrGLGeometryProcessor.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
class GrGLConicEffect : public GrGLGeometryProcessor {
public:
- GrGLConicEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GrGLConicEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE {}
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {}
private:
- GrEffectEdgeType fEdgeType;
+ GrPrimitiveEdgeType fEdgeType;
typedef GrGLGeometryProcessor INHERITED;
};
-GrGLConicEffect::GrGLConicEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GrGLConicEffect::GrGLConicEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor& effect)
: INHERITED (factory) {
const GrConicEffect& ce = effect.cast<GrConicEffect>();
fEdgeType = ce.getEdgeType();
}
void GrGLConicEffect::emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
@@ -54,15 +54,15 @@ void GrGLConicEffect::emitCode(GrGLFullProgramBuilder* builder,
builder->addVarying(kVec4f_GrSLType, "ConicCoeffs",
&vsName, &fsName);
- const GrShaderVar& inConicCoeffs = effect.cast<GrConicEffect>().inConicCoeffs();
+ const GrShaderVar& inConicCoeffs = geometryProcessor.cast<GrConicEffect>().inConicCoeffs();
GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
vsBuilder->codeAppendf("%s = %s;", vsName, inConicCoeffs.c_str());
- GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+ GrGLProcessorFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
fsBuilder->codeAppend("float edgeAlpha;");
switch (fEdgeType) {
- case kHairlineAA_GrEffectEdgeType: {
+ case kHairlineAA_GrProcessorEdgeType: {
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", fsName);
@@ -84,7 +84,7 @@ void GrGLConicEffect::emitCode(GrGLFullProgramBuilder* builder,
// fsBuilder->codeAppend("edgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*edgeAlpha);");
break;
}
- case kFillAA_GrEffectEdgeType: {
+ case kFillAA_GrProcessorEdgeType: {
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", fsName);
@@ -105,7 +105,7 @@ void GrGLConicEffect::emitCode(GrGLFullProgramBuilder* builder,
// fsBuilder->codeAppend("edgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*edgeAlpha);");
break;
}
- case kFillBW_GrEffectEdgeType: {
+ case kFillBW_GrProcessorEdgeType: {
fsBuilder->codeAppendf("edgeAlpha = %s.x * %s.x - %s.y * %s.z;", fsName, fsName,
fsName, fsName);
fsBuilder->codeAppend("edgeAlpha = float(edgeAlpha < 0.0);");
@@ -119,9 +119,9 @@ void GrGLConicEffect::emitCode(GrGLFullProgramBuilder* builder,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
}
-void GrGLConicEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
- const GrConicEffect& ce = effect.cast<GrConicEffect>();
+void GrGLConicEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
+ const GrConicEffect& ce = processor.cast<GrConicEffect>();
uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
b->add32(key);
}
@@ -130,37 +130,37 @@ void GrGLConicEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
GrConicEffect::~GrConicEffect() {}
-const GrBackendEffectFactory& GrConicEffect::getFactory() const {
- return GrTBackendEffectFactory<GrConicEffect>::getInstance();
+const GrBackendGeometryProcessorFactory& GrConicEffect::getFactory() const {
+ return GrTBackendGeometryProcessorFactory<GrConicEffect>::getInstance();
}
-GrConicEffect::GrConicEffect(GrEffectEdgeType edgeType)
+GrConicEffect::GrConicEffect(GrPrimitiveEdgeType edgeType)
: fEdgeType(edgeType)
, fInConicCoeffs(this->addVertexAttrib(GrShaderVar("inConicCoeffs",
kVec4f_GrSLType,
GrShaderVar::kAttribute_TypeModifier))) {
}
-bool GrConicEffect::onIsEqual(const GrEffect& other) const {
+bool GrConicEffect::onIsEqual(const GrProcessor& other) const {
const GrConicEffect& ce = other.cast<GrConicEffect>();
return (ce.fEdgeType == fEdgeType);
}
//////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrConicEffect);
+GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrConicEffect);
-GrEffect* GrConicEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
- GrEffect* effect;
+GrGeometryProcessor* GrConicEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
+ GrGeometryProcessor* gp;
do {
- GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(
- random->nextULessThan(kGrEffectEdgeTypeCnt));
- effect = GrConicEffect::Create(edgeType, caps);
- } while (NULL == effect);
- return effect;
+ GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
+ random->nextULessThan(kGrProcessorEdgeTypeCnt));
+ gp = GrConicEffect::Create(edgeType, caps);
+ } while (NULL == gp);
+ return gp;
}
//////////////////////////////////////////////////////////////////////////////
@@ -169,36 +169,36 @@ GrEffect* GrConicEffect::TestCreate(SkRandom* random,
class GrGLQuadEffect : public GrGLGeometryProcessor {
public:
- GrGLQuadEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GrGLQuadEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE {}
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {}
private:
- GrEffectEdgeType fEdgeType;
+ GrPrimitiveEdgeType fEdgeType;
typedef GrGLGeometryProcessor INHERITED;
};
-GrGLQuadEffect::GrGLQuadEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GrGLQuadEffect::GrGLQuadEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor& effect)
: INHERITED (factory) {
const GrQuadEffect& ce = effect.cast<GrQuadEffect>();
fEdgeType = ce.getEdgeType();
}
void GrGLQuadEffect::emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
@@ -207,14 +207,14 @@ void GrGLQuadEffect::emitCode(GrGLFullProgramBuilder* builder,
builder->addVarying(kVec4f_GrSLType, "HairQuadEdge", &vsName, &fsName);
GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
- const GrShaderVar& inHairQuadEdge = effect.cast<GrQuadEffect>().inHairQuadEdge();
+ const GrShaderVar& inHairQuadEdge = geometryProcessor.cast<GrQuadEffect>().inHairQuadEdge();
vsBuilder->codeAppendf("%s = %s;", vsName, inHairQuadEdge.c_str());
- GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+ GrGLProcessorFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
fsBuilder->codeAppendf("float edgeAlpha;");
switch (fEdgeType) {
- case kHairlineAA_GrEffectEdgeType: {
+ case kHairlineAA_GrProcessorEdgeType: {
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", fsName);
@@ -229,7 +229,7 @@ void GrGLQuadEffect::emitCode(GrGLFullProgramBuilder* builder,
// fsBuilder->codeAppend("edgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*edgeAlpha);");
break;
}
- case kFillAA_GrEffectEdgeType: {
+ case kFillAA_GrProcessorEdgeType: {
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", fsName);
@@ -244,7 +244,7 @@ void GrGLQuadEffect::emitCode(GrGLFullProgramBuilder* builder,
// fsBuilder->codeAppend("edgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*edgeAlpha);");
break;
}
- case kFillBW_GrEffectEdgeType: {
+ case kFillBW_GrProcessorEdgeType: {
fsBuilder->codeAppendf("edgeAlpha = (%s.x * %s.x - %s.y);", fsName, fsName, fsName);
fsBuilder->codeAppend("edgeAlpha = float(edgeAlpha < 0.0);");
break;
@@ -257,9 +257,9 @@ void GrGLQuadEffect::emitCode(GrGLFullProgramBuilder* builder,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
}
-void GrGLQuadEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
- const GrQuadEffect& ce = effect.cast<GrQuadEffect>();
+void GrGLQuadEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
+ const GrQuadEffect& ce = processor.cast<GrQuadEffect>();
uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
b->add32(key);
}
@@ -268,37 +268,37 @@ void GrGLQuadEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
GrQuadEffect::~GrQuadEffect() {}
-const GrBackendEffectFactory& GrQuadEffect::getFactory() const {
- return GrTBackendEffectFactory<GrQuadEffect>::getInstance();
+const GrBackendGeometryProcessorFactory& GrQuadEffect::getFactory() const {
+ return GrTBackendGeometryProcessorFactory<GrQuadEffect>::getInstance();
}
-GrQuadEffect::GrQuadEffect(GrEffectEdgeType edgeType)
+GrQuadEffect::GrQuadEffect(GrPrimitiveEdgeType edgeType)
: fEdgeType(edgeType)
, fInHairQuadEdge(this->addVertexAttrib(GrShaderVar("inCubicCoeffs",
kVec4f_GrSLType,
GrShaderVar::kAttribute_TypeModifier))) {
}
-bool GrQuadEffect::onIsEqual(const GrEffect& other) const {
+bool GrQuadEffect::onIsEqual(const GrProcessor& other) const {
const GrQuadEffect& ce = other.cast<GrQuadEffect>();
return (ce.fEdgeType == fEdgeType);
}
//////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrQuadEffect);
+GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrQuadEffect);
-GrEffect* GrQuadEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
- GrEffect* effect;
+GrGeometryProcessor* GrQuadEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
+ GrGeometryProcessor* gp;
do {
- GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(
- random->nextULessThan(kGrEffectEdgeTypeCnt));
- effect = GrQuadEffect::Create(edgeType, caps);
- } while (NULL == effect);
- return effect;
+ GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
+ random->nextULessThan(kGrProcessorEdgeTypeCnt));
+ gp = GrQuadEffect::Create(edgeType, caps);
+ } while (NULL == gp);
+ return gp;
}
//////////////////////////////////////////////////////////////////////////////
@@ -307,36 +307,36 @@ GrEffect* GrQuadEffect::TestCreate(SkRandom* random,
class GrGLCubicEffect : public GrGLGeometryProcessor {
public:
- GrGLCubicEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GrGLCubicEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE {}
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {}
private:
- GrEffectEdgeType fEdgeType;
+ GrPrimitiveEdgeType fEdgeType;
typedef GrGLGeometryProcessor INHERITED;
};
-GrGLCubicEffect::GrGLCubicEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GrGLCubicEffect::GrGLCubicEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor& processor)
: INHERITED (factory) {
- const GrCubicEffect& ce = effect.cast<GrCubicEffect>();
+ const GrCubicEffect& ce = processor.cast<GrCubicEffect>();
fEdgeType = ce.getEdgeType();
}
void GrGLCubicEffect::emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
@@ -347,10 +347,10 @@ void GrGLCubicEffect::emitCode(GrGLFullProgramBuilder* builder,
&vsName, &fsName, GrGLShaderVar::kHigh_Precision);
GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
- const GrShaderVar& inCubicCoeffs = effect.cast<GrCubicEffect>().inCubicCoeffs();
+ const GrShaderVar& inCubicCoeffs = geometryProcessor.cast<GrCubicEffect>().inCubicCoeffs();
vsBuilder->codeAppendf("%s = %s;", vsName, inCubicCoeffs.c_str());
- GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+ GrGLProcessorFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precision);
GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Precision);
@@ -371,7 +371,7 @@ void GrGLCubicEffect::emitCode(GrGLFullProgramBuilder* builder,
fsBuilder->declAppend(func);
switch (fEdgeType) {
- case kHairlineAA_GrEffectEdgeType: {
+ case kHairlineAA_GrProcessorEdgeType: {
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
fsBuilder->codeAppendf("%s = dFdx(%s.xyz);", dklmdx.c_str(), fsName);
@@ -397,7 +397,7 @@ void GrGLCubicEffect::emitCode(GrGLFullProgramBuilder* builder,
// edgeAlpha.c_str());
break;
}
- case kFillAA_GrEffectEdgeType: {
+ case kFillAA_GrProcessorEdgeType: {
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
fsBuilder->codeAppendf("%s = dFdx(%s.xyz);", dklmdx.c_str(), fsName);
@@ -423,7 +423,7 @@ void GrGLCubicEffect::emitCode(GrGLFullProgramBuilder* builder,
// edgeAlpha.c_str());
break;
}
- case kFillBW_GrEffectEdgeType: {
+ case kFillBW_GrProcessorEdgeType: {
fsBuilder->codeAppendf("%s = %s.x * %s.x * %s.x - %s.y * %s.z;",
edgeAlpha.c_str(), fsName, fsName, fsName, fsName, fsName);
fsBuilder->codeAppendf("%s = float(%s < 0.0);", edgeAlpha.c_str(), edgeAlpha.c_str());
@@ -437,9 +437,9 @@ void GrGLCubicEffect::emitCode(GrGLFullProgramBuilder* builder,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1(edgeAlpha.c_str())).c_str());
}
-void GrGLCubicEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
- const GrCubicEffect& ce = effect.cast<GrCubicEffect>();
+void GrGLCubicEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
+ const GrCubicEffect& ce = processor.cast<GrCubicEffect>();
uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
b->add32(key);
}
@@ -448,36 +448,36 @@ void GrGLCubicEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
GrCubicEffect::~GrCubicEffect() {}
-const GrBackendEffectFactory& GrCubicEffect::getFactory() const {
- return GrTBackendEffectFactory<GrCubicEffect>::getInstance();
+const GrBackendGeometryProcessorFactory& GrCubicEffect::getFactory() const {
+ return GrTBackendGeometryProcessorFactory<GrCubicEffect>::getInstance();
}
-GrCubicEffect::GrCubicEffect(GrEffectEdgeType edgeType)
+GrCubicEffect::GrCubicEffect(GrPrimitiveEdgeType edgeType)
: fEdgeType(edgeType)
, fInCubicCoeffs(this->addVertexAttrib(GrShaderVar("inCubicCoeffs",
kVec4f_GrSLType,
GrShaderVar::kAttribute_TypeModifier))) {
}
-bool GrCubicEffect::onIsEqual(const GrEffect& other) const {
+bool GrCubicEffect::onIsEqual(const GrProcessor& other) const {
const GrCubicEffect& ce = other.cast<GrCubicEffect>();
return (ce.fEdgeType == fEdgeType);
}
//////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrCubicEffect);
+GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCubicEffect);
-GrEffect* GrCubicEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
- GrEffect* effect;
+GrGeometryProcessor* GrCubicEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
+ GrGeometryProcessor* gp;
do {
- GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(
- random->nextULessThan(kGrEffectEdgeTypeCnt));
- effect = GrCubicEffect::Create(edgeType, caps);
- } while (NULL == effect);
- return effect;
+ GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
+ random->nextULessThan(kGrProcessorEdgeTypeCnt));
+ gp = GrCubicEffect::Create(edgeType, caps);
+ } while (NULL == gp);
+ return gp;
}
diff --git a/src/gpu/effects/GrBezierEffect.h b/src/gpu/effects/GrBezierEffect.h
index 4da16fe88..cb79ac39c 100644
--- a/src/gpu/effects/GrBezierEffect.h
+++ b/src/gpu/effects/GrBezierEffect.h
@@ -9,7 +9,7 @@
#define GrBezierEffect_DEFINED
#include "GrDrawTargetCaps.h"
-#include "GrEffect.h"
+#include "GrProcessor.h"
#include "GrGeometryProcessor.h"
#include "GrTypesPriv.h"
@@ -57,24 +57,28 @@ class GrGLConicEffect;
class GrConicEffect : public GrGeometryProcessor {
public:
- static GrEffect* Create(const GrEffectEdgeType edgeType, const GrDrawTargetCaps& caps) {
- GR_CREATE_STATIC_EFFECT(gConicFillAA, GrConicEffect, (kFillAA_GrEffectEdgeType));
- GR_CREATE_STATIC_EFFECT(gConicHairAA, GrConicEffect, (kHairlineAA_GrEffectEdgeType));
- GR_CREATE_STATIC_EFFECT(gConicFillBW, GrConicEffect, (kFillBW_GrEffectEdgeType));
+ static GrGeometryProcessor* Create(const GrPrimitiveEdgeType edgeType,
+ const GrDrawTargetCaps& caps) {
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gConicFillAA, GrConicEffect,
+ (kFillAA_GrProcessorEdgeType));
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gConicHairAA, GrConicEffect,
+ (kHairlineAA_GrProcessorEdgeType));
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gConicFillBW, GrConicEffect,
+ (kFillBW_GrProcessorEdgeType));
switch (edgeType) {
- case kFillAA_GrEffectEdgeType:
+ case kFillAA_GrProcessorEdgeType:
if (!caps.shaderDerivativeSupport()) {
return NULL;
}
gConicFillAA->ref();
return gConicFillAA;
- case kHairlineAA_GrEffectEdgeType:
+ case kHairlineAA_GrProcessorEdgeType:
if (!caps.shaderDerivativeSupport()) {
return NULL;
}
gConicHairAA->ref();
return gConicHairAA;
- case kFillBW_GrEffectEdgeType:
+ case kFillBW_GrProcessorEdgeType:
gConicFillBW->ref();
return gConicFillBW;
default:
@@ -87,28 +91,28 @@ public:
static const char* Name() { return "Conic"; }
inline const GrShaderVar& inConicCoeffs() const { return fInConicCoeffs; }
- inline bool isAntiAliased() const { return GrEffectEdgeTypeIsAA(fEdgeType); }
- inline bool isFilled() const { return GrEffectEdgeTypeIsFill(fEdgeType); }
- inline GrEffectEdgeType getEdgeType() const { return fEdgeType; }
+ inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType); }
+ inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType); }
+ inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
- typedef GrGLConicEffect GLEffect;
+ typedef GrGLConicEffect GLProcessor;
virtual void getConstantColorComponents(GrColor* color,
uint32_t* validFlags) const SK_OVERRIDE {
*validFlags = 0;
}
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE;
private:
- GrConicEffect(GrEffectEdgeType);
+ GrConicEffect(GrPrimitiveEdgeType);
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE;
- GrEffectEdgeType fEdgeType;
+ GrPrimitiveEdgeType fEdgeType;
const GrShaderVar& fInConicCoeffs;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
typedef GrGeometryProcessor INHERITED;
};
@@ -126,24 +130,28 @@ class GrGLQuadEffect;
class GrQuadEffect : public GrGeometryProcessor {
public:
- static GrEffect* Create(const GrEffectEdgeType edgeType, const GrDrawTargetCaps& caps) {
- GR_CREATE_STATIC_EFFECT(gQuadFillAA, GrQuadEffect, (kFillAA_GrEffectEdgeType));
- GR_CREATE_STATIC_EFFECT(gQuadHairAA, GrQuadEffect, (kHairlineAA_GrEffectEdgeType));
- GR_CREATE_STATIC_EFFECT(gQuadFillBW, GrQuadEffect, (kFillBW_GrEffectEdgeType));
+ static GrGeometryProcessor* Create(const GrPrimitiveEdgeType edgeType,
+ const GrDrawTargetCaps& caps) {
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gQuadFillAA, GrQuadEffect,
+ (kFillAA_GrProcessorEdgeType));
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gQuadHairAA, GrQuadEffect,
+ (kHairlineAA_GrProcessorEdgeType));
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gQuadFillBW, GrQuadEffect,
+ (kFillBW_GrProcessorEdgeType));
switch (edgeType) {
- case kFillAA_GrEffectEdgeType:
+ case kFillAA_GrProcessorEdgeType:
if (!caps.shaderDerivativeSupport()) {
return NULL;
}
gQuadFillAA->ref();
return gQuadFillAA;
- case kHairlineAA_GrEffectEdgeType:
+ case kHairlineAA_GrProcessorEdgeType:
if (!caps.shaderDerivativeSupport()) {
return NULL;
}
gQuadHairAA->ref();
return gQuadHairAA;
- case kFillBW_GrEffectEdgeType:
+ case kFillBW_GrProcessorEdgeType:
gQuadFillBW->ref();
return gQuadFillBW;
default:
@@ -156,28 +164,28 @@ public:
static const char* Name() { return "Quad"; }
inline const GrShaderVar& inHairQuadEdge() const { return fInHairQuadEdge; }
- inline bool isAntiAliased() const { return GrEffectEdgeTypeIsAA(fEdgeType); }
- inline bool isFilled() const { return GrEffectEdgeTypeIsFill(fEdgeType); }
- inline GrEffectEdgeType getEdgeType() const { return fEdgeType; }
+ inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType); }
+ inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType); }
+ inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
- typedef GrGLQuadEffect GLEffect;
+ typedef GrGLQuadEffect GLProcessor;
virtual void getConstantColorComponents(GrColor* color,
uint32_t* validFlags) const SK_OVERRIDE {
*validFlags = 0;
}
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE;
private:
- GrQuadEffect(GrEffectEdgeType);
+ GrQuadEffect(GrPrimitiveEdgeType);
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE;
- GrEffectEdgeType fEdgeType;
+ GrPrimitiveEdgeType fEdgeType;
const GrShaderVar& fInHairQuadEdge;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
typedef GrGeometryProcessor INHERITED;
};
@@ -197,24 +205,28 @@ class GrGLCubicEffect;
class GrCubicEffect : public GrGeometryProcessor {
public:
- static GrEffect* Create(const GrEffectEdgeType edgeType, const GrDrawTargetCaps& caps) {
- GR_CREATE_STATIC_EFFECT(gCubicFillAA, GrCubicEffect, (kFillAA_GrEffectEdgeType));
- GR_CREATE_STATIC_EFFECT(gCubicHairAA, GrCubicEffect, (kHairlineAA_GrEffectEdgeType));
- GR_CREATE_STATIC_EFFECT(gCubicFillBW, GrCubicEffect, (kFillBW_GrEffectEdgeType));
+ static GrGeometryProcessor* Create(const GrPrimitiveEdgeType edgeType,
+ const GrDrawTargetCaps& caps) {
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gCubicFillAA, GrCubicEffect,
+ (kFillAA_GrProcessorEdgeType));
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gCubicHairAA, GrCubicEffect,
+ (kHairlineAA_GrProcessorEdgeType));
+ GR_CREATE_STATIC_GEOMETRY_PROCESSOR(gCubicFillBW, GrCubicEffect,
+ (kFillBW_GrProcessorEdgeType));
switch (edgeType) {
- case kFillAA_GrEffectEdgeType:
+ case kFillAA_GrProcessorEdgeType:
if (!caps.shaderDerivativeSupport()) {
return NULL;
}
gCubicFillAA->ref();
return gCubicFillAA;
- case kHairlineAA_GrEffectEdgeType:
+ case kHairlineAA_GrProcessorEdgeType:
if (!caps.shaderDerivativeSupport()) {
return NULL;
}
gCubicHairAA->ref();
return gCubicHairAA;
- case kFillBW_GrEffectEdgeType:
+ case kFillBW_GrProcessorEdgeType:
gCubicFillBW->ref();
return gCubicFillBW;
default:
@@ -227,28 +239,28 @@ public:
static const char* Name() { return "Cubic"; }
inline const GrShaderVar& inCubicCoeffs() const { return fInCubicCoeffs; }
- inline bool isAntiAliased() const { return GrEffectEdgeTypeIsAA(fEdgeType); }
- inline bool isFilled() const { return GrEffectEdgeTypeIsFill(fEdgeType); }
- inline GrEffectEdgeType getEdgeType() const { return fEdgeType; }
+ inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType); }
+ inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType); }
+ inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
- typedef GrGLCubicEffect GLEffect;
+ typedef GrGLCubicEffect GLProcessor;
virtual void getConstantColorComponents(GrColor* color,
uint32_t* validFlags) const SK_OVERRIDE {
*validFlags = 0;
}
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE;
private:
- GrCubicEffect(GrEffectEdgeType);
+ GrCubicEffect(GrPrimitiveEdgeType);
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE;
- GrEffectEdgeType fEdgeType;
+ GrPrimitiveEdgeType fEdgeType;
const GrShaderVar& fInCubicCoeffs;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
typedef GrGeometryProcessor INHERITED;
};
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index e08a60220..d73e604b0 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -19,23 +19,23 @@ const SkScalar GrBicubicEffect::gMitchellCoefficients[16] = {
};
-class GrGLBicubicEffect : public GrGLEffect {
+class GrGLBicubicEffect : public GrGLFragmentProcessor {
public:
- GrGLBicubicEffect(const GrBackendEffectFactory& factory,
- const GrEffect&);
+ GrGLBicubicEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor&);
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
+ static inline void GenKey(const GrProcessor& effect, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
const GrTextureDomain& domain = effect.cast<GrBicubicEffect>().domain();
b->add32(GrTextureDomain::GLDomain::DomainKey(domain));
}
@@ -47,16 +47,16 @@ private:
UniformHandle fImageIncrementUni;
GrTextureDomain::GLDomain fDomain;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
-GrGLBicubicEffect::GrGLBicubicEffect(const GrBackendEffectFactory& factory, const GrEffect&)
+GrGLBicubicEffect::GrGLBicubicEffect(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED(factory) {
}
void GrGLBicubicEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& effect,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -116,9 +116,9 @@ void GrGLBicubicEffect::emitCode(GrGLProgramBuilder* builder,
}
void GrGLBicubicEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
- const GrBicubicEffect& bicubicEffect = effect.cast<GrBicubicEffect>();
- const GrTexture& texture = *effect.texture(0);
+ const GrProcessor& processor) {
+ const GrBicubicEffect& bicubicEffect = processor.cast<GrBicubicEffect>();
+ const GrTexture& texture = *processor.texture(0);
float imageIncrement[2];
imageIncrement[0] = 1.0f / texture.width();
imageIncrement[1] = 1.0f / texture.height();
@@ -158,11 +158,11 @@ GrBicubicEffect::GrBicubicEffect(GrTexture* texture,
GrBicubicEffect::~GrBicubicEffect() {
}
-const GrBackendEffectFactory& GrBicubicEffect::getFactory() const {
- return GrTBackendEffectFactory<GrBicubicEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& GrBicubicEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<GrBicubicEffect>::getInstance();
}
-bool GrBicubicEffect::onIsEqual(const GrEffect& sBase) const {
+bool GrBicubicEffect::onIsEqual(const GrProcessor& sBase) const {
const GrBicubicEffect& s = sBase.cast<GrBicubicEffect>();
return this->textureAccess(0) == s.textureAccess(0) &&
!memcmp(fCoefficients, s.coefficients(), 16) &&
@@ -175,14 +175,14 @@ void GrBicubicEffect::getConstantColorComponents(GrColor* color, uint32_t* valid
return;
}
-GR_DEFINE_EFFECT_TEST(GrBicubicEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrBicubicEffect);
-GrEffect* GrBicubicEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
- int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
- GrEffectUnitTest::kAlphaTextureIdx;
+GrFragmentProcessor* GrBicubicEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
+ int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
+ GrProcessorUnitTest::kAlphaTextureIdx;
SkScalar coefficients[16];
for (int i = 0; i < 16; i++) {
coefficients[i] = random->nextSScalar1();
diff --git a/src/gpu/effects/GrBicubicEffect.h b/src/gpu/effects/GrBicubicEffect.h
index 2c1a299f5..03476da38 100644
--- a/src/gpu/effects/GrBicubicEffect.h
+++ b/src/gpu/effects/GrBicubicEffect.h
@@ -10,8 +10,8 @@
#include "GrSingleTextureEffect.h"
#include "GrTextureDomain.h"
-#include "gl/GrGLEffect.h"
-#include "GrTBackendEffectFactory.h"
+#include "gl/GrGLProcessor.h"
+#include "GrTBackendProcessorFactory.h"
class GrGLBicubicEffect;
@@ -26,9 +26,9 @@ public:
static const char* Name() { return "Bicubic"; }
const float* coefficients() const { return fCoefficients; }
- typedef GrGLBicubicEffect GLEffect;
+ typedef GrGLBicubicEffect GLProcessor;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
const GrTextureDomain& domain() const { return fDomain; }
@@ -36,7 +36,7 @@ public:
/**
* Create a simple filter effect with custom bicubic coefficients and optional domain.
*/
- static GrEffect* Create(GrTexture* tex, const SkScalar coefficients[16],
+ static GrFragmentProcessor* Create(GrTexture* tex, const SkScalar coefficients[16],
const SkRect* domain = NULL) {
if (NULL == domain) {
static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_TileMode,
@@ -53,7 +53,7 @@ public:
/**
* Create a Mitchell filter effect with specified texture matrix and x/y tile modes.
*/
- static GrEffect* Create(GrTexture* tex, const SkMatrix& matrix,
+ static GrFragmentProcessor* Create(GrTexture* tex, const SkMatrix& matrix,
SkShader::TileMode tileModes[2]) {
return Create(tex, gMitchellCoefficients, matrix, tileModes);
}
@@ -62,15 +62,17 @@ public:
* Create a filter effect with custom bicubic coefficients, the texture matrix, and the x/y
* tilemodes.
*/
- static GrEffect* Create(GrTexture* tex, const SkScalar coefficients[16],
- const SkMatrix& matrix, const SkShader::TileMode tileModes[2]) {
+ static GrFragmentProcessor* Create(GrTexture* tex, const SkScalar coefficients[16],
+ const SkMatrix& matrix,
+ const SkShader::TileMode tileModes[2]) {
return SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, matrix, tileModes));
}
/**
* Create a Mitchell filter effect with a texture matrix and a domain.
*/
- static GrEffect* Create(GrTexture* tex, const SkMatrix& matrix, const SkRect& domain) {
+ static GrFragmentProcessor* Create(GrTexture* tex, const SkMatrix& matrix,
+ const SkRect& domain) {
return SkNEW_ARGS(GrBicubicEffect, (tex, gMitchellCoefficients, matrix, domain));
}
@@ -89,12 +91,12 @@ private:
const SkMatrix &matrix, const SkShader::TileMode tileModes[2]);
GrBicubicEffect(GrTexture*, const SkScalar coefficients[16],
const SkMatrix &matrix, const SkRect& domain);
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
float fCoefficients[16];
GrTextureDomain fDomain;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
static const SkScalar gMitchellCoefficients[16];
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 40003068a..3042d86f0 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -7,25 +7,26 @@
#include "GrConfigConversionEffect.h"
#include "GrContext.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "GrSimpleTextureEffect.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "SkMatrix.h"
-class GrGLConfigConversionEffect : public GrGLEffect {
+class GrGLConfigConversionEffect : public GrGLFragmentProcessor {
public:
- GrGLConfigConversionEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+ GrGLConfigConversionEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor& processor)
: INHERITED (factory) {
- const GrConfigConversionEffect& configConversionEffect = effect.cast<GrConfigConversionEffect>();
+ const GrConfigConversionEffect& configConversionEffect =
+ processor.cast<GrConfigConversionEffect>();
fSwapRedAndBlue = configConversionEffect.swapsRedAndBlue();
fPMConversion = configConversionEffect.pmConversion();
}
virtual void emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey& key,
+ const GrFragmentProcessor&,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -84,9 +85,9 @@ public:
fsBuilder->codeAppend(modulate.c_str());
}
- static inline void GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
- const GrConfigConversionEffect& conv = effect.cast<GrConfigConversionEffect>();
+ static inline void GenKey(const GrProcessor& processor, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
+ const GrConfigConversionEffect& conv = processor.cast<GrConfigConversionEffect>();
uint32_t key = (conv.swapsRedAndBlue() ? 0 : 1) | (conv.pmConversion() << 1);
b->add32(key);
}
@@ -95,7 +96,7 @@ private:
bool fSwapRedAndBlue;
GrConfigConversionEffect::PMConversion fPMConversion;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
@@ -114,11 +115,11 @@ GrConfigConversionEffect::GrConfigConversionEffect(GrTexture* texture,
SkASSERT(swapRedAndBlue || kNone_PMConversion != pmConversion);
}
-const GrBackendEffectFactory& GrConfigConversionEffect::getFactory() const {
- return GrTBackendEffectFactory<GrConfigConversionEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& GrConfigConversionEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<GrConfigConversionEffect>::getInstance();
}
-bool GrConfigConversionEffect::onIsEqual(const GrEffect& s) const {
+bool GrConfigConversionEffect::onIsEqual(const GrProcessor& s) const {
const GrConfigConversionEffect& other = s.cast<GrConfigConversionEffect>();
return this->texture(0) == s.texture(0) &&
other.fSwapRedAndBlue == fSwapRedAndBlue &&
@@ -132,12 +133,12 @@ void GrConfigConversionEffect::getConstantColorComponents(GrColor* color,
///////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrConfigConversionEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConfigConversionEffect);
-GrEffect* GrConfigConversionEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
+GrFragmentProcessor* GrConfigConversionEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
PMConversion pmConv = static_cast<PMConversion>(random->nextULessThan(kPMConversionCnt));
bool swapRB;
if (kNone_PMConversion == pmConv) {
@@ -146,10 +147,10 @@ GrEffect* GrConfigConversionEffect::TestCreate(SkRandom* random,
swapRB = random->nextBool();
}
return SkNEW_ARGS(GrConfigConversionEffect,
- (textures[GrEffectUnitTest::kSkiaPMTextureIdx],
+ (textures[GrProcessorUnitTest::kSkiaPMTextureIdx],
swapRB,
pmConv,
- GrEffectUnitTest::TestMatrix(random)));
+ GrProcessorUnitTest::TestMatrix(random)));
}
///////////////////////////////////////////////////////////////////////////////
@@ -215,34 +216,31 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
// from readTex to tempTex followed by a PM->UPM draw to readTex and finally read the data.
// We then verify that two reads produced the same values.
- SkAutoTUnref<GrEffect> pmToUPM1(SkNEW_ARGS(GrConfigConversionEffect, (dataTex,
- false,
- *pmToUPMRule,
- SkMatrix::I())));
- SkAutoTUnref<GrEffect> upmToPM(SkNEW_ARGS(GrConfigConversionEffect, (readTex,
- false,
- *upmToPMRule,
- SkMatrix::I())));
- SkAutoTUnref<GrEffect> pmToUPM2(SkNEW_ARGS(GrConfigConversionEffect, (tempTex,
- false,
- *pmToUPMRule,
- SkMatrix::I())));
+ SkAutoTUnref<GrFragmentProcessor> pmToUPM1(
+ SkNEW_ARGS(GrConfigConversionEffect,
+ (dataTex, false, *pmToUPMRule, SkMatrix::I())));
+ SkAutoTUnref<GrFragmentProcessor> upmToPM(
+ SkNEW_ARGS(GrConfigConversionEffect,
+ (readTex, false, *upmToPMRule, SkMatrix::I())));
+ SkAutoTUnref<GrFragmentProcessor> pmToUPM2(
+ SkNEW_ARGS(GrConfigConversionEffect,
+ (tempTex, false, *pmToUPMRule, SkMatrix::I())));
context->setRenderTarget(readTex->asRenderTarget());
GrPaint paint1;
- paint1.addColorEffect(pmToUPM1);
+ paint1.addColorProcessor(pmToUPM1);
context->drawRectToRect(paint1, kDstRect, kSrcRect);
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead);
context->setRenderTarget(tempTex->asRenderTarget());
GrPaint paint2;
- paint2.addColorEffect(upmToPM);
+ paint2.addColorProcessor(upmToPM);
context->drawRectToRect(paint2, kDstRect, kSrcRect);
context->setRenderTarget(readTex->asRenderTarget());
GrPaint paint3;
- paint3.addColorEffect(pmToUPM2);
+ paint3.addColorProcessor(pmToUPM2);
context->drawRectToRect(paint3, kDstRect, kSrcRect);
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead);
@@ -263,7 +261,7 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
}
}
-const GrEffect* GrConfigConversionEffect::Create(GrTexture* texture,
+const GrFragmentProcessor* GrConfigConversionEffect::Create(GrTexture* texture,
bool swapRedAndBlue,
PMConversion pmConversion,
const SkMatrix& matrix) {
diff --git a/src/gpu/effects/GrConfigConversionEffect.h b/src/gpu/effects/GrConfigConversionEffect.h
index 4416d0545..765e49b45 100644
--- a/src/gpu/effects/GrConfigConversionEffect.h
+++ b/src/gpu/effects/GrConfigConversionEffect.h
@@ -10,7 +10,7 @@
#include "GrSingleTextureEffect.h"
-class GrEffectStage;
+class GrProcessorStage;
class GrGLConfigConversionEffect;
/**
@@ -34,16 +34,14 @@ public:
kPMConversionCnt
};
- // Installs an effect in the GrEffectStage to perform a config conversion.
- static const GrEffect* Create(GrTexture*,
- bool swapRedAndBlue,
- PMConversion pmConversion,
- const SkMatrix& matrix);
+ // Installs an effect in the GrProcessorStage to perform a config conversion.
+ static const GrFragmentProcessor* Create(GrTexture*, bool swapRedAndBlue, PMConversion,
+ const SkMatrix&);
static const char* Name() { return "Config Conversion"; }
- typedef GrGLConfigConversionEffect GLEffect;
+ typedef GrGLConfigConversionEffect GLProcessor;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
@@ -65,12 +63,12 @@ private:
PMConversion pmConversion,
const SkMatrix& matrix);
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
bool fSwapRedAndBlue;
PMConversion fPMConversion;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
typedef GrSingleTextureEffect INHERITED;
};
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index afe3674d5..4857a9e96 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -8,24 +8,24 @@
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrConvexPolyEffect.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "SkPath.h"
//////////////////////////////////////////////////////////////////////////////
class GLAARectEffect;
-class AARectEffect : public GrEffect {
+class AARectEffect : public GrFragmentProcessor {
public:
- typedef GLAARectEffect GLEffect;
+ typedef GLAARectEffect GLProcessor;
const SkRect& getRect() const { return fRect; }
static const char* Name() { return "AARect"; }
- static GrEffect* Create(GrEffectEdgeType edgeType, const SkRect& rect) {
+ static GrFragmentProcessor* Create(GrPrimitiveEdgeType edgeType, const SkRect& rect) {
return SkNEW_ARGS(AARectEffect, (edgeType, rect));
}
@@ -40,87 +40,87 @@ public:
}
}
- GrEffectEdgeType getEdgeType() const { return fEdgeType; }
+ GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
private:
- AARectEffect(GrEffectEdgeType edgeType, const SkRect& rect) : fRect(rect), fEdgeType(edgeType) {
+ AARectEffect(GrPrimitiveEdgeType edgeType, const SkRect& rect) : fRect(rect), fEdgeType(edgeType) {
this->setWillReadFragmentPosition();
}
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE {
const AARectEffect& aare = other.cast<AARectEffect>();
return fRect == aare.fRect;
}
- SkRect fRect;
- GrEffectEdgeType fEdgeType;
+ SkRect fRect;
+ GrPrimitiveEdgeType fEdgeType;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
};
-GR_DEFINE_EFFECT_TEST(AARectEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(AARectEffect);
-GrEffect* AARectEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
+GrFragmentProcessor* AARectEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
SkRect rect = SkRect::MakeLTRB(random->nextSScalar1(),
random->nextSScalar1(),
random->nextSScalar1(),
random->nextSScalar1());
- GrEffect* effect;
+ GrFragmentProcessor* fp;
do {
- GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(random->nextULessThan(
- kGrEffectEdgeTypeCnt));
+ GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(random->nextULessThan(
+ kGrProcessorEdgeTypeCnt));
- effect = AARectEffect::Create(edgeType, rect);
- } while (NULL == effect);
- return effect;
+ fp = AARectEffect::Create(edgeType, rect);
+ } while (NULL == fp);
+ return fp;
}
//////////////////////////////////////////////////////////////////////////////
-class GLAARectEffect : public GrGLEffect {
+class GLAARectEffect : public GrGLFragmentProcessor {
public:
- GLAARectEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GLAARectEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& fp,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
private:
GrGLProgramDataManager::UniformHandle fRectUniform;
SkRect fPrevRect;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
-GLAARectEffect::GLAARectEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GLAARectEffect::GLAARectEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor& effect)
: INHERITED (factory) {
fPrevRect.fLeft = SK_ScalarNaN;
}
void GLAARectEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& fp,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) {
- const AARectEffect& aare = effect.cast<AARectEffect>();
+ const AARectEffect& aare = fp.cast<AARectEffect>();
const char *rectName;
// The rect uniform's xyzw refer to (left + 0.5, top + 0.5, right - 0.5, bottom - 0.5),
// respectively.
@@ -131,7 +131,7 @@ void GLAARectEffect::emitCode(GrGLProgramBuilder* builder,
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
const char* fragmentPos = fsBuilder->fragmentPosition();
- if (GrEffectEdgeTypeIsAA(aare.getEdgeType())) {
+ if (GrProcessorEdgeTypeIsAA(aare.getEdgeType())) {
// The amount of coverage removed in x and y by the edges is computed as a pair of negative
// numbers, xSub and ySub.
fsBuilder->codeAppend("\t\tfloat xSub, ySub;\n");
@@ -150,15 +150,15 @@ void GLAARectEffect::emitCode(GrGLProgramBuilder* builder,
fsBuilder->codeAppendf("\t\talpha *= (%s.w - %s.y) > -0.5 ? 1.0 : 0.0;\n", rectName, fragmentPos);
}
- if (GrEffectEdgeTypeIsInverseFill(aare.getEdgeType())) {
+ if (GrProcessorEdgeTypeIsInverseFill(aare.getEdgeType())) {
fsBuilder->codeAppend("\t\talpha = 1.0 - alpha;\n");
}
fsBuilder->codeAppendf("\t\t%s = %s;\n", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
}
-void GLAARectEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect& effect) {
- const AARectEffect& aare = effect.cast<AARectEffect>();
+void GLAARectEffect::setData(const GrGLProgramDataManager& pdman, const GrProcessor& processor) {
+ const AARectEffect& aare = processor.cast<AARectEffect>();
const SkRect& rect = aare.getRect();
if (rect != fPrevRect) {
pdman.set4f(fRectUniform, rect.fLeft + 0.5f, rect.fTop + 0.5f,
@@ -167,54 +167,54 @@ void GLAARectEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect
}
}
-void GLAARectEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
- const AARectEffect& aare = effect.cast<AARectEffect>();
+void GLAARectEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
+ const AARectEffect& aare = processor.cast<AARectEffect>();
b->add32(aare.getEdgeType());
}
-const GrBackendEffectFactory& AARectEffect::getFactory() const {
- return GrTBackendEffectFactory<AARectEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& AARectEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<AARectEffect>::getInstance();
}
//////////////////////////////////////////////////////////////////////////////
-class GrGLConvexPolyEffect : public GrGLEffect {
+class GrGLConvexPolyEffect : public GrGLFragmentProcessor {
public:
- GrGLConvexPolyEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GrGLConvexPolyEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& fp,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
private:
GrGLProgramDataManager::UniformHandle fEdgeUniform;
SkScalar fPrevEdges[3 * GrConvexPolyEffect::kMaxEdges];
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
-GrGLConvexPolyEffect::GrGLConvexPolyEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GrGLConvexPolyEffect::GrGLConvexPolyEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor&)
: INHERITED (factory) {
fPrevEdges[0] = SK_ScalarNaN;
}
void GrGLConvexPolyEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& fp,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) {
- const GrConvexPolyEffect& cpe = effect.cast<GrConvexPolyEffect>();
+ const GrConvexPolyEffect& cpe = fp.cast<GrConvexPolyEffect>();
const char *edgeArrayName;
fEdgeUniform = builder->addUniformArray(GrGLProgramBuilder::kFragment_Visibility,
@@ -229,7 +229,7 @@ void GrGLConvexPolyEffect::emitCode(GrGLProgramBuilder* builder,
for (int i = 0; i < cpe.getEdgeCount(); ++i) {
fsBuilder->codeAppendf("\t\tedge = dot(%s[%d], vec3(%s.x, %s.y, 1));\n",
edgeArrayName, i, fragmentPos, fragmentPos);
- if (GrEffectEdgeTypeIsAA(cpe.getEdgeType())) {
+ if (GrProcessorEdgeTypeIsAA(cpe.getEdgeType())) {
fsBuilder->codeAppend("\t\tedge = clamp(edge, 0.0, 1.0);\n");
} else {
fsBuilder->codeAppend("\t\tedge = edge >= 0.5 ? 1.0 : 0.0;\n");
@@ -242,14 +242,14 @@ void GrGLConvexPolyEffect::emitCode(GrGLProgramBuilder* builder,
fsBuilder->codeAppend("\t\tif (-1.0 == alpha) {\n\t\t\tdiscard;\n\t\t}\n");
}
- if (GrEffectEdgeTypeIsInverseFill(cpe.getEdgeType())) {
+ if (GrProcessorEdgeTypeIsInverseFill(cpe.getEdgeType())) {
fsBuilder->codeAppend("\talpha = 1.0 - alpha;\n");
}
fsBuilder->codeAppendf("\t%s = %s;\n", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
}
-void GrGLConvexPolyEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect& effect) {
+void GrGLConvexPolyEffect::setData(const GrGLProgramDataManager& pdman, const GrProcessor& effect) {
const GrConvexPolyEffect& cpe = effect.cast<GrConvexPolyEffect>();
size_t byteSize = 3 * cpe.getEdgeCount() * sizeof(SkScalar);
if (0 != memcmp(fPrevEdges, cpe.getEdges(), byteSize)) {
@@ -258,19 +258,19 @@ void GrGLConvexPolyEffect::setData(const GrGLProgramDataManager& pdman, const Gr
}
}
-void GrGLConvexPolyEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
- const GrConvexPolyEffect& cpe = effect.cast<GrConvexPolyEffect>();
- GR_STATIC_ASSERT(kGrEffectEdgeTypeCnt <= 8);
+void GrGLConvexPolyEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
+ const GrConvexPolyEffect& cpe = processor.cast<GrConvexPolyEffect>();
+ GR_STATIC_ASSERT(kGrProcessorEdgeTypeCnt <= 8);
uint32_t key = (cpe.getEdgeCount() << 3) | cpe.getEdgeType();
b->add32(key);
}
//////////////////////////////////////////////////////////////////////////////
-GrEffect* GrConvexPolyEffect::Create(GrEffectEdgeType type, const SkPath& path,
- const SkVector* offset) {
- if (kHairlineAA_GrEffectEdgeType == type) {
+GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType type, const SkPath& path,
+ const SkVector* offset) {
+ if (kHairlineAA_GrProcessorEdgeType == type) {
return NULL;
}
if (path.getSegmentMasks() != SkPath::kLine_SegmentMask ||
@@ -314,13 +314,13 @@ GrEffect* GrConvexPolyEffect::Create(GrEffectEdgeType type, const SkPath& path,
}
}
if (path.isInverseFillType()) {
- type = GrInvertEffectEdgeType(type);
+ type = GrInvertProcessorEdgeType(type);
}
return Create(type, n, edges);
}
-GrEffect* GrConvexPolyEffect::Create(GrEffectEdgeType edgeType, const SkRect& rect) {
- if (kHairlineAA_GrEffectEdgeType == edgeType){
+GrFragmentProcessor* GrConvexPolyEffect::Create(GrPrimitiveEdgeType edgeType, const SkRect& rect) {
+ if (kHairlineAA_GrProcessorEdgeType == edgeType){
return NULL;
}
return AARectEffect::Create(edgeType, rect);
@@ -332,11 +332,11 @@ void GrConvexPolyEffect::getConstantColorComponents(GrColor* color, uint32_t* va
*validFlags = 0;
}
-const GrBackendEffectFactory& GrConvexPolyEffect::getFactory() const {
- return GrTBackendEffectFactory<GrConvexPolyEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& GrConvexPolyEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<GrConvexPolyEffect>::getInstance();
}
-GrConvexPolyEffect::GrConvexPolyEffect(GrEffectEdgeType edgeType, int n, const SkScalar edges[])
+GrConvexPolyEffect::GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, const SkScalar edges[])
: fEdgeType(edgeType)
, fEdgeCount(n) {
// Factory function should have already ensured this.
@@ -350,7 +350,7 @@ GrConvexPolyEffect::GrConvexPolyEffect(GrEffectEdgeType edgeType, int n, const S
this->setWillReadFragmentPosition();
}
-bool GrConvexPolyEffect::onIsEqual(const GrEffect& other) const {
+bool GrConvexPolyEffect::onIsEqual(const GrProcessor& other) const {
const GrConvexPolyEffect& cpe = other.cast<GrConvexPolyEffect>();
// ignore the fact that 0 == -0 and just use memcmp.
return (cpe.fEdgeType == fEdgeType && cpe.fEdgeCount == fEdgeCount &&
@@ -359,23 +359,23 @@ bool GrConvexPolyEffect::onIsEqual(const GrEffect& other) const {
//////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrConvexPolyEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConvexPolyEffect);
-GrEffect* GrConvexPolyEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
+GrFragmentProcessor* GrConvexPolyEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
int count = random->nextULessThan(kMaxEdges) + 1;
SkScalar edges[kMaxEdges * 3];
for (int i = 0; i < 3 * count; ++i) {
edges[i] = random->nextSScalar1();
}
- GrEffect* effect;
+ GrFragmentProcessor* fp;
do {
- GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(
- random->nextULessThan(kGrEffectEdgeTypeCnt));
- effect = GrConvexPolyEffect::Create(edgeType, count, edges);
- } while (NULL == effect);
- return effect;
+ GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(
+ random->nextULessThan(kGrProcessorEdgeTypeCnt));
+ fp = GrConvexPolyEffect::Create(edgeType, count, edges);
+ } while (NULL == fp);
+ return fp;
}
diff --git a/src/gpu/effects/GrConvexPolyEffect.h b/src/gpu/effects/GrConvexPolyEffect.h
index 9164b3ecf..e4749390a 100644
--- a/src/gpu/effects/GrConvexPolyEffect.h
+++ b/src/gpu/effects/GrConvexPolyEffect.h
@@ -9,7 +9,7 @@
#define GrConvexPolyEffect_DEFINED
#include "GrDrawTargetCaps.h"
-#include "GrEffect.h"
+#include "GrProcessor.h"
#include "GrTypesPriv.h"
class GrGLConvexPolyEffect;
@@ -20,7 +20,7 @@ class SkPath;
* Bounding geometry is rendered and the effect computes coverage based on the fragment's
* position relative to the polygon.
*/
-class GrConvexPolyEffect : public GrEffect {
+class GrConvexPolyEffect : public GrFragmentProcessor {
public:
enum {
kMaxEdges = 8,
@@ -37,8 +37,9 @@ public:
* have to modify the effect/shaderbuilder interface to make it possible (e.g. give access
* to the view matrix or untransformed positions in the fragment shader).
*/
- static GrEffect* Create(GrEffectEdgeType edgeType, int n, const SkScalar edges[]) {
- if (n <= 0 || n > kMaxEdges || kHairlineAA_GrEffectEdgeType == edgeType) {
+ static GrFragmentProcessor* Create(GrPrimitiveEdgeType edgeType, int n,
+ const SkScalar edges[]) {
+ if (n <= 0 || n > kMaxEdges || kHairlineAA_GrProcessorEdgeType == edgeType) {
return NULL;
}
return SkNEW_ARGS(GrConvexPolyEffect, (edgeType, n, edges));
@@ -49,41 +50,42 @@ public:
* inverse filled, or has too many edges, this will return NULL. If offset is non-NULL, then
* the path is translated by the vector.
*/
- static GrEffect* Create(GrEffectEdgeType, const SkPath&, const SkVector* offset = NULL);
+ static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkPath&,
+ const SkVector* offset = NULL);
/**
* Creates an effect that fills inside the rect with AA edges..
*/
- static GrEffect* Create(GrEffectEdgeType, const SkRect&);
+ static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkRect&);
virtual ~GrConvexPolyEffect();
static const char* Name() { return "ConvexPoly"; }
- GrEffectEdgeType getEdgeType() const { return fEdgeType; }
+ GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
int getEdgeCount() const { return fEdgeCount; }
const SkScalar* getEdges() const { return fEdges; }
- typedef GrGLConvexPolyEffect GLEffect;
+ typedef GrGLConvexPolyEffect GLProcessor;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
private:
- GrConvexPolyEffect(GrEffectEdgeType edgeType, int n, const SkScalar edges[]);
+ GrConvexPolyEffect(GrPrimitiveEdgeType edgeType, int n, const SkScalar edges[]);
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE;
- GrEffectEdgeType fEdgeType;
- int fEdgeCount;
- SkScalar fEdges[3 * kMaxEdges];
+ GrPrimitiveEdgeType fEdgeType;
+ int fEdgeCount;
+ SkScalar fEdges[3 * kMaxEdges];
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index b0abdcf9e..a836d43f2 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -7,29 +7,29 @@
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrConvolutionEffect.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
#include "gl/GrGLTexture.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
// For brevity
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
-class GrGLConvolutionEffect : public GrGLEffect {
+class GrGLConvolutionEffect : public GrGLFragmentProcessor {
public:
- GrGLConvolutionEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GrGLConvolutionEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLProgramDataManager& pdman, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager& pdman, const GrProcessor&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
private:
int width() const { return Gr1DKernelEffect::WidthFromRadius(fRadius); }
@@ -43,21 +43,21 @@ private:
UniformHandle fImageIncrementUni;
UniformHandle fBoundsUni;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
-GrGLConvolutionEffect::GrGLConvolutionEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GrGLConvolutionEffect::GrGLConvolutionEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor& processor)
: INHERITED(factory) {
- const GrConvolutionEffect& c = effect.cast<GrConvolutionEffect>();
+ const GrConvolutionEffect& c = processor.cast<GrConvolutionEffect>();
fRadius = c.radius();
fUseBounds = c.useBounds();
fDirection = c.direction();
}
void GrGLConvolutionEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey& key,
+ const GrFragmentProcessor&,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -106,8 +106,8 @@ void GrGLConvolutionEffect::emitCode(GrGLProgramBuilder* builder,
}
void GrGLConvolutionEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
- const GrConvolutionEffect& conv = effect.cast<GrConvolutionEffect>();
+ const GrProcessor& processor) {
+ const GrConvolutionEffect& conv = processor.cast<GrConvolutionEffect>();
GrTexture& texture = *conv.texture(0);
// the code we generated was for a specific kernel radius
SkASSERT(conv.radius() == fRadius);
@@ -136,9 +136,9 @@ void GrGLConvolutionEffect::setData(const GrGLProgramDataManager& pdman,
pdman.set1fv(fKernelUni, this->width(), conv.kernel());
}
-void GrGLConvolutionEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
- const GrConvolutionEffect& conv = effect.cast<GrConvolutionEffect>();
+void GrGLConvolutionEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
+ const GrConvolutionEffect& conv = processor.cast<GrConvolutionEffect>();
uint32_t key = conv.radius();
key <<= 2;
if (conv.useBounds()) {
@@ -196,11 +196,11 @@ GrConvolutionEffect::GrConvolutionEffect(GrTexture* texture,
GrConvolutionEffect::~GrConvolutionEffect() {
}
-const GrBackendEffectFactory& GrConvolutionEffect::getFactory() const {
- return GrTBackendEffectFactory<GrConvolutionEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& GrConvolutionEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<GrConvolutionEffect>::getInstance();
}
-bool GrConvolutionEffect::onIsEqual(const GrEffect& sBase) const {
+bool GrConvolutionEffect::onIsEqual(const GrProcessor& sBase) const {
const GrConvolutionEffect& s = sBase.cast<GrConvolutionEffect>();
return (this->texture(0) == s.texture(0) &&
this->radius() == s.radius() &&
@@ -212,14 +212,14 @@ bool GrConvolutionEffect::onIsEqual(const GrEffect& sBase) const {
///////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrConvolutionEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConvolutionEffect);
-GrEffect* GrConvolutionEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
- int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
- GrEffectUnitTest::kAlphaTextureIdx;
+GrFragmentProcessor* GrConvolutionEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
+ int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
+ GrProcessorUnitTest::kAlphaTextureIdx;
Direction dir = random->nextBool() ? kX_Direction : kY_Direction;
int radius = random->nextRangeU(1, kMaxKernelRadius);
float kernel[kMaxKernelWidth];
diff --git a/src/gpu/effects/GrConvolutionEffect.h b/src/gpu/effects/GrConvolutionEffect.h
index a96ea7be8..f2a2d5a77 100644
--- a/src/gpu/effects/GrConvolutionEffect.h
+++ b/src/gpu/effects/GrConvolutionEffect.h
@@ -22,12 +22,12 @@ class GrConvolutionEffect : public Gr1DKernelEffect {
public:
/// Convolve with an arbitrary user-specified kernel
- static GrEffect* Create(GrTexture* tex,
- Direction dir,
- int halfWidth,
- const float* kernel,
- bool useBounds,
- float bounds[2]) {
+ static GrFragmentProcessor* Create(GrTexture* tex,
+ Direction dir,
+ int halfWidth,
+ const float* kernel,
+ bool useBounds,
+ float bounds[2]) {
return SkNEW_ARGS(GrConvolutionEffect, (tex,
dir,
halfWidth,
@@ -37,12 +37,12 @@ public:
}
/// Convolve with a Gaussian kernel
- static GrEffect* CreateGaussian(GrTexture* tex,
- Direction dir,
- int halfWidth,
- float gaussianSigma,
- bool useBounds,
- float bounds[2]) {
+ static GrFragmentProcessor* CreateGaussian(GrTexture* tex,
+ Direction dir,
+ int halfWidth,
+ float gaussianSigma,
+ bool useBounds,
+ float bounds[2]) {
return SkNEW_ARGS(GrConvolutionEffect, (tex,
dir,
halfWidth,
@@ -60,9 +60,9 @@ public:
static const char* Name() { return "Convolution"; }
- typedef GrGLConvolutionEffect GLEffect;
+ typedef GrGLConvolutionEffect GLProcessor;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
virtual void getConstantColorComponents(GrColor*, uint32_t* validFlags) const {
// If the texture was opaque we could know that the output color if we knew the sum of the
@@ -101,9 +101,9 @@ private:
bool useBounds,
float bounds[2]);
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
typedef Gr1DKernelEffect INHERITED;
};
diff --git a/src/gpu/effects/GrCustomCoordsTextureEffect.cpp b/src/gpu/effects/GrCustomCoordsTextureEffect.cpp
index 212d181a2..b9794c149 100644
--- a/src/gpu/effects/GrCustomCoordsTextureEffect.cpp
+++ b/src/gpu/effects/GrCustomCoordsTextureEffect.cpp
@@ -7,27 +7,27 @@
#include "GrCustomCoordsTextureEffect.h"
#include "gl/builders/GrGLFullProgramBuilder.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
#include "gl/GrGLTexture.h"
#include "gl/GrGLGeometryProcessor.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "GrTexture.h"
class GrGLCustomCoordsTextureEffect : public GrGLGeometryProcessor {
public:
- GrGLCustomCoordsTextureEffect(const GrBackendEffectFactory& factory, const GrEffect& effect)
+ GrGLCustomCoordsTextureEffect(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED (factory) {}
virtual void emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) SK_OVERRIDE {
const GrCustomCoordsTextureEffect& customCoordsTextureEffect =
- effect.cast<GrCustomCoordsTextureEffect>();
+ geometryProcessor.cast<GrCustomCoordsTextureEffect>();
SkASSERT(1 == customCoordsTextureEffect.getVertexAttribs().count());
SkString fsCoordName;
@@ -40,7 +40,7 @@ public:
const GrShaderVar& inTextureCoords = customCoordsTextureEffect.inTextureCoords();
vsBuilder->codeAppendf("\t%s = %s;\n", vsVaryingName, inTextureCoords.c_str());
- GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+ GrGLProcessorFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
fsBuilder->codeAppendf("\t%s = ", outputColor);
fsBuilder->appendTextureLookupAndModulate(inputColor,
samplers[0],
@@ -49,8 +49,8 @@ public:
fsBuilder->codeAppend(";\n");
}
- virtual void setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) SK_OVERRIDE {}
+ virtual void setData(const GrGLProgramDataManager&,
+ const GrProcessor&) SK_OVERRIDE {}
private:
typedef GrGLGeometryProcessor INHERITED;
@@ -67,7 +67,7 @@ GrCustomCoordsTextureEffect::GrCustomCoordsTextureEffect(GrTexture* texture,
this->addTextureAccess(&fTextureAccess);
}
-bool GrCustomCoordsTextureEffect::onIsEqual(const GrEffect& other) const {
+bool GrCustomCoordsTextureEffect::onIsEqual(const GrProcessor& other) const {
const GrCustomCoordsTextureEffect& cte = other.cast<GrCustomCoordsTextureEffect>();
return fTextureAccess == cte.fTextureAccess;
}
@@ -82,20 +82,20 @@ void GrCustomCoordsTextureEffect::getConstantColorComponents(GrColor* color,
}
}
-const GrBackendEffectFactory& GrCustomCoordsTextureEffect::getFactory() const {
- return GrTBackendEffectFactory<GrCustomCoordsTextureEffect>::getInstance();
+const GrBackendGeometryProcessorFactory& GrCustomCoordsTextureEffect::getFactory() const {
+ return GrTBackendGeometryProcessorFactory<GrCustomCoordsTextureEffect>::getInstance();
}
///////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrCustomCoordsTextureEffect);
+GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCustomCoordsTextureEffect);
-GrEffect* GrCustomCoordsTextureEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
- int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
- GrEffectUnitTest::kAlphaTextureIdx;
+GrGeometryProcessor* GrCustomCoordsTextureEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
+ int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
+ GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
SkShader::kClamp_TileMode,
SkShader::kRepeat_TileMode,
diff --git a/src/gpu/effects/GrCustomCoordsTextureEffect.h b/src/gpu/effects/GrCustomCoordsTextureEffect.h
index 02e7c4401..f48a144c5 100644
--- a/src/gpu/effects/GrCustomCoordsTextureEffect.h
+++ b/src/gpu/effects/GrCustomCoordsTextureEffect.h
@@ -8,7 +8,7 @@
#ifndef GrCustomCoordsTextureEffect_DEFINED
#define GrCustomCoordsTextureEffect_DEFINED
-#include "GrEffect.h"
+#include "GrProcessor.h"
#include "GrGeometryProcessor.h"
class GrGLCustomCoordsTextureEffect;
@@ -20,7 +20,7 @@ class GrGLCustomCoordsTextureEffect;
*/
class GrCustomCoordsTextureEffect : public GrGeometryProcessor {
public:
- static GrEffect* Create(GrTexture* tex, const GrTextureParams& p) {
+ static GrGeometryProcessor* Create(GrTexture* tex, const GrTextureParams& p) {
return SkNEW_ARGS(GrCustomCoordsTextureEffect, (tex, p));
}
@@ -32,19 +32,19 @@ public:
const GrShaderVar& inTextureCoords() const { return fInTextureCoords; }
- typedef GrGLCustomCoordsTextureEffect GLEffect;
+ typedef GrGLCustomCoordsTextureEffect GLProcessor;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE;
private:
GrCustomCoordsTextureEffect(GrTexture* texture, const GrTextureParams& params);
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE;
GrTextureAccess fTextureAccess;
const GrShaderVar& fInTextureCoords;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
typedef GrGeometryProcessor INHERITED;
};
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp
index 38a2d4e4b..704a6ac3e 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -9,19 +9,19 @@
#include "../GrAARectRenderer.h"
-#include "effects/GrGeometryProcessor.h"
+#include "GrGeometryProcessor.h"
#include "gl/builders/GrGLFullProgramBuilder.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/GrGLGeometryProcessor.h"
#include "gl/GrGLSL.h"
#include "GrContext.h"
#include "GrCoordTransform.h"
#include "GrDrawTarget.h"
#include "GrDrawTargetCaps.h"
-#include "GrEffect.h"
+#include "GrProcessor.h"
#include "GrGpu.h"
#include "GrStrokeInfo.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "SkGr.h"
///////////////////////////////////////////////////////////////////////////////
@@ -75,7 +75,7 @@ extern const GrVertexAttrib gDashLineNoAAVertexAttribs[] = {
extern const GrVertexAttrib gDashLineVertexAttribs[] = {
{ kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding },
- { kVec2f_GrVertexAttribType, sizeof(SkPoint), kEffect_GrVertexAttribBinding },
+ { kVec2f_GrVertexAttribType, sizeof(SkPoint), kGeometryProcessor_GrVertexAttribBinding },
};
};
@@ -344,13 +344,13 @@ bool GrDashingEffect::DrawDashLine(const SkPoint pts[2], const GrPaint& paint,
devInfo.fPhase = devPhase;
devInfo.fCount = 2;
devInfo.fIntervals = devIntervals;
- GrEffectEdgeType edgeType= useAA ? kFillAA_GrEffectEdgeType :
- kFillBW_GrEffectEdgeType;
+ GrPrimitiveEdgeType edgeType= useAA ? kFillAA_GrProcessorEdgeType :
+ kFillBW_GrProcessorEdgeType;
bool isRoundCap = SkPaint::kRound_Cap == cap;
GrDashingEffect::DashCap capType = isRoundCap ? GrDashingEffect::kRound_DashCap :
GrDashingEffect::kNonRound_DashCap;
drawState->setGeometryProcessor(
- GrDashingEffect::Create(edgeType, devInfo, strokeWidth, capType))->unref();
+ GrDashingEffect::Create(edgeType, devInfo, strokeWidth, capType))->unref();
// Set up the vertex data for the line and start/end dashes
drawState->setVertexAttribs<gDashLineVertexAttribs>(SK_ARRAY_COUNT(gDashLineVertexAttribs),
@@ -436,7 +436,9 @@ class DashingCircleEffect : public GrGeometryProcessor {
public:
typedef SkPathEffect::DashInfo DashInfo;
- static GrEffect* Create(GrEffectEdgeType edgeType, const DashInfo& info, SkScalar radius);
+ static GrGeometryProcessor* Create(GrPrimitiveEdgeType edgeType,
+ const DashInfo& info,
+ SkScalar radius);
virtual ~DashingCircleEffect();
@@ -444,7 +446,7 @@ public:
const GrShaderVar& inCoord() const { return fInCoord; }
- GrEffectEdgeType getEdgeType() const { return fEdgeType; }
+ GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
SkScalar getRadius() const { return fRadius; }
@@ -452,24 +454,24 @@ public:
SkScalar getIntervalLength() const { return fIntervalLength; }
- typedef GLDashingCircleEffect GLEffect;
+ typedef GLDashingCircleEffect GLProcessor;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE;
private:
- DashingCircleEffect(GrEffectEdgeType edgeType, const DashInfo& info, SkScalar radius);
+ DashingCircleEffect(GrPrimitiveEdgeType edgeType, const DashInfo& info, SkScalar radius);
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE;
- GrEffectEdgeType fEdgeType;
+ GrPrimitiveEdgeType fEdgeType;
const GrShaderVar& fInCoord;
SkScalar fIntervalLength;
SkScalar fRadius;
SkScalar fCenterX;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
typedef GrGeometryProcessor INHERITED;
};
@@ -478,19 +480,19 @@ private:
class GLDashingCircleEffect : public GrGLGeometryProcessor {
public:
- GLDashingCircleEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GLDashingCircleEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
private:
GrGLProgramDataManager::UniformHandle fParamUniform;
@@ -500,8 +502,8 @@ private:
typedef GrGLGeometryProcessor INHERITED;
};
-GLDashingCircleEffect::GLDashingCircleEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GLDashingCircleEffect::GLDashingCircleEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor&)
: INHERITED (factory) {
fPrevRadius = SK_ScalarMin;
fPrevCenterX = SK_ScalarMin;
@@ -509,13 +511,13 @@ GLDashingCircleEffect::GLDashingCircleEffect(const GrBackendEffectFactory& facto
}
void GLDashingCircleEffect::emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) {
- const DashingCircleEffect& dce = effect.cast<DashingCircleEffect>();
+ const DashingCircleEffect& dce = geometryProcessor.cast<DashingCircleEffect>();
const char *paramName;
// The param uniforms, xyz, refer to circle radius - 0.5, cicles center x coord, and
// the total interval length of the dash.
@@ -531,13 +533,13 @@ void GLDashingCircleEffect::emitCode(GrGLFullProgramBuilder* builder,
vsBuilder->codeAppendf("\t%s = %s;\n", vsCoordName, dce.inCoord().c_str());
// transforms all points so that we can compare them to our test circle
- GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+ GrGLProcessorFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
fsBuilder->codeAppendf("\t\tfloat xShifted = %s.x - floor(%s.x / %s.z) * %s.z;\n",
fsCoordName, fsCoordName, paramName, paramName);
fsBuilder->codeAppendf("\t\tvec2 fragPosShifted = vec2(xShifted, %s.y);\n", fsCoordName);
fsBuilder->codeAppendf("\t\tvec2 center = vec2(%s.y, 0.0);\n", paramName);
fsBuilder->codeAppend("\t\tfloat dist = length(center - fragPosShifted);\n");
- if (GrEffectEdgeTypeIsAA(dce.getEdgeType())) {
+ if (GrProcessorEdgeTypeIsAA(dce.getEdgeType())) {
fsBuilder->codeAppendf("\t\tfloat diff = dist - %s.x;\n", paramName);
fsBuilder->codeAppend("\t\tdiff = 1.0 - diff;\n");
fsBuilder->codeAppend("\t\tfloat alpha = clamp(diff, 0.0, 1.0);\n");
@@ -549,8 +551,9 @@ void GLDashingCircleEffect::emitCode(GrGLFullProgramBuilder* builder,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
}
-void GLDashingCircleEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect& effect) {
- const DashingCircleEffect& dce = effect.cast<DashingCircleEffect>();
+void GLDashingCircleEffect::setData(const GrGLProgramDataManager& pdman
+ , const GrProcessor& processor) {
+ const DashingCircleEffect& dce = processor.cast<DashingCircleEffect>();
SkScalar radius = dce.getRadius();
SkScalar centerX = dce.getCenterX();
SkScalar intervalLength = dce.getIntervalLength();
@@ -562,16 +565,16 @@ void GLDashingCircleEffect::setData(const GrGLProgramDataManager& pdman, const G
}
}
-void GLDashingCircleEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
- const DashingCircleEffect& dce = effect.cast<DashingCircleEffect>();
+void GLDashingCircleEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
+ const DashingCircleEffect& dce = processor.cast<DashingCircleEffect>();
b->add32(dce.getEdgeType());
}
//////////////////////////////////////////////////////////////////////////////
-GrEffect* DashingCircleEffect::Create(GrEffectEdgeType edgeType, const DashInfo& info,
- SkScalar radius) {
+GrGeometryProcessor* DashingCircleEffect::Create(GrPrimitiveEdgeType edgeType, const DashInfo& info,
+ SkScalar radius) {
if (info.fCount != 2 || info.fIntervals[0] != 0) {
return NULL;
}
@@ -585,11 +588,11 @@ void DashingCircleEffect::getConstantColorComponents(GrColor* color, uint32_t* v
*validFlags = 0;
}
-const GrBackendEffectFactory& DashingCircleEffect::getFactory() const {
- return GrTBackendEffectFactory<DashingCircleEffect>::getInstance();
+const GrBackendGeometryProcessorFactory& DashingCircleEffect::getFactory() const {
+ return GrTBackendGeometryProcessorFactory<DashingCircleEffect>::getInstance();
}
-DashingCircleEffect::DashingCircleEffect(GrEffectEdgeType edgeType, const DashInfo& info,
+DashingCircleEffect::DashingCircleEffect(GrPrimitiveEdgeType edgeType, const DashInfo& info,
SkScalar radius)
: fEdgeType(edgeType)
, fInCoord(this->addVertexAttrib(GrShaderVar("inCoord",
@@ -602,7 +605,7 @@ DashingCircleEffect::DashingCircleEffect(GrEffectEdgeType edgeType, const DashIn
fCenterX = SkScalarHalf(offLen);
}
-bool DashingCircleEffect::onIsEqual(const GrEffect& other) const {
+bool DashingCircleEffect::onIsEqual(const GrProcessor& other) const {
const DashingCircleEffect& dce = other.cast<DashingCircleEffect>();
return (fEdgeType == dce.fEdgeType &&
fIntervalLength == dce.fIntervalLength &&
@@ -610,15 +613,14 @@ bool DashingCircleEffect::onIsEqual(const GrEffect& other) const {
fCenterX == dce.fCenterX);
}
-GR_DEFINE_EFFECT_TEST(DashingCircleEffect);
+GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect);
-GrEffect* DashingCircleEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
- GrEffect* effect;
- GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(random->nextULessThan(
- kGrEffectEdgeTypeCnt));
+GrGeometryProcessor* DashingCircleEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
+ GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(random->nextULessThan(
+ kGrProcessorEdgeTypeCnt));
SkScalar strokeWidth = random->nextRangeScalar(0, 100.f);
DashInfo info;
info.fCount = 2;
@@ -628,8 +630,7 @@ GrEffect* DashingCircleEffect::TestCreate(SkRandom* random,
info.fIntervals[1] = random->nextRangeScalar(0, 10.f);
info.fPhase = random->nextRangeScalar(0, info.fIntervals[1]);
- effect = DashingCircleEffect::Create(edgeType, info, strokeWidth);
- return effect;
+ return DashingCircleEffect::Create(edgeType, info, strokeWidth);
}
//////////////////////////////////////////////////////////////////////////////
@@ -649,7 +650,9 @@ class DashingLineEffect : public GrGeometryProcessor {
public:
typedef SkPathEffect::DashInfo DashInfo;
- static GrEffect* Create(GrEffectEdgeType edgeType, const DashInfo& info, SkScalar strokeWidth);
+ static GrGeometryProcessor* Create(GrPrimitiveEdgeType edgeType,
+ const DashInfo& info,
+ SkScalar strokeWidth);
virtual ~DashingLineEffect();
@@ -657,29 +660,29 @@ public:
const GrShaderVar& inCoord() const { return fInCoord; }
- GrEffectEdgeType getEdgeType() const { return fEdgeType; }
+ GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
const SkRect& getRect() const { return fRect; }
SkScalar getIntervalLength() const { return fIntervalLength; }
- typedef GLDashingLineEffect GLEffect;
+ typedef GLDashingLineEffect GLProcessor;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE;
private:
- DashingLineEffect(GrEffectEdgeType edgeType, const DashInfo& info, SkScalar strokeWidth);
+ DashingLineEffect(GrPrimitiveEdgeType edgeType, const DashInfo& info, SkScalar strokeWidth);
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE;
- GrEffectEdgeType fEdgeType;
+ GrPrimitiveEdgeType fEdgeType;
const GrShaderVar& fInCoord;
SkRect fRect;
SkScalar fIntervalLength;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
typedef GrGeometryProcessor INHERITED;
};
@@ -688,19 +691,19 @@ private:
class GLDashingLineEffect : public GrGLGeometryProcessor {
public:
- GLDashingLineEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GLDashingLineEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
private:
GrGLProgramDataManager::UniformHandle fRectUniform;
@@ -710,21 +713,21 @@ private:
typedef GrGLGeometryProcessor INHERITED;
};
-GLDashingLineEffect::GLDashingLineEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GLDashingLineEffect::GLDashingLineEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor&)
: INHERITED (factory) {
fPrevRect.fLeft = SK_ScalarNaN;
fPrevIntervalLength = SK_ScalarMax;
}
void GLDashingLineEffect::emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
- const char* outputColor,
- const char* inputColor,
- const TransformedCoordsArray&,
- const TextureSamplerArray& samplers) {
- const DashingLineEffect& de = effect.cast<DashingLineEffect>();
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
+ const char* outputColor,
+ const char* inputColor,
+ const TransformedCoordsArray&,
+ const TextureSamplerArray& samplers) {
+ const DashingLineEffect& de = geometryProcessor.cast<DashingLineEffect>();
const char *rectName;
// The rect uniform's xyzw refer to (left + 0.5, top + 0.5, right - 0.5, bottom - 0.5),
// respectively.
@@ -745,11 +748,11 @@ void GLDashingLineEffect::emitCode(GrGLFullProgramBuilder* builder,
vsBuilder->codeAppendf("\t%s = %s;\n", vsCoordName, de.inCoord().c_str());
// transforms all points so that we can compare them to our test rect
- GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+ GrGLProcessorFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
fsBuilder->codeAppendf("\t\tfloat xShifted = %s.x - floor(%s.x / %s) * %s;\n",
fsCoordName, fsCoordName, intervalName, intervalName);
fsBuilder->codeAppendf("\t\tvec2 fragPosShifted = vec2(xShifted, %s.y);\n", fsCoordName);
- if (GrEffectEdgeTypeIsAA(de.getEdgeType())) {
+ if (GrProcessorEdgeTypeIsAA(de.getEdgeType())) {
// The amount of coverage removed in x and y by the edges is computed as a pair of negative
// numbers, xSub and ySub.
fsBuilder->codeAppend("\t\tfloat xSub, ySub;\n");
@@ -770,8 +773,9 @@ void GLDashingLineEffect::emitCode(GrGLFullProgramBuilder* builder,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
}
-void GLDashingLineEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect& effect) {
- const DashingLineEffect& de = effect.cast<DashingLineEffect>();
+void GLDashingLineEffect::setData(const GrGLProgramDataManager& pdman,
+ const GrProcessor& processor) {
+ const DashingLineEffect& de = processor.cast<DashingLineEffect>();
const SkRect& rect = de.getRect();
SkScalar intervalLength = de.getIntervalLength();
if (rect != fPrevRect || intervalLength != fPrevIntervalLength) {
@@ -783,16 +787,17 @@ void GLDashingLineEffect::setData(const GrGLProgramDataManager& pdman, const GrE
}
}
-void GLDashingLineEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
- const DashingLineEffect& de = effect.cast<DashingLineEffect>();
+void GLDashingLineEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
+ const DashingLineEffect& de = processor.cast<DashingLineEffect>();
b->add32(de.getEdgeType());
}
//////////////////////////////////////////////////////////////////////////////
-GrEffect* DashingLineEffect::Create(GrEffectEdgeType edgeType, const DashInfo& info,
- SkScalar strokeWidth) {
+GrGeometryProcessor* DashingLineEffect::Create(GrPrimitiveEdgeType edgeType,
+ const DashInfo& info,
+ SkScalar strokeWidth) {
if (info.fCount != 2) {
return NULL;
}
@@ -806,11 +811,11 @@ void DashingLineEffect::getConstantColorComponents(GrColor* color, uint32_t* val
*validFlags = 0;
}
-const GrBackendEffectFactory& DashingLineEffect::getFactory() const {
- return GrTBackendEffectFactory<DashingLineEffect>::getInstance();
+const GrBackendGeometryProcessorFactory& DashingLineEffect::getFactory() const {
+ return GrTBackendGeometryProcessorFactory<DashingLineEffect>::getInstance();
}
-DashingLineEffect::DashingLineEffect(GrEffectEdgeType edgeType, const DashInfo& info,
+DashingLineEffect::DashingLineEffect(GrPrimitiveEdgeType edgeType, const DashInfo& info,
SkScalar strokeWidth)
: fEdgeType(edgeType)
, fInCoord(this->addVertexAttrib(GrShaderVar("inCoord",
@@ -824,22 +829,21 @@ DashingLineEffect::DashingLineEffect(GrEffectEdgeType edgeType, const DashInfo&
fRect.set(halfOffLen, -halfStroke, halfOffLen + onLen, halfStroke);
}
-bool DashingLineEffect::onIsEqual(const GrEffect& other) const {
+bool DashingLineEffect::onIsEqual(const GrProcessor& other) const {
const DashingLineEffect& de = other.cast<DashingLineEffect>();
return (fEdgeType == de.fEdgeType &&
fRect == de.fRect &&
fIntervalLength == de.fIntervalLength);
}
-GR_DEFINE_EFFECT_TEST(DashingLineEffect);
+GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect);
-GrEffect* DashingLineEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
- GrEffect* effect;
- GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(random->nextULessThan(
- kGrEffectEdgeTypeCnt));
+GrGeometryProcessor* DashingLineEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
+ GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(random->nextULessThan(
+ kGrProcessorEdgeTypeCnt));
SkScalar strokeWidth = random->nextRangeScalar(0, 100.f);
DashInfo info;
info.fCount = 2;
@@ -849,14 +853,15 @@ GrEffect* DashingLineEffect::TestCreate(SkRandom* random,
info.fIntervals[1] = random->nextRangeScalar(0, 10.f);
info.fPhase = random->nextRangeScalar(0, info.fIntervals[0] + info.fIntervals[1]);
- effect = DashingLineEffect::Create(edgeType, info, strokeWidth);
- return effect;
+ return DashingLineEffect::Create(edgeType, info, strokeWidth);
}
//////////////////////////////////////////////////////////////////////////////
-GrEffect* GrDashingEffect::Create(GrEffectEdgeType edgeType, const SkPathEffect::DashInfo& info,
- SkScalar strokeWidth, GrDashingEffect::DashCap cap) {
+GrGeometryProcessor* GrDashingEffect::Create(GrPrimitiveEdgeType edgeType,
+ const SkPathEffect::DashInfo& info,
+ SkScalar strokeWidth,
+ GrDashingEffect::DashCap cap) {
switch (cap) {
case GrDashingEffect::kRound_DashCap:
return DashingCircleEffect::Create(edgeType, info, SkScalarHalf(strokeWidth));
diff --git a/src/gpu/effects/GrDashingEffect.h b/src/gpu/effects/GrDashingEffect.h
index 1a51e89ac..331b6c8d0 100644
--- a/src/gpu/effects/GrDashingEffect.h
+++ b/src/gpu/effects/GrDashingEffect.h
@@ -14,6 +14,7 @@
class GrGpu;
class GrDrawTarget;
+class GrGeometryProcessor;
class GrPaint;
class GrStrokeInfo;
@@ -35,8 +36,10 @@ namespace GrDashingEffect {
* Bounding geometry is rendered and the effect computes coverage based on the fragment's
* position relative to the dashed line.
*/
- GrEffect* Create(GrEffectEdgeType edgeType, const SkPathEffect::DashInfo& info,
- SkScalar strokeWidth, DashCap cap);
+ GrGeometryProcessor* Create(GrPrimitiveEdgeType edgeType,
+ const SkPathEffect::DashInfo& info,
+ SkScalar strokeWidth,
+ DashCap cap);
}
#endif
diff --git a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
index ab7652571..d5d334805 100755
--- a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
+++ b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
@@ -7,11 +7,11 @@
#include "GrDistanceFieldTextureEffect.h"
#include "gl/builders/GrGLFullProgramBuilder.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
#include "gl/GrGLTexture.h"
#include "gl/GrGLGeometryProcessor.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "GrTexture.h"
#include "SkDistanceFieldGen.h"
@@ -31,8 +31,8 @@
class GrGLDistanceFieldTextureEffect : public GrGLGeometryProcessor {
public:
- GrGLDistanceFieldTextureEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+ GrGLDistanceFieldTextureEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor&)
: INHERITED (factory)
, fTextureSize(SkISize::Make(-1,-1))
#ifdef SK_GAMMA_APPLY_TO_A8
@@ -41,17 +41,17 @@ public:
{}
virtual void emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) SK_OVERRIDE {
const GrDistanceFieldTextureEffect& dfTexEffect =
- effect.cast<GrDistanceFieldTextureEffect>();
+ geometryProcessor.cast<GrDistanceFieldTextureEffect>();
SkASSERT(1 == dfTexEffect.getVertexAttribs().count());
- GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+ GrGLProcessorFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
@@ -131,7 +131,7 @@ public:
}
virtual void setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) SK_OVERRIDE {
+ const GrProcessor& effect) SK_OVERRIDE {
SkASSERT(fTextureSizeUni.isValid());
GrTexture* texture = effect.texture(0);
@@ -144,7 +144,7 @@ public:
}
#ifdef SK_GAMMA_APPLY_TO_A8
const GrDistanceFieldTextureEffect& dfTexEffect =
- effect.cast<GrDistanceFieldTextureEffect>();
+ effect.cast<GrDistanceFieldTextureEffect>();
float luminance = dfTexEffect.getLuminance();
if (luminance != fLuminance) {
pdman.set1f(fLuminanceUni, luminance);
@@ -153,10 +153,10 @@ public:
#endif
}
- static inline void GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
+ static inline void GenKey(const GrProcessor& processor, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
const GrDistanceFieldTextureEffect& dfTexEffect =
- effect.cast<GrDistanceFieldTextureEffect>();
+ processor.cast<GrDistanceFieldTextureEffect>();
b->add32(dfTexEffect.getFlags());
}
@@ -196,7 +196,7 @@ GrDistanceFieldTextureEffect::GrDistanceFieldTextureEffect(GrTexture* texture,
#endif
}
-bool GrDistanceFieldTextureEffect::onIsEqual(const GrEffect& other) const {
+bool GrDistanceFieldTextureEffect::onIsEqual(const GrProcessor& other) const {
const GrDistanceFieldTextureEffect& cte = other.cast<GrDistanceFieldTextureEffect>();
return fTextureAccess == cte.fTextureAccess &&
#ifdef SK_GAMMA_APPLY_TO_A8
@@ -216,23 +216,23 @@ void GrDistanceFieldTextureEffect::getConstantColorComponents(GrColor* color,
}
}
-const GrBackendEffectFactory& GrDistanceFieldTextureEffect::getFactory() const {
- return GrTBackendEffectFactory<GrDistanceFieldTextureEffect>::getInstance();
+const GrBackendGeometryProcessorFactory& GrDistanceFieldTextureEffect::getFactory() const {
+ return GrTBackendGeometryProcessorFactory<GrDistanceFieldTextureEffect>::getInstance();
}
///////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrDistanceFieldTextureEffect);
+GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldTextureEffect);
-GrEffect* GrDistanceFieldTextureEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
- int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
- GrEffectUnitTest::kAlphaTextureIdx;
+GrGeometryProcessor* GrDistanceFieldTextureEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
+ int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
+ GrProcessorUnitTest::kAlphaTextureIdx;
#ifdef SK_GAMMA_APPLY_TO_A8
- int texIdx2 = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
- GrEffectUnitTest::kAlphaTextureIdx;
+ int texIdx2 = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
+ GrProcessorUnitTest::kAlphaTextureIdx;
#endif
static const SkShader::TileMode kTileModes[] = {
SkShader::kClamp_TileMode,
@@ -263,21 +263,21 @@ GrEffect* GrDistanceFieldTextureEffect::TestCreate(SkRandom* random,
class GrGLDistanceFieldLCDTextureEffect : public GrGLGeometryProcessor {
public:
- GrGLDistanceFieldLCDTextureEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+ GrGLDistanceFieldLCDTextureEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor&)
: INHERITED (factory)
, fTextureSize(SkISize::Make(-1,-1))
, fTextColor(GrColor_ILLEGAL) {}
virtual void emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) SK_OVERRIDE {
const GrDistanceFieldLCDTextureEffect& dfTexEffect =
- effect.cast<GrDistanceFieldLCDTextureEffect>();
+ geometryProcessor.cast<GrDistanceFieldLCDTextureEffect>();
SkASSERT(1 == dfTexEffect.getVertexAttribs().count());
SkString fsCoordName;
@@ -295,7 +295,7 @@ public:
kVec3f_GrSLType, "TextureSize",
&textureSizeUniName);
- GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+ GrGLProcessorFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
@@ -400,13 +400,13 @@ public:
}
virtual void setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) SK_OVERRIDE {
+ const GrProcessor& processor) SK_OVERRIDE {
SkASSERT(fTextureSizeUni.isValid());
SkASSERT(fTextColorUni.isValid());
const GrDistanceFieldLCDTextureEffect& dfTexEffect =
- effect.cast<GrDistanceFieldLCDTextureEffect>();
- GrTexture* texture = effect.texture(0);
+ processor.cast<GrDistanceFieldLCDTextureEffect>();
+ GrTexture* texture = processor.texture(0);
if (texture->width() != fTextureSize.width() ||
texture->height() != fTextureSize.height()) {
fTextureSize = SkISize::Make(texture->width(), texture->height());
@@ -431,10 +431,10 @@ public:
}
}
- static inline void GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
+ static inline void GenKey(const GrProcessor& processor, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
const GrDistanceFieldLCDTextureEffect& dfTexEffect =
- effect.cast<GrDistanceFieldLCDTextureEffect>();
+ processor.cast<GrDistanceFieldLCDTextureEffect>();
b->add32(dfTexEffect.getFlags());
}
@@ -468,7 +468,7 @@ GrDistanceFieldLCDTextureEffect::GrDistanceFieldLCDTextureEffect(
this->addTextureAccess(&fGammaTextureAccess);
}
-bool GrDistanceFieldLCDTextureEffect::onIsEqual(const GrEffect& other) const {
+bool GrDistanceFieldLCDTextureEffect::onIsEqual(const GrProcessor& other) const {
const GrDistanceFieldLCDTextureEffect& cte = other.cast<GrDistanceFieldLCDTextureEffect>();
return (fTextureAccess == cte.fTextureAccess &&
fGammaTextureAccess == cte.fGammaTextureAccess &&
@@ -486,22 +486,22 @@ void GrDistanceFieldLCDTextureEffect::getConstantColorComponents(GrColor* color,
}
}
-const GrBackendEffectFactory& GrDistanceFieldLCDTextureEffect::getFactory() const {
- return GrTBackendEffectFactory<GrDistanceFieldLCDTextureEffect>::getInstance();
+const GrBackendGeometryProcessorFactory& GrDistanceFieldLCDTextureEffect::getFactory() const {
+ return GrTBackendGeometryProcessorFactory<GrDistanceFieldLCDTextureEffect>::getInstance();
}
///////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrDistanceFieldLCDTextureEffect);
+GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextureEffect);
-GrEffect* GrDistanceFieldLCDTextureEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
- int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
- GrEffectUnitTest::kAlphaTextureIdx;
- int texIdx2 = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
- GrEffectUnitTest::kAlphaTextureIdx;
+GrGeometryProcessor* GrDistanceFieldLCDTextureEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
+ int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
+ GrProcessorUnitTest::kAlphaTextureIdx;
+ int texIdx2 = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
+ GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
SkShader::kClamp_TileMode,
SkShader::kRepeat_TileMode,
diff --git a/src/gpu/effects/GrDistanceFieldTextureEffect.h b/src/gpu/effects/GrDistanceFieldTextureEffect.h
index 5f08edaa7..b8d774d61 100644
--- a/src/gpu/effects/GrDistanceFieldTextureEffect.h
+++ b/src/gpu/effects/GrDistanceFieldTextureEffect.h
@@ -8,7 +8,7 @@
#ifndef GrDistanceFieldTextureEffect_DEFINED
#define GrDistanceFieldTextureEffect_DEFINED
-#include "GrEffect.h"
+#include "GrProcessor.h"
#include "GrGeometryProcessor.h"
class GrGLDistanceFieldTextureEffect;
@@ -41,15 +41,15 @@ enum GrDistanceFieldEffectFlags {
class GrDistanceFieldTextureEffect : public GrGeometryProcessor {
public:
#ifdef SK_GAMMA_APPLY_TO_A8
- static GrEffect* Create(GrTexture* tex, const GrTextureParams& params,
- GrTexture* gamma, const GrTextureParams& gammaParams, float lum,
- uint32_t flags) {
+ static GrGeometryProcessor* Create(GrTexture* tex, const GrTextureParams& params,
+ GrTexture* gamma, const GrTextureParams& gammaParams,
+ float lum, uint32_t flags) {
return SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, params, gamma, gammaParams, lum,
flags));
}
#else
- static GrEffect* Create(GrTexture* tex, const GrTextureParams& params,
- uint32_t flags) {
+ static GrGeometryProcessor* Create(GrTexture* tex, const GrTextureParams& params,
+ uint32_t flags) {
return SkNEW_ARGS(GrDistanceFieldTextureEffect, (tex, params, flags));
}
#endif
@@ -66,9 +66,9 @@ public:
#endif
uint32_t getFlags() const { return fFlags; }
- typedef GrGLDistanceFieldTextureEffect GLEffect;
+ typedef GrGLDistanceFieldTextureEffect GLProcessor;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE;
private:
GrDistanceFieldTextureEffect(GrTexture* texture, const GrTextureParams& params,
@@ -77,7 +77,7 @@ private:
#endif
uint32_t flags);
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE;
GrTextureAccess fTextureAccess;
#ifdef SK_GAMMA_APPLY_TO_A8
@@ -87,9 +87,9 @@ private:
uint32_t fFlags;
const GrShaderVar& fInTextureCoords;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
/**
@@ -100,9 +100,9 @@ private:
*/
class GrDistanceFieldLCDTextureEffect : public GrGeometryProcessor {
public:
- static GrEffect* Create(GrTexture* tex, const GrTextureParams& params,
- GrTexture* gamma, const GrTextureParams& gammaParams,
- SkColor textColor, uint32_t flags) {
+ static GrGeometryProcessor* Create(GrTexture* tex, const GrTextureParams& params,
+ GrTexture* gamma, const GrTextureParams& gammaParams,
+ SkColor textColor, uint32_t flags) {
return SkNEW_ARGS(GrDistanceFieldLCDTextureEffect,
(tex, params, gamma, gammaParams, textColor, flags));
}
@@ -116,9 +116,9 @@ public:
GrColor getTextColor() const { return fTextColor; }
uint32_t getFlags() const { return fFlags; }
- typedef GrGLDistanceFieldLCDTextureEffect GLEffect;
+ typedef GrGLDistanceFieldLCDTextureEffect GLProcessor;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERRIDE;
private:
GrDistanceFieldLCDTextureEffect(GrTexture* texture, const GrTextureParams& params,
@@ -126,7 +126,7 @@ private:
SkColor textColor,
uint32_t flags);
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE;
GrTextureAccess fTextureAccess;
GrTextureAccess fGammaTextureAccess;
@@ -134,9 +134,9 @@ private:
uint32_t fFlags;
const GrShaderVar& fInTextureCoords;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_GEOMETRY_PROCESSOR_TEST;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
#endif
diff --git a/src/gpu/effects/GrDitherEffect.cpp b/src/gpu/effects/GrDitherEffect.cpp
index 35726fdea..fe7447d17 100644
--- a/src/gpu/effects/GrDitherEffect.cpp
+++ b/src/gpu/effects/GrDitherEffect.cpp
@@ -8,9 +8,9 @@
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrDitherEffect.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "SkRect.h"
@@ -18,22 +18,22 @@
class GLDitherEffect;
-class DitherEffect : public GrEffect {
+class DitherEffect : public GrFragmentProcessor {
public:
- static GrEffect* Create() {
- GR_CREATE_STATIC_EFFECT(gDitherEffect, DitherEffect, ())
+ static GrFragmentProcessor* Create() {
+ GR_CREATE_STATIC_FRAGMENT_PROCESSOR(gDitherEffect, DitherEffect, ())
return SkRef(gDitherEffect);
}
virtual ~DitherEffect() {};
static const char* Name() { return "Dither"; }
- typedef GLDitherEffect GLEffect;
+ typedef GLDitherEffect GLProcessor;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
- return GrTBackendEffectFactory<DitherEffect>::getInstance();
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
+ return GrTBackendFragmentProcessorFactory<DitherEffect>::getInstance();
}
private:
@@ -42,11 +42,11 @@ private:
}
// All dither effects are equal
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE { return true; }
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE { return true; }
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
void DitherEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const {
@@ -55,41 +55,41 @@ void DitherEffect::getConstantColorComponents(GrColor* color, uint32_t* validFla
//////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(DitherEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(DitherEffect);
-GrEffect* DitherEffect::TestCreate(SkRandom*,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture*[]) {
+GrFragmentProcessor* DitherEffect::TestCreate(SkRandom*,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture*[]) {
return DitherEffect::Create();
}
//////////////////////////////////////////////////////////////////////////////
-class GLDitherEffect : public GrGLEffect {
+class GLDitherEffect : public GrGLFragmentProcessor {
public:
- GLDitherEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GLDitherEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& fp,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
private:
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
-GLDitherEffect::GLDitherEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GLDitherEffect::GLDitherEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor&)
: INHERITED (factory) {
}
void GLDitherEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& fp,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
@@ -113,4 +113,4 @@ void GLDitherEffect::emitCode(GrGLProgramBuilder* builder,
//////////////////////////////////////////////////////////////////////////////
-GrEffect* GrDitherEffect::Create() { return DitherEffect::Create(); }
+GrFragmentProcessor* GrDitherEffect::Create() { return DitherEffect::Create(); }
diff --git a/src/gpu/effects/GrDitherEffect.h b/src/gpu/effects/GrDitherEffect.h
index 88e0a27ae..ac4c78440 100644
--- a/src/gpu/effects/GrDitherEffect.h
+++ b/src/gpu/effects/GrDitherEffect.h
@@ -11,13 +11,13 @@
#include "GrTypes.h"
#include "GrTypesPriv.h"
-class GrEffect;
+class GrProcessor;
namespace GrDitherEffect {
/**
* Creates an effect that dithers the resulting color to an RGBA8 framebuffer
*/
- GrEffect* Create();
+ GrFragmentProcessor* Create();
};
#endif
diff --git a/src/gpu/effects/GrGeometryProcessor.h b/src/gpu/effects/GrGeometryProcessor.h
deleted file mode 100644
index 0e1c80c15..000000000
--- a/src/gpu/effects/GrGeometryProcessor.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrGeometryProcessor_DEFINED
-#define GrGeometryProcessor_DEFINED
-
-#include "GrEffect.h"
-
-/**
- * If an effect needs specialized vertex shader code, then it must inherit from this class.
- * Otherwise it won't be able to add vertex attribs, and it will be given a vertexless shader
- * program in emitCode.
- */
-class GrGeometryProcessor : public GrEffect {
-public:
- GrGeometryProcessor() { fRequiresVertexShader = true; }
-
-protected:
- /**
- * Subclasses call this from their constructor to register vertex attributes (at most
- * kMaxVertexAttribs). This must only be called from the constructor because GrEffects are
- * immutable.
- *
- * We return a reference to the added var so that derived classes can name it nicely and use it
- * in shader code.
- */
- const GrShaderVar& addVertexAttrib(const GrShaderVar& var) {
- SkASSERT(GrShaderVar::kAttribute_TypeModifier == var.getTypeModifier());
- SkASSERT(fVertexAttribs.count() < kMaxVertexAttribs);
- return fVertexAttribs.push_back(var);
- }
-
-private:
- typedef GrEffect INHERITED;
-};
-
-#endif
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index 4ba1895ca..c0080c61d 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -6,26 +6,26 @@
*/
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrMatrixConvolutionEffect.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
#include "gl/GrGLTexture.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
-class GrGLMatrixConvolutionEffect : public GrGLEffect {
+class GrGLMatrixConvolutionEffect : public GrGLFragmentProcessor {
public:
- GrGLMatrixConvolutionEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect);
+ GrGLMatrixConvolutionEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor&);
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
private:
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
@@ -40,26 +40,26 @@ private:
UniformHandle fBiasUni;
GrTextureDomain::GLDomain fDomain;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
-GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor& processor)
: INHERITED(factory) {
- const GrMatrixConvolutionEffect& m = effect.cast<GrMatrixConvolutionEffect>();
+ const GrMatrixConvolutionEffect& m = processor.cast<GrMatrixConvolutionEffect>();
fKernelSize = m.kernelSize();
fConvolveAlpha = m.convolveAlpha();
}
void GrGLMatrixConvolutionEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& fp,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
const TextureSamplerArray& samplers) {
sk_ignore_unused_variable(inputColor);
- const GrTextureDomain& domain = effect.cast<GrMatrixConvolutionEffect>().domain();
+ const GrTextureDomain& domain = fp.cast<GrMatrixConvolutionEffect>().domain();
fBoundsUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec4f_GrSLType, "Bounds");
@@ -120,9 +120,9 @@ void GrGLMatrixConvolutionEffect::emitCode(GrGLProgramBuilder* builder,
fsBuilder->codeAppend(modulate.c_str());
}
-void GrGLMatrixConvolutionEffect::GenKey(const GrEffect& effect,
- const GrGLCaps&, GrEffectKeyBuilder* b) {
- const GrMatrixConvolutionEffect& m = effect.cast<GrMatrixConvolutionEffect>();
+void GrGLMatrixConvolutionEffect::GenKey(const GrProcessor& processor,
+ const GrGLCaps&, GrProcessorKeyBuilder* b) {
+ const GrMatrixConvolutionEffect& m = processor.cast<GrMatrixConvolutionEffect>();
SkASSERT(m.kernelSize().width() <= 0x7FFF && m.kernelSize().height() <= 0xFFFF);
uint32_t key = m.kernelSize().width() << 16 | m.kernelSize().height();
key |= m.convolveAlpha() ? 1 << 31 : 0;
@@ -131,8 +131,8 @@ void GrGLMatrixConvolutionEffect::GenKey(const GrEffect& effect,
}
void GrGLMatrixConvolutionEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
- const GrMatrixConvolutionEffect& conv = effect.cast<GrMatrixConvolutionEffect>();
+ const GrProcessor& processor) {
+ const GrMatrixConvolutionEffect& conv = processor.cast<GrMatrixConvolutionEffect>();
GrTexture& texture = *conv.texture(0);
// the code we generated was for a specific kernel size
SkASSERT(conv.kernelSize() == fKernelSize);
@@ -173,11 +173,11 @@ GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrTexture* texture,
GrMatrixConvolutionEffect::~GrMatrixConvolutionEffect() {
}
-const GrBackendEffectFactory& GrMatrixConvolutionEffect::getFactory() const {
- return GrTBackendEffectFactory<GrMatrixConvolutionEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& GrMatrixConvolutionEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<GrMatrixConvolutionEffect>::getInstance();
}
-bool GrMatrixConvolutionEffect::onIsEqual(const GrEffect& sBase) const {
+bool GrMatrixConvolutionEffect::onIsEqual(const GrProcessor& sBase) const {
const GrMatrixConvolutionEffect& s = sBase.cast<GrMatrixConvolutionEffect>();
return this->texture(0) == s.texture(0) &&
fKernelSize == s.kernelSize() &&
@@ -191,16 +191,17 @@ bool GrMatrixConvolutionEffect::onIsEqual(const GrEffect& sBase) const {
}
// Static function to create a 2D convolution
-GrEffect* GrMatrixConvolutionEffect::CreateGaussian(GrTexture* texture,
- const SkIRect& bounds,
- const SkISize& kernelSize,
- SkScalar gain,
- SkScalar bias,
- const SkIPoint& kernelOffset,
- GrTextureDomain::Mode tileMode,
- bool convolveAlpha,
- SkScalar sigmaX,
- SkScalar sigmaY) {
+GrFragmentProcessor*
+GrMatrixConvolutionEffect::CreateGaussian(GrTexture* texture,
+ const SkIRect& bounds,
+ const SkISize& kernelSize,
+ SkScalar gain,
+ SkScalar bias,
+ const SkIPoint& kernelOffset,
+ GrTextureDomain::Mode tileMode,
+ bool convolveAlpha,
+ SkScalar sigmaX,
+ SkScalar sigmaY) {
float kernel[MAX_KERNEL_SIZE];
int width = kernelSize.width();
int height = kernelSize.height();
@@ -238,14 +239,14 @@ GrEffect* GrMatrixConvolutionEffect::CreateGaussian(GrTexture* texture,
convolveAlpha));
}
-GR_DEFINE_EFFECT_TEST(GrMatrixConvolutionEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMatrixConvolutionEffect);
-GrEffect* GrMatrixConvolutionEffect::TestCreate(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
- int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
- GrEffectUnitTest::kAlphaTextureIdx;
+GrFragmentProcessor* GrMatrixConvolutionEffect::TestCreate(SkRandom* random,
+ GrContext* context,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
+ int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
+ GrProcessorUnitTest::kAlphaTextureIdx;
int width = random->nextRangeU(1, MAX_KERNEL_SIZE);
int height = random->nextRangeU(1, MAX_KERNEL_SIZE / width);
SkISize kernelSize = SkISize::Make(width, height);
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.h b/src/gpu/effects/GrMatrixConvolutionEffect.h
index 814299f2d..4cc4296ee 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.h
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.h
@@ -19,15 +19,15 @@ class GrGLMatrixConvolutionEffect;
class GrMatrixConvolutionEffect : public GrSingleTextureEffect {
public:
- static GrEffect* Create(GrTexture* texture,
- const SkIRect& bounds,
- const SkISize& kernelSize,
- const SkScalar* kernel,
- SkScalar gain,
- SkScalar bias,
- const SkIPoint& kernelOffset,
- GrTextureDomain::Mode tileMode,
- bool convolveAlpha) {
+ static GrFragmentProcessor* Create(GrTexture* texture,
+ const SkIRect& bounds,
+ const SkISize& kernelSize,
+ const SkScalar* kernel,
+ SkScalar gain,
+ SkScalar bias,
+ const SkIPoint& kernelOffset,
+ GrTextureDomain::Mode tileMode,
+ bool convolveAlpha) {
return SkNEW_ARGS(GrMatrixConvolutionEffect, (texture,
bounds,
kernelSize,
@@ -39,16 +39,16 @@ public:
convolveAlpha));
}
- static GrEffect* CreateGaussian(GrTexture* texture,
- const SkIRect& bounds,
- const SkISize& kernelSize,
- SkScalar gain,
- SkScalar bias,
- const SkIPoint& kernelOffset,
- GrTextureDomain::Mode tileMode,
- bool convolveAlpha,
- SkScalar sigmaX,
- SkScalar sigmaY);
+ static GrFragmentProcessor* CreateGaussian(GrTexture* texture,
+ const SkIRect& bounds,
+ const SkISize& kernelSize,
+ SkScalar gain,
+ SkScalar bias,
+ const SkIPoint& kernelOffset,
+ GrTextureDomain::Mode tileMode,
+ bool convolveAlpha,
+ SkScalar sigmaX,
+ SkScalar sigmaY);
virtual ~GrMatrixConvolutionEffect();
@@ -68,9 +68,9 @@ public:
bool convolveAlpha() const { return fConvolveAlpha; }
const GrTextureDomain& domain() const { return fDomain; }
- typedef GrGLMatrixConvolutionEffect GLEffect;
+ typedef GrGLMatrixConvolutionEffect GLProcessor;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
private:
GrMatrixConvolutionEffect(GrTexture*,
@@ -83,7 +83,7 @@ private:
GrTextureDomain::Mode tileMode,
bool convolveAlpha);
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
SkIRect fBounds;
SkISize fKernelSize;
@@ -94,7 +94,7 @@ private:
bool fConvolveAlpha;
GrTextureDomain fDomain;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
typedef GrSingleTextureEffect INHERITED;
};
diff --git a/src/gpu/effects/GrOvalEffect.cpp b/src/gpu/effects/GrOvalEffect.cpp
index 65f188e90..10fd8a6bf 100644
--- a/src/gpu/effects/GrOvalEffect.cpp
+++ b/src/gpu/effects/GrOvalEffect.cpp
@@ -8,9 +8,9 @@
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrOvalEffect.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "SkRect.h"
@@ -18,9 +18,9 @@
class GLCircleEffect;
-class CircleEffect : public GrEffect {
+class CircleEffect : public GrFragmentProcessor {
public:
- static GrEffect* Create(GrEffectEdgeType, const SkPoint& center, SkScalar radius);
+ static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkPoint& center, SkScalar radius);
virtual ~CircleEffect() {};
static const char* Name() { return "Circle"; }
@@ -28,29 +28,30 @@ public:
const SkPoint& getCenter() const { return fCenter; }
SkScalar getRadius() const { return fRadius; }
- GrEffectEdgeType getEdgeType() const { return fEdgeType; }
+ GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
- typedef GLCircleEffect GLEffect;
+ typedef GLCircleEffect GLProcessor;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
private:
- CircleEffect(GrEffectEdgeType, const SkPoint& center, SkScalar radius);
+ CircleEffect(GrPrimitiveEdgeType, const SkPoint& center, SkScalar radius);
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
SkPoint fCenter;
SkScalar fRadius;
- GrEffectEdgeType fEdgeType;
+ GrPrimitiveEdgeType fEdgeType;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
-GrEffect* CircleEffect::Create(GrEffectEdgeType edgeType, const SkPoint& center, SkScalar radius) {
+GrFragmentProcessor* CircleEffect::Create(GrPrimitiveEdgeType edgeType, const SkPoint& center,
+ SkScalar radius) {
SkASSERT(radius >= 0);
return SkNEW_ARGS(CircleEffect, (edgeType, center, radius));
}
@@ -59,81 +60,81 @@ void CircleEffect::getConstantColorComponents(GrColor* color, uint32_t* validFla
*validFlags = 0;
}
-const GrBackendEffectFactory& CircleEffect::getFactory() const {
- return GrTBackendEffectFactory<CircleEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& CircleEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<CircleEffect>::getInstance();
}
-CircleEffect::CircleEffect(GrEffectEdgeType edgeType, const SkPoint& c, SkScalar r)
+CircleEffect::CircleEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkScalar r)
: fCenter(c)
, fRadius(r)
, fEdgeType(edgeType) {
this->setWillReadFragmentPosition();
}
-bool CircleEffect::onIsEqual(const GrEffect& other) const {
+bool CircleEffect::onIsEqual(const GrProcessor& other) const {
const CircleEffect& ce = other.cast<CircleEffect>();
return fEdgeType == ce.fEdgeType && fCenter == ce.fCenter && fRadius == ce.fRadius;
}
//////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(CircleEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleEffect);
-GrEffect* CircleEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
+GrFragmentProcessor* CircleEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
SkPoint center;
center.fX = random->nextRangeScalar(0.f, 1000.f);
center.fY = random->nextRangeScalar(0.f, 1000.f);
SkScalar radius = random->nextRangeF(0.f, 1000.f);
- GrEffectEdgeType et;
+ GrPrimitiveEdgeType et;
do {
- et = (GrEffectEdgeType)random->nextULessThan(kGrEffectEdgeTypeCnt);
- } while (kHairlineAA_GrEffectEdgeType == et);
+ et = (GrPrimitiveEdgeType)random->nextULessThan(kGrProcessorEdgeTypeCnt);
+ } while (kHairlineAA_GrProcessorEdgeType == et);
return CircleEffect::Create(et, center, radius);
}
//////////////////////////////////////////////////////////////////////////////
-class GLCircleEffect : public GrGLEffect {
+class GLCircleEffect : public GrGLFragmentProcessor {
public:
- GLCircleEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GLCircleEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& fp,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
private:
GrGLProgramDataManager::UniformHandle fCircleUniform;
SkPoint fPrevCenter;
SkScalar fPrevRadius;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
-GLCircleEffect::GLCircleEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GLCircleEffect::GLCircleEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor&)
: INHERITED (factory) {
fPrevRadius = -1.f;
}
void GLCircleEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& fp,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) {
- const CircleEffect& ce = effect.cast<CircleEffect>();
+ const CircleEffect& ce = fp.cast<CircleEffect>();
const char *circleName;
// The circle uniform is (center.x, center.y, radius + 0.5) for regular fills and
// (... ,radius - 0.5) for inverse fills.
@@ -145,15 +146,15 @@ void GLCircleEffect::emitCode(GrGLProgramBuilder* builder,
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
const char* fragmentPos = fsBuilder->fragmentPosition();
- SkASSERT(kHairlineAA_GrEffectEdgeType != ce.getEdgeType());
- if (GrEffectEdgeTypeIsInverseFill(ce.getEdgeType())) {
+ SkASSERT(kHairlineAA_GrProcessorEdgeType != ce.getEdgeType());
+ if (GrProcessorEdgeTypeIsInverseFill(ce.getEdgeType())) {
fsBuilder->codeAppendf("\t\tfloat d = length(%s.xy - %s.xy) - %s.z;\n",
circleName, fragmentPos, circleName);
} else {
fsBuilder->codeAppendf("\t\tfloat d = %s.z - length(%s.xy - %s.xy);\n",
circleName, fragmentPos, circleName);
}
- if (GrEffectEdgeTypeIsAA(ce.getEdgeType())) {
+ if (GrProcessorEdgeTypeIsAA(ce.getEdgeType())) {
fsBuilder->codeAppend("\t\td = clamp(d, 0.0, 1.0);\n");
} else {
fsBuilder->codeAppend("\t\td = d > 0.5 ? 1.0 : 0.0;\n");
@@ -163,17 +164,17 @@ void GLCircleEffect::emitCode(GrGLProgramBuilder* builder,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("d")).c_str());
}
-void GLCircleEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
- const CircleEffect& ce = effect.cast<CircleEffect>();
+void GLCircleEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
+ const CircleEffect& ce = processor.cast<CircleEffect>();
b->add32(ce.getEdgeType());
}
-void GLCircleEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect& effect) {
- const CircleEffect& ce = effect.cast<CircleEffect>();
+void GLCircleEffect::setData(const GrGLProgramDataManager& pdman, const GrProcessor& processor) {
+ const CircleEffect& ce = processor.cast<CircleEffect>();
if (ce.getRadius() != fPrevRadius || ce.getCenter() != fPrevCenter) {
SkScalar radius = ce.getRadius();
- if (GrEffectEdgeTypeIsInverseFill(ce.getEdgeType())) {
+ if (GrProcessorEdgeTypeIsInverseFill(ce.getEdgeType())) {
radius -= 0.5f;
} else {
radius += 0.5f;
@@ -188,9 +189,10 @@ void GLCircleEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect
class GLEllipseEffect;
-class EllipseEffect : public GrEffect {
+class EllipseEffect : public GrFragmentProcessor {
public:
- static GrEffect* Create(GrEffectEdgeType, const SkPoint& center, SkScalar rx, SkScalar ry);
+ static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkPoint& center, SkScalar rx,
+ SkScalar ry);
virtual ~EllipseEffect() {};
static const char* Name() { return "Ellipse"; }
@@ -198,32 +200,32 @@ public:
const SkPoint& getCenter() const { return fCenter; }
SkVector getRadii() const { return fRadii; }
- GrEffectEdgeType getEdgeType() const { return fEdgeType; }
+ GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
- typedef GLEllipseEffect GLEffect;
+ typedef GLEllipseEffect GLProcessor;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
private:
- EllipseEffect(GrEffectEdgeType, const SkPoint& center, SkScalar rx, SkScalar ry);
+ EllipseEffect(GrPrimitiveEdgeType, const SkPoint& center, SkScalar rx, SkScalar ry);
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
SkPoint fCenter;
SkVector fRadii;
- GrEffectEdgeType fEdgeType;
+ GrPrimitiveEdgeType fEdgeType;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
-GrEffect* EllipseEffect::Create(GrEffectEdgeType edgeType,
- const SkPoint& center,
- SkScalar rx,
- SkScalar ry) {
+GrFragmentProcessor* EllipseEffect::Create(GrPrimitiveEdgeType edgeType,
+ const SkPoint& center,
+ SkScalar rx,
+ SkScalar ry) {
SkASSERT(rx >= 0 && ry >= 0);
return SkNEW_ARGS(EllipseEffect, (edgeType, center, rx, ry));
}
@@ -232,82 +234,82 @@ void EllipseEffect::getConstantColorComponents(GrColor* color, uint32_t* validFl
*validFlags = 0;
}
-const GrBackendEffectFactory& EllipseEffect::getFactory() const {
- return GrTBackendEffectFactory<EllipseEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& EllipseEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<EllipseEffect>::getInstance();
}
-EllipseEffect::EllipseEffect(GrEffectEdgeType edgeType, const SkPoint& c, SkScalar rx, SkScalar ry)
+EllipseEffect::EllipseEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkScalar rx, SkScalar ry)
: fCenter(c)
, fRadii(SkVector::Make(rx, ry))
, fEdgeType(edgeType) {
this->setWillReadFragmentPosition();
}
-bool EllipseEffect::onIsEqual(const GrEffect& other) const {
+bool EllipseEffect::onIsEqual(const GrProcessor& other) const {
const EllipseEffect& ee = other.cast<EllipseEffect>();
return fEdgeType == ee.fEdgeType && fCenter == ee.fCenter && fRadii == ee.fRadii;
}
//////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(EllipseEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(EllipseEffect);
-GrEffect* EllipseEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
+GrFragmentProcessor* EllipseEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
SkPoint center;
center.fX = random->nextRangeScalar(0.f, 1000.f);
center.fY = random->nextRangeScalar(0.f, 1000.f);
SkScalar rx = random->nextRangeF(0.f, 1000.f);
SkScalar ry = random->nextRangeF(0.f, 1000.f);
- GrEffectEdgeType et;
+ GrPrimitiveEdgeType et;
do {
- et = (GrEffectEdgeType)random->nextULessThan(kGrEffectEdgeTypeCnt);
- } while (kHairlineAA_GrEffectEdgeType == et);
+ et = (GrPrimitiveEdgeType)random->nextULessThan(kGrProcessorEdgeTypeCnt);
+ } while (kHairlineAA_GrProcessorEdgeType == et);
return EllipseEffect::Create(et, center, rx, ry);
}
//////////////////////////////////////////////////////////////////////////////
-class GLEllipseEffect : public GrGLEffect {
+class GLEllipseEffect : public GrGLFragmentProcessor {
public:
- GLEllipseEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GLEllipseEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& fp,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
private:
GrGLProgramDataManager::UniformHandle fEllipseUniform;
SkPoint fPrevCenter;
SkVector fPrevRadii;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
-GLEllipseEffect::GLEllipseEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GLEllipseEffect::GLEllipseEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor& effect)
: INHERITED (factory) {
fPrevRadii.fX = -1.f;
}
void GLEllipseEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& fp,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) {
- const EllipseEffect& ee = effect.cast<EllipseEffect>();
+ const EllipseEffect& ee = fp.cast<EllipseEffect>();
const char *ellipseName;
// The ellipse uniform is (center.x, center.y, 1 / rx^2, 1 / ry^2)
fEllipseUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
@@ -330,19 +332,19 @@ void GLEllipseEffect::emitCode(GrGLProgramBuilder* builder,
fsBuilder->codeAppendf("\t\tfloat approx_dist = implicit * inversesqrt(grad_dot);\n");
switch (ee.getEdgeType()) {
- case kFillAA_GrEffectEdgeType:
+ case kFillAA_GrProcessorEdgeType:
fsBuilder->codeAppend("\t\tfloat alpha = clamp(0.5 - approx_dist, 0.0, 1.0);\n");
break;
- case kInverseFillAA_GrEffectEdgeType:
+ case kInverseFillAA_GrProcessorEdgeType:
fsBuilder->codeAppend("\t\tfloat alpha = clamp(0.5 + approx_dist, 0.0, 1.0);\n");
break;
- case kFillBW_GrEffectEdgeType:
+ case kFillBW_GrProcessorEdgeType:
fsBuilder->codeAppend("\t\tfloat alpha = approx_dist > 0.0 ? 0.0 : 1.0;\n");
break;
- case kInverseFillBW_GrEffectEdgeType:
+ case kInverseFillBW_GrProcessorEdgeType:
fsBuilder->codeAppend("\t\tfloat alpha = approx_dist > 0.0 ? 1.0 : 0.0;\n");
break;
- case kHairlineAA_GrEffectEdgeType:
+ case kHairlineAA_GrProcessorEdgeType:
SkFAIL("Hairline not expected here.");
}
@@ -350,13 +352,13 @@ void GLEllipseEffect::emitCode(GrGLProgramBuilder* builder,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
}
-void GLEllipseEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
+void GLEllipseEffect::GenKey(const GrProcessor& effect, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
const EllipseEffect& ee = effect.cast<EllipseEffect>();
b->add32(ee.getEdgeType());
}
-void GLEllipseEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect& effect) {
+void GLEllipseEffect::setData(const GrGLProgramDataManager& pdman, const GrProcessor& effect) {
const EllipseEffect& ee = effect.cast<EllipseEffect>();
if (ee.getRadii() != fPrevRadii || ee.getCenter() != fPrevCenter) {
SkScalar invRXSqd = 1.f / (ee.getRadii().fX * ee.getRadii().fX);
@@ -369,8 +371,8 @@ void GLEllipseEffect::setData(const GrGLProgramDataManager& pdman, const GrEffec
//////////////////////////////////////////////////////////////////////////////
-GrEffect* GrOvalEffect::Create(GrEffectEdgeType edgeType, const SkRect& oval) {
- if (kHairlineAA_GrEffectEdgeType == edgeType) {
+GrFragmentProcessor* GrOvalEffect::Create(GrPrimitiveEdgeType edgeType, const SkRect& oval) {
+ if (kHairlineAA_GrProcessorEdgeType == edgeType) {
return NULL;
}
SkScalar w = oval.width();
diff --git a/src/gpu/effects/GrOvalEffect.h b/src/gpu/effects/GrOvalEffect.h
index 37574ec58..41e22cc00 100644
--- a/src/gpu/effects/GrOvalEffect.h
+++ b/src/gpu/effects/GrOvalEffect.h
@@ -11,14 +11,14 @@
#include "GrTypes.h"
#include "GrTypesPriv.h"
-class GrEffect;
+class GrProcessor;
struct SkRect;
namespace GrOvalEffect {
/**
* Creates an effect that performs clipping against an oval.
*/
- GrEffect* Create(GrEffectEdgeType, const SkRect&);
+ GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkRect&);
};
#endif
diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp
index 1c45c3774..f5131feba 100644
--- a/src/gpu/effects/GrRRectEffect.cpp
+++ b/src/gpu/effects/GrRRectEffect.cpp
@@ -8,11 +8,11 @@
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrRRectEffect.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
#include "GrConvexPolyEffect.h"
#include "GrOvalEffect.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "SkRRect.h"
@@ -23,7 +23,7 @@ static const SkScalar kRadiusMin = SK_ScalarHalf;
class GLCircularRRectEffect;
-class CircularRRectEffect : public GrEffect {
+class CircularRRectEffect : public GrFragmentProcessor {
public:
enum CornerFlags {
@@ -45,7 +45,8 @@ public:
// The flags are used to indicate which corners are circluar (unflagged corners are assumed to
// be square).
- static GrEffect* Create(GrEffectEdgeType, uint32_t circularCornerFlags, const SkRRect&);
+ static GrFragmentProcessor* Create(GrPrimitiveEdgeType, uint32_t circularCornerFlags,
+ const SkRRect&);
virtual ~CircularRRectEffect() {};
static const char* Name() { return "CircularRRect"; }
@@ -54,32 +55,32 @@ public:
uint32_t getCircularCornerFlags() const { return fCircularCornerFlags; }
- GrEffectEdgeType getEdgeType() const { return fEdgeType; }
+ GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
- typedef GLCircularRRectEffect GLEffect;
+ typedef GLCircularRRectEffect GLProcessor;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
private:
- CircularRRectEffect(GrEffectEdgeType, uint32_t circularCornerFlags, const SkRRect&);
+ CircularRRectEffect(GrPrimitiveEdgeType, uint32_t circularCornerFlags, const SkRRect&);
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE;
- SkRRect fRRect;
- GrEffectEdgeType fEdgeType;
- uint32_t fCircularCornerFlags;
+ SkRRect fRRect;
+ GrPrimitiveEdgeType fEdgeType;
+ uint32_t fCircularCornerFlags;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
-GrEffect* CircularRRectEffect::Create(GrEffectEdgeType edgeType,
- uint32_t circularCornerFlags,
- const SkRRect& rrect) {
- if (kFillAA_GrEffectEdgeType != edgeType && kInverseFillAA_GrEffectEdgeType != edgeType) {
+GrFragmentProcessor* CircularRRectEffect::Create(GrPrimitiveEdgeType edgeType,
+ uint32_t circularCornerFlags,
+ const SkRRect& rrect) {
+ if (kFillAA_GrProcessorEdgeType != edgeType && kInverseFillAA_GrProcessorEdgeType != edgeType) {
return NULL;
}
return SkNEW_ARGS(CircularRRectEffect, (edgeType, circularCornerFlags, rrect));
@@ -89,19 +90,19 @@ void CircularRRectEffect::getConstantColorComponents(GrColor* color, uint32_t* v
*validFlags = 0;
}
-const GrBackendEffectFactory& CircularRRectEffect::getFactory() const {
- return GrTBackendEffectFactory<CircularRRectEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& CircularRRectEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<CircularRRectEffect>::getInstance();
}
-CircularRRectEffect::CircularRRectEffect(GrEffectEdgeType edgeType, uint32_t circularCornerFlags,
- const SkRRect& rrect)
+CircularRRectEffect::CircularRRectEffect(GrPrimitiveEdgeType edgeType, uint32_t circularCornerFlags,
+ const SkRRect& rrect)
: fRRect(rrect)
, fEdgeType(edgeType)
, fCircularCornerFlags(circularCornerFlags) {
this->setWillReadFragmentPosition();
}
-bool CircularRRectEffect::onIsEqual(const GrEffect& other) const {
+bool CircularRRectEffect::onIsEqual(const GrProcessor& other) const {
const CircularRRectEffect& crre = other.cast<CircularRRectEffect>();
// The corner flags are derived from fRRect, so no need to check them.
return fEdgeType == crre.fEdgeType && fRRect == crre.fRRect;
@@ -109,64 +110,65 @@ bool CircularRRectEffect::onIsEqual(const GrEffect& other) const {
//////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(CircularRRectEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircularRRectEffect);
-GrEffect* CircularRRectEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
+GrFragmentProcessor* CircularRRectEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
SkScalar w = random->nextRangeScalar(20.f, 1000.f);
SkScalar h = random->nextRangeScalar(20.f, 1000.f);
SkScalar r = random->nextRangeF(kRadiusMin, 9.f);
SkRRect rrect;
rrect.setRectXY(SkRect::MakeWH(w, h), r, r);
- GrEffect* effect;
+ GrFragmentProcessor* fp;
do {
- GrEffectEdgeType et = (GrEffectEdgeType)random->nextULessThan(kGrEffectEdgeTypeCnt);
- effect = GrRRectEffect::Create(et, rrect);
- } while (NULL == effect);
- return effect;
+ GrPrimitiveEdgeType et =
+ (GrPrimitiveEdgeType)random->nextULessThan(kGrProcessorEdgeTypeCnt);
+ fp = GrRRectEffect::Create(et, rrect);
+ } while (NULL == fp);
+ return fp;
}
//////////////////////////////////////////////////////////////////////////////
-class GLCircularRRectEffect : public GrGLEffect {
+class GLCircularRRectEffect : public GrGLFragmentProcessor {
public:
- GLCircularRRectEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GLCircularRRectEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& fp,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
private:
GrGLProgramDataManager::UniformHandle fInnerRectUniform;
GrGLProgramDataManager::UniformHandle fRadiusPlusHalfUniform;
SkRRect fPrevRRect;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
-GLCircularRRectEffect::GLCircularRRectEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GLCircularRRectEffect::GLCircularRRectEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor& )
: INHERITED (factory) {
fPrevRRect.setEmpty();
}
void GLCircularRRectEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& fp,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) {
- const CircularRRectEffect& crre = effect.cast<CircularRRectEffect>();
+ const CircularRRectEffect& crre = fp.cast<CircularRRectEffect>();
const char *rectName;
const char *radiusPlusHalfName;
// The inner rect is the rrect bounds inset by the radius. Its left, top, right, and bottom
@@ -285,7 +287,7 @@ void GLCircularRRectEffect::emitCode(GrGLProgramBuilder* builder,
break;
}
- if (kInverseFillAA_GrEffectEdgeType == crre.getEdgeType()) {
+ if (kInverseFillAA_GrProcessorEdgeType == crre.getEdgeType()) {
fsBuilder->codeAppend("\t\talpha = 1.0 - alpha;\n");
}
@@ -293,16 +295,16 @@ void GLCircularRRectEffect::emitCode(GrGLProgramBuilder* builder,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
}
-void GLCircularRRectEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
- const CircularRRectEffect& crre = effect.cast<CircularRRectEffect>();
- GR_STATIC_ASSERT(kGrEffectEdgeTypeCnt <= 8);
+void GLCircularRRectEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
+ const CircularRRectEffect& crre = processor.cast<CircularRRectEffect>();
+ GR_STATIC_ASSERT(kGrProcessorEdgeTypeCnt <= 8);
b->add32((crre.getCircularCornerFlags() << 3) | crre.getEdgeType());
}
void GLCircularRRectEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
- const CircularRRectEffect& crre = effect.cast<CircularRRectEffect>();
+ const GrProcessor& processor) {
+ const CircularRRectEffect& crre = processor.cast<CircularRRectEffect>();
const SkRRect& rrect = crre.getRRect();
if (rrect != fPrevRRect) {
SkRect rect = rrect.getBounds();
@@ -383,9 +385,9 @@ void GLCircularRRectEffect::setData(const GrGLProgramDataManager& pdman,
class GLEllipticalRRectEffect;
-class EllipticalRRectEffect : public GrEffect {
+class EllipticalRRectEffect : public GrFragmentProcessor {
public:
- static GrEffect* Create(GrEffectEdgeType, const SkRRect&);
+ static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkRRect&);
virtual ~EllipticalRRectEffect() {};
static const char* Name() { return "EllipticalRRect"; }
@@ -393,29 +395,30 @@ public:
const SkRRect& getRRect() const { return fRRect; }
- GrEffectEdgeType getEdgeType() const { return fEdgeType; }
+ GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; }
- typedef GLEllipticalRRectEffect GLEffect;
+ typedef GLEllipticalRRectEffect GLProcessor;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
private:
- EllipticalRRectEffect(GrEffectEdgeType, const SkRRect&);
+ EllipticalRRectEffect(GrPrimitiveEdgeType, const SkRRect&);
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE;
SkRRect fRRect;
- GrEffectEdgeType fEdgeType;
+ GrPrimitiveEdgeType fEdgeType;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
-GrEffect* EllipticalRRectEffect::Create(GrEffectEdgeType edgeType, const SkRRect& rrect) {
- if (kFillAA_GrEffectEdgeType != edgeType && kInverseFillAA_GrEffectEdgeType != edgeType) {
+GrFragmentProcessor*
+EllipticalRRectEffect::Create(GrPrimitiveEdgeType edgeType, const SkRRect& rrect) {
+ if (kFillAA_GrProcessorEdgeType != edgeType && kInverseFillAA_GrProcessorEdgeType != edgeType) {
return NULL;
}
return SkNEW_ARGS(EllipticalRRectEffect, (edgeType, rrect));
@@ -425,29 +428,29 @@ void EllipticalRRectEffect::getConstantColorComponents(GrColor* color, uint32_t*
*validFlags = 0;
}
-const GrBackendEffectFactory& EllipticalRRectEffect::getFactory() const {
- return GrTBackendEffectFactory<EllipticalRRectEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& EllipticalRRectEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<EllipticalRRectEffect>::getInstance();
}
-EllipticalRRectEffect::EllipticalRRectEffect(GrEffectEdgeType edgeType, const SkRRect& rrect)
+EllipticalRRectEffect::EllipticalRRectEffect(GrPrimitiveEdgeType edgeType, const SkRRect& rrect)
: fRRect(rrect)
, fEdgeType(edgeType){
this->setWillReadFragmentPosition();
}
-bool EllipticalRRectEffect::onIsEqual(const GrEffect& other) const {
+bool EllipticalRRectEffect::onIsEqual(const GrProcessor& other) const {
const EllipticalRRectEffect& erre = other.cast<EllipticalRRectEffect>();
return fEdgeType == erre.fEdgeType && fRRect == erre.fRRect;
}
//////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(EllipticalRRectEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(EllipticalRRectEffect);
-GrEffect* EllipticalRRectEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture*[]) {
+GrFragmentProcessor* EllipticalRRectEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture*[]) {
SkScalar w = random->nextRangeScalar(20.f, 1000.f);
SkScalar h = random->nextRangeScalar(20.f, 1000.f);
SkVector r[4];
@@ -474,48 +477,48 @@ GrEffect* EllipticalRRectEffect::TestCreate(SkRandom* random,
rrect.setRectXY(SkRect::MakeWH(w, h), r[SkRRect::kUpperLeft_Corner].fX,
r[SkRRect::kUpperLeft_Corner].fY);
}
- GrEffect* effect;
+ GrFragmentProcessor* fp;
do {
- GrEffectEdgeType et = (GrEffectEdgeType)random->nextULessThan(kGrEffectEdgeTypeCnt);
- effect = GrRRectEffect::Create(et, rrect);
- } while (NULL == effect);
- return effect;
+ GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)random->nextULessThan(kGrProcessorEdgeTypeCnt);
+ fp = GrRRectEffect::Create(et, rrect);
+ } while (NULL == fp);
+ return fp;
}
//////////////////////////////////////////////////////////////////////////////
-class GLEllipticalRRectEffect : public GrGLEffect {
+class GLEllipticalRRectEffect : public GrGLFragmentProcessor {
public:
- GLEllipticalRRectEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GLEllipticalRRectEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& effect,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
private:
GrGLProgramDataManager::UniformHandle fInnerRectUniform;
GrGLProgramDataManager::UniformHandle fInvRadiiSqdUniform;
SkRRect fPrevRRect;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
-GLEllipticalRRectEffect::GLEllipticalRRectEffect(const GrBackendEffectFactory& factory,
- const GrEffect& effect)
+GLEllipticalRRectEffect::GLEllipticalRRectEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor& effect)
: INHERITED (factory) {
fPrevRRect.setEmpty();
}
void GLEllipticalRRectEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& effect,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
@@ -580,7 +583,7 @@ void GLEllipticalRRectEffect::emitCode(GrGLProgramBuilder* builder,
fsBuilder->codeAppend("\t\tgrad_dot = max(grad_dot, 1.0e-4);\n");
fsBuilder->codeAppendf("\t\tfloat approx_dist = implicit * inversesqrt(grad_dot);\n");
- if (kFillAA_GrEffectEdgeType == erre.getEdgeType()) {
+ if (kFillAA_GrProcessorEdgeType == erre.getEdgeType()) {
fsBuilder->codeAppend("\t\tfloat alpha = clamp(0.5 - approx_dist, 0.0, 1.0);\n");
} else {
fsBuilder->codeAppend("\t\tfloat alpha = clamp(0.5 + approx_dist, 0.0, 1.0);\n");
@@ -590,15 +593,15 @@ void GLEllipticalRRectEffect::emitCode(GrGLProgramBuilder* builder,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
}
-void GLEllipticalRRectEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
+void GLEllipticalRRectEffect::GenKey(const GrProcessor& effect, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
const EllipticalRRectEffect& erre = effect.cast<EllipticalRRectEffect>();
- GR_STATIC_ASSERT(kLast_GrEffectEdgeType < (1 << 3));
+ GR_STATIC_ASSERT(kLast_GrProcessorEdgeType < (1 << 3));
b->add32(erre.getRRect().getType() | erre.getEdgeType() << 3);
}
void GLEllipticalRRectEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
+ const GrProcessor& effect) {
const EllipticalRRectEffect& erre = effect.cast<EllipticalRRectEffect>();
const SkRRect& rrect = erre.getRRect();
if (rrect != fPrevRRect) {
@@ -636,7 +639,7 @@ void GLEllipticalRRectEffect::setData(const GrGLProgramDataManager& pdman,
//////////////////////////////////////////////////////////////////////////////
-GrEffect* GrRRectEffect::Create(GrEffectEdgeType edgeType, const SkRRect& rrect) {
+GrFragmentProcessor* GrRRectEffect::Create(GrPrimitiveEdgeType edgeType, const SkRRect& rrect) {
if (rrect.isRect()) {
return GrConvexPolyEffect::Create(edgeType, rrect.getBounds());
}
diff --git a/src/gpu/effects/GrRRectEffect.h b/src/gpu/effects/GrRRectEffect.h
index bcf4884dd..eaaf9a072 100644
--- a/src/gpu/effects/GrRRectEffect.h
+++ b/src/gpu/effects/GrRRectEffect.h
@@ -11,7 +11,7 @@
#include "GrTypes.h"
#include "GrTypesPriv.h"
-class GrEffect;
+class GrProcessor;
class SkRRect;
namespace GrRRectEffect {
@@ -19,7 +19,7 @@ namespace GrRRectEffect {
* Creates an effect that performs anti-aliased clipping against a SkRRect. It doesn't support
* all varieties of SkRRect so the caller must check for a NULL return.
*/
- GrEffect* Create(GrEffectEdgeType, const SkRRect&);
+ GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkRRect&);
};
#endif
diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp
index f2a932b02..6743ddbbe 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/GrSimpleTextureEffect.cpp
@@ -7,21 +7,21 @@
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrSimpleTextureEffect.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/GrGLSL.h"
#include "gl/GrGLTexture.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrTBackendProcessorFactory.h"
#include "GrTexture.h"
-class GrGLSimpleTextureEffect : public GrGLEffect {
+class GrGLSimpleTextureEffect : public GrGLFragmentProcessor {
public:
- GrGLSimpleTextureEffect(const GrBackendEffectFactory& factory, const GrEffect&)
+ GrGLSimpleTextureEffect(const GrBackendProcessorFactory& factory, const GrProcessor&)
: INHERITED (factory) {
}
virtual void emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& fp,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -36,7 +36,7 @@ public:
}
private:
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
@@ -45,20 +45,20 @@ void GrSimpleTextureEffect::getConstantColorComponents(GrColor* color, uint32_t*
this->updateConstantColorComponentsForModulation(color, validFlags);
}
-const GrBackendEffectFactory& GrSimpleTextureEffect::getFactory() const {
- return GrTBackendEffectFactory<GrSimpleTextureEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& GrSimpleTextureEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<GrSimpleTextureEffect>::getInstance();
}
///////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrSimpleTextureEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSimpleTextureEffect);
-GrEffect* GrSimpleTextureEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
- int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
- GrEffectUnitTest::kAlphaTextureIdx;
+GrFragmentProcessor* GrSimpleTextureEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
+ int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
+ GrProcessorUnitTest::kAlphaTextureIdx;
static const SkShader::TileMode kTileModes[] = {
SkShader::kClamp_TileMode,
SkShader::kRepeat_TileMode,
@@ -77,6 +77,6 @@ GrEffect* GrSimpleTextureEffect::TestCreate(SkRandom* random,
};
GrCoordSet coordSet = kCoordSets[random->nextULessThan(SK_ARRAY_COUNT(kCoordSets))];
- const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random);
+ const SkMatrix& matrix = GrProcessorUnitTest::TestMatrix(random);
return GrSimpleTextureEffect::Create(textures[texIdx], matrix, coordSet);
}
diff --git a/src/gpu/effects/GrSimpleTextureEffect.h b/src/gpu/effects/GrSimpleTextureEffect.h
index e81dd86cb..dc9cf85e0 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.h
+++ b/src/gpu/effects/GrSimpleTextureEffect.h
@@ -23,25 +23,25 @@ class GrGLSimpleTextureEffect;
class GrSimpleTextureEffect : public GrSingleTextureEffect {
public:
/* unfiltered, clamp mode */
- static GrEffect* Create(GrTexture* tex,
- const SkMatrix& matrix,
- GrCoordSet coordSet = kLocal_GrCoordSet) {
+ static GrFragmentProcessor* Create(GrTexture* tex,
+ const SkMatrix& matrix,
+ GrCoordSet coordSet = kLocal_GrCoordSet) {
return SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, GrTextureParams::kNone_FilterMode,
coordSet));
}
/* clamp mode */
- static GrEffect* Create(GrTexture* tex,
- const SkMatrix& matrix,
- GrTextureParams::FilterMode filterMode,
- GrCoordSet coordSet = kLocal_GrCoordSet) {
+ static GrFragmentProcessor* Create(GrTexture* tex,
+ const SkMatrix& matrix,
+ GrTextureParams::FilterMode filterMode,
+ GrCoordSet coordSet = kLocal_GrCoordSet) {
return SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, filterMode, coordSet));
}
- static GrEffect* Create(GrTexture* tex,
- const SkMatrix& matrix,
- const GrTextureParams& p,
- GrCoordSet coordSet = kLocal_GrCoordSet) {
+ static GrFragmentProcessor* Create(GrTexture* tex,
+ const SkMatrix& matrix,
+ const GrTextureParams& p,
+ GrCoordSet coordSet = kLocal_GrCoordSet) {
return SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, p, coordSet));
}
@@ -51,9 +51,9 @@ public:
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
- typedef GrGLSimpleTextureEffect GLEffect;
+ typedef GrGLSimpleTextureEffect GLProcessor;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
private:
GrSimpleTextureEffect(GrTexture* texture,
@@ -70,12 +70,12 @@ private:
: GrSingleTextureEffect(texture, matrix, params, coordSet) {
}
- virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
+ virtual bool onIsEqual(const GrProcessor& other) const SK_OVERRIDE {
const GrSimpleTextureEffect& ste = other.cast<GrSimpleTextureEffect>();
return this->hasSameTextureParamsMatrixAndSourceCoords(ste);
}
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
typedef GrSingleTextureEffect INHERITED;
};
diff --git a/src/gpu/effects/GrSingleTextureEffect.h b/src/gpu/effects/GrSingleTextureEffect.h
index a8f9a6d52..6349ee789 100644
--- a/src/gpu/effects/GrSingleTextureEffect.h
+++ b/src/gpu/effects/GrSingleTextureEffect.h
@@ -8,7 +8,7 @@
#ifndef GrSingleTextureEffect_DEFINED
#define GrSingleTextureEffect_DEFINED
-#include "GrEffect.h"
+#include "GrProcessor.h"
#include "SkMatrix.h"
#include "GrCoordTransform.h"
@@ -18,7 +18,7 @@ class GrTexture;
* A base class for effects that draw a single texture with a texture matrix. This effect has no
* backend implementations. One must be provided by the subclass.
*/
-class GrSingleTextureEffect : public GrEffect {
+class GrSingleTextureEffect : public GrFragmentProcessor {
public:
virtual ~GrSingleTextureEffect();
@@ -61,7 +61,7 @@ private:
GrCoordTransform fCoordTransform;
GrTextureAccess fTextureAccess;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
#endif
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index 664c65c12..1d3b37ddd 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -8,8 +8,8 @@
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrTextureDomain.h"
#include "GrSimpleTextureEffect.h"
-#include "GrTBackendEffectFactory.h"
-#include "gl/GrGLEffect.h"
+#include "GrTBackendProcessorFactory.h"
+#include "gl/GrGLProcessor.h"
#include "SkFloatingPoint.h"
@@ -44,7 +44,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLShaderBuilder* builder,
const GrTextureDomain& textureDomain,
const char* outColor,
const SkString& inCoords,
- const GrGLEffect::TextureSampler sampler,
+ const GrGLProcessor::TextureSampler sampler,
const char* inModulateColor) {
SkASSERT((Mode)-1 == fMode || textureDomain.mode() == fMode);
SkDEBUGCODE(fMode = textureDomain.mode();)
@@ -165,40 +165,40 @@ void GrTextureDomain::GLDomain::setData(const GrGLProgramDataManager& pdman,
//////////////////////////////////////////////////////////////////////////////
-class GrGLTextureDomainEffect : public GrGLEffect {
+class GrGLTextureDomainEffect : public GrGLFragmentProcessor {
public:
- GrGLTextureDomainEffect(const GrBackendEffectFactory&, const GrEffect&);
+ GrGLTextureDomainEffect(const GrBackendProcessorFactory&, const GrProcessor&);
virtual void emitCode(GrGLProgramBuilder*,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
private:
GrTextureDomain::GLDomain fGLDomain;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
-GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendEffectFactory& factory,
- const GrEffect&)
+GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendProcessorFactory& factory,
+ const GrProcessor&)
: INHERITED(factory) {
}
void GrGLTextureDomainEffect::emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& fp,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
const TextureSamplerArray& samplers) {
- const GrTextureDomainEffect& textureDomainEffect = effect.cast<GrTextureDomainEffect>();
+ const GrTextureDomainEffect& textureDomainEffect = fp.cast<GrTextureDomainEffect>();
const GrTextureDomain& domain = textureDomainEffect.textureDomain();
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
@@ -207,27 +207,27 @@ void GrGLTextureDomainEffect::emitCode(GrGLProgramBuilder* builder,
}
void GrGLTextureDomainEffect::setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) {
- const GrTextureDomainEffect& textureDomainEffect = effect.cast<GrTextureDomainEffect>();
+ const GrProcessor& processor) {
+ const GrTextureDomainEffect& textureDomainEffect = processor.cast<GrTextureDomainEffect>();
const GrTextureDomain& domain = textureDomainEffect.textureDomain();
- fGLDomain.setData(pdman, domain, effect.texture(0)->origin());
+ fGLDomain.setData(pdman, domain, processor.texture(0)->origin());
}
-void GrGLTextureDomainEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
- GrEffectKeyBuilder* b) {
- const GrTextureDomain& domain = effect.cast<GrTextureDomainEffect>().textureDomain();
+void GrGLTextureDomainEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
+ const GrTextureDomain& domain = processor.cast<GrTextureDomainEffect>().textureDomain();
b->add32(GrTextureDomain::GLDomain::DomainKey(domain));
}
///////////////////////////////////////////////////////////////////////////////
-GrEffect* GrTextureDomainEffect::Create(GrTexture* texture,
- const SkMatrix& matrix,
- const SkRect& domain,
- GrTextureDomain::Mode mode,
- GrTextureParams::FilterMode filterMode,
- GrCoordSet coordSet) {
+GrFragmentProcessor* GrTextureDomainEffect::Create(GrTexture* texture,
+ const SkMatrix& matrix,
+ const SkRect& domain,
+ GrTextureDomain::Mode mode,
+ GrTextureParams::FilterMode filterMode,
+ GrCoordSet coordSet) {
static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1};
if (GrTextureDomain::kIgnore_Mode == mode ||
(GrTextureDomain::kClamp_Mode == mode && domain.contains(kFullRect))) {
@@ -259,11 +259,11 @@ GrTextureDomainEffect::~GrTextureDomainEffect() {
}
-const GrBackendEffectFactory& GrTextureDomainEffect::getFactory() const {
- return GrTBackendEffectFactory<GrTextureDomainEffect>::getInstance();
+const GrBackendFragmentProcessorFactory& GrTextureDomainEffect::getFactory() const {
+ return GrTBackendFragmentProcessorFactory<GrTextureDomainEffect>::getInstance();
}
-bool GrTextureDomainEffect::onIsEqual(const GrEffect& sBase) const {
+bool GrTextureDomainEffect::onIsEqual(const GrProcessor& sBase) const {
const GrTextureDomainEffect& s = sBase.cast<GrTextureDomainEffect>();
return this->hasSameTextureParamsMatrixAndSourceCoords(s) &&
this->fTextureDomain == s.fTextureDomain;
@@ -279,14 +279,14 @@ void GrTextureDomainEffect::getConstantColorComponents(GrColor* color, uint32_t*
///////////////////////////////////////////////////////////////////////////////
-GR_DEFINE_EFFECT_TEST(GrTextureDomainEffect);
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrTextureDomainEffect);
-GrEffect* GrTextureDomainEffect::TestCreate(SkRandom* random,
- GrContext*,
- const GrDrawTargetCaps&,
- GrTexture* textures[]) {
- int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
- GrEffectUnitTest::kAlphaTextureIdx;
+GrFragmentProcessor* GrTextureDomainEffect::TestCreate(SkRandom* random,
+ GrContext*,
+ const GrDrawTargetCaps&,
+ GrTexture* textures[]) {
+ int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
+ GrProcessorUnitTest::kAlphaTextureIdx;
SkRect domain;
domain.fLeft = random->nextUScalar1();
domain.fRight = random->nextRangeScalar(domain.fLeft, SK_Scalar1);
@@ -294,7 +294,7 @@ GrEffect* GrTextureDomainEffect::TestCreate(SkRandom* random,
domain.fBottom = random->nextRangeScalar(domain.fTop, SK_Scalar1);
GrTextureDomain::Mode mode =
(GrTextureDomain::Mode) random->nextULessThan(GrTextureDomain::kModeCount);
- const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random);
+ const SkMatrix& matrix = GrProcessorUnitTest::TestMatrix(random);
bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? random->nextBool() : false;
GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoordSet;
return GrTextureDomainEffect::Create(textures[texIdx],
diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h
index 6cb5ad408..5751bad0f 100644
--- a/src/gpu/effects/GrTextureDomain.h
+++ b/src/gpu/effects/GrTextureDomain.h
@@ -9,7 +9,7 @@
#define GrTextureDomainEffect_DEFINED
#include "GrSingleTextureEffect.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
class GrGLProgramBuilder;
class GrGLShaderBuilder;
@@ -73,7 +73,7 @@ public:
}
/**
- * A GrGLEffect subclass that corresponds to a GrEffect subclass that uses GrTextureDomain
+ * A GrGLProcessor subclass that corresponds to a GrProcessor subclass that uses GrTextureDomain
* should include this helper. It generates the texture domain GLSL, produces the part of the
* effect key that reflects the texture domain code, and performs the uniform uploads necessary
* for texture domains.
@@ -86,7 +86,8 @@ public:
}
/**
- * Call this from GrGLEffect::emitCode() to sample the texture W.R.T. the domain and mode.
+ * Call this from GrGLProcessor::emitCode() to sample the texture W.R.T. the domain and
+ * mode.
*
* @param outcolor name of vec4 variable to hold the sampled color.
* @param inCoords name of vec2 variable containing the coords to be used with the domain.
@@ -98,12 +99,12 @@ public:
const GrTextureDomain& textureDomain,
const char* outColor,
const SkString& inCoords,
- const GrGLEffect::TextureSampler sampler,
+ const GrGLProcessor::TextureSampler sampler,
const char* inModulateColor = NULL);
/**
- * Call this from GrGLEffect::setData() to upload uniforms necessary for the texture domain.
- * The rectangle is automatically adjusted to account for the texture's origin.
+ * Call this from GrGLProcessor::setData() to upload uniforms necessary for the texture
+ * domain. The rectangle is automatically adjusted to account for the texture's origin.
*/
void setData(const GrGLProgramDataManager& pdman, const GrTextureDomain& textureDomain,
GrSurfaceOrigin textureOrigin);
@@ -113,8 +114,8 @@ public:
};
/**
- * GrGLEffect::GenKey() must call this and include the returned value in it's computed key.
- * The returned will be limited to the lower kDomainKeyBits bits.
+ * GrGLProcessor::GenKey() must call this and include the returned value in it's computed
+ * key. The returned will be limited to the lower kDomainKeyBits bits.
*/
static uint32_t DomainKey(const GrTextureDomain& domain) {
GR_STATIC_ASSERT(kModeCount <= 4);
@@ -144,20 +145,20 @@ class GrGLTextureDomainEffect;
class GrTextureDomainEffect : public GrSingleTextureEffect {
public:
- static GrEffect* Create(GrTexture*,
- const SkMatrix&,
- const SkRect& domain,
- GrTextureDomain::Mode,
- GrTextureParams::FilterMode filterMode,
- GrCoordSet = kLocal_GrCoordSet);
+ static GrFragmentProcessor* Create(GrTexture*,
+ const SkMatrix&,
+ const SkRect& domain,
+ GrTextureDomain::Mode,
+ GrTextureParams::FilterMode filterMode,
+ GrCoordSet = kLocal_GrCoordSet);
virtual ~GrTextureDomainEffect();
static const char* Name() { return "TextureDomain"; }
- typedef GrGLTextureDomainEffect GLEffect;
+ typedef GrGLTextureDomainEffect GLProcessor;
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE;
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
const GrTextureDomain& textureDomain() const { return fTextureDomain; }
@@ -173,9 +174,9 @@ private:
GrTextureParams::FilterMode,
GrCoordSet);
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
- GR_DECLARE_EFFECT_TEST;
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
typedef GrSingleTextureEffect INHERITED;
};
diff --git a/src/gpu/effects/GrYUVtoRGBEffect.cpp b/src/gpu/effects/GrYUVtoRGBEffect.cpp
index dc67028df..436106c99 100644
--- a/src/gpu/effects/GrYUVtoRGBEffect.cpp
+++ b/src/gpu/effects/GrYUVtoRGBEffect.cpp
@@ -9,23 +9,23 @@
#include "GrYUVtoRGBEffect.h"
#include "GrCoordTransform.h"
-#include "GrEffect.h"
-#include "gl/GrGLEffect.h"
-#include "GrTBackendEffectFactory.h"
+#include "GrProcessor.h"
+#include "gl/GrGLProcessor.h"
+#include "GrTBackendProcessorFactory.h"
namespace {
-class YUVtoRGBEffect : public GrEffect {
+class YUVtoRGBEffect : public GrFragmentProcessor {
public:
- static GrEffect* Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture,
- SkYUVColorSpace colorSpace) {
+ static GrFragmentProcessor* Create(GrTexture* yTexture, GrTexture* uTexture,
+ GrTexture* vTexture, SkYUVColorSpace colorSpace) {
return SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture, colorSpace));
}
static const char* Name() { return "YUV to RGB"; }
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
- return GrTBackendEffectFactory<YUVtoRGBEffect>::getInstance();
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE {
+ return GrTBackendFragmentProcessorFactory<YUVtoRGBEffect>::getInstance();
}
virtual void getConstantColorComponents(GrColor* color,
@@ -39,22 +39,22 @@ public:
return fColorSpace;
}
- class GLEffect : public GrGLEffect {
+ class GLProcessor : public GrGLFragmentProcessor {
public:
static const GrGLfloat kJPEGConversionMatrix[16];
static const GrGLfloat kRec601ConversionMatrix[16];
// this class always generates the same code.
- static void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
+ static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {}
- GLEffect(const GrBackendEffectFactory& factory,
- const GrEffect&)
+ GLProcessor(const GrBackendProcessorFactory& factory,
+ const GrProcessor&)
: INHERITED(factory) {
}
virtual void emitCode(GrGLProgramBuilder* builder,
- const GrEffect&,
- const GrEffectKey&,
+ const GrFragmentProcessor&,
+ const GrProcessorKey&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
@@ -75,8 +75,8 @@ public:
}
virtual void setData(const GrGLProgramDataManager& pdman,
- const GrEffect& effect) SK_OVERRIDE {
- const YUVtoRGBEffect& yuvEffect = effect.cast<YUVtoRGBEffect>();
+ const GrProcessor& processor) SK_OVERRIDE {
+ const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>();
switch (yuvEffect.getColorSpace()) {
case kJPEG_SkYUVColorSpace:
pdman.setMatrix4f(fMatrixUni, kJPEGConversionMatrix);
@@ -90,7 +90,7 @@ public:
private:
GrGLProgramDataManager::UniformHandle fMatrixUni;
- typedef GrGLEffect INHERITED;
+ typedef GrGLFragmentProcessor INHERITED;
};
private:
@@ -109,7 +109,7 @@ private:
this->setWillNotUseInputColor();
}
- virtual bool onIsEqual(const GrEffect& sBase) const {
+ virtual bool onIsEqual(const GrProcessor& sBase) const {
const YUVtoRGBEffect& s = sBase.cast<YUVtoRGBEffect>();
return fYAccess.getTexture() == s.fYAccess.getTexture() &&
fUAccess.getTexture() == s.fUAccess.getTexture() &&
@@ -123,15 +123,15 @@ private:
GrTextureAccess fVAccess;
SkYUVColorSpace fColorSpace;
- typedef GrEffect INHERITED;
+ typedef GrFragmentProcessor INHERITED;
};
-const GrGLfloat YUVtoRGBEffect::GLEffect::kJPEGConversionMatrix[16] = {
+const GrGLfloat YUVtoRGBEffect::GLProcessor::kJPEGConversionMatrix[16] = {
1.0f, 0.0f, 1.402f, -0.701f,
1.0f, -0.34414f, -0.71414f, 0.529f,
1.0f, 1.772f, 0.0f, -0.886f,
0.0f, 0.0f, 0.0f, 1.0};
-const GrGLfloat YUVtoRGBEffect::GLEffect::kRec601ConversionMatrix[16] = {
+const GrGLfloat YUVtoRGBEffect::GLProcessor::kRec601ConversionMatrix[16] = {
1.164f, 0.0f, 1.596f, -0.87075f,
1.164f, -0.391f, -0.813f, 0.52925f,
1.164f, 2.018f, 0.0f, -1.08175f,
@@ -140,7 +140,8 @@ const GrGLfloat YUVtoRGBEffect::GLEffect::kRec601ConversionMatrix[16] = {
//////////////////////////////////////////////////////////////////////////////
-GrEffect* GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture,
- SkYUVColorSpace colorSpace) {
+GrFragmentProcessor*
+GrYUVtoRGBEffect::Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture,
+ SkYUVColorSpace colorSpace) {
return YUVtoRGBEffect::Create(yTexture, uTexture, vTexture, colorSpace);
}
diff --git a/src/gpu/effects/GrYUVtoRGBEffect.h b/src/gpu/effects/GrYUVtoRGBEffect.h
index 52ccd23bb..4c057bd0a 100644
--- a/src/gpu/effects/GrYUVtoRGBEffect.h
+++ b/src/gpu/effects/GrYUVtoRGBEffect.h
@@ -10,15 +10,15 @@
#include "SkImageInfo.h"
-class GrEffect;
+class GrFragmentProcessor;
class GrTexture;
namespace GrYUVtoRGBEffect {
/**
* Creates an effect that performs color conversion from YUV to RGB
*/
- GrEffect* Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture,
- SkYUVColorSpace colorSpace);
+ GrFragmentProcessor* Create(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture,
+ SkYUVColorSpace colorSpace);
};
#endif
diff --git a/src/gpu/gl/GrGLGeometryProcessor.h b/src/gpu/gl/GrGLGeometryProcessor.h
index d057154c6..b879e12da 100644
--- a/src/gpu/gl/GrGLGeometryProcessor.h
+++ b/src/gpu/gl/GrGLGeometryProcessor.h
@@ -8,45 +8,32 @@
#ifndef GrGLGeometryProcessor_DEFINED
#define GrGLGeometryProcessor_DEFINED
-#include "GrGLEffect.h"
+#include "GrGLProcessor.h"
/**
* If a GL effect needs a GrGLFullShaderBuilder* object to emit vertex code, then it must inherit
* from this class. Since paths don't have vertices, this class is only meant to be used internally
* by skia, for special cases.
*/
-class GrGLGeometryProcessor : public GrGLEffect {
+class GrGLGeometryProcessor : public GrGLProcessor {
public:
- GrGLGeometryProcessor(const GrBackendEffectFactory& factory)
- : INHERITED(factory) { fIsVertexEffect = true; }
+ GrGLGeometryProcessor(const GrBackendProcessorFactory& factory)
+ : INHERITED(factory) {}
/**
* This is similar to emitCode() in the base class, except it takes a full shader builder.
* This allows the effect subclass to emit vertex code.
*/
virtual void emitCode(GrGLFullProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrGeometryProcessor& geometryProcessor,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
const TextureSamplerArray& samplers) = 0;
- /**
- * Provide a default override for base class's emitCode() function.
- */
- virtual void emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
- const char* outputColor,
- const char* inputColor,
- const TransformedCoordsArray& coords,
- const TextureSamplerArray& samplers) SK_OVERRIDE {
- SkFAIL("GrGLGeometryProcessor requires GrGLFullProgramBuilder* overload for emitCode().");
- }
-
private:
- typedef GrGLEffect INHERITED;
+ typedef GrGLProcessor INHERITED;
};
#endif
diff --git a/src/gpu/gl/GrGLEffect.h b/src/gpu/gl/GrGLProcessor.h
index 61e3ed8e5..8455305b0 100644
--- a/src/gpu/gl/GrGLEffect.h
+++ b/src/gpu/gl/GrGLProcessor.h
@@ -5,46 +5,45 @@
* found in the LICENSE file.
*/
-#ifndef GrGLEffect_DEFINED
-#define GrGLEffect_DEFINED
+#ifndef GrGLProcessor_DEFINED
+#define GrGLProcessor_DEFINED
-#include "GrBackendEffectFactory.h"
+#include "GrBackendProcessorFactory.h"
#include "GrGLProgramEffects.h"
#include "GrGLShaderVar.h"
#include "GrGLSL.h"
-class GrGLShaderBuilder;
-
/** @file
This file contains specializations for OpenGL of the shader stages declared in
- include/gpu/GrEffect.h. Objects of type GrGLEffect are responsible for emitting the
- GLSL code that implements a GrEffect and for uploading uniforms at draw time. If they don't
+ include/gpu/GrProcessor.h. Objects of type GrGLProcessor are responsible for emitting the
+ GLSL code that implements a GrProcessor and for uploading uniforms at draw time. If they don't
always emit the same GLSL code, they must have a function:
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*)
- that is used to implement a program cache. When two GrEffects produce the same key this means
- that their GrGLEffects would emit the same GLSL code.
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*)
+ that is used to implement a program cache. When two GrProcessors produce the same key this means
+ that their GrGLProcessors would emit the same GLSL code.
- The GrGLEffect subclass must also have a constructor of the form:
- EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrEffect&)
+ The GrGLProcessor subclass must also have a constructor of the form:
+ EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrProcessor&)
- These objects are created by the factory object returned by the GrEffect::getFactory().
+ These objects are created by the factory object returned by the GrProcessor::getFactory().
*/
-class GrGLTexture;
-class GrGLGeometryProcessor;
-
-class GrGLEffect {
+class GrGLProcessor {
public:
+ GrGLProcessor(const GrBackendProcessorFactory& factory)
+ : fFactory(factory) {
+ }
+
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
/**
- * Passed to GrGLEffects so they can add transformed coordinates to their shader code.
+ * Passed to GrGLProcessors so they can add transformed coordinates to their shader code.
*/
typedef GrShaderVar TransformedCoords;
typedef SkTArray<GrShaderVar> TransformedCoordsArray;
/**
- * Passed to GrGLEffects so they can add texture reads to their shader code.
+ * Passed to GrGLProcessors so they can add texture reads to their shader code.
*/
class TextureSampler {
public:
@@ -70,12 +69,32 @@ public:
typedef SkTArray<TextureSampler> TextureSamplerArray;
- GrGLEffect(const GrBackendEffectFactory& factory)
- : fFactory(factory)
- , fIsVertexEffect(false) {
+ virtual ~GrGLProcessor() {}
+
+ /** A GrGLProcessor instance can be reused with any GrProcessor that produces the same stage
+ key; this function reads data from a GrProcessor and uploads any uniform variables required
+ by the shaders created in emitCode(). The GrProcessor installed in the GrDrawEffect is
+ guaranteed to be of the same type that created this GrGLProcessor and to have an identical
+ effect key as the one that created this GrGLProcessor. Effects that use local coords have
+ to consider whether the GrProcessorStage's coord change matrix should be used. When explicit
+ local coordinates are used it can be ignored. */
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) {}
+
+ const char* name() const { return fFactory.name(); }
+
+ static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {}
+
+protected:
+ const GrBackendProcessorFactory& fFactory;
+};
+
+class GrGLFragmentProcessor : public GrGLProcessor {
+public:
+ GrGLFragmentProcessor(const GrBackendProcessorFactory& factory)
+ : INHERITED(factory) {
}
- virtual ~GrGLEffect() {}
+ virtual ~GrGLFragmentProcessor() {}
/** Called when the program stage should insert its code into the shaders. The code in each
shader will be in its own block ({}) and so locally scoped names will not collide across
@@ -83,7 +102,7 @@ public:
@param builder Interface used to emit code in the shaders.
@param effect The effect that generated this program stage.
- @param key The key that was computed by GenKey() from the generating GrEffect.
+ @param key The key that was computed by GenKey() from the generating GrProcessor.
@param outputColor A predefined vec4 in the FS in which the stage should place its output
color (or coverage).
@param inputColor A vec4 that holds the input color to the stage in the FS. This may be
@@ -91,42 +110,20 @@ public:
TODO: Better system for communicating optimization info (e.g. input
color is solid white, trans black, known to be opaque, etc.) that allows
the effect to communicate back similar known info about its output.
- @param samplers One entry for each GrTextureAccess of the GrEffect that generated the
- GrGLEffect. These can be passed to the builder to emit texture
- reads in the generated code.
+ @param samplers Contains one entry for each GrTextureAccess of the GrProcessor. These
+ can be passed to the builder to emit texture reads in the generated
+ code.
*/
virtual void emitCode(GrGLProgramBuilder* builder,
- const GrEffect& effect,
- const GrEffectKey& key,
+ const GrFragmentProcessor& effect,
+ const GrProcessorKey& key,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
const TextureSamplerArray& samplers) = 0;
- /** A GrGLEffect instance can be reused with any GrEffect that produces the same stage
- key; this function reads data from a GrEffect and uploads any uniform variables required
- by the shaders created in emitCode(). The GrEffect is
- guaranteed to be of the same type that created this GrGLEffect and to have an identical
- effect key as the one that created this GrGLEffect. Effects that use local coords have
- to consider whether the GrEffectStage's coord change matrix should be used. When explicit
- local coordinates are used it can be ignored. */
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) {}
-
- const char* name() const { return fFactory.name(); }
-
- static void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
-
- /** Used by the system when generating shader code, to see if this effect can be downcasted to
- the internal GrGLGeometryProcessor type */
- bool isVertexEffect() const { return fIsVertexEffect; }
-
-protected:
- const GrBackendEffectFactory& fFactory;
-
private:
- friend class GrGLGeometryProcessor; // to set fIsVertexEffect
-
- bool fIsVertexEffect;
+ typedef GrGLProcessor INHERITED;
};
#endif
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 1639a842b..aae9bd8ce 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -7,12 +7,12 @@
#include "GrGLProgram.h"
-#include "builders/GrGLFragmentOnlyProgramBuilder.h"
#include "builders/GrGLFullProgramBuilder.h"
+#include "builders/GrGLFragmentOnlyProgramBuilder.h"
#include "GrAllocator.h"
-#include "GrEffect.h"
+#include "GrProcessor.h"
#include "GrCoordTransform.h"
-#include "GrGLEffect.h"
+#include "GrGLProcessor.h"
#include "GrGpuGL.h"
#include "GrGLPathRendering.h"
#include "GrGLShaderVar.h"
@@ -25,9 +25,9 @@
GrGLProgram* GrGLProgram::Create(GrGpuGL* gpu,
const GrGLProgramDesc& desc,
- const GrEffectStage* geometryProcessor,
- const GrEffectStage* colorStages[],
- const GrEffectStage* coverageStages[]) {
+ const GrGeometryStage* geometryProcessor,
+ const GrFragmentStage* colorStages[],
+ const GrFragmentStage* coverageStages[]) {
SkAutoTDelete<GrGLProgramBuilder> builder;
if (desc.getHeader().fUseFragShaderOnly) {
SkASSERT(gpu->glCaps().pathRenderingSupport());
@@ -92,9 +92,9 @@ void GrGLProgram::initSamplerUniforms() {
void GrGLProgram::setData(const GrOptDrawState& optState,
GrGpu::DrawType drawType,
- const GrEffectStage* geometryProcessor,
- const GrEffectStage* colorStages[],
- const GrEffectStage* coverageStages[],
+ const GrGeometryStage* geometryProcessor,
+ const GrFragmentStage* colorStages[],
+ const GrFragmentStage* coverageStages[],
const GrDeviceCoordTexture* dstCopy,
SharedGLState* sharedState) {
GrColor color = optState.getColor();
@@ -127,7 +127,7 @@ void GrGLProgram::setData(const GrOptDrawState& optState,
if (fGeometryProcessor.get()) {
SkASSERT(geometryProcessor);
- fGeometryProcessor->setData(fGpu, drawType, fProgramDataManager, &geometryProcessor);
+ fGeometryProcessor->setData(fGpu, drawType, fProgramDataManager, geometryProcessor);
}
fColorEffects->setData(fGpu, drawType, fProgramDataManager, colorStages);
fCoverageEffects->setData(fGpu, drawType, fProgramDataManager, coverageStages);
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index 3238a75fe..ce7e6b098 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -20,7 +20,7 @@
#include "SkString.h"
#include "SkXfermode.h"
-class GrGLEffect;
+class GrGLProcessor;
class GrGLProgramEffects;
class GrGLProgramBuilder;
@@ -41,9 +41,9 @@ public:
static GrGLProgram* Create(GrGpuGL* gpu,
const GrGLProgramDesc& desc,
- const GrEffectStage* geometryProcessor,
- const GrEffectStage* colorStages[],
- const GrEffectStage* coverageStages[]);
+ const GrGeometryStage* geometryProcessor,
+ const GrFragmentStage* colorStages[],
+ const GrFragmentStage* coverageStages[]);
virtual ~GrGLProgram();
@@ -147,16 +147,16 @@ public:
};
/**
- * This function uploads uniforms and calls each GrGLEffect's setData. It is called before a
+ * This function uploads uniforms and calls each GrGLProcessor's setData. It is called before a
* draw occurs using the program after the program has already been bound. It also uses the
- * GrGpuGL object to bind the textures required by the GrGLEffects. The color and coverage
+ * GrGpuGL object to bind the textures required by the GrGLProcessors. The color and coverage
* stages come from GrGLProgramDesc::Build().
*/
void setData(const GrOptDrawState&,
GrGpu::DrawType,
- const GrEffectStage* geometryProcessor,
- const GrEffectStage* colorStages[],
- const GrEffectStage* coverageStages[],
+ const GrGeometryStage* geometryProcessor,
+ const GrFragmentStage* colorStages[],
+ const GrFragmentStage* coverageStages[],
const GrDeviceCoordTexture* dstCopy, // can be NULL
SharedGLState*);
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 5eef81bc3..19a26c9b0 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -7,8 +7,8 @@
#include "gl/builders/GrGLProgramBuilder.h"
#include "GrGLProgramDesc.h"
-#include "GrBackendEffectFactory.h"
-#include "GrEffect.h"
+#include "GrBackendProcessorFactory.h"
+#include "GrProcessor.h"
#include "GrGpuGL.h"
#include "GrOptDrawState.h"
@@ -60,10 +60,10 @@ static bool swizzle_requires_alpha_remapping(const GrGLCaps& caps,
return false;
}
-static uint32_t gen_attrib_key(const GrEffect* effect) {
+static uint32_t gen_attrib_key(const GrGeometryProcessor* effect) {
uint32_t key = 0;
- const GrEffect::VertexAttribArray& vars = effect->getVertexAttribs();
+ const GrGeometryProcessor::VertexAttribArray& vars = effect->getVertexAttribs();
int numAttributes = vars.count();
SkASSERT(numAttributes <= 2);
for (int a = 0; a < numAttributes; ++a) {
@@ -73,10 +73,10 @@ static uint32_t gen_attrib_key(const GrEffect* effect) {
return key;
}
-static uint32_t gen_transform_key(const GrEffectStage& effectStage,
+static uint32_t gen_transform_key(const GrProcessorStage& effectStage,
bool useExplicitLocalCoords) {
uint32_t totalKey = 0;
- int numTransforms = effectStage.getEffect()->numTransforms();
+ int numTransforms = effectStage.getProcessor()->numTransforms();
for (int t = 0; t < numTransforms; ++t) {
uint32_t key = 0;
if (effectStage.isPerspectiveCoordTransform(t, useExplicitLocalCoords)) {
@@ -85,7 +85,7 @@ static uint32_t gen_transform_key(const GrEffectStage& effectStage,
key |= kNoPersp_MatrixType;
}
- const GrCoordTransform& coordTransform = effectStage.getEffect()->coordTransform(t);
+ const GrCoordTransform& coordTransform = effectStage.getProcessor()->coordTransform(t);
if (kLocal_GrCoordSet != coordTransform.sourceCoords() && useExplicitLocalCoords) {
key |= kPositionCoords_Flag;
}
@@ -96,7 +96,7 @@ static uint32_t gen_transform_key(const GrEffectStage& effectStage,
return totalKey;
}
-static uint32_t gen_texture_key(const GrEffect* effect, const GrGLCaps& caps) {
+static uint32_t gen_texture_key(const GrProcessor* effect, const GrGLCaps& caps) {
uint32_t key = 0;
int numTextures = effect->numTextures();
for (int t = 0; t < numTextures; ++t) {
@@ -114,60 +114,93 @@ static uint32_t gen_texture_key(const GrEffect* effect, const GrGLCaps& caps) {
* be dependent on properties of the effect that the effect itself doesn't use
* in its key (e.g. the pixel format of textures used). So we create a meta-key for
* every effect using this function. It is also responsible for inserting the effect's class ID
- * which must be different for every GrEffect subclass. It can fail if an effect uses too many
- * textures, attributes, etc for the space allotted in the meta-key.
+ * which must be different for every GrProcessor subclass. It can fail if an effect uses too many
+ * textures, transforms, etc, for the space allotted in the meta-key.
*/
-static bool gen_effect_meta_key(const GrEffectStage& effectStage,
- bool useExplicitLocalCoords,
- const GrGLCaps& caps,
- GrEffectKeyBuilder* b) {
+static uint32_t* get_processor_meta_key(const GrProcessorStage& processorStage,
+ bool useExplicitLocalCoords,
+ const GrGLCaps& caps,
+ GrProcessorKeyBuilder* b) {
- uint32_t textureKey = gen_texture_key(effectStage.getEffect(), caps);
- uint32_t transformKey = gen_transform_key(effectStage,useExplicitLocalCoords);
- uint32_t attribKey = gen_attrib_key(effectStage.getEffect());
- uint32_t classID = effectStage.getEffect()->getFactory().effectClassID();
+ uint32_t textureKey = gen_texture_key(processorStage.getProcessor(), caps);
+ uint32_t transformKey = gen_transform_key(processorStage,useExplicitLocalCoords);
+ uint32_t classID = processorStage.getProcessor()->getFactory().effectClassID();
// Currently we allow 16 bits for each of the above portions of the meta-key. Fail if they
// don't fit.
static const uint32_t kMetaKeyInvalidMask = ~((uint32_t) SK_MaxU16);
- if ((textureKey | transformKey | attribKey | classID) & kMetaKeyInvalidMask) {
- return false;
+ if ((textureKey | transformKey | classID) & kMetaKeyInvalidMask) {
+ return NULL;
}
uint32_t* key = b->add32n(2);
key[0] = (textureKey << 16 | transformKey);
- key[1] = (classID << 16 | attribKey);
+ key[1] = (classID << 16);
+ return key;
+}
+
+bool GrGLProgramDesc::GetProcessorKey(const GrProcessorStage& stage,
+ const GrGLCaps& caps,
+ bool useExplicitLocalCoords,
+ GrProcessorKeyBuilder* b,
+ uint16_t* processorKeySize) {
+ const GrProcessor& effect = *stage.getProcessor();
+ const GrBackendProcessorFactory& factory = effect.getFactory();
+ factory.getGLProcessorKey(effect, caps, b);
+ size_t size = b->size();
+ if (size > SK_MaxU16) {
+ *processorKeySize = 0; // suppresses a warning.
+ return false;
+ }
+ *processorKeySize = SkToU16(size);
+ if (NULL == get_processor_meta_key(stage, useExplicitLocalCoords, caps, b)) {
+ return false;
+ }
return true;
}
-bool GrGLProgramDesc::GetEffectKey(const GrEffectStage& stage, const GrGLCaps& caps,
- bool useExplicitLocalCoords, GrEffectKeyBuilder* b,
- uint16_t* effectKeySize) {
- const GrBackendEffectFactory& factory = stage.getEffect()->getFactory();
- const GrEffect& effect = *stage.getEffect();
- factory.getGLEffectKey(effect, caps, b);
+bool GrGLProgramDesc::GetGeometryProcessorKey(const GrGeometryStage& stage,
+ const GrGLCaps& caps,
+ bool useExplicitLocalCoords,
+ GrProcessorKeyBuilder* b,
+ uint16_t* processorKeySize) {
+ const GrProcessor& effect = *stage.getProcessor();
+ const GrBackendProcessorFactory& factory = effect.getFactory();
+ factory.getGLProcessorKey(effect, caps, b);
size_t size = b->size();
if (size > SK_MaxU16) {
- *effectKeySize = 0; // suppresses a warning.
+ *processorKeySize = 0; // suppresses a warning.
return false;
}
- *effectKeySize = SkToU16(size);
- if (!gen_effect_meta_key(stage, useExplicitLocalCoords, caps, b)) {
+ *processorKeySize = SkToU16(size);
+ uint32_t* key = get_processor_meta_key(stage, useExplicitLocalCoords, caps, b);
+ if (NULL == key) {
return false;
}
+ uint32_t attribKey = gen_attrib_key(stage.getGeometryProcessor());
+
+ // Currently we allow 16 bits for each of the above portions of the meta-key. Fail if they
+ // don't fit.
+ static const uint32_t kMetaKeyInvalidMask = ~((uint32_t) SK_MaxU16);
+ if ((attribKey) & kMetaKeyInvalidMask) {
+ return false;
+ }
+
+ key[1] |= attribKey;
return true;
}
+
bool GrGLProgramDesc::Build(const GrOptDrawState& optState,
GrGpu::DrawType drawType,
GrBlendCoeff srcCoeff,
GrBlendCoeff dstCoeff,
GrGpuGL* gpu,
const GrDeviceCoordTexture* dstCopy,
- const GrEffectStage** geometryProcessor,
- SkTArray<const GrEffectStage*, true>* colorStages,
- SkTArray<const GrEffectStage*, true>* coverageStages,
+ const GrGeometryStage** geometryProcessor,
+ SkTArray<const GrFragmentStage*, true>* colorStages,
+ SkTArray<const GrFragmentStage*, true>* coverageStages,
GrGLProgramDesc* desc) {
colorStages->reset();
coverageStages->reset();
@@ -190,7 +223,6 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState,
desc->fKey.push_back_n(kEffectKeyOffsetsAndLengthOffset + 2 * sizeof(uint16_t) * numStages);
int offsetAndSizeIndex = 0;
- bool effectKeySuccess = true;
KeyHeader* header = desc->header();
// make sure any padding in the header is zeroed.
@@ -202,18 +234,22 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState,
reinterpret_cast<uint16_t*>(desc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset +
offsetAndSizeIndex * 2 * sizeof(uint16_t));
- GrEffectKeyBuilder b(&desc->fKey);
- uint16_t effectKeySize;
- uint32_t effectOffset = desc->fKey.count();
- effectKeySuccess |= GetEffectKey(*optState.getGeometryProcessor(), gpu->glCaps(),
- requiresLocalCoordAttrib, &b, &effectKeySize);
- effectKeySuccess |= (effectOffset <= SK_MaxU16);
-
- offsetAndSize[0] = SkToU16(effectOffset);
- offsetAndSize[1] = effectKeySize;
- ++offsetAndSizeIndex;
- *geometryProcessor = optState.getGeometryProcessor();
- header->fHasGeometryProcessor = true;
+ GrProcessorKeyBuilder b(&desc->fKey);
+ uint16_t processorKeySize;
+ uint32_t processorOffset = desc->fKey.count();
+ const GrGeometryStage& gpStage = *optState.getGeometryProcessor();
+ if (processorOffset > SK_MaxU16 ||
+ !GetGeometryProcessorKey(gpStage, gpu->glCaps(), requiresLocalCoordAttrib, &b,
+ &processorKeySize)) {
+ desc->fKey.reset();
+ return false;
+ }
+
+ offsetAndSize[0] = SkToU16(processorOffset);
+ offsetAndSize[1] = processorKeySize;
+ ++offsetAndSizeIndex;
+ *geometryProcessor = &gpStage;
+ header->fHasGeometryProcessor = true;
}
for (int s = 0; s < optState.numColorStages(); ++s) {
@@ -221,15 +257,18 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState,
reinterpret_cast<uint16_t*>(desc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset +
offsetAndSizeIndex * 2 * sizeof(uint16_t));
- GrEffectKeyBuilder b(&desc->fKey);
- uint16_t effectKeySize;
- uint32_t effectOffset = desc->fKey.count();
- effectKeySuccess |= GetEffectKey(optState.getColorStage(s), gpu->glCaps(),
- requiresLocalCoordAttrib, &b, &effectKeySize);
- effectKeySuccess |= (effectOffset <= SK_MaxU16);
+ GrProcessorKeyBuilder b(&desc->fKey);
+ uint16_t processorKeySize;
+ uint32_t processorOffset = desc->fKey.count();
+ if (processorOffset > SK_MaxU16 ||
+ !GetProcessorKey(optState.getColorStage(s), gpu->glCaps(),
+ requiresLocalCoordAttrib, &b, &processorKeySize)) {
+ desc->fKey.reset();
+ return false;
+ }
- offsetAndSize[0] = SkToU16(effectOffset);
- offsetAndSize[1] = effectKeySize;
+ offsetAndSize[0] = SkToU16(processorOffset);
+ offsetAndSize[1] = processorKeySize;
++offsetAndSizeIndex;
}
@@ -238,23 +277,21 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState,
reinterpret_cast<uint16_t*>(desc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset +
offsetAndSizeIndex * 2 * sizeof(uint16_t));
- GrEffectKeyBuilder b(&desc->fKey);
- uint16_t effectKeySize;
- uint32_t effectOffset = desc->fKey.count();
- effectKeySuccess |= GetEffectKey(optState.getCoverageStage(s), gpu->glCaps(),
- requiresLocalCoordAttrib, &b, &effectKeySize);
- effectKeySuccess |= (effectOffset <= SK_MaxU16);
+ GrProcessorKeyBuilder b(&desc->fKey);
+ uint16_t processorKeySize;
+ uint32_t processorOffset = desc->fKey.count();
+ if (processorOffset > SK_MaxU16 ||
+ !GetProcessorKey(optState.getCoverageStage(s), gpu->glCaps(),
+ requiresLocalCoordAttrib, &b, &processorKeySize)) {
+ desc->fKey.reset();
+ return false;
+ }
- offsetAndSize[0] = SkToU16(effectOffset);
- offsetAndSize[1] = effectKeySize;
+ offsetAndSize[0] = SkToU16(processorOffset);
+ offsetAndSize[1] = processorKeySize;
++offsetAndSizeIndex;
}
- if (!effectKeySuccess) {
- desc->fKey.reset();
- return false;
- }
-
// Because header is a pointer into the dynamic array, we can't push any new data into the key
// below here.
diff --git a/src/gpu/gl/GrGLProgramDesc.h b/src/gpu/gl/GrGLProgramDesc.h
index 172a202b4..97f00f44b 100644
--- a/src/gpu/gl/GrGLProgramDesc.h
+++ b/src/gpu/gl/GrGLProgramDesc.h
@@ -8,7 +8,7 @@
#ifndef GrGLProgramDesc_DEFINED
#define GrGLProgramDesc_DEFINED
-#include "GrGLEffect.h"
+#include "GrGLProcessor.h"
#include "GrDrawState.h"
#include "GrGpu.h"
#include "GrOptDrawState.h"
@@ -46,11 +46,11 @@ public:
// For unit testing.
bool setRandom(SkRandom*,
- GrGpuGL* gpu,
+ GrGpuGL*,
const GrRenderTarget* dummyDstRenderTarget,
const GrTexture* dummyDstCopyTexture,
- const GrEffectStage* geometryProcessor,
- const GrEffectStage* stages[],
+ const GrGeometryStage* geometryProcessor,
+ const GrFragmentStage* stages[],
int numColorStages,
int numCoverageStages,
int currAttribIndex,
@@ -63,15 +63,15 @@ public:
* color stages in the output.
*/
static bool Build(const GrOptDrawState&,
- GrGpu::DrawType drawType,
+ GrGpu::DrawType,
GrBlendCoeff srcCoeff,
GrBlendCoeff dstCoeff,
- GrGpuGL* gpu,
+ GrGpuGL*,
const GrDeviceCoordTexture* dstCopy,
- const GrEffectStage** outGeometryProcessor,
- SkTArray<const GrEffectStage*, true>* outColorStages,
- SkTArray<const GrEffectStage*, true>* outCoverageStages,
- GrGLProgramDesc* outDesc);
+ const GrGeometryStage** geometryProcessor,
+ SkTArray<const GrFragmentStage*, true>* colorStages,
+ SkTArray<const GrFragmentStage*, true>* coverageStages,
+ GrGLProgramDesc*);
bool hasGeometryProcessor() const {
return SkToBool(this->getHeader().fHasGeometryProcessor);
@@ -177,10 +177,17 @@ private:
KeyHeader* header() { return this->atOffset<KeyHeader, kHeaderOffset>(); }
// Shared code between setRandom() and Build().
- static bool GetEffectKey(const GrEffectStage& stage, const GrGLCaps& caps,
- bool useExplicitLocalCoords, GrEffectKeyBuilder* b,
- uint16_t* effectKeySize);
-
+ static bool GetProcessorKey(const GrProcessorStage& stage,
+ const GrGLCaps& caps,
+ bool useExplicitLocalCoords,
+ GrProcessorKeyBuilder* b,
+ uint16_t* effectKeySize);
+
+ static bool GetGeometryProcessorKey(const GrGeometryStage& stage,
+ const GrGLCaps& caps,
+ bool useExplicitLocalCoords,
+ GrProcessorKeyBuilder* b,
+ uint16_t* effectKeySize);
void finalize();
const KeyHeader& getHeader() const { return *this->atOffset<KeyHeader, kHeaderOffset>(); }
@@ -209,7 +216,7 @@ private:
}
}
- GrEffectKey get(int index) const {
+ GrProcessorKey get(int index) const {
const uint16_t* offsetsAndLengths = reinterpret_cast<const uint16_t*>(
fDesc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset);
// We store two uint16_ts per effect, one for the offset to the effect's key and one for
@@ -218,7 +225,7 @@ private:
uint16_t length = offsetsAndLengths[2 * (fBaseIndex + index) + 1];
// Currently effects must add to the key in units of uint32_t.
SkASSERT(0 == (length % sizeof(uint32_t)));
- return GrEffectKey(reinterpret_cast<const uint32_t*>(fDesc->fKey.begin() + offset),
+ return GrProcessorKey(reinterpret_cast<const uint32_t*>(fDesc->fKey.begin() + offset),
length / sizeof(uint32_t));
}
private:
@@ -237,7 +244,7 @@ private:
// GrGLProgram and GrGLShaderBuilder read the private fields to generate code. TODO: Split out
// part of GrGLShaderBuilder that is used by effects so that this header doesn't need to be
- // visible to GrGLEffects. Then make public accessors as necessary and remove friends.
+ // visible to GrGLProcessors. Then make public accessors as necessary and remove friends.
friend class GrGLProgram;
friend class GrGLProgramBuilder;
friend class GrGLFullProgramBuilder;
diff --git a/src/gpu/gl/GrGLProgramEffects.cpp b/src/gpu/gl/GrGLProgramEffects.cpp
index 1bdcf87a4..6ab865473 100644
--- a/src/gpu/gl/GrGLProgramEffects.cpp
+++ b/src/gpu/gl/GrGLProgramEffects.cpp
@@ -6,26 +6,26 @@
*/
#include "GrGLProgramEffects.h"
-#include "gl/GrGLEffect.h"
+#include "gl/GrGLProcessor.h"
#include "gl/GrGLPathRendering.h"
#include "gl/builders/GrGLFullProgramBuilder.h"
#include "gl/builders/GrGLFragmentOnlyProgramBuilder.h"
#include "gl/GrGLGeometryProcessor.h"
#include "gl/GrGpuGL.h"
-typedef GrGLEffect::TransformedCoords TransformedCoords;
-typedef GrGLEffect::TransformedCoordsArray TransformedCoordsArray;
-typedef GrGLEffect::TextureSampler TextureSampler;
-typedef GrGLEffect::TextureSamplerArray TextureSamplerArray;
+typedef GrGLProcessor::TransformedCoords TransformedCoords;
+typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray;
+typedef GrGLProcessor::TextureSampler TextureSampler;
+typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray;
namespace {
/**
* Retrieves the final matrix that a transform needs to apply to its source coords.
*/
-SkMatrix get_transform_matrix(const GrEffectStage& effectStage,
+SkMatrix get_transform_matrix(const GrProcessorStage& effectStage,
bool useExplicitLocalCoords,
int transformIdx) {
- const GrCoordTransform& coordTransform = effectStage.getEffect()->coordTransform(transformIdx);
+ const GrCoordTransform& coordTransform = effectStage.getProcessor()->coordTransform(transformIdx);
SkMatrix combined;
if (kLocal_GrCoordSet == coordTransform.sourceCoords()) {
@@ -53,14 +53,14 @@ SkMatrix get_transform_matrix(const GrEffectStage& effectStage,
////////////////////////////////////////////////////////////////////////////////
GrGLProgramEffects::~GrGLProgramEffects() {
- int numEffects = fGLEffects.count();
+ int numEffects = fGLProcessors.count();
for (int e = 0; e < numEffects; ++e) {
- SkDELETE(fGLEffects[e]);
+ SkDELETE(fGLProcessors[e]);
}
}
void GrGLProgramEffects::initSamplers(const GrGLProgramDataManager& programResourceManager, int* texUnitIdx) {
- int numEffects = fGLEffects.count();
+ int numEffects = fGLProcessors.count();
SkASSERT(numEffects == fSamplers.count());
for (int e = 0; e < numEffects; ++e) {
SkTArray<Sampler, true>& samplers = fSamplers[e];
@@ -73,7 +73,7 @@ void GrGLProgramEffects::initSamplers(const GrGLProgramDataManager& programResou
}
}
-void GrGLProgramEffects::bindTextures(GrGpuGL* gpu, const GrEffect& effect, int effectIdx) {
+void GrGLProgramEffects::bindTextures(GrGpuGL* gpu, const GrProcessor& effect, int effectIdx) {
const SkTArray<Sampler, true>& samplers = fSamplers[effectIdx];
int numSamplers = samplers.count();
SkASSERT(numSamplers == effect.numTextures());
@@ -91,31 +91,47 @@ void GrGLProgramEffects::bindTextures(GrGpuGL* gpu, const GrEffect& effect, int
void GrGLVertexProgramEffects::setData(GrGpuGL* gpu,
GrGpu::DrawType drawType,
const GrGLProgramDataManager& programDataManager,
- const GrEffectStage* effectStages[]) {
- int numEffects = fGLEffects.count();
+ const GrGeometryStage* effectStages) {
+ SkASSERT(1 == fGLProcessors.count());
+ SkASSERT(1 == fTransforms.count());
+ SkASSERT(1 == fSamplers.count());
+ this->setDataInternal(gpu, drawType, programDataManager, *effectStages, 0);
+}
+
+void GrGLVertexProgramEffects::setData(GrGpuGL* gpu,
+ GrGpu::DrawType drawType,
+ const GrGLProgramDataManager& programDataManager,
+ const GrFragmentStage* effectStages[]) {
+ int numEffects = fGLProcessors.count();
SkASSERT(numEffects == fTransforms.count());
SkASSERT(numEffects == fSamplers.count());
for (int e = 0; e < numEffects; ++e) {
- const GrEffectStage& effectStage = *effectStages[e];
- const GrEffect& effect = *effectStage.getEffect();
- fGLEffects[e]->setData(programDataManager, effect);
- if (GrGpu::IsPathRenderingDrawType(drawType)) {
- this->setPathTransformData(gpu, programDataManager, effectStage, e);
- } else {
- this->setTransformData(gpu, programDataManager, effectStage, e);
- }
+ this->setDataInternal(gpu, drawType, programDataManager, *effectStages[e], e);
+ }
+}
- this->bindTextures(gpu, effect, e);
+void GrGLVertexProgramEffects::setDataInternal(GrGpuGL* gpu,
+ GrGpu::DrawType drawType,
+ const GrGLProgramDataManager& programDataManager,
+ const GrProcessorStage& effectStage,
+ int index) {
+ const GrProcessor& effect = *effectStage.getProcessor();
+ fGLProcessors[index]->setData(programDataManager, effect);
+ if (GrGpu::IsPathRenderingDrawType(drawType)) {
+ this->setPathTransformData(gpu, programDataManager, effectStage, index);
+ } else {
+ this->setTransformData(gpu, programDataManager, effectStage, index);
}
+ this->bindTextures(gpu, effect, index);
}
void GrGLVertexProgramEffects::setTransformData(GrGpuGL* gpu,
const GrGLProgramDataManager& pdman,
- const GrEffectStage& effectStage,
+ const GrProcessorStage& effectStage,
int effectIdx) {
SkTArray<Transform, true>& transforms = fTransforms[effectIdx];
int numTransforms = transforms.count();
- SkASSERT(numTransforms == effectStage.getEffect()->numTransforms());
+ SkASSERT(numTransforms == effectStage.getProcessor()->numTransforms());
for (int t = 0; t < numTransforms; ++t) {
SkASSERT(transforms[t].fHandle.isValid());
const SkMatrix& matrix = get_transform_matrix(effectStage, fHasExplicitLocalCoords, t);
@@ -128,11 +144,11 @@ void GrGLVertexProgramEffects::setTransformData(GrGpuGL* gpu,
void GrGLVertexProgramEffects::setPathTransformData(GrGpuGL* gpu,
const GrGLProgramDataManager& pdman,
- const GrEffectStage& effectStage,
+ const GrProcessorStage& effectStage,
int effectIdx) {
SkTArray<PathTransform, true>& transforms = fPathTransforms[effectIdx];
int numTransforms = transforms.count();
- SkASSERT(numTransforms == effectStage.getEffect()->numTransforms());
+ SkASSERT(numTransforms == effectStage.getProcessor()->numTransforms());
for (int t = 0; t < numTransforms; ++t) {
SkASSERT(transforms[t].fHandle.isValid());
const SkMatrix& transform = get_transform_matrix(effectStage, fHasExplicitLocalCoords, t);
@@ -158,24 +174,24 @@ void GrGLVertexProgramEffects::setPathTransformData(GrGpuGL* gpu,
void GrGLPathTexGenProgramEffects::setData(GrGpuGL* gpu,
GrGpu::DrawType,
const GrGLProgramDataManager& pdman,
- const GrEffectStage* effectStages[]) {
- int numEffects = fGLEffects.count();
+ const GrFragmentStage* effectStages[]) {
+ int numEffects = fGLProcessors.count();
SkASSERT(numEffects == fTransforms.count());
SkASSERT(numEffects == fSamplers.count());
for (int e = 0; e < numEffects; ++e) {
- const GrEffectStage& effectStage = *effectStages[e];
- const GrEffect& effect = *effectStage.getEffect();
- fGLEffects[e]->setData(pdman, effect);
+ const GrProcessorStage& effectStage = *effectStages[e];
+ const GrProcessor& effect = *effectStage.getProcessor();
+ fGLProcessors[e]->setData(pdman, effect);
this->setPathTexGenState(gpu, effectStage, e);
this->bindTextures(gpu, effect, e);
}
}
void GrGLPathTexGenProgramEffects::setPathTexGenState(GrGpuGL* gpu,
- const GrEffectStage& effectStage,
+ const GrProcessorStage& effectStage,
int effectIdx) {
int texCoordIndex = fTransforms[effectIdx].fTexCoordIndex;
- int numTransforms = effectStage.getEffect()->numTransforms();
+ int numTransforms = effectStage.getProcessor()->numTransforms();
for (int t = 0; t < numTransforms; ++t) {
const SkMatrix& transform = get_transform_matrix(effectStage, false, t);
GrGLPathRendering::PathTexGenComponents components =
diff --git a/src/gpu/gl/GrGLProgramEffects.h b/src/gpu/gl/GrGLProgramEffects.h
index 8b870d441..6140cde88 100644
--- a/src/gpu/gl/GrGLProgramEffects.h
+++ b/src/gpu/gl/GrGLProgramEffects.h
@@ -8,21 +8,21 @@
#ifndef GrGLProgramEffects_DEFINED
#define GrGLProgramEffects_DEFINED
-#include "GrBackendEffectFactory.h"
+#include "GrBackendProcessorFactory.h"
#include "GrGLProgramDataManager.h"
#include "GrGpu.h"
#include "GrTexture.h"
#include "GrTextureAccess.h"
-class GrEffect;
-class GrEffectStage;
+class GrProcessor;
+class GrProcessorStage;
class GrGLVertexProgramEffectsBuilder;
class GrGLProgramBuilder;
class GrGLFullProgramBuilder;
class GrGLFragmentOnlyProgramBuilder;
/**
- * This class encapsulates an array of GrGLEffects and their supporting data (coord transforms
+ * This class encapsulates an array of GrGLProcessors and their supporting data (coord transforms
* and textures). It is built with GrGLProgramEffectsBuilder, then used to manage the necessary GL
* state and shader uniforms.
*/
@@ -30,7 +30,6 @@ class GrGLProgramEffects : public SkRefCnt {
public:
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
typedef GrGLProgramDataManager::VaryingHandle VaryingHandle;
-
virtual ~GrGLProgramEffects();
/**
@@ -45,18 +44,25 @@ public:
virtual void setData(GrGpuGL*,
GrGpu::DrawType,
const GrGLProgramDataManager&,
- const GrEffectStage* effectStages[]) = 0;
+ const GrGeometryStage* effectStages) {
+ SkFAIL("For geometry processor only");
+ }
+
+ virtual void setData(GrGpuGL*,
+ GrGpu::DrawType,
+ const GrGLProgramDataManager&,
+ const GrFragmentStage* effectStages[]) = 0;
protected:
GrGLProgramEffects(int reserveCount)
- : fGLEffects(reserveCount)
+ : fGLProcessors(reserveCount)
, fSamplers(reserveCount) {
}
/**
* Helper for setData(). Binds all the textures for an effect.
*/
- void bindTextures(GrGpuGL*, const GrEffect&, int effectIdx);
+ void bindTextures(GrGpuGL*, const GrProcessor&, int effectIdx);
struct Sampler {
SkDEBUGCODE(Sampler() : fTextureUnit(-1) {})
@@ -67,10 +73,10 @@ protected:
/*
* Helpers for shader builders to build up program effects objects alongside shader code
*/
- void addEffect(GrGLEffect* effect) { fGLEffects.push_back(effect); }
+ void addEffect(GrGLProcessor* effect) { fGLProcessors.push_back(effect); }
SkTArray<Sampler, true>& addSamplers() { return fSamplers.push_back(); }
- SkTArray<GrGLEffect*> fGLEffects;
+ SkTArray<GrGLProcessor*> fGLProcessors;
SkTArray<SkSTArray<4, Sampler, true> > fSamplers;
private:
@@ -91,7 +97,12 @@ public:
virtual void setData(GrGpuGL*,
GrGpu::DrawType,
const GrGLProgramDataManager&,
- const GrEffectStage* effectStages[]) SK_OVERRIDE;
+ const GrGeometryStage* effectStages) SK_OVERRIDE;
+
+ virtual void setData(GrGpuGL*,
+ GrGpu::DrawType,
+ const GrGLProgramDataManager&,
+ const GrFragmentStage* effectStages[]) SK_OVERRIDE;
private:
GrGLVertexProgramEffects(int reserveCount, bool explicitLocalCoords)
@@ -123,10 +134,16 @@ private:
/**
* Helper for setData(). Sets all the transform matrices for an effect.
*/
- void setTransformData(GrGpuGL* gpu, const GrGLProgramDataManager&, const GrEffectStage&,
+ void setDataInternal(GrGpuGL* gpu,
+ GrGpu::DrawType drawType,
+ const GrGLProgramDataManager& programDataManager,
+ const GrProcessorStage& effectStage,
+ int index);
+ void setTransformData(GrGpuGL* gpu, const GrGLProgramDataManager&, const GrProcessorStage&,
int effectIdx);
- void setPathTransformData(GrGpuGL* gpu, const GrGLProgramDataManager&, const GrEffectStage&,
- int effectIdx);
+ void setPathTransformData(GrGpuGL* gpu, const GrGLProgramDataManager&,
+ const GrProcessorStage&, int effectIdx);
+
SkTArray<SkSTArray<2, Transform, true> > fTransforms;
SkTArray<SkTArray<PathTransform, true> > fPathTransforms;
@@ -148,7 +165,7 @@ public:
virtual void setData(GrGpuGL*,
GrGpu::DrawType,
const GrGLProgramDataManager&,
- const GrEffectStage* effectStages[]) SK_OVERRIDE;
+ const GrFragmentStage* effectStages[]) SK_OVERRIDE;
private:
GrGLPathTexGenProgramEffects(int reserveCount)
@@ -159,7 +176,7 @@ private:
/**
* Helper for setData(). Sets the PathTexGen state for each transform in an effect.
*/
- void setPathTexGenState(GrGpuGL*, const GrEffectStage&, int effectIdx);
+ void setPathTexGenState(GrGpuGL*, const GrProcessorStage&, int effectIdx);
struct Transforms {
Transforms(int texCoordIndex)
diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h
index 06a0e3bf2..9dccd1828 100644
--- a/src/gpu/gl/GrGpuGL.h
+++ b/src/gpu/gl/GrGpuGL.h
@@ -179,9 +179,9 @@ private:
void abandon();
GrGLProgram* getProgram(const GrGLProgramDesc& desc,
- const GrEffectStage* geometryProcessor,
- const GrEffectStage* colorStages[],
- const GrEffectStage* coverageStages[]);
+ const GrGeometryStage* geometryProcessor,
+ const GrFragmentStage* colorStages[],
+ const GrFragmentStage* coverageStages[]);
private:
enum {
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index 387741be6..91a39f00d 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -7,8 +7,8 @@
#include "GrGpuGL.h"
-#include "GrEffect.h"
-#include "GrGLEffect.h"
+#include "GrProcessor.h"
+#include "GrGLProcessor.h"
#include "GrGLPathRendering.h"
#include "GrOptDrawState.h"
#include "SkRTConf.h"
@@ -91,9 +91,9 @@ int GrGpuGL::ProgramCache::search(const GrGLProgramDesc& desc) const {
}
GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrGLProgramDesc& desc,
- const GrEffectStage* geometryProcessor,
- const GrEffectStage* colorStages[],
- const GrEffectStage* coverageStages[]) {
+ const GrGeometryStage* geometryProcessor,
+ const GrFragmentStage* colorStages[],
+ const GrFragmentStage* coverageStages[]) {
#ifdef PROGRAM_CACHE_STATS
++fTotalRequests;
#endif
@@ -227,9 +227,9 @@ bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC
return false;
}
- const GrEffectStage* geometryProcessor = NULL;
- SkSTArray<8, const GrEffectStage*, true> colorStages;
- SkSTArray<8, const GrEffectStage*, true> coverageStages;
+ const GrGeometryStage* geometryProcessor = NULL;
+ SkSTArray<8, const GrFragmentStage*, true> colorStages;
+ SkSTArray<8, const GrFragmentStage*, true> coverageStages;
GrGLProgramDesc desc;
if (!GrGLProgramDesc::Build(*optState.get(),
type,
diff --git a/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp b/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp
index 9c3243378..2c70a75ca 100644
--- a/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp
@@ -25,9 +25,9 @@ int GrGLFragmentOnlyProgramBuilder::addTexCoordSets(int count) {
}
void
-GrGLFragmentOnlyProgramBuilder::createAndEmitEffects(const GrEffectStage* geometryProcessor,
- const GrEffectStage* colorStages[],
- const GrEffectStage* coverageStages[],
+GrGLFragmentOnlyProgramBuilder::createAndEmitEffects(const GrGeometryStage* geometryProcessor,
+ const GrFragmentStage* colorStages[],
+ const GrFragmentStage* coverageStages[],
GrGLSLExpr4* inputColor,
GrGLSLExpr4* inputCoverage) {
///////////////////////////////////////////////////////////////////////////
@@ -47,9 +47,8 @@ GrGLFragmentOnlyProgramBuilder::createAndEmitEffects(const GrEffectStage* geomet
}
GrGLProgramEffects* GrGLFragmentOnlyProgramBuilder::onCreateAndEmitEffects(
- const GrEffectStage* effectStages[], int effectCnt,
+ const GrFragmentStage* effectStages[], int effectCnt,
const GrGLProgramDesc::EffectKeyProvider& keyProvider, GrGLSLExpr4* inOutFSColor) {
-
fProgramEffects.reset(SkNEW_ARGS(GrGLPathTexGenProgramEffects, (effectCnt)));
this->INHERITED::createAndEmitEffects(effectStages,
effectCnt,
@@ -58,23 +57,22 @@ GrGLProgramEffects* GrGLFragmentOnlyProgramBuilder::onCreateAndEmitEffects(
return fProgramEffects.detach();
}
-void GrGLFragmentOnlyProgramBuilder::emitEffect(const GrEffectStage& stage,
- const GrEffectKey& key,
- const char* outColor,
- const char* inColor,
- int stageIndex) {
+void GrGLFragmentOnlyProgramBuilder::emitEffect(const GrProcessorStage& stage,
+ const GrProcessorKey& key,
+ const char* outColor,
+ const char* inColor,
+ int stageIndex) {
SkASSERT(fProgramEffects.get());
- const GrEffect& effect = *stage.getEffect();
- SkASSERT(0 == effect.getVertexAttribs().count());
+ const GrProcessor& effect = *stage.getProcessor();
- SkSTArray<2, GrGLEffect::TransformedCoords> coords(effect.numTransforms());
- SkSTArray<4, GrGLEffect::TextureSampler> samplers(effect.numTextures());
+ SkSTArray<2, GrGLProcessor::TransformedCoords> coords(effect.numTransforms());
+ SkSTArray<4, GrGLProcessor::TextureSampler> samplers(effect.numTextures());
this->setupPathTexGen(stage, &coords);
this->emitSamplers(effect, &samplers);
- GrGLEffect* glEffect = effect.getFactory().createGLInstance(effect);
- SkASSERT(!glEffect->isVertexEffect());
+ SkASSERT(fEffectEmitter);
+ GrGLProcessor* glEffect = fEffectEmitter->createGLInstance();
fProgramEffects->addEffect(glEffect);
GrGLFragmentShaderBuilder* fsBuilder = this->getFragmentShaderBuilder();
@@ -83,14 +81,14 @@ void GrGLFragmentOnlyProgramBuilder::emitEffect(const GrEffectStage& stage,
openBrace.printf("\t{ // Stage %d: %s\n", stageIndex, glEffect->name());
fsBuilder->codeAppend(openBrace.c_str());
- glEffect->emitCode(this, effect, key, outColor, inColor, coords, samplers);
+ fEffectEmitter->emit(key, outColor, inColor, coords, samplers);
fsBuilder->codeAppend("\t}\n");
}
-void GrGLFragmentOnlyProgramBuilder::setupPathTexGen(const GrEffectStage& effectStage,
- GrGLEffect::TransformedCoordsArray* outCoords) {
- int numTransforms = effectStage.getEffect()->numTransforms();
+void GrGLFragmentOnlyProgramBuilder::setupPathTexGen(
+ const GrProcessorStage& effectStage, GrGLProcessor::TransformedCoordsArray* outCoords) {
+ int numTransforms = effectStage.getProcessor()->numTransforms();
int texCoordIndex = this->addTexCoordSets(numTransforms);
fProgramEffects->addTransforms(texCoordIndex);
@@ -103,6 +101,6 @@ void GrGLFragmentOnlyProgramBuilder::setupPathTexGen(const GrEffectStage& effect
kVec2f_GrSLType;
name.printf("%s(gl_TexCoord[%i])", GrGLSLTypeString(type), texCoordIndex++);
- SkNEW_APPEND_TO_TARRAY(outCoords, GrGLEffect::TransformedCoords, (name, type));
+ SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords, (name, type));
}
}
diff --git a/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.h b/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.h
index 291669c0a..b1fb88d95 100644
--- a/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.h
@@ -17,19 +17,19 @@ public:
int addTexCoordSets(int count);
private:
- virtual void createAndEmitEffects(const GrEffectStage* geometryProcessor,
- const GrEffectStage* colorStages[],
- const GrEffectStage* coverageStages[],
+ virtual void createAndEmitEffects(const GrGeometryStage* geometryProcessor,
+ const GrFragmentStage* colorStages[],
+ const GrFragmentStage* coverageStages[],
GrGLSLExpr4* inputColor,
GrGLSLExpr4* inputCoverage) SK_OVERRIDE;
- GrGLProgramEffects* onCreateAndEmitEffects(const GrEffectStage* effectStages[],
+ GrGLProgramEffects* onCreateAndEmitEffects(const GrFragmentStage* effectStages[],
int effectCnt,
const GrGLProgramDesc::EffectKeyProvider&,
GrGLSLExpr4* inOutFSColor);
- virtual void emitEffect(const GrEffectStage& stage,
- const GrEffectKey& key,
+ virtual void emitEffect(const GrProcessorStage& stage,
+ const GrProcessorKey& key,
const char* outColor,
const char* inColor,
int stageIndex) SK_OVERRIDE;
@@ -42,7 +42,7 @@ private:
* types are appended to the TransformedCoordsArray* object, which is in turn passed to the
* effect's emitCode() function.
*/
- void setupPathTexGen(const GrEffectStage&, GrGLEffect::TransformedCoordsArray*);
+ void setupPathTexGen(const GrProcessorStage&, GrGLProcessor::TransformedCoordsArray*);
virtual GrGLProgramEffects* getProgramEffects() SK_OVERRIDE { return fProgramEffects.get(); }
diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
index 7279f1c39..4266d9fc4 100644
--- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
@@ -80,9 +80,13 @@ GrGLFragmentShaderBuilder::GrGLFragmentShaderBuilder(GrGLProgramBuilder* program
const char* GrGLFragmentShaderBuilder::dstColor() {
if (fProgramBuilder->fCodeStage.inStageCode()) {
- const GrEffect* effect = fProgramBuilder->fCodeStage.effectStage()->getEffect();
- if (!effect->willReadDstColor()) {
- SkDEBUGFAIL("GrGLEffect asked for dst color but its generating GrEffect "
+ const GrProcessor* effect = fProgramBuilder->fCodeStage.effectStage()->getProcessor();
+ // TODO GPs can't read dst color, and full program builder only returns a pointer to the
+ // base fragment shader builder which does not have this function. Unfortunately,
+ // the code stage class only has a GrProcessor pointer so this is required for the time
+ // being
+ if (!static_cast<const GrFragmentProcessor*>(effect)->willReadDstColor()) {
+ SkDEBUGFAIL("GrGLProcessor asked for dst color but its generating GrProcessor "
"did not request access.");
return "";
}
@@ -119,7 +123,8 @@ bool GrGLFragmentShaderBuilder::enableFeature(GLSLFeature feature) {
}
}
-SkString GrGLFragmentShaderBuilder::ensureFSCoords2D(const TransformedCoordsArray& coords, int index) {
+SkString GrGLFragmentShaderBuilder::ensureFSCoords2D(
+ const GrGLProcessor::TransformedCoordsArray& coords, int index) {
if (kVec3f_GrSLType != coords[index].getType()) {
SkASSERT(kVec2f_GrSLType == coords[index].getType());
return coords[index].getName();
@@ -137,9 +142,9 @@ SkString GrGLFragmentShaderBuilder::ensureFSCoords2D(const TransformedCoordsArra
const char* GrGLFragmentShaderBuilder::fragmentPosition() {
GrGLProgramBuilder::CodeStage* cs = &fProgramBuilder->fCodeStage;
if (cs->inStageCode()) {
- const GrEffect* effect = cs->effectStage()->getEffect();
+ const GrProcessor* effect = cs->effectStage()->getProcessor();
if (!effect->willReadFragmentPosition()) {
- SkDEBUGFAIL("GrGLEffect asked for frag position but its generating GrEffect "
+ SkDEBUGFAIL("GrGLProcessor asked for frag position but its generating GrProcessor "
"did not request access.");
return "";
}
diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
index b3e0ab040..38d569e73 100644
--- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
+++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
@@ -11,27 +11,14 @@
class GrGLProgramBuilder;
-class GrGLFragmentShaderBuilder : public GrGLShaderBuilder {
+/*
+ * This base class encapsulates the functionality which all GrProcessors are allowed to use in their
+ * fragment shader
+ */
+class GrGLProcessorFragmentShaderBuilder : public GrGLShaderBuilder {
public:
- typedef uint8_t DstReadKey;
- typedef uint8_t FragPosKey;
-
- /** Returns a key for adding code to read the copy-of-dst color in service of effects that
- require reading the dst. It must not return 0 because 0 indicates that there is no dst
- copy read at all (in which case this function should not be called). */
- static DstReadKey KeyForDstRead(const GrTexture* dstCopy, const GrGLCaps&);
-
- /** Returns a key for reading the fragment location. This should only be called if there is an
- effect that will requires the fragment position. If the fragment position is not required,
- the key is 0. */
- static FragPosKey KeyForFragmentPosition(const GrRenderTarget* dst, const GrGLCaps&);
-
- GrGLFragmentShaderBuilder(GrGLProgramBuilder* program, const GrGLProgramDesc& desc);
-
- /** Returns the variable name that holds the color of the destination pixel. This may be NULL if
- no effect advertised that it will read the destination. */
- const char* dstColor();
-
+ GrGLProcessorFragmentShaderBuilder(GrGLProgramBuilder* program) : INHERITED(program) {}
+ virtual ~GrGLProcessorFragmentShaderBuilder() {}
/**
* Use of these features may require a GLSL extension to be enabled. Shaders may not compile
* if code is added that uses one of these features without calling enableFeature()
@@ -45,19 +32,65 @@ public:
* If the feature is supported then true is returned and any necessary #extension declarations
* are added to the shaders. If the feature is not supported then false will be returned.
*/
- bool enableFeature(GLSLFeature);
+ virtual bool enableFeature(GLSLFeature) = 0;
/**
* This returns a variable name to access the 2D, perspective correct version of the coords in
* the fragment shader. If the coordinates at index are 3-dimensional, it immediately emits a
* perspective divide into the fragment shader (xy / z) to convert them to 2D.
*/
- SkString ensureFSCoords2D(const TransformedCoordsArray& coords, int index);
+ virtual SkString ensureFSCoords2D(const GrGLProcessor::TransformedCoordsArray& coords,
+ int index) = 0;
/** Returns a variable name that represents the position of the fragment in the FS. The position
is in device space (e.g. 0,0 is the top left and pixel centers are at half-integers). */
- const char* fragmentPosition();
+ virtual const char* fragmentPosition() = 0;
+
+private:
+ typedef GrGLShaderBuilder INHERITED;
+};
+
+/*
+ * Fragment processor's, in addition to all of the above, may need to use dst color so they use
+ * this builder to create their shader
+ */
+class GrGLFragmentProcessorShaderBuilder : public GrGLProcessorFragmentShaderBuilder {
+public:
+ GrGLFragmentProcessorShaderBuilder(GrGLProgramBuilder* program) : INHERITED(program) {}
+ /** Returns the variable name that holds the color of the destination pixel. This may be NULL if
+ no effect advertised that it will read the destination. */
+ virtual const char* dstColor() = 0;
+
+private:
+ typedef GrGLProcessorFragmentShaderBuilder INHERITED;
+};
+
+class GrGLFragmentShaderBuilder : public GrGLFragmentProcessorShaderBuilder {
+public:
+ typedef uint8_t DstReadKey;
+ typedef uint8_t FragPosKey;
+
+ /** Returns a key for adding code to read the copy-of-dst color in service of effects that
+ require reading the dst. It must not return 0 because 0 indicates that there is no dst
+ copy read at all (in which case this function should not be called). */
+ static DstReadKey KeyForDstRead(const GrTexture* dstCopy, const GrGLCaps&);
+
+ /** Returns a key for reading the fragment location. This should only be called if there is an
+ effect that will requires the fragment position. If the fragment position is not required,
+ the key is 0. */
+ static FragPosKey KeyForFragmentPosition(const GrRenderTarget* dst, const GrGLCaps&);
+
+ GrGLFragmentShaderBuilder(GrGLProgramBuilder* program, const GrGLProgramDesc& desc);
+
+ virtual const char* dstColor() SK_OVERRIDE;
+
+ virtual bool enableFeature(GLSLFeature) SK_OVERRIDE;
+
+ virtual SkString ensureFSCoords2D(const GrGLProcessor::TransformedCoordsArray& coords,
+ int index) SK_OVERRIDE;
+
+ virtual const char* fragmentPosition() SK_OVERRIDE;
private:
/*
@@ -113,7 +146,7 @@ private:
friend class GrGLProgramBuilder;
friend class GrGLFullProgramBuilder;
- typedef GrGLShaderBuilder INHERITED;
+ typedef GrGLFragmentProcessorShaderBuilder INHERITED;
};
#endif
diff --git a/src/gpu/gl/builders/GrGLFullProgramBuilder.cpp b/src/gpu/gl/builders/GrGLFullProgramBuilder.cpp
index dd6409e6f..46db712a9 100644
--- a/src/gpu/gl/builders/GrGLFullProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLFullProgramBuilder.cpp
@@ -10,16 +10,17 @@
#include "../GrGpuGL.h"
GrGLFullProgramBuilder::GrGLFullProgramBuilder(GrGpuGL* gpu,
- const GrGLProgramDesc& desc)
+ const GrGLProgramDesc& desc)
: INHERITED(gpu, desc)
+ , fGLGeometryProcessorEmitter(this)
, fGS(this)
, fVS(this) {
}
void
-GrGLFullProgramBuilder::createAndEmitEffects(const GrEffectStage* geometryProcessor,
- const GrEffectStage* colorStages[],
- const GrEffectStage* coverageStages[],
+GrGLFullProgramBuilder::createAndEmitEffects(const GrGeometryStage* geometryProcessor,
+ const GrFragmentStage* colorStages[],
+ const GrFragmentStage* coverageStages[],
GrGLSLExpr4* inputColor,
GrGLSLExpr4* inputCoverage) {
fVS.emitCodeBeforeEffects(inputColor, inputCoverage);
@@ -27,7 +28,6 @@ GrGLFullProgramBuilder::createAndEmitEffects(const GrEffectStage* geometryProces
///////////////////////////////////////////////////////////////////////////
// emit the per-effect code for both color and coverage effects
- bool useLocalCoords = this->getVertexShaderBuilder()->hasExplicitLocalCoords();
EffectKeyProvider colorKeyProvider(&this->desc(), EffectKeyProvider::kColor_EffectType);
fColorEffects.reset(this->onCreateAndEmitEffects(colorStages,
this->desc().numColorEffects(),
@@ -35,10 +35,15 @@ GrGLFullProgramBuilder::createAndEmitEffects(const GrEffectStage* geometryProces
inputColor));
if (geometryProcessor) {
+ const GrGeometryProcessor& gp = *geometryProcessor->getGeometryProcessor();
+ fGLGeometryProcessorEmitter.set(&gp);
+ fEffectEmitter = &fGLGeometryProcessorEmitter;
+ fVS.emitAttributes(gp);
GrGLSLExpr4 gpInputCoverage = *inputCoverage;
GrGLSLExpr4 gpOutputCoverage;
EffectKeyProvider gpKeyProvider(&this->desc(),
EffectKeyProvider::kGeometryProcessor_EffectType);
+ bool useLocalCoords = this->getVertexShaderBuilder()->hasExplicitLocalCoords();
fProgramEffects.reset(SkNEW_ARGS(GrGLVertexProgramEffects, (1, useLocalCoords)));
this->INHERITED::emitEffect(*geometryProcessor, 0, gpKeyProvider, &gpInputCoverage,
&gpOutputCoverage);
@@ -86,7 +91,7 @@ GrGLFullProgramBuilder::addSeparableVarying(GrSLType type,
}
GrGLProgramEffects* GrGLFullProgramBuilder::onCreateAndEmitEffects(
- const GrEffectStage* effectStages[],
+ const GrFragmentStage* effectStages[],
int effectCnt,
const GrGLProgramDesc::EffectKeyProvider& keyProvider,
GrGLSLExpr4* inOutFSColor) {
@@ -100,21 +105,21 @@ GrGLProgramEffects* GrGLFullProgramBuilder::onCreateAndEmitEffects(
return fProgramEffects.detach();
}
-void GrGLFullProgramBuilder::emitEffect(const GrEffectStage& stage,
- const GrEffectKey& key,
- const char* outColor,
- const char* inColor,
- int stageIndex) {
+void GrGLFullProgramBuilder::emitEffect(const GrProcessorStage& stage,
+ const GrProcessorKey& key,
+ const char* outColor,
+ const char* inColor,
+ int stageIndex) {
SkASSERT(fProgramEffects.get());
- const GrEffect& effect = *stage.getEffect();
- SkSTArray<2, GrGLEffect::TransformedCoords> coords(effect.numTransforms());
- SkSTArray<4, GrGLEffect::TextureSampler> samplers(effect.numTextures());
+ const GrProcessor& effect = *stage.getProcessor();
+ SkSTArray<2, GrGLProcessor::TransformedCoords> coords(effect.numTransforms());
+ SkSTArray<4, GrGLProcessor::TextureSampler> samplers(effect.numTextures());
- fVS.emitAttributes(stage);
this->emitTransforms(stage, &coords);
this->emitSamplers(effect, &samplers);
- GrGLEffect* glEffect = effect.getFactory().createGLInstance(effect);
+ SkASSERT(fEffectEmitter);
+ GrGLProcessor* glEffect = fEffectEmitter->createGLInstance();
fProgramEffects->addEffect(glEffect);
// Enclose custom code in a block to avoid namespace conflicts
@@ -123,22 +128,17 @@ void GrGLFullProgramBuilder::emitEffect(const GrEffectStage& stage,
fFS.codeAppend(openBrace.c_str());
fVS.codeAppend(openBrace.c_str());
- if (glEffect->isVertexEffect()) {
- GrGLGeometryProcessor* vertexEffect = static_cast<GrGLGeometryProcessor*>(glEffect);
- vertexEffect->emitCode(this, effect, key, outColor, inColor, coords, samplers);
- } else {
- glEffect->emitCode(this, effect, key, outColor, inColor, coords, samplers);
- }
+ fEffectEmitter->emit(key, outColor, inColor, coords, samplers);
fVS.codeAppend("\t}\n");
fFS.codeAppend("\t}\n");
}
-void GrGLFullProgramBuilder::emitTransforms(const GrEffectStage& effectStage,
- GrGLEffect::TransformedCoordsArray* outCoords) {
+void GrGLFullProgramBuilder::emitTransforms(const GrProcessorStage& effectStage,
+ GrGLProcessor::TransformedCoordsArray* outCoords) {
SkTArray<GrGLVertexProgramEffects::Transform, true>& transforms =
fProgramEffects->addTransforms();
- const GrEffect* effect = effectStage.getEffect();
+ const GrProcessor* effect = effectStage.getProcessor();
int numTransforms = effect->numTransforms();
transforms.push_back_n(numTransforms);
@@ -199,7 +199,7 @@ void GrGLFullProgramBuilder::emitTransforms(const GrEffectStage& effectStage,
fVS.codeAppendf("%s = %s * vec3(%s, 1);",
vsVaryingName, uniName, coords.c_str());
}
- SkNEW_APPEND_TO_TARRAY(outCoords, GrGLEffect::TransformedCoords,
+ SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords,
(SkString(fsVaryingName), varyingType));
}
}
diff --git a/src/gpu/gl/builders/GrGLFullProgramBuilder.h b/src/gpu/gl/builders/GrGLFullProgramBuilder.h
index 7480ff385..41da17ff9 100644
--- a/src/gpu/gl/builders/GrGLFullProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLFullProgramBuilder.h
@@ -9,6 +9,7 @@
#define GrGLFullProgramBuilder_DEFINED
#include "GrGLProgramBuilder.h"
+#include "../GrGLGeometryProcessor.h"
class GrGLVertexProgramEffects;
@@ -38,20 +39,63 @@ public:
GrGLVertexShaderBuilder* getVertexShaderBuilder() { return &fVS; }
+ /*
+ * This non-virtual call will hide the parent call to prevent GPs from accessing fragment shader
+ * functionality they shouldn't be using
+ */
+ GrGLProcessorFragmentShaderBuilder* getFragmentShaderBuilder() { return &fFS; }
+
private:
- virtual void createAndEmitEffects(const GrEffectStage* geometryProcessor,
- const GrEffectStage* colorStages[],
- const GrEffectStage* coverageStages[],
+ virtual void createAndEmitEffects(const GrGeometryStage* geometryProcessor,
+ const GrFragmentStage* colorStages[],
+ const GrFragmentStage* coverageStages[],
GrGLSLExpr4* inputColor,
GrGLSLExpr4* inputCoverage) SK_OVERRIDE;
- GrGLProgramEffects* onCreateAndEmitEffects(const GrEffectStage* effectStages[],
+ GrGLProgramEffects* onCreateAndEmitEffects(const GrFragmentStage* effectStages[],
int effectCnt,
const GrGLProgramDesc::EffectKeyProvider&,
GrGLSLExpr4* inOutFSColor);
- virtual void emitEffect(const GrEffectStage& stage,
- const GrEffectKey& key,
+ class GrGLGeometryProcessorEmitter : public GrGLProgramBuilder::GrGLProcessorEmitterInterface {
+ public:
+ GrGLGeometryProcessorEmitter(GrGLFullProgramBuilder* builder)
+ : fBuilder(builder)
+ , fGeometryProcessor(NULL)
+ , fGLGeometryProcessor(NULL) {}
+ virtual ~GrGLGeometryProcessorEmitter() {}
+ void set(const GrGeometryProcessor* gp) {
+ SkASSERT(NULL == fGeometryProcessor);
+ fGeometryProcessor = gp;
+ }
+ virtual GrGLProcessor* createGLInstance() {
+ SkASSERT(fGeometryProcessor);
+ SkASSERT(NULL == fGLGeometryProcessor);
+ fGLGeometryProcessor =
+ fGeometryProcessor->getFactory().createGLInstance(*fGeometryProcessor);
+ return fGLGeometryProcessor;
+ }
+ virtual void emit(const GrProcessorKey& key,
+ const char* outColor,
+ const char* inColor,
+ const GrGLProcessor::TransformedCoordsArray& coords,
+ const GrGLProcessor::TextureSamplerArray& samplers) {
+ SkASSERT(fGeometryProcessor);
+ SkASSERT(fGLGeometryProcessor);
+ fGLGeometryProcessor->emitCode(fBuilder, *fGeometryProcessor, key, outColor,
+ inColor, coords, samplers);
+ // this will not leak because it has already been used by createGLInstance
+ fGLGeometryProcessor = NULL;
+ fGeometryProcessor = NULL;
+ }
+ private:
+ GrGLFullProgramBuilder* fBuilder;
+ const GrGeometryProcessor* fGeometryProcessor;
+ GrGLGeometryProcessor* fGLGeometryProcessor;
+ };
+
+ virtual void emitEffect(const GrProcessorStage& stage,
+ const GrProcessorKey& key,
const char* outColor,
const char* inColor,
int stageIndex) SK_OVERRIDE;
@@ -63,8 +107,8 @@ private:
* of the varyings in the VS and FS as well their types are appended to the
* TransformedCoordsArray* object, which is in turn passed to the effect's emitCode() function.
*/
- void emitTransforms(const GrEffectStage& effectStage,
- GrGLEffect::TransformedCoordsArray* outCoords);
+ void emitTransforms(const GrProcessorStage& effectStage,
+ GrGLProcessor::TransformedCoordsArray* outCoords);
virtual bool compileAndAttachShaders(GrGLuint programId,
SkTDArray<GrGLuint>* shaderIds) const SK_OVERRIDE;
@@ -75,6 +119,7 @@ private:
typedef GrGLProgramDesc::EffectKeyProvider EffectKeyProvider;
+ GrGLGeometryProcessorEmitter fGLGeometryProcessorEmitter;
GrGLGeometryShaderBuilder fGS;
GrGLVertexShaderBuilder fVS;
SkAutoTDelete<GrGLVertexProgramEffects> fProgramEffects;
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 328243d95..909ac76d6 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -30,9 +30,9 @@ static const GrGLShaderVar::Precision kDefaultFragmentPrecision = GrGLShaderVar:
///////////////////////////////////////////////////////////////////////////////////////////////////
-bool GrGLProgramBuilder::genProgram(const GrEffectStage* geometryProcessor,
- const GrEffectStage* colorStages[],
- const GrEffectStage* coverageStages[]) {
+bool GrGLProgramBuilder::genProgram(const GrGeometryStage* geometryProcessor,
+ const GrFragmentStage* colorStages[],
+ const GrFragmentStage* coverageStages[]) {
const GrGLProgramDesc::KeyHeader& header = this->desc().getHeader();
fFS.emitCodeBeforeEffects();
@@ -84,11 +84,13 @@ bool GrGLProgramBuilder::genProgram(const GrEffectStage* geometryProcessor,
GrGLProgramBuilder::GrGLProgramBuilder(GrGpuGL* gpu,
const GrGLProgramDesc& desc)
- : fFragOnly(SkToBool(desc.getHeader().fUseFragShaderOnly))
+ : fEffectEmitter(NULL)
+ , fFragOnly(SkToBool(desc.getHeader().fUseFragShaderOnly))
, fTexCoordSetCnt(0)
, fProgramID(0)
, fFS(this, desc)
, fSeparableVaryingInfos(kVarsPerBlock)
+ , fGrProcessorEmitter(this)
, fDesc(desc)
, fGpu(gpu)
, fUniforms(kVarsPerBlock) {
@@ -157,7 +159,7 @@ void GrGLProgramBuilder::appendUniformDecls(ShaderVisibility visibility,
}
}
-void GrGLProgramBuilder::createAndEmitEffects(const GrEffectStage* effectStages[],
+void GrGLProgramBuilder::createAndEmitEffects(const GrFragmentStage* effectStages[],
int effectCnt,
const GrGLProgramDesc::EffectKeyProvider& keyProvider,
GrGLSLExpr4* fsInOutColor) {
@@ -167,6 +169,8 @@ void GrGLProgramBuilder::createAndEmitEffects(const GrEffectStage* effectStages[
GrGLSLExpr4 outColor;
for (int e = 0; e < effectCnt; ++e) {
+ fGrProcessorEmitter.set(effectStages[e]->getFragmentProcessor());
+ fEffectEmitter = &fGrProcessorEmitter;
// calls into the subclass to emit the actual effect into the program effect object
this->emitEffect(*effectStages[e], e, keyProvider, &inColor, &outColor);
effectEmitted = true;
@@ -177,12 +181,12 @@ void GrGLProgramBuilder::createAndEmitEffects(const GrEffectStage* effectStages[
}
}
-void GrGLProgramBuilder::emitEffect(const GrEffectStage& effectStage,
+void GrGLProgramBuilder::emitEffect(const GrProcessorStage& effectStage,
int effectIndex,
const GrGLProgramDesc::EffectKeyProvider& keyProvider,
GrGLSLExpr4* inColor,
GrGLSLExpr4* outColor) {
- SkASSERT(effectStage.getEffect());
+ SkASSERT(effectStage.getProcessor());
CodeStage::AutoStageRestore csar(&fCodeStage, &effectStage);
if (inColor->isZeros()) {
@@ -206,8 +210,8 @@ void GrGLProgramBuilder::emitEffect(const GrEffectStage& effectStage,
*inColor = *outColor;
}
-void GrGLProgramBuilder::emitSamplers(const GrEffect& effect,
- GrGLEffect::TextureSamplerArray* outSamplers) {
+void GrGLProgramBuilder::emitSamplers(const GrProcessor& effect,
+ GrGLProcessor::TextureSamplerArray* outSamplers) {
SkTArray<GrGLProgramEffects::Sampler, true>& samplers =
this->getProgramEffects()->addSamplers();
int numTextures = effect.numTextures();
@@ -218,7 +222,7 @@ void GrGLProgramBuilder::emitSamplers(const GrEffect& effect,
samplers[t].fUniform = this->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kSampler2D_GrSLType,
name.c_str());
- SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLEffect::TextureSampler,
+ SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLProcessor::TextureSampler,
(samplers[t].fUniform, effect.textureAccess(t)));
}
}
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h
index 9f8defb6d..f6397d887 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.h
@@ -9,13 +9,14 @@
#define GrGLProgramBuilder_DEFINED
#include "GrAllocator.h"
-#include "GrBackendEffectFactory.h"
+#include "GrBackendProcessorFactory.h"
#include "GrColor.h"
-#include "GrEffect.h"
+#include "GrProcessor.h"
#include "GrGLFragmentShaderBuilder.h"
#include "GrGLGeometryShaderBuilder.h"
#include "GrGLVertexShaderBuilder.h"
#include "SkTypes.h"
+#include "gl/GrGLProcessor.h"
#include "gl/GrGLProgramDesc.h"
#include "gl/GrGLProgramEffects.h"
#include "gl/GrGLSL.h"
@@ -24,7 +25,7 @@
#include <stdarg.h>
class GrGLContextInfo;
-class GrEffectStage;
+class GrProcessorStage;
class GrGLProgramDesc;
/**
@@ -85,9 +86,9 @@ public:
* @return true if generation was successful.
*/
- bool genProgram(const GrEffectStage* inGeometryProcessor,
- const GrEffectStage* inColorStages[],
- const GrEffectStage* inCoverageStages[]);
+ bool genProgram(const GrGeometryStage* inGeometryProcessor,
+ const GrFragmentStage* inColorStages[],
+ const GrFragmentStage* inCoverageStages[]);
GrGLProgramEffects* getGeometryProcessor() const {
SkASSERT(fProgramID); return fGeometryProcessor.get();
@@ -149,7 +150,7 @@ protected:
const GrGLProgramDesc& desc() const { return fDesc; }
// Helper for emitEffects().
- void createAndEmitEffects(const GrEffectStage* effectStages[],
+ void createAndEmitEffects(const GrFragmentStage* effectStages[],
int effectCnt,
const GrGLProgramDesc::EffectKeyProvider&,
GrGLSLExpr4* inOutFSColor);
@@ -158,7 +159,7 @@ protected:
* A helper function called to emit the geometry processor as well as individual coverage
* and color stages. this will call into subclasses emit effect
*/
- void emitEffect(const GrEffectStage& effectStage,
+ void emitEffect(const GrProcessorStage& effectStage,
int effectIndex,
const GrGLProgramDesc::EffectKeyProvider& keyProvider,
GrGLSLExpr4* inColor,
@@ -169,7 +170,8 @@ protected:
* appends the necessary data to the TextureSamplerArray* object so effects can add texture
* lookups to their code. This method is only meant to be called during the construction phase.
*/
- void emitSamplers(const GrEffect& effect, GrGLEffect::TextureSamplerArray* outSamplers);
+ void emitSamplers(const GrProcessor& effect,
+ GrGLProcessor::TextureSamplerArray* outSamplers);
// Generates a name for a variable. The generated string will be name prefixed by the prefix
// char (unless the prefix is '\0'). It also mangles the name to be stage-specific if we're
@@ -193,7 +195,7 @@ protected:
return SkToBool(fEffectStage);
}
- const GrEffectStage* effectStage() const {
+ const GrProcessorStage* effectStage() const {
this->validate();
return fEffectStage;
}
@@ -205,7 +207,7 @@ protected:
class AutoStageRestore : SkNoncopyable {
public:
- AutoStageRestore(CodeStage* codeStage, const GrEffectStage* newStage) {
+ AutoStageRestore(CodeStage* codeStage, const GrProcessorStage* newStage) {
SkASSERT(codeStage);
fSavedIndex = codeStage->fCurrentIndex;
fSavedEffectStage = codeStage->fEffectStage;
@@ -226,15 +228,64 @@ protected:
private:
CodeStage* fCodeStage;
int fSavedIndex;
- const GrEffectStage* fSavedEffectStage;
+ const GrProcessorStage* fSavedEffectStage;
};
private:
void validate() const { SkASSERT((NULL == fEffectStage) == (-1 == fCurrentIndex)); }
int fNextIndex;
int fCurrentIndex;
- const GrEffectStage* fEffectStage;
+ const GrProcessorStage* fEffectStage;
};
+ class GrGLProcessorEmitterInterface {
+ public:
+ virtual ~GrGLProcessorEmitterInterface() {}
+ virtual GrGLProcessor* createGLInstance() = 0;
+ virtual void emit(const GrProcessorKey& key,
+ const char* outColor,
+ const char* inColor,
+ const GrGLProcessor::TransformedCoordsArray& coords,
+ const GrGLProcessor::TextureSamplerArray& samplers) = 0;
+ };
+
+ class GrGLFragmentProcessorEmitter : public GrGLProcessorEmitterInterface {
+ public:
+ GrGLFragmentProcessorEmitter(GrGLProgramBuilder* builder)
+ : fBuilder(builder)
+ , fFragmentProcessor(NULL)
+ , fGLFragmentProcessor(NULL) {}
+ virtual ~GrGLFragmentProcessorEmitter() {}
+ void set(const GrFragmentProcessor* fp) {
+ SkASSERT(NULL == fFragmentProcessor);
+ fFragmentProcessor = fp;
+ }
+ virtual GrGLProcessor* createGLInstance() {
+ SkASSERT(fFragmentProcessor);
+ SkASSERT(NULL == fGLFragmentProcessor);
+ fGLFragmentProcessor =
+ fFragmentProcessor->getFactory().createGLInstance(*fFragmentProcessor);
+ return fGLFragmentProcessor;
+ }
+ virtual void emit(const GrProcessorKey& key,
+ const char* outColor,
+ const char* inColor,
+ const GrGLProcessor::TransformedCoordsArray& coords,
+ const GrGLProcessor::TextureSamplerArray& samplers) {
+ SkASSERT(fFragmentProcessor);
+ SkASSERT(fGLFragmentProcessor);
+ fGLFragmentProcessor->emitCode(fBuilder, *fFragmentProcessor, key, outColor, inColor,
+ coords, samplers);
+ // this will not leak because it hasa already been used by createGLInstance
+ fGLFragmentProcessor = NULL;
+ fFragmentProcessor = NULL;
+ }
+ private:
+ GrGLProgramBuilder* fBuilder;
+ const GrFragmentProcessor* fFragmentProcessor;
+ GrGLFragmentProcessor* fGLFragmentProcessor;
+ };
+
+ GrGLProcessorEmitterInterface* fEffectEmitter;
CodeStage fCodeStage;
SkAutoTUnref<GrGLProgramEffects> fGeometryProcessor;
SkAutoTUnref<GrGLProgramEffects> fColorEffects;
@@ -247,16 +298,16 @@ protected:
SeparableVaryingInfoArray fSeparableVaryingInfos;
private:
- virtual void createAndEmitEffects(const GrEffectStage* geometryProcessor,
- const GrEffectStage* colorStages[],
- const GrEffectStage* coverageStages[],
+ virtual void createAndEmitEffects(const GrGeometryStage* geometryProcessor,
+ const GrFragmentStage* colorStages[],
+ const GrFragmentStage* coverageStages[],
GrGLSLExpr4* inputColor,
GrGLSLExpr4* inputCoverage) = 0;
/*
* Subclasses override emitEffect below to emit data and code for a specific single effect
*/
- virtual void emitEffect(const GrEffectStage&,
- const GrEffectKey&,
+ virtual void emitEffect(const GrProcessorStage&,
+ const GrProcessorKey&,
const char* outColor,
const char* inColor,
int stageIndex) = 0;
@@ -273,6 +324,8 @@ private:
**/
bool finish();
+ GrGLFragmentProcessorEmitter fGrProcessorEmitter;
+
const GrGLProgramDesc& fDesc;
GrGpuGL* fGpu;
UniformInfoArray fUniforms;
diff --git a/src/gpu/gl/builders/GrGLShaderBuilder.h b/src/gpu/gl/builders/GrGLShaderBuilder.h
index 45d3d1ee3..e99fcce74 100644
--- a/src/gpu/gl/builders/GrGLShaderBuilder.h
+++ b/src/gpu/gl/builders/GrGLShaderBuilder.h
@@ -12,15 +12,15 @@
#include "gl/GrGLProgramEffects.h"
#include "gl/GrGLSL.h"
#include "gl/GrGLProgramDataManager.h"
-#include "GrBackendEffectFactory.h"
+#include "GrBackendProcessorFactory.h"
#include "GrColor.h"
-#include "GrEffect.h"
+#include "GrProcessor.h"
#include "SkTypes.h"
#include <stdarg.h>
class GrGLContextInfo;
-class GrEffectStage;
+class GrProcessorStage;
class GrGLProgramDesc;
class GrGLProgramBuilder;
class GrGLFullProgramBuilder;
@@ -30,8 +30,8 @@ class GrGLFullProgramBuilder;
*/
class GrGLShaderBuilder {
public:
- typedef GrGLEffect::TransformedCoordsArray TransformedCoordsArray;
- typedef GrGLEffect::TextureSampler TextureSampler;
+ typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray;
+ typedef GrGLProcessor::TextureSampler TextureSampler;
GrGLShaderBuilder(GrGLProgramBuilder* program);
void addInput(GrGLShaderVar i) { fInputs.push_back(i); }
@@ -75,7 +75,7 @@ public:
static const GrGLenum* GetTexParamSwizzle(GrPixelConfig config, const GrGLCaps& caps);
/**
- * Called by GrGLEffects to add code to one of the shaders.
+ * Called by GrGLProcessors to add code to one of the shaders.
*/
void codeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
va_list args;
diff --git a/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp b/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
index f99791e24..4877071d7 100644
--- a/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLVertexShaderBuilder.cpp
@@ -37,10 +37,8 @@ bool GrGLVertexShaderBuilder::addAttribute(const GrShaderVar& var) {
return true;
}
-void GrGLVertexShaderBuilder::emitAttributes(const GrEffectStage& stage) {
- const GrEffect& effect = *stage.getEffect();
- const GrEffect::VertexAttribArray& vars =
- effect.getVertexAttribs();
+void GrGLVertexShaderBuilder::emitAttributes(const GrGeometryProcessor& gp) {
+ const GrGeometryProcessor::VertexAttribArray& vars = gp.getVertexAttribs();
int numAttributes = vars.count();
for (int a = 0; a < numAttributes; ++a) {
this->addAttribute(vars[a]);
@@ -95,7 +93,7 @@ void GrGLVertexShaderBuilder::bindProgramLocations(GrGLuint programId) {
int i = fEffectAttribOffset;
for (int index = 0; index < vaCount; index++) {
- if (kEffect_GrVertexAttribBinding != vaPtr[index].fBinding) {
+ if (kGeometryProcessor_GrVertexAttribBinding != vaPtr[index].fBinding) {
continue;
}
SkASSERT(index != header.fPositionAttributeIndex &&
diff --git a/src/gpu/gl/builders/GrGLVertexShaderBuilder.h b/src/gpu/gl/builders/GrGLVertexShaderBuilder.h
index 434e7e63c..c93b3be66 100644
--- a/src/gpu/gl/builders/GrGLVertexShaderBuilder.h
+++ b/src/gpu/gl/builders/GrGLVertexShaderBuilder.h
@@ -18,7 +18,7 @@ public:
/*
* this call is only for GrGLProgramEffects' internal use
*/
- void emitAttributes(const GrEffectStage& stage);
+ void emitAttributes(const GrGeometryProcessor& gp);
/**
* Are explicit local coordinates provided as input to the vertex shader.
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index e4d9675bf..a16173b96 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -12,7 +12,7 @@
#if SK_SUPPORT_GPU && SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
-#include "GrBackendEffectFactory.h"
+#include "GrBackendProcessorFactory.h"
#include "GrContextFactory.h"
#include "GrOptDrawState.h"
#include "effects/GrConfigConversionEffect.h"
@@ -22,25 +22,22 @@
#include "SkRandom.h"
#include "Test.h"
-static void get_stage_stats(const GrEffectStage stage, bool* readsDst,
+static void get_stage_stats(const GrFragmentStage stage, bool* readsDst,
bool* readsFragPosition, bool* requiresVertexShader) {
- if (stage.getEffect()->willReadDstColor()) {
+ if (stage.getFragmentProcessor()->willReadDstColor()) {
*readsDst = true;
}
- if (stage.getEffect()->willReadFragmentPosition()) {
+ if (stage.getProcessor()->willReadFragmentPosition()) {
*readsFragPosition = true;
}
- if (stage.getEffect()->requiresVertexShader()) {
- *requiresVertexShader = true;
- }
}
bool GrGLProgramDesc::setRandom(SkRandom* random,
GrGpuGL* gpu,
const GrRenderTarget* dstRenderTarget,
const GrTexture* dstCopyTexture,
- const GrEffectStage* geometryProcessor,
- const GrEffectStage* stages[],
+ const GrGeometryStage* geometryProcessor,
+ const GrFragmentStage* stages[],
int numColorStages,
int numCoverageStages,
int currAttribIndex,
@@ -64,7 +61,7 @@ bool GrGLProgramDesc::setRandom(SkRandom* random,
bool vertexShader = SkToBool(geometryProcessor);
int offset = 0;
if (geometryProcessor) {
- const GrEffectStage* stage = geometryProcessor;
+ const GrGeometryStage* stage = geometryProcessor;
uint16_t* offsetAndSize = reinterpret_cast<uint16_t*>(fKey.begin() +
kEffectKeyOffsetsAndLengthOffset +
offset * 2 * sizeof(uint16_t));
@@ -73,20 +70,21 @@ bool GrGLProgramDesc::setRandom(SkRandom* random,
fKey.reset();
return false;
}
- GrEffectKeyBuilder b(&fKey);
+ GrProcessorKeyBuilder b(&fKey);
uint16_t effectKeySize;
- if (!GetEffectKey(*stage, gpu->glCaps(), useLocalCoords, &b, &effectKeySize)) {
+ if (!GetProcessorKey(*stage, gpu->glCaps(), useLocalCoords, &b, &effectKeySize)) {
fKey.reset();
return false;
}
- get_stage_stats(*stage, &dstRead, &fragPos, &vertexShader);
+ vertexShader = true;
+ fragPos = stage->getProcessor()->willReadFragmentPosition();
offsetAndSize[0] = effectKeyOffset;
offsetAndSize[1] = effectKeySize;
offset++;
}
for (int s = 0; s < numStages; ++s, ++offset) {
- const GrEffectStage* stage = stages[s];
+ const GrFragmentStage* stage = stages[s];
uint16_t* offsetAndSize = reinterpret_cast<uint16_t*>(fKey.begin() +
kEffectKeyOffsetsAndLengthOffset +
offset * 2 * sizeof(uint16_t));
@@ -95,9 +93,9 @@ bool GrGLProgramDesc::setRandom(SkRandom* random,
fKey.reset();
return false;
}
- GrEffectKeyBuilder b(&fKey);
+ GrProcessorKeyBuilder b(&fKey);
uint16_t effectKeySize;
- if (!GetEffectKey(*stages[s], gpu->glCaps(), useLocalCoords, &b, &effectKeySize)) {
+ if (!GetProcessorKey(*stages[s], gpu->glCaps(), useLocalCoords, &b, &effectKeySize)) {
fKey.reset();
return false;
}
@@ -190,8 +188,8 @@ bool GrGLProgramDesc::setRandom(SkRandom* random,
// than two attributes.
GrVertexAttrib genericVertexAttribs[] = {
{ kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding },
- { kVec2f_GrVertexAttribType, 0, kEffect_GrVertexAttribBinding },
- { kVec2f_GrVertexAttribType, 0, kEffect_GrVertexAttribBinding }
+ { kVec2f_GrVertexAttribType, 0, kGeometryProcessor_GrVertexAttribBinding },
+ { kVec2f_GrVertexAttribType, 0, kGeometryProcessor_GrVertexAttribBinding }
};
/*
@@ -256,37 +254,31 @@ bool GrGpuGL::programUnitTest(int maxStages) {
int numColorStages = random.nextULessThan(numStages + 1);
int numCoverageStages = numStages - numColorStages;
- SkAutoSTMalloc<8, const GrEffectStage*> stages(numStages);
+ SkAutoSTMalloc<8, const GrFragmentStage*> stages(numStages);
bool usePathRendering = this->glCaps().pathRenderingSupport() && random.nextBool();
GrGpu::DrawType drawType = usePathRendering ? GrGpu::kDrawPath_DrawType :
GrGpu::kDrawPoints_DrawType;
- SkAutoTDelete<GrEffectStage> geometryProcessor;
+ SkAutoTDelete<GrGeometryStage> geometryProcessor;
bool hasGeometryProcessor = usePathRendering ? false : random.nextBool();
if (hasGeometryProcessor) {
while (true) {
- SkAutoTUnref<const GrEffect> effect(GrEffectTestFactory::CreateStage(
- &random,
- this->getContext(),
- *this->caps(),
- dummyTextures));
+ SkAutoTUnref<const GrGeometryProcessor> effect(
+ GrProcessorTestFactory<GrGeometryProcessor>::CreateStage(&random, this->getContext(), *this->caps(),
+ dummyTextures));
SkASSERT(effect);
// Only geometryProcessor can use vertex shader
- if (!effect->requiresVertexShader()) {
- continue;
- }
-
- GrEffectStage* stage = SkNEW_ARGS(GrEffectStage, (effect.get()));
+ GrGeometryStage* stage = SkNEW_ARGS(GrGeometryStage, (effect.get()));
geometryProcessor.reset(stage);
// we have to set dummy vertex attribs
- const GrEffect::VertexAttribArray& v = effect->getVertexAttribs();
+ const GrGeometryProcessor::VertexAttribArray& v = effect->getVertexAttribs();
int numVertexAttribs = v.count();
- SkASSERT(GrEffect::kMaxVertexAttribs == 2 &&
- GrEffect::kMaxVertexAttribs >= numVertexAttribs);
+ SkASSERT(GrGeometryProcessor::kMaxVertexAttribs == 2 &&
+ GrGeometryProcessor::kMaxVertexAttribs >= numVertexAttribs);
size_t runningStride = GrVertexAttribTypeSize(genericVertexAttribs[0].fType);
for (int i = 0; i < numVertexAttribs; i++) {
genericVertexAttribs[i + 1].fOffset = runningStride;
@@ -303,18 +295,14 @@ bool GrGpuGL::programUnitTest(int maxStages) {
}
}
for (int s = 0; s < numStages;) {
- SkAutoTUnref<const GrEffect> effect(GrEffectTestFactory::CreateStage(
+ SkAutoTUnref<const GrFragmentProcessor> effect(
+ GrProcessorTestFactory<GrFragmentProcessor>::CreateStage(
&random,
this->getContext(),
*this->caps(),
dummyTextures));
SkASSERT(effect);
- // Only geometryProcessor can use vertex shader
- if (effect->requiresVertexShader()) {
- continue;
- }
-
// If adding this effect would exceed the max texture coord set count then generate a
// new random effect.
if (usePathRendering && this->glPathRendering()->texturingMode() ==
@@ -325,7 +313,7 @@ bool GrGpuGL::programUnitTest(int maxStages) {
}
currTextureCoordSet += numTransforms;
}
- GrEffectStage* stage = SkNEW_ARGS(GrEffectStage, (effect.get()));
+ GrFragmentStage* stage = SkNEW_ARGS(GrFragmentStage, (effect.get()));
stages[s] = stage;
++s;
diff --git a/tests/GpuColorFilterTest.cpp b/tests/GpuColorFilterTest.cpp
index e1850f91d..202756b0e 100644
--- a/tests/GpuColorFilterTest.cpp
+++ b/tests/GpuColorFilterTest.cpp
@@ -10,7 +10,7 @@
#include "GrContext.h"
#include "GrContextFactory.h"
-#include "GrEffect.h"
+#include "GrProcessor.h"
#include "SkColorFilter.h"
#include "SkGr.h"
#include "Test.h"
@@ -98,7 +98,7 @@ static void test_getConstantColorComponents(skiatest::Reporter* reporter, GrCont
for (size_t i = 0; i < SK_ARRAY_COUNT(filterTests); ++i) {
const GetConstantComponentTestCase& test = filterTests[i];
SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(test.filterColor, test.filterMode));
- SkAutoTUnref<GrEffect> effect(cf->asNewEffect(grContext));
+ SkAutoTUnref<GrFragmentProcessor> effect(cf->asFragmentProcessor(grContext));
GrColor color = test.inputColor;
uint32_t components = test.inputComponents;
effect->getConstantColorComponents(&color, &components);