Remove GrStagedProcessor, remove the word Stage as it applies to FPs
Committed: https://skia.googlesource.com/skia/+/24243446cdf7b7e4e132c2a0c387c7723777e0c7
Review URL: https://codereview.chromium.org/1307223004
diff --git a/gm/bigrrectaaeffect.cpp b/gm/bigrrectaaeffect.cpp
index cf151fb..f19b57c 100644
--- a/gm/bigrrectaaeffect.cpp
+++ b/gm/bigrrectaaeffect.cpp
@@ -77,7 +77,7 @@
SkAutoTUnref<GrFragmentProcessor> fp(GrRRectEffect::Create(edgeType, rrect));
SkASSERT(fp);
if (fp) {
- pipelineBuilder.addCoverageProcessor(fp);
+ pipelineBuilder.addCoverageFragmentProcessor(fp);
pipelineBuilder.setRenderTarget(rt);
SkRect bounds = SkRect::MakeWH(SkIntToScalar(kMaxSize),
diff --git a/gm/constcolorprocessor.cpp b/gm/constcolorprocessor.cpp
index 2287af4..f5d7853 100644
--- a/gm/constcolorprocessor.cpp
+++ b/gm/constcolorprocessor.cpp
@@ -113,7 +113,7 @@
GrClip clip;
GrPipelineBuilder pipelineBuilder(grPaint, rt, clip);
- pipelineBuilder.addColorProcessor(fp);
+ pipelineBuilder.addColorFragmentProcessor(fp);
tt.target()->drawNonAARect(pipelineBuilder,
grPaint.getColor(),
diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp
index bd92069..95482f7 100644
--- a/gm/convexpolyeffect.cpp
+++ b/gm/convexpolyeffect.cpp
@@ -191,7 +191,7 @@
}
GrPipelineBuilder pipelineBuilder;
- pipelineBuilder.addCoverageProcessor(fp);
+ pipelineBuilder.addCoverageFragmentProcessor(fp);
pipelineBuilder.setRenderTarget(rt);
ConvexPolyTestBatch::Geometry geometry;
@@ -240,7 +240,7 @@
}
GrPipelineBuilder pipelineBuilder;
- pipelineBuilder.addCoverageProcessor(fp);
+ pipelineBuilder.addCoverageFragmentProcessor(fp);
pipelineBuilder.setRenderTarget(rt);
ConvexPolyTestBatch::Geometry geometry;
diff --git a/gm/rrects.cpp b/gm/rrects.cpp
index 62ad48f..f9a21db 100644
--- a/gm/rrects.cpp
+++ b/gm/rrects.cpp
@@ -114,7 +114,7 @@
SkAutoTUnref<GrFragmentProcessor> fp(GrRRectEffect::Create(edgeType,
rrect));
if (fp) {
- pipelineBuilder.addCoverageProcessor(fp);
+ pipelineBuilder.addCoverageFragmentProcessor(fp);
pipelineBuilder.setRenderTarget(rt);
SkRect bounds = rrect.getBounds();
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index 7c53467..eb0f2cc 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -128,7 +128,7 @@
}
const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y);
pipelineBuilder.setRenderTarget(rt);
- pipelineBuilder.addColorProcessor(fp);
+ pipelineBuilder.addColorFragmentProcessor(fp);
tt.target()->drawNonAARect(pipelineBuilder,
GrColor_WHITE,
diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp
index 7dbd24e..9d5ec45 100644
--- a/gm/yuvtorgbeffect.cpp
+++ b/gm/yuvtorgbeffect.cpp
@@ -123,7 +123,7 @@
SkMatrix viewMatrix;
viewMatrix.setTranslate(x, y);
pipelineBuilder.setRenderTarget(rt);
- pipelineBuilder.addColorProcessor(fp);
+ pipelineBuilder.addColorFragmentProcessor(fp);
tt.target()->drawNonAARect(pipelineBuilder,
GrColor_WHITE,
viewMatrix,
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi
index ab57af1..7750e7b 100644
--- a/gyp/gpu.gypi
+++ b/gyp/gpu.gypi
@@ -35,7 +35,6 @@
'<(skia_include_path)/gpu/GrRenderTarget.h',
'<(skia_include_path)/gpu/GrResourceKey.h',
'<(skia_include_path)/gpu/GrShaderVar.h',
- '<(skia_include_path)/gpu/GrStagedProcessor.h',
'<(skia_include_path)/gpu/GrSurface.h',
'<(skia_include_path)/gpu/GrTexture.h',
'<(skia_include_path)/gpu/GrTextureProvider.h',
@@ -149,7 +148,6 @@
'<(skia_src_path)/gpu/GrPathUtils.cpp',
'<(skia_src_path)/gpu/GrPathUtils.h',
'<(skia_src_path)/gpu/GrPendingProgramElement.h',
- '<(skia_src_path)/gpu/GrPendingFragmentStage.h',
'<(skia_src_path)/gpu/GrPipeline.cpp',
'<(skia_src_path)/gpu/GrPipeline.h',
'<(skia_src_path)/gpu/GrPipelineBuilder.cpp',
diff --git a/include/gpu/GrFragmentProcessor.h b/include/gpu/GrFragmentProcessor.h
index 097925b..e4d9151 100644
--- a/include/gpu/GrFragmentProcessor.h
+++ b/include/gpu/GrFragmentProcessor.h
@@ -9,7 +9,6 @@
#define GrFragmentProcessor_DEFINED
#include "GrProcessor.h"
-#include "GrStagedProcessor.h"
class GrCoordTransform;
class GrGLSLCaps;
@@ -29,12 +28,14 @@
, fNumTexturesExclChildren(0)
, fNumTransformsExclChildren(0) {}
+ ~GrFragmentProcessor() override;
+
GrGLFragmentProcessor* createGLInstance() const;
void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const {
this->onGetGLProcessorKey(caps, b);
for (int i = 0; i < fChildProcessors.count(); ++i) {
- fChildProcessors[i].processor()->getGLProcessorKey(caps, b);
+ fChildProcessors[i]->getGLProcessorKey(caps, b);
}
}
@@ -60,9 +61,7 @@
int numChildProcessors() const { return fChildProcessors.count(); }
- const GrFragmentProcessor& childProcessor(int index) const {
- return *fChildProcessors[index].processor();
- }
+ const GrFragmentProcessor& childProcessor(int index) const { return *fChildProcessors[index]; }
/** Do any of the coordtransforms for this processor require local coords? */
bool usesLocalCoords() const { return fUsesLocalCoords; }
@@ -176,7 +175,9 @@
int fNumTexturesExclChildren;
int fNumTransformsExclChildren;
- SkTArray<GrFragmentStage, false> fChildProcessors;
+ // TODO: These must convert their processors to pending-execution refs when the parent is
+ // converted (do this automatically in GrProgramElement?).
+ SkTArray<const GrFragmentProcessor*, true> fChildProcessors;
typedef GrProcessor INHERITED;
};
diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h
index e11ccc7..f8aaa0e 100644
--- a/include/gpu/GrPaint.h
+++ b/include/gpu/GrPaint.h
@@ -11,7 +11,6 @@
#define GrPaint_DEFINED
#include "GrColor.h"
-#include "GrStagedProcessor.h"
#include "GrProcessorDataManager.h"
#include "GrXferProcessor.h"
#include "effects/GrPorterDuffXferProcessor.h"
@@ -44,7 +43,7 @@
GrPaint(const GrPaint& paint) { *this = paint; }
- ~GrPaint() {}
+ ~GrPaint() { this->resetFragmentProcessors(); }
/**
* The initial color of the drawn primitive. Defaults to solid white.
@@ -78,18 +77,18 @@
/**
* Appends an additional color processor to the color computation.
*/
- const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* fp) {
+ const GrFragmentProcessor* addColorFragmentProcessor(const GrFragmentProcessor* fp) {
SkASSERT(fp);
- SkNEW_APPEND_TO_TARRAY(&fColorStages, GrFragmentStage, (fp));
+ fColorFragmentProcessors.push_back(SkRef(fp));
return fp;
}
/**
* Appends an additional coverage processor to the coverage computation.
*/
- const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* fp) {
+ const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragmentProcessor* fp) {
SkASSERT(fp);
- SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrFragmentStage, (fp));
+ fCoverageFragmentProcessors.push_back(SkRef(fp));
return fp;
}
@@ -102,9 +101,10 @@
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(); }
+ int numColorFragmentProcessors() const { return fColorFragmentProcessors.count(); }
+ int numCoverageFragmentProcessors() const { return fCoverageFragmentProcessors.count(); }
+ int numTotalFragmentProcessors() const { return this->numColorFragmentProcessors() +
+ this->numCoverageFragmentProcessors(); }
const GrXPFactory* getXPFactory() const {
if (!fXPFactory) {
@@ -113,17 +113,27 @@
return fXPFactory.get();
}
- const GrFragmentStage& getColorStage(int s) const { return fColorStages[s]; }
- const GrFragmentStage& getCoverageStage(int s) const { return fCoverageStages[s]; }
+ const GrFragmentProcessor* getColorFragmentProcessor(int i) const {
+ return fColorFragmentProcessors[i];
+ }
+ const GrFragmentProcessor* getCoverageFragmentProcessor(int i) const {
+ return fCoverageFragmentProcessors[i];
+ }
GrPaint& operator=(const GrPaint& paint) {
fAntiAlias = paint.fAntiAlias;
fDither = paint.fDither;
fColor = paint.fColor;
-
- fColorStages = paint.fColorStages;
- fCoverageStages = paint.fCoverageStages;
+ this->resetFragmentProcessors();
+ fColorFragmentProcessors = paint.fColorFragmentProcessors;
+ fCoverageFragmentProcessors = paint.fCoverageFragmentProcessors;
+ for (int i = 0; i < fColorFragmentProcessors.count(); ++i) {
+ fColorFragmentProcessors[i]->ref();
+ }
+ for (int i = 0; i < fCoverageFragmentProcessors.count(); ++i) {
+ fCoverageFragmentProcessors[i]->ref();
+ }
fXPFactory.reset(SkRef(paint.getXPFactory()));
fProcDataManager.reset(new GrProcessorDataManager(*paint.processorDataManager()));
@@ -144,15 +154,26 @@
const GrProcessorDataManager* processorDataManager() const { return fProcDataManager.get(); }
private:
- mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
- SkSTArray<4, GrFragmentStage> fColorStages;
- SkSTArray<2, GrFragmentStage> fCoverageStages;
+ void resetFragmentProcessors() {
+ for (int i = 0; i < fColorFragmentProcessors.count(); ++i) {
+ fColorFragmentProcessors[i]->unref();
+ }
+ for (int i = 0; i < fCoverageFragmentProcessors.count(); ++i) {
+ fCoverageFragmentProcessors[i]->unref();
+ }
+ fColorFragmentProcessors.reset();
+ fCoverageFragmentProcessors.reset();
+ }
- bool fAntiAlias;
- bool fDither;
+ mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
+ SkSTArray<4, const GrFragmentProcessor*, true> fColorFragmentProcessors;
+ SkSTArray<2, const GrFragmentProcessor*, true> fCoverageFragmentProcessors;
- GrColor fColor;
- SkAutoTUnref<GrProcessorDataManager> fProcDataManager;
+ bool fAntiAlias;
+ bool fDither;
+
+ GrColor fColor;
+ SkAutoTUnref<GrProcessorDataManager> fProcDataManager;
};
#endif
diff --git a/include/gpu/GrStagedProcessor.h b/include/gpu/GrStagedProcessor.h
deleted file mode 100644
index fe3afcc..0000000
--- a/include/gpu/GrStagedProcessor.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrStagedProcessorStage_DEFINED
-#define GrStagedProcessorStage_DEFINED
-
-#include "SkRefCnt.h"
-
-class GrFragmentProcessor;
-
-/**
- * Wraps a GrFragmentProcessor, basically a copyable SkAutoTUnref
- * Templatized based on the ref type so backends can use the same wrapper
- */
-template<template<typename> class T>
-class GrStagedProcessor {
-public:
- explicit GrStagedProcessor(const GrFragmentProcessor* proc) : fProc(SkRef(proc)) {}
-
- GrStagedProcessor(const GrStagedProcessor& other) { fProc.reset(SkRef(other.fProc.get())); }
-
- const GrFragmentProcessor* processor() const { return fProc.get(); }
-
- bool operator==(const GrStagedProcessor& that) const {
- return this->processor()->isEqual(*that.processor());
- }
-
- bool operator!=(const GrStagedProcessor& that) const { return !(*this == that); }
-
- const char* name() const { return fProc->name(); }
-
-protected:
- GrStagedProcessor() {}
-
- T<const GrFragmentProcessor> fProc;
-};
-
-typedef GrStagedProcessor<SkAutoTUnref> GrFragmentStage;
-
-#endif
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 0a46cb3..90f14c5 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -352,7 +352,7 @@
GrPaint paint;
if (this->asFragmentProcessor(&fp, paint.getProcessorDataManager(), srcTexture, matrix, bounds)) {
SkASSERT(fp);
- paint.addColorProcessor(fp)->unref();
+ paint.addColorFragmentProcessor(fp)->unref();
GrDrawContext* drawContext = context->drawContext();
if (drawContext) {
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 852d29b..dc2a40a 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -859,7 +859,7 @@
return false;
}
- grp->addCoverageProcessor(fp);
+ grp->addCoverageFragmentProcessor(fp);
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
@@ -1135,7 +1135,7 @@
return false;
}
- grp->addCoverageProcessor(fp);
+ grp->addCoverageFragmentProcessor(fp);
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
@@ -1211,8 +1211,8 @@
SkMatrix matrix;
matrix.setIDiv(src->width(), src->height());
// Blend pathTexture over blurTexture.
- paint.addCoverageProcessor(GrSimpleTextureEffect::Create(paint.getProcessorDataManager(),
- src, matrix))->unref();
+ paint.addCoverageFragmentProcessor(
+ GrSimpleTextureEffect::Create(paint.getProcessorDataManager(), src, matrix))->unref();
if (kInner_SkBlurStyle == fBlurStyle) {
// inner: dst = dst * src
paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op);
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 0c2cb8a..62fca7b 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -438,7 +438,7 @@
offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset.fX),
SkIntToScalar(colorOffset.fY - displacementOffset.fY));
- paint.addColorProcessor(
+ paint.addColorFragmentProcessor(
GrDisplacementMapEffect::Create(paint.getProcessorDataManager(),
fXChannelSelector,
fYChannelSelector,
diff --git a/src/effects/SkGpuBlurUtils.cpp b/src/effects/SkGpuBlurUtils.cpp
index 7c239a1..2b6b310 100644
--- a/src/effects/SkGpuBlurUtils.cpp
+++ b/src/effects/SkGpuBlurUtils.cpp
@@ -59,7 +59,7 @@
GrPaint paint;
SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian(
paint.getProcessorDataManager(), texture, direction, radius, sigma, useBounds, bounds));
- paint.addColorProcessor(conv);
+ paint.addColorFragmentProcessor(conv);
drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, srcRect);
}
@@ -83,7 +83,7 @@
texture, bounds, size, 1.0, 0.0, kernelOffset,
useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_Mode,
true, sigmaX, sigmaY));
- paint.addColorProcessor(conv);
+ paint.addColorFragmentProcessor(conv);
drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, srcRect);
}
@@ -216,7 +216,7 @@
domain,
GrTextureDomain::kDecal_Mode,
GrTextureParams::kBilerp_FilterMode));
- paint.addColorProcessor(fp);
+ paint.addColorFragmentProcessor(fp);
} else {
GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBilerp_FilterMode);
paint.addColorTextureProcessor(srcTexture, matrix, params);
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 58978b7..2bb1582 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -354,7 +354,7 @@
GrPaint paint;
GrFragmentProcessor* fp = this->getFragmentProcessor(paint.getProcessorDataManager(), src,
matrix, bounds, boundaryMode);
- paint.addColorProcessor(fp)->unref();
+ paint.addColorFragmentProcessor(fp)->unref();
drawContext->drawNonAARectToRect(dst->asRenderTarget(), clip, paint, SkMatrix::I(),
dstRect, srcRect);
}
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 7d6bfff..b8efd2d 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -471,12 +471,12 @@
float bounds[2],
Gr1DKernelEffect::Direction direction) {
GrPaint paint;
- paint.addColorProcessor(GrMorphologyEffect::Create(paint.getProcessorDataManager(),
- texture,
- direction,
- radius,
- morphType,
- bounds))->unref();
+ paint.addColorFragmentProcessor(GrMorphologyEffect::Create(paint.getProcessorDataManager(),
+ texture,
+ direction,
+ radius,
+ morphType,
+ bounds))->unref();
drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
SkRect::Make(srcRect));
}
@@ -491,11 +491,11 @@
GrMorphologyEffect::MorphologyType morphType,
Gr1DKernelEffect::Direction direction) {
GrPaint paint;
- paint.addColorProcessor(GrMorphologyEffect::Create(paint.getProcessorDataManager(),
- texture,
- direction,
- radius,
- morphType))->unref();
+ paint.addColorFragmentProcessor(GrMorphologyEffect::Create(paint.getProcessorDataManager(),
+ texture,
+ direction,
+ radius,
+ morphType))->unref();
drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
SkRect::Make(srcRect));
}
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index e014cc0..f62773a 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -189,8 +189,8 @@
GrTextureParams::kNone_FilterMode)
);
- paint.addColorProcessor(foregroundDomain.get());
- paint.addColorProcessor(xferProcessor)->unref();
+ paint.addColorFragmentProcessor(foregroundDomain.get());
+ paint.addColorFragmentProcessor(xferProcessor)->unref();
GrDrawContext* drawContext = context->drawContext();
if (!drawContext) {
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 6013b58..ede386a 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -36,7 +36,7 @@
matrix.setTranslate(-maskRect.fLeft, -maskRect.fTop);
matrix.postIDiv(mask->width(), mask->height());
- grp->addCoverageProcessor(GrSimpleTextureEffect::Create(grp->getProcessorDataManager(),
+ grp->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(grp->getProcessorDataManager(),
mask, matrix,
kDevice_GrCoordSet))->unref();
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index b58faaa..c9362fa 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -46,7 +46,7 @@
SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height());
// This could be a long-lived effect that is cached with the alpha-mask.
- arfps->addCoverageProcessor(
+ arfps->addCoverageFragmentProcessor(
GrTextureDomainEffect::Create(arfps->getProcessorDataManager(),
result,
mat,
@@ -200,7 +200,7 @@
break;
}
if (fp) {
- arfps->addCoverageProcessor(fp);
+ arfps->addCoverageFragmentProcessor(fp);
} else {
failed = true;
break;
@@ -488,7 +488,7 @@
SkMatrix sampleM;
sampleM.setIDiv(srcMask->width(), srcMask->height());
- pipelineBuilder->addCoverageProcessor(
+ pipelineBuilder->addCoverageFragmentProcessor(
GrTextureDomainEffect::Create(pipelineBuilder->getProcessorDataManager(),
srcMask,
sampleM,
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 3a1ca13..0e01313 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -427,7 +427,7 @@
if (!drawContext) {
return false;
}
- paint.addColorProcessor(fp);
+ paint.addColorFragmentProcessor(fp);
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
drawContext->drawRect(renderTarget, GrClip::WideOpen(), paint, matrix, rect, NULL);
@@ -532,7 +532,7 @@
GrConfigConversionEffect::kNone_PMConversion, textureMatrix));
}
if (fp) {
- paint.addColorProcessor(fp);
+ paint.addColorFragmentProcessor(fp);
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
GrDrawContext* drawContext = this->drawContext();
drawContext->drawRect(temp->asRenderTarget(), GrClip::WideOpen(), paint,
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 829f0ed..4847612 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -1419,7 +1419,7 @@
return false;
}
arfps.set(&pipelineBuilder);
- arfps.addCoverageProcessor(fp)->unref();
+ arfps.addCoverageFragmentProcessor(fp)->unref();
}
SkStrokeRec fillRec(SkStrokeRec::kFill_InitStyle);
@@ -1449,7 +1449,7 @@
return false;
}
- arfps.addCoverageProcessor(effect)->unref();
+ arfps.addCoverageFragmentProcessor(effect)->unref();
SkRect bounds = outer->getBounds();
if (applyAA) {
bounds.outset(SK_ScalarHalf, SK_ScalarHalf);
diff --git a/src/gpu/GrPaint.cpp b/src/gpu/GrPaint.cpp
index 1e57525..dc1644b 100644
--- a/src/gpu/GrPaint.cpp
+++ b/src/gpu/GrPaint.cpp
@@ -24,32 +24,33 @@
}
void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
- this->addColorProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
+ this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
matrix))->unref();
}
void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
- this->addCoverageProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
+ this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
matrix))->unref();
}
void GrPaint::addColorTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addColorProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
+ this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
params))->unref();
}
void GrPaint::addCoverageTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addCoverageProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
+ this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
params))->unref();
}
bool GrPaint::isConstantBlendedColor(GrColor* color) const {
GrProcOptInfo colorProcInfo;
- colorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColorStages(), fColor,
+ colorProcInfo.calcWithInitialValues(fColorFragmentProcessors.begin(),
+ this->numColorFragmentProcessors(), fColor,
kRGBA_GrColorComponentFlags, false);
GrXPFactory::InvariantBlendedColor blendedColor;
diff --git a/src/gpu/GrPendingFragmentStage.h b/src/gpu/GrPendingFragmentStage.h
deleted file mode 100644
index dfa5688..0000000
--- a/src/gpu/GrPendingFragmentStage.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrPendingFragmentStage_DEFINED
-#define GrPendingFragmentStage_DEFINED
-
-#include "GrStagedProcessor.h"
-#include "GrPendingProgramElement.h"
-
-/**
- * This a baked variant of GrFragmentStage, as recorded in GrPipeline
- */
-class GrPendingFragmentStage : public GrStagedProcessor<GrPendingProgramElement> {
-public:
- GrPendingFragmentStage(const GrFragmentStage& stage) {
- INHERITED::fProc.reset(stage.processor());
- }
-
-private:
- typedef GrStagedProcessor<GrPendingProgramElement> INHERITED;
-};
-
-#endif
diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp
index 148ebb4..93647d6 100644
--- a/src/gpu/GrPipeline.cpp
+++ b/src/gpu/GrPipeline.cpp
@@ -29,8 +29,8 @@
}
GrColor overrideColor = GrColor_ILLEGAL;
- if (args.fColorPOI.firstEffectiveStageIndex() != 0) {
- overrideColor = args.fColorPOI.inputColorToEffectiveStage();
+ if (args.fColorPOI.firstEffectiveProcessorIndex() != 0) {
+ overrideColor = args.fColorPOI.inputColorToFirstEffectiveProccesor();
}
GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags;
@@ -73,31 +73,36 @@
pipeline->fFlags |= kSnapVertices_Flag;
}
- int firstColorStageIdx = args.fColorPOI.firstEffectiveStageIndex();
+ int firstColorProcessorIdx = args.fColorPOI.firstEffectiveProcessorIndex();
- // TODO: Once we can handle single or four channel input into coverage stages then we can use
- // GrPipelineBuilder's coverageProcInfo (like color above) to set this initial information.
- int firstCoverageStageIdx = 0;
+ // TODO: Once we can handle single or four channel input into coverage GrFragmentProcessors
+ // then we can use GrPipelineBuilder's coverageProcInfo (like color above) to set this initial
+ // information.
+ int firstCoverageProcessorIdx = 0;
pipeline->adjustProgramFromOptimizations(builder, optFlags, args.fColorPOI, args.fCoveragePOI,
- &firstColorStageIdx, &firstCoverageStageIdx);
+ &firstColorProcessorIdx, &firstCoverageProcessorIdx);
bool usesLocalCoords = false;
- // Copy Stages from PipelineBuilder to Pipeline
- for (int i = firstColorStageIdx; i < builder.numColorFragmentStages(); ++i) {
- const GrFragmentStage& fps = builder.fColorStages[i];
- const GrFragmentProcessor* fp = fps.processor();
- SkNEW_APPEND_TO_TARRAY(&pipeline->fFragmentStages, GrPendingFragmentStage, (fps));
+ // Copy GrFragmentProcessors from GrPipelineBuilder to Pipeline
+ pipeline->fNumColorProcessors = builder.numColorFragmentProcessors() - firstColorProcessorIdx;
+ int numTotalProcessors = pipeline->fNumColorProcessors +
+ builder.numCoverageFragmentProcessors() - firstCoverageProcessorIdx;
+ pipeline->fFragmentProcessors.reset(numTotalProcessors);
+ int currFPIdx = 0;
+ for (int i = firstColorProcessorIdx; i < builder.numColorFragmentProcessors();
+ ++i, ++currFPIdx) {
+ const GrFragmentProcessor* fp = builder.getColorFragmentProcessor(i);
+ pipeline->fFragmentProcessors[currFPIdx].reset(fp);
usesLocalCoords = usesLocalCoords || fp->usesLocalCoords();
fp->gatherCoordTransforms(&pipeline->fCoordTransforms);
}
- pipeline->fNumColorStages = pipeline->fFragmentStages.count();
- for (int i = firstCoverageStageIdx; i < builder.numCoverageFragmentStages(); ++i) {
- const GrFragmentStage& fps = builder.fCoverageStages[i];
- const GrFragmentProcessor* fp = fps.processor();
- SkNEW_APPEND_TO_TARRAY(&pipeline->fFragmentStages, GrPendingFragmentStage, (fps));
+ for (int i = firstCoverageProcessorIdx; i < builder.numCoverageFragmentProcessors();
+ ++i, ++currFPIdx) {
+ const GrFragmentProcessor* fp = builder.getCoverageFragmentProcessor(i);
+ pipeline->fFragmentProcessors[currFPIdx].reset(fp);
usesLocalCoords = usesLocalCoords || fp->usesLocalCoords();
fp->gatherCoordTransforms(&pipeline->fCoordTransforms);
}
@@ -134,13 +139,13 @@
GrXferProcessor::OptFlags flags,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
- int* firstColorStageIdx,
- int* firstCoverageStageIdx) {
+ int* firstColorProcessorIdx,
+ int* firstCoverageProcessorIdx) {
fReadsFragPosition = fXferProcessor->willReadFragmentPosition();
if ((flags & GrXferProcessor::kIgnoreColor_OptFlag) ||
(flags & GrXferProcessor::kOverrideColor_OptFlag)) {
- *firstColorStageIdx = pipelineBuilder.numColorFragmentStages();
+ *firstColorProcessorIdx = pipelineBuilder.numColorFragmentProcessors();
} else {
if (coveragePOI.readsFragPosition()) {
fReadsFragPosition = true;
@@ -148,7 +153,7 @@
}
if (flags & GrXferProcessor::kIgnoreCoverage_OptFlag) {
- *firstCoverageStageIdx = pipelineBuilder.numCoverageFragmentStages();
+ *firstCoverageProcessorIdx = pipelineBuilder.numCoverageFragmentProcessors();
} else {
if (coveragePOI.readsFragPosition()) {
fReadsFragPosition = true;
@@ -163,8 +168,8 @@
SkASSERT(&a != &b);
if (a.getRenderTarget() != b.getRenderTarget() ||
- a.fFragmentStages.count() != b.fFragmentStages.count() ||
- a.fNumColorStages != b.fNumColorStages ||
+ a.fFragmentProcessors.count() != b.fFragmentProcessors.count() ||
+ a.fNumColorProcessors != b.fNumColorProcessors ||
a.fScissorState != b.fScissorState ||
a.fFlags != b.fFlags ||
a.fStencilSettings != b.fStencilSettings ||
@@ -176,9 +181,8 @@
return false;
}
- for (int i = 0; i < a.numFragmentStages(); i++) {
- if (!a.getFragmentStage(i).processor()->isEqual(*b.getFragmentStage(i).processor(),
- ignoreCoordTransforms)) {
+ for (int i = 0; i < a.numFragmentProcessors(); i++) {
+ if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i), ignoreCoordTransforms)) {
return false;
}
}
diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h
index ea2ea85..db14155 100644
--- a/src/gpu/GrPipeline.h
+++ b/src/gpu/GrPipeline.h
@@ -9,9 +9,10 @@
#define GrPipeline_DEFINED
#include "GrColor.h"
+#include "GrFragmentProcessor.h"
#include "GrGpu.h"
#include "GrNonAtomicRef.h"
-#include "GrPendingFragmentStage.h"
+#include "GrPendingProgramElement.h"
#include "GrPrimitiveProcessor.h"
#include "GrProgramDesc.h"
#include "GrStencil.h"
@@ -84,22 +85,26 @@
/// @name GrFragmentProcessors
- int numColorFragmentStages() const { return fNumColorStages; }
- int numCoverageFragmentStages() const { return fFragmentStages.count() - fNumColorStages; }
- int numFragmentStages() const { return fFragmentStages.count(); }
+ int numColorFragmentProcessors() const { return fNumColorProcessors; }
+ int numCoverageFragmentProcessors() const {
+ return fFragmentProcessors.count() - fNumColorProcessors;
+ }
+ int numFragmentProcessors() const { return fFragmentProcessors.count(); }
const GrXferProcessor* getXferProcessor() const { return fXferProcessor.get(); }
- const GrPendingFragmentStage& getColorStage(int idx) const {
- SkASSERT(idx < this->numColorFragmentStages());
- return fFragmentStages[idx];
+ const GrFragmentProcessor& getColorFragmentProcessor(int idx) const {
+ SkASSERT(idx < this->numColorFragmentProcessors());
+ return *fFragmentProcessors[idx].get();
}
- const GrPendingFragmentStage& getCoverageStage(int idx) const {
- SkASSERT(idx < this->numCoverageFragmentStages());
- return fFragmentStages[fNumColorStages + idx];
+
+ const GrFragmentProcessor& getCoverageFragmentProcessor(int idx) const {
+ SkASSERT(idx < this->numCoverageFragmentProcessors());
+ return *fFragmentProcessors[fNumColorProcessors + idx].get();
}
- const GrPendingFragmentStage& getFragmentStage(int idx) const {
- return fFragmentStages[idx];
+
+ const GrFragmentProcessor& getFragmentProcessor(int idx) const {
+ return *fFragmentProcessors[idx].get();
}
/// @}
@@ -149,8 +154,8 @@
GrXferProcessor::OptFlags,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
- int* firstColorStageIdx,
- int* firstCoverageStageIdx);
+ int* firstColorProcessorIdx,
+ int* firstCoverageProcessorIdx);
/**
* Calculates the primary and secondary output types of the shader. For certain output types
@@ -167,7 +172,8 @@
};
typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget;
- typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray;
+ typedef GrPendingProgramElement<const GrFragmentProcessor> PendingFragmentProcessor;
+ typedef SkAutoSTArray<8, PendingFragmentProcessor> FragmentProcessorArray;
typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor;
RenderTarget fRenderTarget;
GrScissorState fScissorState;
@@ -175,11 +181,11 @@
GrPipelineBuilder::DrawFace fDrawFace;
uint32_t fFlags;
ProgramXferProcessor fXferProcessor;
- FragmentStageArray fFragmentStages;
+ FragmentProcessorArray fFragmentProcessors;
bool fReadsFragPosition;
- // This function is equivalent to the offset into fFragmentStages where coverage stages begin.
- int fNumColorStages;
+ // This value is also the index in fFragmentProcessors where coverage processors begin.
+ int fNumColorProcessors;
SkSTArray<8, const GrCoordTransform*, true> fCoordTransforms;
GrProgramDesc fDesc;
diff --git a/src/gpu/GrPipelineBuilder.cpp b/src/gpu/GrPipelineBuilder.cpp
index d7db201..0af0eab 100644
--- a/src/gpu/GrPipelineBuilder.cpp
+++ b/src/gpu/GrPipelineBuilder.cpp
@@ -20,20 +20,6 @@
SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
}
-GrPipelineBuilder& GrPipelineBuilder::operator=(const GrPipelineBuilder& that) {
- fProcDataManager.reset(new GrProcessorDataManager(*that.processorDataManager()));
- fRenderTarget.reset(SkSafeRef(that.fRenderTarget.get()));
- fFlags = that.fFlags;
- fStencilSettings = that.fStencilSettings;
- fDrawFace = that.fDrawFace;
- fXPFactory.reset(SkRef(that.getXPFactory()));
- fColorStages = that.fColorStages;
- fCoverageStages = that.fCoverageStages;
- fClip = that.fClip;
-
- return *this;
-}
-
GrPipelineBuilder::GrPipelineBuilder(const GrPaint& paint, GrRenderTarget* rt, const GrClip& clip) {
SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
@@ -41,15 +27,12 @@
fProcDataManager.reset(
const_cast<GrProcessorDataManager*>(SkRef(paint.processorDataManager())));
- fColorStages.reset();
- fCoverageStages.reset();
-
- for (int i = 0; i < paint.numColorStages(); ++i) {
- fColorStages.push_back(paint.getColorStage(i));
+ for (int i = 0; i < paint.numColorFragmentProcessors(); ++i) {
+ fColorFragmentProcessors.push_back(SkRef(paint.getColorFragmentProcessor(i)));
}
- for (int i = 0; i < paint.numCoverageStages(); ++i) {
- fCoverageStages.push_back(paint.getCoverageStage(i));
+ for (int i = 0; i < paint.numCoverageFragmentProcessors(); ++i) {
+ fCoverageFragmentProcessors.push_back(SkRef(paint.getCoverageFragmentProcessor(i)));
}
fXPFactory.reset(SkRef(paint.getXPFactory()));
@@ -80,21 +63,26 @@
void GrPipelineBuilder::AutoRestoreFragmentProcessorState::set(
const GrPipelineBuilder* pipelineBuilder) {
if (fPipelineBuilder) {
- int m = fPipelineBuilder->numColorFragmentStages() - fColorEffectCnt;
+ int m = fPipelineBuilder->numColorFragmentProcessors() - fColorEffectCnt;
SkASSERT(m >= 0);
- fPipelineBuilder->fColorStages.pop_back_n(m);
+ for (int i = 0; i < m; ++i) {
+ fPipelineBuilder->fColorFragmentProcessors.fromBack(i)->unref();
+ }
+ fPipelineBuilder->fColorFragmentProcessors.pop_back_n(m);
- int n = fPipelineBuilder->numCoverageFragmentStages() - fCoverageEffectCnt;
+ int n = fPipelineBuilder->numCoverageFragmentProcessors() - fCoverageEffectCnt;
SkASSERT(n >= 0);
- fPipelineBuilder->fCoverageStages.pop_back_n(n);
-
+ for (int i = 0; i < n; ++i) {
+ fPipelineBuilder->fCoverageFragmentProcessors.fromBack(i)->unref();
+ }
+ fPipelineBuilder->fCoverageFragmentProcessors.pop_back_n(n);
SkDEBUGCODE(--fPipelineBuilder->fBlockEffectRemovalCnt;)
fPipelineBuilder->getProcessorDataManager()->restoreToSaveMarker(/*fSaveMarker*/);
}
fPipelineBuilder = const_cast<GrPipelineBuilder*>(pipelineBuilder);
if (NULL != pipelineBuilder) {
- fColorEffectCnt = pipelineBuilder->numColorFragmentStages();
- fCoverageEffectCnt = pipelineBuilder->numCoverageFragmentStages();
+ fColorEffectCnt = pipelineBuilder->numColorFragmentProcessors();
+ fCoverageEffectCnt = pipelineBuilder->numCoverageFragmentProcessors();
SkDEBUGCODE(++pipelineBuilder->fBlockEffectRemovalCnt;)
fSaveMarker = pipelineBuilder->processorDataManager()->currentSaveMarker();
}
@@ -104,25 +92,33 @@
GrPipelineBuilder::~GrPipelineBuilder() {
SkASSERT(0 == fBlockEffectRemovalCnt);
+ for (int i = 0; i < fColorFragmentProcessors.count(); ++i) {
+ fColorFragmentProcessors[i]->unref();
+ }
+ for (int i = 0; i < fCoverageFragmentProcessors.count(); ++i) {
+ fCoverageFragmentProcessors[i]->unref();
+ }
}
////////////////////////////////////////////////////////////////////////////////
void GrPipelineBuilder::calcColorInvariantOutput(const GrPrimitiveProcessor* pp) const {
- fColorProcInfo.calcColorWithPrimProc(pp, fColorStages.begin(), this->numColorFragmentStages());
+ fColorProcInfo.calcColorWithPrimProc(pp, fColorFragmentProcessors.begin(),
+ this->numColorFragmentProcessors());
+
}
void GrPipelineBuilder::calcCoverageInvariantOutput(const GrPrimitiveProcessor* pp) const {
- fCoverageProcInfo.calcCoverageWithPrimProc(pp, fCoverageStages.begin(),
- this->numCoverageFragmentStages());
+ fCoverageProcInfo.calcCoverageWithPrimProc(pp, fCoverageFragmentProcessors.begin(),
+ this->numCoverageFragmentProcessors());
}
void GrPipelineBuilder::calcColorInvariantOutput(const GrDrawBatch* batch) const {
- fColorProcInfo.calcColorWithBatch(batch, fColorStages.begin(), this->numColorFragmentStages());
+ fColorProcInfo.calcColorWithBatch(batch, fColorFragmentProcessors.begin(),
+ this->numColorFragmentProcessors());
}
void GrPipelineBuilder::calcCoverageInvariantOutput(const GrDrawBatch* batch) const {
- fCoverageProcInfo.calcCoverageWithBatch(batch, fCoverageStages.begin(),
- this->numCoverageFragmentStages());
+ fCoverageProcInfo.calcCoverageWithBatch(batch, fCoverageFragmentProcessors.begin(),
+ this->numCoverageFragmentProcessors());
}
-
diff --git a/src/gpu/GrPipelineBuilder.h b/src/gpu/GrPipelineBuilder.h
index 1c6eb5f..47b996a 100644
--- a/src/gpu/GrPipelineBuilder.h
+++ b/src/gpu/GrPipelineBuilder.h
@@ -12,7 +12,6 @@
#include "GrCaps.h"
#include "GrClip.h"
#include "GrGpuResourceRef.h"
-#include "GrStagedProcessor.h"
#include "GrProcOptInfo.h"
#include "GrProcessorDataManager.h"
#include "GrRenderTarget.h"
@@ -29,15 +28,10 @@
class GrPaint;
class GrTexture;
-class GrPipelineBuilder {
+class GrPipelineBuilder : public SkNoncopyable {
public:
GrPipelineBuilder();
- GrPipelineBuilder(const GrPipelineBuilder& pipelineBuilder) {
- SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
- *this = pipelineBuilder;
- }
-
/**
* Initializes the GrPipelineBuilder based on a GrPaint, render target, and clip. Note
* that GrPipelineBuilder encompasses more than GrPaint. Aspects of GrPipelineBuilder that have
@@ -58,51 +52,56 @@
/// feed their output to the GrXferProcessor which controls blending.
////
- int numColorFragmentStages() const { return fColorStages.count(); }
- int numCoverageFragmentStages() const { return fCoverageStages.count(); }
- int numFragmentStages() const { return this->numColorFragmentStages() +
- this->numCoverageFragmentStages(); }
+ int numColorFragmentProcessors() const { return fColorFragmentProcessors.count(); }
+ int numCoverageFragmentProcessors() const { return fCoverageFragmentProcessors.count(); }
+ int numFragmentProcessors() const { return this->numColorFragmentProcessors() +
+ this->numCoverageFragmentProcessors(); }
- const GrFragmentStage& getColorFragmentStage(int idx) const { return fColorStages[idx]; }
- const GrFragmentStage& getCoverageFragmentStage(int idx) const { return fCoverageStages[idx]; }
-
- const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* effect) {
- SkASSERT(effect);
- SkNEW_APPEND_TO_TARRAY(&fColorStages, GrFragmentStage, (effect));
- return effect;
+ const GrFragmentProcessor* getColorFragmentProcessor(int idx) const {
+ return fColorFragmentProcessors[idx];
+ }
+ const GrFragmentProcessor* getCoverageFragmentProcessor(int idx) const {
+ return fCoverageFragmentProcessors[idx];
}
- const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* effect) {
- SkASSERT(effect);
- SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrFragmentStage, (effect));
- return effect;
+ const GrFragmentProcessor* addColorFragmentProcessor(const GrFragmentProcessor* processor) {
+ SkASSERT(processor);
+ fColorFragmentProcessors.push_back(SkRef(processor));
+ return processor;
+ }
+
+ const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragmentProcessor* processor) {
+ SkASSERT(processor);
+ fCoverageFragmentProcessors.push_back(SkRef(processor));
+ return processor;
}
/**
* Creates a GrSimpleTextureEffect that uses local coords as texture coordinates.
*/
void addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
- this->addColorProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
- matrix))->unref();
+ this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
+ matrix))->unref();
}
void addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
- this->addCoverageProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
- matrix))->unref();
+ this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
+ matrix))->unref();
}
void addColorTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addColorProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
- params))->unref();
+ this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
+ matrix,
+ params))->unref();
}
void addCoverageTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addCoverageProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
- params))->unref();
+ this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
+ matrix, params))->unref();
}
/**
@@ -139,9 +138,9 @@
return fPipelineBuilder->getProcessorDataManager();
}
- const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* processor) {
+ const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragmentProcessor* processor) {
SkASSERT(this->isSet());
- return fPipelineBuilder->addCoverageProcessor(processor);
+ return fPipelineBuilder->addCoverageFragmentProcessor(processor);
}
private:
@@ -385,8 +384,6 @@
///////////////////////////////////////////////////////////////////////////
- GrPipelineBuilder& operator=(const GrPipelineBuilder& that);
-
// TODO delete when we have Batch
const GrProcOptInfo& colorProcInfo(const GrPrimitiveProcessor* pp) const {
this->calcColorInvariantOutput(pp);
@@ -439,7 +436,7 @@
// This is used to assert that this condition holds.
SkDEBUGCODE(mutable int fBlockEffectRemovalCnt;)
- typedef SkSTArray<4, GrFragmentStage> FragmentStageArray;
+ typedef SkSTArray<4, const GrFragmentProcessor*, true> FragmentProcessorArray;
SkAutoTUnref<GrProcessorDataManager> fProcDataManager;
SkAutoTUnref<GrRenderTarget> fRenderTarget;
@@ -447,8 +444,8 @@
GrStencilSettings fStencilSettings;
DrawFace fDrawFace;
mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
- FragmentStageArray fColorStages;
- FragmentStageArray fCoverageStages;
+ FragmentProcessorArray fColorFragmentProcessors;
+ FragmentProcessorArray fCoverageFragmentProcessors;
GrClip fClip;
mutable GrProcOptInfo fColorProcInfo;
diff --git a/src/gpu/GrProcOptInfo.cpp b/src/gpu/GrProcOptInfo.cpp
index af6b81e..19302cc 100644
--- a/src/gpu/GrProcOptInfo.cpp
+++ b/src/gpu/GrProcOptInfo.cpp
@@ -12,43 +12,43 @@
#include "batches/GrDrawBatch.h"
void GrProcOptInfo::calcColorWithBatch(const GrDrawBatch* batch,
- const GrFragmentStage* stages,
- int stageCount) {
+ const GrFragmentProcessor* const processors[],
+ int cnt) {
GrInitInvariantOutput out;
batch->getInvariantOutputColor(&out);
fInOut.reset(out);
- this->internalCalc(stages, stageCount, batch->willReadFragmentPosition());
+ this->internalCalc(processors, cnt, batch->willReadFragmentPosition());
}
void GrProcOptInfo::calcCoverageWithBatch(const GrDrawBatch* batch,
- const GrFragmentStage* stages,
- int stageCount) {
+ const GrFragmentProcessor* const processors[],
+ int cnt) {
GrInitInvariantOutput out;
batch->getInvariantOutputCoverage(&out);
fInOut.reset(out);
- this->internalCalc(stages, stageCount, batch->willReadFragmentPosition());
+ this->internalCalc(processors, cnt, batch->willReadFragmentPosition());
}
void GrProcOptInfo::calcColorWithPrimProc(const GrPrimitiveProcessor* primProc,
- const GrFragmentStage* stages,
- int stageCount) {
+ const GrFragmentProcessor * const processors[],
+ int cnt) {
GrInitInvariantOutput out;
primProc->getInvariantOutputColor(&out);
fInOut.reset(out);
- this->internalCalc(stages, stageCount, primProc->willReadFragmentPosition());
+ this->internalCalc(processors, cnt, primProc->willReadFragmentPosition());
}
void GrProcOptInfo::calcCoverageWithPrimProc(const GrPrimitiveProcessor* primProc,
- const GrFragmentStage* stages,
- int stageCount) {
+ const GrFragmentProcessor * const processors[],
+ int cnt) {
GrInitInvariantOutput out;
primProc->getInvariantOutputCoverage(&out);
fInOut.reset(out);
- this->internalCalc(stages, stageCount, primProc->willReadFragmentPosition());
+ this->internalCalc(processors, cnt, primProc->willReadFragmentPosition());
}
-void GrProcOptInfo::calcWithInitialValues(const GrFragmentStage* stages,
- int stageCount,
+void GrProcOptInfo::calcWithInitialValues(const GrFragmentProcessor * const processors[],
+ int cnt,
GrColor startColor,
GrColorComponentFlags flags,
bool areCoverageStages) {
@@ -57,24 +57,24 @@
out.fColor = startColor;
out.fValidFlags = flags;
fInOut.reset(out);
- this->internalCalc(stages, stageCount, false);
+ this->internalCalc(processors, cnt, false);
}
-void GrProcOptInfo::internalCalc(const GrFragmentStage* stages,
- int stageCount,
+void GrProcOptInfo::internalCalc(const GrFragmentProcessor* const processors[],
+ int cnt,
bool initWillReadFragmentPosition) {
- fFirstEffectStageIndex = 0;
+ fFirstEffectiveProcessorIndex = 0;
fInputColorIsUsed = true;
fInputColor = fInOut.color();
fReadsFragPosition = initWillReadFragmentPosition;
- for (int i = 0; i < stageCount; ++i) {
- const GrFragmentProcessor* processor = stages[i].processor();
+ for (int i = 0; i < cnt; ++i) {
+ const GrFragmentProcessor* processor = processors[i];
fInOut.resetWillUseInputColor();
processor->computeInvariantOutput(&fInOut);
SkDEBUGCODE(fInOut.validate());
if (!fInOut.willUseInputColor()) {
- fFirstEffectStageIndex = i;
+ fFirstEffectiveProcessorIndex = i;
fInputColorIsUsed = false;
// Reset these since we don't care if previous stages read these values
fReadsFragPosition = initWillReadFragmentPosition;
@@ -83,7 +83,7 @@
fReadsFragPosition = true;
}
if (kRGBA_GrColorComponentFlags == fInOut.validFlags()) {
- fFirstEffectStageIndex = i + 1;
+ fFirstEffectiveProcessorIndex = i + 1;
fInputColor = fInOut.color();
fInputColorIsUsed = true;
// Since we are clearing all previous color stages we are in a state where we have found
diff --git a/src/gpu/GrProcOptInfo.h b/src/gpu/GrProcOptInfo.h
index cf7e350..ad23614 100644
--- a/src/gpu/GrProcOptInfo.h
+++ b/src/gpu/GrProcOptInfo.h
@@ -10,7 +10,6 @@
#include "GrColor.h"
#include "GrInvariantOutput.h"
-#include "GrStagedProcessor.h"
class GrDrawBatch;
class GrFragmentProcessor;
@@ -26,21 +25,22 @@
public:
GrProcOptInfo()
: fInOut(0, static_cast<GrColorComponentFlags>(0), false)
- , fFirstEffectStageIndex(0)
+ , fFirstEffectiveProcessorIndex(0)
, fInputColorIsUsed(true)
, fInputColor(0)
, fReadsFragPosition(false) {}
- void calcWithInitialValues(const GrFragmentStage*, int stageCount, GrColor startColor,
- GrColorComponentFlags flags, bool areCoverageStages);
+ void calcWithInitialValues(const GrFragmentProcessor* const *, int cnt, GrColor startColor,
+ GrColorComponentFlags, bool areCoverageStages);
- void calcColorWithBatch(const GrDrawBatch*, const GrFragmentStage*, int stagecount);
- void calcCoverageWithBatch(const GrDrawBatch*, const GrFragmentStage*, int stagecount);
+ void calcColorWithBatch(const GrDrawBatch*, const GrFragmentProcessor* const[], int cnt);
+ void calcCoverageWithBatch(const GrDrawBatch*, const GrFragmentProcessor* const[], int cnt);
// TODO delete these when batch is everywhere
- void calcColorWithPrimProc(const GrPrimitiveProcessor*, const GrFragmentStage*, int stagecount);
- void calcCoverageWithPrimProc(const GrPrimitiveProcessor*, const GrFragmentStage*,
- int stagecount);
+ void calcColorWithPrimProc(const GrPrimitiveProcessor*, const GrFragmentProcessor* const[],
+ int cnt);
+ void calcCoverageWithPrimProc(const GrPrimitiveProcessor*, const GrFragmentProcessor* const[],
+ int cnt);
bool isSolidWhite() const { return fInOut.isSolidWhite(); }
bool isOpaque() const { return fInOut.isOpaque(); }
@@ -60,38 +60,38 @@
}
/**
- * Returns the index of the first effective color stage. If an intermediate stage doesn't read
- * its input or has a known output, then we can ignore all earlier stages since they will not
- * affect the final output. Thus the first effective stage index is the index to the first stage
- * that will have an effect on the final output.
+ * Returns the index of the first effective color processor. If an intermediate processor
+ * doesn't read its input or has a known output, then we can ignore all earlier processors
+ * since they will not affect the final output. Thus the first effective processors index is
+ * the index to the first processor that will have an effect on the final output.
*
- * If stages before the firstEffectiveStageIndex are removed, corresponding values from
- * inputColorIsUsed(), inputColorToEffectiveStage(), removeVertexAttribs(), and readsDst() must
- * be used when setting up the draw to ensure correct drawing.
+ * If processors before the firstEffectiveProcessorIndex() are removed, corresponding values
+ * from inputColorIsUsed(), inputColorToEffectiveProcessor(), removeVertexAttribs(), and
+ * readsDst() must be used when setting up the draw to ensure correct drawing.
*/
- int firstEffectiveStageIndex() const { return fFirstEffectStageIndex; }
+ int firstEffectiveProcessorIndex() const { return fFirstEffectiveProcessorIndex; }
/**
- * True if the first effective stage reads its input, false otherwise.
+ * True if the first effective processor reads its input, false otherwise.
*/
bool inputColorIsUsed() const { return fInputColorIsUsed; }
/**
* If input color is used and per-vertex colors are not used, this is the input color to the
- * first effective stage.
+ * first effective processor.
*/
- GrColor inputColorToEffectiveStage() const { return fInputColor; }
+ GrColor inputColorToFirstEffectiveProccesor() const { return fInputColor; }
/**
- * Returns true if any of the stages preserved by GrProcOptInfo read the frag position.
+ * Returns true if any of the processor preserved by GrProcOptInfo read the frag position.
*/
bool readsFragPosition() const { return fReadsFragPosition; }
private:
- void internalCalc(const GrFragmentStage*, int stagecount, bool initWillReadFragPosition);
+ void internalCalc(const GrFragmentProcessor* const[], int cnt, bool initWillReadFragPosition);
GrInvariantOutput fInOut;
- int fFirstEffectStageIndex;
+ int fFirstEffectiveProcessorIndex;
bool fInputColorIsUsed;
GrColor fInputColor;
bool fReadsFragPosition;
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp
index db1e2d9..3cbf777 100644
--- a/src/gpu/GrProcessor.cpp
+++ b/src/gpu/GrProcessor.cpp
@@ -130,6 +130,12 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
+GrFragmentProcessor::~GrFragmentProcessor() {
+ for (int i = 0; i < fChildProcessors.count(); ++i) {
+ fChildProcessors[i]->unref();
+ }
+}
+
bool GrFragmentProcessor::isEqual(const GrFragmentProcessor& that,
bool ignoreCoordTransforms) const {
if (this->classID() != that.classID() ||
@@ -161,7 +167,7 @@
GrGLFragmentProcessor* glFragProc = this->onCreateGLInstance();
glFragProc->fChildProcessors.push_back_n(fChildProcessors.count());
for (int i = 0; i < fChildProcessors.count(); ++i) {
- glFragProc->fChildProcessors[i] = fChildProcessors[i].processor()->createGLInstance();
+ glFragProc->fChildProcessors[i] = fChildProcessors[i]->createGLInstance();
}
return glFragProc;
}
@@ -199,7 +205,7 @@
}
int index = fChildProcessors.count();
- fChildProcessors.push_back(GrFragmentStage(child));
+ fChildProcessors.push_back(SkRef(child));
if (child->willReadFragmentPosition()) {
this->setWillReadFragmentPosition();
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index f421b81..ce00ad9 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -366,7 +366,7 @@
maskMatrix.setIDiv(texture->width(), texture->height());
maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop));
- pipelineBuilder->addCoverageProcessor(
+ pipelineBuilder->addCoverageFragmentProcessor(
GrSimpleTextureEffect::Create(pipelineBuilder->getProcessorDataManager(),
texture,
maskMatrix,
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index aefa389..722f744 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -963,7 +963,7 @@
}
// The bitmap read has to be first
- grPaint.addColorProcessor(fp);
+ grPaint.addColorFragmentProcessor(fp);
if (!SkPaint2GrPaintNoShader(context, renderTarget, paint, SkColor2GrColor(paint.getColor()),
false, &grPaint)) {
return;
@@ -1305,7 +1305,7 @@
SkMatrix::I(), params));
}
- grPaint.addColorProcessor(fp);
+ grPaint.addColorFragmentProcessor(fp);
bool alphaOnly = !(kAlpha_8_SkColorType == bitmap.colorType());
GrColor paintColor = (alphaOnly) ? SkColor2GrColorJustAlpha(paint.getColor()) :
SkColor2GrColor(paint.getColor());
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index ef8460b..f55aa6a 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -469,7 +469,7 @@
yuvToRgbProcessor(GrYUVtoRGBEffect::Create(paint.getProcessorDataManager(), yuvTextures[0],
yuvTextures[1], yuvTextures[2],
yuvInfo.fSize, yuvInfo.fColorSpace));
- paint.addColorProcessor(yuvToRgbProcessor);
+ paint.addColorFragmentProcessor(yuvToRgbProcessor);
SkRect r = SkRect::MakeWH(SkIntToScalar(yuvInfo.fSize[0].fWidth),
SkIntToScalar(yuvInfo.fSize[0].fHeight));
@@ -810,7 +810,7 @@
if (colorFilter->asFragmentProcessors(context, grPaint->getProcessorDataManager(),
&array)) {
for (int i = 0; i < array.count(); ++i) {
- grPaint->addColorProcessor(array[i]);
+ grPaint->addColorFragmentProcessor(array[i]);
array[i]->unref();
}
}
@@ -820,7 +820,7 @@
#ifndef SK_IGNORE_GPU_DITHER
// If the dither flag is set, then we need to see if the underlying context
// supports it. If not, then install a dither effect.
- if (skPaint.isDither() && grPaint->numColorStages() > 0) {
+ if (skPaint.isDither() && grPaint->numColorFragmentProcessors() > 0) {
// What are we rendering into?
SkASSERT(rt);
@@ -832,7 +832,7 @@
// not going to be dithered by the GPU.
SkAutoTUnref<GrFragmentProcessor> fp(GrDitherEffect::Create());
if (fp.get()) {
- grPaint->addColorProcessor(fp);
+ grPaint->addColorFragmentProcessor(fp);
grPaint->setDither(false);
}
}
@@ -863,7 +863,7 @@
return false;
}
if (fp) {
- grPaint->addColorProcessor(fp)->unref();
+ grPaint->addColorFragmentProcessor(fp)->unref();
constantColor = false;
}
}
diff --git a/src/gpu/batches/GrDrawBatch.h b/src/gpu/batches/GrDrawBatch.h
index ed33816..f7c206d 100644
--- a/src/gpu/batches/GrDrawBatch.h
+++ b/src/gpu/batches/GrDrawBatch.h
@@ -64,12 +64,12 @@
SkString dumpInfo() const override {
SkString string;
string.append("ColorStages:\n");
- for (int i = 0; i < this->pipeline()->numColorFragmentStages(); i++) {
- string.appendf("\t\t%s\n", this->pipeline()->getColorStage(i).processor()->name());
+ for (int i = 0; i < this->pipeline()->numColorFragmentProcessors(); i++) {
+ string.appendf("\t\t%s\n", this->pipeline()->getColorFragmentProcessor(i).name());
}
string.append("CoverageStages:\n");
- for (int i = 0; i < this->pipeline()->numCoverageFragmentStages(); i++) {
- string.appendf("\t%s\n", this->pipeline()->getCoverageStage(i).processor()->name());
+ for (int i = 0; i < this->pipeline()->numCoverageFragmentProcessors(); i++) {
+ string.appendf("\t%s\n", this->pipeline()->getCoverageFragmentProcessor(i).name());
}
string.appendf("XP: %s\n", this->pipeline()->getXferProcessor()->name());
return string;
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 06b2d8d..cee0f2f 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -223,7 +223,7 @@
SkAutoTUnref<GrFragmentProcessor> pmToUPM2(new GrConfigConversionEffect(
paint3.getProcessorDataManager(), tempTex, false, *pmToUPMRule, SkMatrix::I()));
- paint1.addColorProcessor(pmToUPM1);
+ paint1.addColorFragmentProcessor(pmToUPM1);
GrDrawContext* readDrawContext = context->drawContext();
@@ -241,7 +241,7 @@
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead);
- paint2.addColorProcessor(upmToPM);
+ paint2.addColorFragmentProcessor(upmToPM);
GrDrawContext* tempDrawContext = context->drawContext();
if (!tempDrawContext) {
@@ -255,7 +255,7 @@
kDstRect,
kSrcRect);
- paint3.addColorProcessor(pmToUPM2);
+ paint3.addColorFragmentProcessor(pmToUPM2);
readDrawContext = context->drawContext();
if (!readDrawContext) {
diff --git a/src/gpu/gl/GrGLPathProgram.cpp b/src/gpu/gl/GrGLPathProgram.cpp
index 4b31f02..5bcadfe 100644
--- a/src/gpu/gl/GrGLPathProgram.cpp
+++ b/src/gpu/gl/GrGLPathProgram.cpp
@@ -31,13 +31,13 @@
}
void GrGLPathProgram::setTransformData(const GrPrimitiveProcessor& primProc,
- const GrPendingFragmentStage& proc,
+ const GrFragmentProcessor& processor,
int index,
GrGLInstalledFragProc* ip) {
GrGLPathProcessor* pathProc =
static_cast<GrGLPathProcessor*>(fGeometryProcessor.get()->fGLProc.get());
pathProc->setTransformData(primProc, fPathProgramDataManager, index,
- proc.processor()->coordTransforms());
+ processor.coordTransforms());
}
void GrGLPathProgram::onSetRenderTargetState(const GrPrimitiveProcessor& primProc,
diff --git a/src/gpu/gl/GrGLPathProgram.h b/src/gpu/gl/GrGLPathProgram.h
index c7ca3dc..74f43e5 100644
--- a/src/gpu/gl/GrGLPathProgram.h
+++ b/src/gpu/gl/GrGLPathProgram.h
@@ -34,7 +34,7 @@
private:
void didSetData() override;
virtual void setTransformData(const GrPrimitiveProcessor&,
- const GrPendingFragmentStage&,
+ const GrFragmentProcessor&,
int index,
GrGLInstalledFragProc*) override;
void onSetRenderTargetState(const GrPrimitiveProcessor&, const GrPipeline&) override;
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 5af84e0..3aaa7ea 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -105,25 +105,24 @@
const GrPipeline& pipeline,
SkTArray<const GrTextureAccess*>* textureBindings) {
int numProcessors = fFragmentProcessors->fProcs.count();
- for (int e = 0; e < numProcessors; ++e) {
- const GrPendingFragmentStage& stage = pipeline.getFragmentStage(e);
- const GrFragmentProcessor& processor = *stage.processor();
- fFragmentProcessors->fProcs[e]->fGLProc->setData(fProgramDataManager, processor);
+ for (int i = 0; i < numProcessors; ++i) {
+ const GrFragmentProcessor& processor = pipeline.getFragmentProcessor(i);
+ fFragmentProcessors->fProcs[i]->fGLProc->setData(fProgramDataManager, processor);
this->setTransformData(primProc,
- stage,
- e,
- fFragmentProcessors->fProcs[e]);
- append_texture_bindings(fFragmentProcessors->fProcs[e], processor, textureBindings);
+ processor,
+ i,
+ fFragmentProcessors->fProcs[i]);
+ append_texture_bindings(fFragmentProcessors->fProcs[i], processor, textureBindings);
}
}
void GrGLProgram::setTransformData(const GrPrimitiveProcessor& primProc,
- const GrPendingFragmentStage& processor,
+ const GrFragmentProcessor& processor,
int index,
GrGLInstalledFragProc* ip) {
GrGLGeometryProcessor* gp =
static_cast<GrGLGeometryProcessor*>(fGeometryProcessor.get()->fGLProc.get());
gp->setTransformData(primProc, fProgramDataManager, index,
- processor.processor()->coordTransforms());
+ processor.coordTransforms());
}
void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc,
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index c8fa1b1..fee6277 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -115,7 +115,7 @@
void setFragmentData(const GrPrimitiveProcessor&, const GrPipeline&,
SkTArray<const GrTextureAccess*>* textureBindings);
virtual void setTransformData(const GrPrimitiveProcessor&,
- const GrPendingFragmentStage&,
+ const GrFragmentProcessor&,
int index,
GrGLInstalledFragProc*);
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 5365ffb..6b38cc6 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -134,9 +134,8 @@
return false;
}
- for (int s = 0; s < pipeline.numFragmentStages(); ++s) {
- const GrPendingFragmentStage& fps = pipeline.getFragmentStage(s);
- const GrFragmentProcessor& fp = *fps.processor();
+ for (int i = 0; i < pipeline.numFragmentProcessors(); ++i) {
+ const GrFragmentProcessor& fp = pipeline.getFragmentProcessor(i);
if (!get_frag_proc_and_meta_keys(primProc, fp, gpu->glCaps(), &b)) {
glDesc->key().reset();
return false;
@@ -167,8 +166,8 @@
header->fFragPosKey = 0;
}
header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters();
- header->fColorEffectCnt = pipeline.numColorFragmentStages();
- header->fCoverageEffectCnt = pipeline.numCoverageFragmentStages();
+ header->fColorEffectCnt = pipeline.numColorFragmentProcessors();
+ header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors();
glDesc->finalize();
return true;
}
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 39d8ec5..d0eb4d4 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -186,15 +186,15 @@
int totalTextures = primProc.numTextures();
const int maxTextureUnits = fGpu->glCaps().maxFragmentTextureUnits();
- for (int i = 0; i < this->pipeline().numFragmentStages(); i++) {
- const GrFragmentProcessor* processor = this->pipeline().getFragmentStage(i).processor();
+ for (int i = 0; i < this->pipeline().numFragmentProcessors(); i++) {
+ const GrFragmentProcessor& processor = this->pipeline().getFragmentProcessor(i);
if (!primProc.hasTransformedLocalCoords()) {
- SkSTArray<2, const GrCoordTransform*, true>& procCoords = fCoordTransforms.push_back();
- processor->gatherCoordTransforms(&procCoords);
+ SkTArray<const GrCoordTransform*, true>& procCoords = fCoordTransforms.push_back();
+ processor.gatherCoordTransforms(&procCoords);
}
- totalTextures += processor->numTextures();
+ totalTextures += processor.numTextures();
if (totalTextures >= maxTextureUnits) {
GrCapsDebugf(fGpu->caps(), "Program would use too many texture units\n");
return false;
@@ -204,9 +204,9 @@
this->emitAndInstallProc(primProc, inputColor, inputCoverage);
fFragmentProcessors.reset(new GrGLInstalledFragProcs);
- int numProcs = this->pipeline().numFragmentStages();
- this->emitAndInstallFragProcs(0, this->pipeline().numColorFragmentStages(), inputColor);
- this->emitAndInstallFragProcs(this->pipeline().numColorFragmentStages(), numProcs,
+ int numProcs = this->pipeline().numFragmentProcessors();
+ this->emitAndInstallFragProcs(0, this->pipeline().numColorFragmentProcessors(), inputColor);
+ this->emitAndInstallFragProcs(this->pipeline().numColorFragmentProcessors(), numProcs,
inputCoverage);
this->emitAndInstallXferProc(*this->pipeline().getXferProcessor(), *inputColor, *inputCoverage);
return true;
@@ -215,10 +215,10 @@
void GrGLProgramBuilder::emitAndInstallFragProcs(int procOffset,
int numProcs,
GrGLSLExpr4* inOut) {
- for (int e = procOffset; e < numProcs; ++e) {
+ for (int i = procOffset; i < numProcs; ++i) {
GrGLSLExpr4 output;
- const GrPendingFragmentStage& stage = this->pipeline().getFragmentStage(e);
- this->emitAndInstallProc(stage, e, *inOut, &output);
+ const GrFragmentProcessor& fp = this->pipeline().getFragmentProcessor(i);
+ this->emitAndInstallProc(fp, i, *inOut, &output);
*inOut = output;
}
}
@@ -239,7 +239,7 @@
// TODO Processors cannot output zeros because an empty string is all 1s
// the fix is to allow effects to take the GrGLSLExpr4 directly
-void GrGLProgramBuilder::emitAndInstallProc(const GrPendingFragmentStage& proc,
+void GrGLProgramBuilder::emitAndInstallProc(const GrFragmentProcessor& fp,
int index,
const GrGLSLExpr4& input,
GrGLSLExpr4* output) {
@@ -249,10 +249,10 @@
// Enclose custom code in a block to avoid namespace conflicts
SkString openBrace;
- openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name());
+ openBrace.printf("{ // Stage %d, %s\n", fStageIndex, fp.name());
fFS.codeAppend(openBrace.c_str());
- this->emitAndInstallProc(proc, index, output->c_str(), input.isOnes() ? NULL : input.c_str());
+ this->emitAndInstallProc(fp, index, output->c_str(), input.isOnes() ? NULL : input.c_str());
fFS.codeAppend("}");
}
@@ -276,13 +276,12 @@
fFS.codeAppend("}");
}
-void GrGLProgramBuilder::emitAndInstallProc(const GrPendingFragmentStage& fs,
+void GrGLProgramBuilder::emitAndInstallProc(const GrFragmentProcessor& fp,
int index,
const char* outColor,
const char* inColor) {
GrGLInstalledFragProc* ifp = new GrGLInstalledFragProc;
- const GrFragmentProcessor& fp = *fs.processor();
ifp->fGLProc.reset(fp.createGLInstance());
SkSTArray<4, GrGLProcessor::TextureSampler> samplers(fp.numTextures());
@@ -501,7 +500,7 @@
GrGLInstalledFragProcs::~GrGLInstalledFragProcs() {
int numProcs = fProcs.count();
- for (int e = 0; e < numProcs; ++e) {
- delete fProcs[e];
+ for (int i = 0; i < numProcs; ++i) {
+ delete fProcs[i];
}
}
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h
index bdd96d2..06d0fa0 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.h
@@ -16,9 +16,10 @@
#include "../GrGLUniformHandle.h"
#include "../GrGLPrimitiveProcessor.h"
#include "../GrGLXferProcessor.h"
-#include "../../GrPendingFragmentStage.h"
#include "../../GrPipeline.h"
+class GrFragmentProcessor;
+
// Enough precision to represent 1 / 2048 accurately in printf
#define GR_SIGNIFICANT_POW2_DECIMAL_DIG 11
@@ -301,7 +302,7 @@
void nameExpression(GrGLSLExpr4*, const char* baseName);
bool emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr4* inputCoverage);
void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOut);
- void emitAndInstallProc(const GrPendingFragmentStage&,
+ void emitAndInstallProc(const GrFragmentProcessor&,
int index,
const GrGLSLExpr4& input,
GrGLSLExpr4* output);
@@ -311,7 +312,7 @@
GrGLSLExpr4* outputCoverage);
// these emit functions help to keep the createAndEmitProcessors template general
- void emitAndInstallProc(const GrPendingFragmentStage&,
+ void emitAndInstallProc(const GrFragmentProcessor&,
int index,
const char* outColor,
const char* inColor);
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 1be6eaa..d758795 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -248,8 +248,9 @@
GrPaint paint;
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
- paint.addColorProcessor(GrYUVtoRGBEffect::Create(paint.getProcessorDataManager(), yTex, uTex,
- vTex, yuvSizes, colorSpace))->unref();
+ paint.addColorFragmentProcessor(GrYUVtoRGBEffect::Create(paint.getProcessorDataManager(),
+ yTex, uTex, vTex, yuvSizes,
+ colorSpace))->unref();
const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth),
SkIntToScalar(dstDesc.fHeight));
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 4b3bcdf..d5251ba 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -148,9 +148,9 @@
// finally add the stage to the correct pipeline in the drawstate
if (s < numColorProcs) {
- pipelineBuilder->addColorProcessor(fp);
+ pipelineBuilder->addColorFragmentProcessor(fp);
} else {
- pipelineBuilder->addCoverageProcessor(fp);
+ pipelineBuilder->addCoverageFragmentProcessor(fp);
}
++s;
}