Revert of Remove GrStagedProcessor, remove the word Stage as it applies to FPs (patchset #6 id:90001 of https://codereview.chromium.org/1307223004/ )
Reason for revert:
Causes bot failures:
https://uberchromegw.corp.google.com/i/client.skia/builders/Test-Mac10.9-Clang-MacMini6.2-GPU-HD4000-x86_64-Debug/builds/1639
https://uberchromegw.corp.google.com/i/client.skia/builders/Test-Ubuntu-GCC-ShuttleA-GPU-GTX660-x86_64-Debug/builds/1702
https://uberchromegw.corp.google.com/i/client.skia.android/builders/Test-Android-GCC-NexusPlayer-GPU-PowerVR-x86-Debug/builds/1223
Original issue's description:
> Remove GrStagedProcessor, remove the word Stage as it applies to FPs
>
> Committed: https://skia.googlesource.com/skia/+/24243446cdf7b7e4e132c2a0c387c7723777e0c7
TBR=joshualitt@google.com,egdaniel@google.com,bsalomon@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/1306803003
diff --git a/gm/bigrrectaaeffect.cpp b/gm/bigrrectaaeffect.cpp
index f19b57c..cf151fb 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.addCoverageFragmentProcessor(fp);
+ pipelineBuilder.addCoverageProcessor(fp);
pipelineBuilder.setRenderTarget(rt);
SkRect bounds = SkRect::MakeWH(SkIntToScalar(kMaxSize),
diff --git a/gm/constcolorprocessor.cpp b/gm/constcolorprocessor.cpp
index 59d1706..30544af 100644
--- a/gm/constcolorprocessor.cpp
+++ b/gm/constcolorprocessor.cpp
@@ -113,7 +113,7 @@
GrClip clip;
GrPipelineBuilder pipelineBuilder(grPaint, rt, clip);
- pipelineBuilder.addColorFragmentProcessor(fp);
+ pipelineBuilder.addColorProcessor(fp);
tt.target()->drawNonAARect(pipelineBuilder,
grPaint.getColor(),
diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp
index 77eb152..30471a79 100644
--- a/gm/convexpolyeffect.cpp
+++ b/gm/convexpolyeffect.cpp
@@ -191,7 +191,7 @@
}
GrPipelineBuilder pipelineBuilder;
- pipelineBuilder.addCoverageFragmentProcessor(fp);
+ pipelineBuilder.addCoverageProcessor(fp);
pipelineBuilder.setRenderTarget(rt);
ConvexPolyTestBatch::Geometry geometry;
@@ -240,7 +240,7 @@
}
GrPipelineBuilder pipelineBuilder;
- pipelineBuilder.addCoverageFragmentProcessor(fp);
+ pipelineBuilder.addCoverageProcessor(fp);
pipelineBuilder.setRenderTarget(rt);
ConvexPolyTestBatch::Geometry geometry;
diff --git a/gm/rrects.cpp b/gm/rrects.cpp
index f9a21db..62ad48f 100644
--- a/gm/rrects.cpp
+++ b/gm/rrects.cpp
@@ -114,7 +114,7 @@
SkAutoTUnref<GrFragmentProcessor> fp(GrRRectEffect::Create(edgeType,
rrect));
if (fp) {
- pipelineBuilder.addCoverageFragmentProcessor(fp);
+ pipelineBuilder.addCoverageProcessor(fp);
pipelineBuilder.setRenderTarget(rt);
SkRect bounds = rrect.getBounds();
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index 1951c20..07b7119 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -128,7 +128,7 @@
}
const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y);
pipelineBuilder.setRenderTarget(rt);
- pipelineBuilder.addColorFragmentProcessor(fp);
+ pipelineBuilder.addColorProcessor(fp);
tt.target()->drawNonAARect(pipelineBuilder,
GrColor_WHITE,
diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp
index 7a4029c..4ec86f4 100644
--- a/gm/yuvtorgbeffect.cpp
+++ b/gm/yuvtorgbeffect.cpp
@@ -123,7 +123,7 @@
SkMatrix viewMatrix;
viewMatrix.setTranslate(x, y);
pipelineBuilder.setRenderTarget(rt);
- pipelineBuilder.addColorFragmentProcessor(fp);
+ pipelineBuilder.addColorProcessor(fp);
tt.target()->drawNonAARect(pipelineBuilder,
GrColor_WHITE,
viewMatrix,
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi
index 11beb94..3e08a50 100644
--- a/gyp/gpu.gypi
+++ b/gyp/gpu.gypi
@@ -35,6 +35,7 @@
'<(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',
@@ -148,6 +149,7 @@
'<(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 e4d9151..097925b 100644
--- a/include/gpu/GrFragmentProcessor.h
+++ b/include/gpu/GrFragmentProcessor.h
@@ -9,6 +9,7 @@
#define GrFragmentProcessor_DEFINED
#include "GrProcessor.h"
+#include "GrStagedProcessor.h"
class GrCoordTransform;
class GrGLSLCaps;
@@ -28,14 +29,12 @@
, 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]->getGLProcessorKey(caps, b);
+ fChildProcessors[i].processor()->getGLProcessorKey(caps, b);
}
}
@@ -61,7 +60,9 @@
int numChildProcessors() const { return fChildProcessors.count(); }
- const GrFragmentProcessor& childProcessor(int index) const { return *fChildProcessors[index]; }
+ const GrFragmentProcessor& childProcessor(int index) const {
+ return *fChildProcessors[index].processor();
+ }
/** Do any of the coordtransforms for this processor require local coords? */
bool usesLocalCoords() const { return fUsesLocalCoords; }
@@ -175,9 +176,7 @@
int fNumTexturesExclChildren;
int fNumTransformsExclChildren;
- // 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;
+ SkTArray<GrFragmentStage, false> fChildProcessors;
typedef GrProcessor INHERITED;
};
diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h
index 3013863..e4b2b09 100644
--- a/include/gpu/GrPaint.h
+++ b/include/gpu/GrPaint.h
@@ -11,6 +11,7 @@
#define GrPaint_DEFINED
#include "GrColor.h"
+#include "GrStagedProcessor.h"
#include "GrProcessorDataManager.h"
#include "GrXferProcessor.h"
#include "effects/GrPorterDuffXferProcessor.h"
@@ -43,7 +44,7 @@
GrPaint(const GrPaint& paint) { *this = paint; }
- ~GrPaint() { this->resetFragmentProcessors(); }
+ ~GrPaint() {}
/**
* The initial color of the drawn primitive. Defaults to solid white.
@@ -77,18 +78,18 @@
/**
* Appends an additional color processor to the color computation.
*/
- const GrFragmentProcessor* addColorFragmentProcessor(const GrFragmentProcessor* fp) {
+ const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* fp) {
SkASSERT(fp);
- fColorFragmentProcessors.push_back(SkRef(fp));
+ SkNEW_APPEND_TO_TARRAY(&fColorStages, GrFragmentStage, (fp));
return fp;
}
/**
* Appends an additional coverage processor to the coverage computation.
*/
- const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragmentProcessor* fp) {
+ const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* fp) {
SkASSERT(fp);
- fCoverageFragmentProcessors.push_back(SkRef(fp));
+ SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrFragmentStage, (fp));
return fp;
}
@@ -101,10 +102,9 @@
void addColorTextureProcessor(GrTexture*, const SkMatrix&, const GrTextureParams&);
void addCoverageTextureProcessor(GrTexture*, const SkMatrix&, const GrTextureParams&);
- int numColorFragmentProcessors() const { return fColorFragmentProcessors.count(); }
- int numCoverageFragmentProcessors() const { return fCoverageFragmentProcessors.count(); }
- int numTotalFragmentProcessors() const { return this->numColorFragmentProcessors() +
- this->numCoverageFragmentProcessors(); }
+ int numColorStages() const { return fColorStages.count(); }
+ int numCoverageStages() const { return fCoverageStages.count(); }
+ int numTotalStages() const { return this->numColorStages() + this->numCoverageStages(); }
const GrXPFactory* getXPFactory() const {
if (!fXPFactory) {
@@ -113,27 +113,17 @@
return fXPFactory.get();
}
- const GrFragmentProcessor* getColorFragmentProcessor(int i) const {
- return fColorFragmentProcessors[i];
- }
- const GrFragmentProcessor* getCoverageFragmentProcessor(int i) const {
- return fCoverageFragmentProcessors[i];
- }
+ const GrFragmentStage& getColorStage(int s) const { return fColorStages[s]; }
+ const GrFragmentStage& getCoverageStage(int s) const { return fCoverageStages[s]; }
GrPaint& operator=(const GrPaint& paint) {
fAntiAlias = paint.fAntiAlias;
fDither = paint.fDither;
fColor = paint.fColor;
- this->resetFragmentProcessors();
- fColorFragmentProcessors = paint.fColorFragmentProcessors;
- fCoverageFragmentProcessors = paint.fCoverageFragmentProcessors;
- for (int i = 0; i < fColorFragmentProcessors.count(); ++i) {
- fColorFragmentProcessors[i]->ref();
- }
- for (int i = 0; i < fColorFragmentProcessors.count(); ++i) {
- fColorFragmentProcessors[i]->ref();
- }
+
+ fColorStages = paint.fColorStages;
+ fCoverageStages = paint.fCoverageStages;
fXPFactory.reset(SkRef(paint.getXPFactory()));
fProcDataManager.reset(SkNEW_ARGS(GrProcessorDataManager, (*paint.processorDataManager())));
@@ -154,26 +144,15 @@
const GrProcessorDataManager* processorDataManager() const { return fProcDataManager.get(); }
private:
- 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();
- }
+ mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
+ SkSTArray<4, GrFragmentStage> fColorStages;
+ SkSTArray<2, GrFragmentStage> fCoverageStages;
- mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
- SkSTArray<4, const GrFragmentProcessor*, true> fColorFragmentProcessors;
- SkSTArray<2, const GrFragmentProcessor*, true> fCoverageFragmentProcessors;
+ bool fAntiAlias;
+ bool fDither;
- bool fAntiAlias;
- bool fDither;
-
- GrColor fColor;
- SkAutoTUnref<GrProcessorDataManager> fProcDataManager;
+ GrColor fColor;
+ SkAutoTUnref<GrProcessorDataManager> fProcDataManager;
};
#endif
diff --git a/include/gpu/GrStagedProcessor.h b/include/gpu/GrStagedProcessor.h
new file mode 100644
index 0000000..fe3afcc
--- /dev/null
+++ b/include/gpu/GrStagedProcessor.h
@@ -0,0 +1,44 @@
+/*
+ * 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 e9be109..5157db2 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.addColorFragmentProcessor(fp)->unref();
+ paint.addColorProcessor(fp)->unref();
GrDrawContext* drawContext = context->drawContext();
if (drawContext) {
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 7faf52e..96789c2 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -859,7 +859,7 @@
return false;
}
- grp->addCoverageFragmentProcessor(fp);
+ grp->addCoverageProcessor(fp);
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
@@ -1135,7 +1135,7 @@
return false;
}
- grp->addCoverageFragmentProcessor(fp);
+ grp->addCoverageProcessor(fp);
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
@@ -1211,8 +1211,8 @@
SkMatrix matrix;
matrix.setIDiv(src->width(), src->height());
// Blend pathTexture over blurTexture.
- paint.addCoverageFragmentProcessor(
- GrSimpleTextureEffect::Create(paint.getProcessorDataManager(), src, matrix))->unref();
+ paint.addCoverageProcessor(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 fe52317..f360fe1 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -444,7 +444,7 @@
offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset.fX),
SkIntToScalar(colorOffset.fY - displacementOffset.fY));
- paint.addColorFragmentProcessor(
+ paint.addColorProcessor(
GrDisplacementMapEffect::Create(paint.getProcessorDataManager(),
fXChannelSelector,
fYChannelSelector,
diff --git a/src/effects/SkGpuBlurUtils.cpp b/src/effects/SkGpuBlurUtils.cpp
index 2b6b310..7c239a1 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.addColorFragmentProcessor(conv);
+ paint.addColorProcessor(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.addColorFragmentProcessor(conv);
+ paint.addColorProcessor(conv);
drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, srcRect);
}
@@ -216,7 +216,7 @@
domain,
GrTextureDomain::kDecal_Mode,
GrTextureParams::kBilerp_FilterMode));
- paint.addColorFragmentProcessor(fp);
+ paint.addColorProcessor(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 6dbe734..c63b2eb 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.addColorFragmentProcessor(fp)->unref();
+ paint.addColorProcessor(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 f1a7d09..01e978e 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -471,12 +471,12 @@
float bounds[2],
Gr1DKernelEffect::Direction direction) {
GrPaint paint;
- paint.addColorFragmentProcessor(GrMorphologyEffect::Create(paint.getProcessorDataManager(),
- texture,
- direction,
- radius,
- morphType,
- bounds))->unref();
+ paint.addColorProcessor(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.addColorFragmentProcessor(GrMorphologyEffect::Create(paint.getProcessorDataManager(),
- texture,
- direction,
- radius,
- morphType))->unref();
+ paint.addColorProcessor(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 f62773a..e014cc0 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -189,8 +189,8 @@
GrTextureParams::kNone_FilterMode)
);
- paint.addColorFragmentProcessor(foregroundDomain.get());
- paint.addColorFragmentProcessor(xferProcessor)->unref();
+ paint.addColorProcessor(foregroundDomain.get());
+ paint.addColorProcessor(xferProcessor)->unref();
GrDrawContext* drawContext = context->drawContext();
if (!drawContext) {
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index ede386a..6013b58 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->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(grp->getProcessorDataManager(),
+ grp->addCoverageProcessor(GrSimpleTextureEffect::Create(grp->getProcessorDataManager(),
mask, matrix,
kDevice_GrCoordSet))->unref();
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index c9362fa..b58faaa 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->addCoverageFragmentProcessor(
+ arfps->addCoverageProcessor(
GrTextureDomainEffect::Create(arfps->getProcessorDataManager(),
result,
mat,
@@ -200,7 +200,7 @@
break;
}
if (fp) {
- arfps->addCoverageFragmentProcessor(fp);
+ arfps->addCoverageProcessor(fp);
} else {
failed = true;
break;
@@ -488,7 +488,7 @@
SkMatrix sampleM;
sampleM.setIDiv(srcMask->width(), srcMask->height());
- pipelineBuilder->addCoverageFragmentProcessor(
+ pipelineBuilder->addCoverageProcessor(
GrTextureDomainEffect::Create(pipelineBuilder->getProcessorDataManager(),
srcMask,
sampleM,
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 8b8528b..2f334c6 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -427,7 +427,7 @@
if (!drawContext) {
return false;
}
- paint.addColorFragmentProcessor(fp);
+ paint.addColorProcessor(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.addColorFragmentProcessor(fp);
+ paint.addColorProcessor(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 f4dca8b..2ad7e72 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -1423,7 +1423,7 @@
return false;
}
arfps.set(&pipelineBuilder);
- arfps.addCoverageFragmentProcessor(fp)->unref();
+ arfps.addCoverageProcessor(fp)->unref();
}
SkStrokeRec fillRec(SkStrokeRec::kFill_InitStyle);
@@ -1453,7 +1453,7 @@
return false;
}
- arfps.addCoverageFragmentProcessor(effect)->unref();
+ arfps.addCoverageProcessor(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 d37ac57..7427785 100644
--- a/src/gpu/GrPaint.cpp
+++ b/src/gpu/GrPaint.cpp
@@ -25,33 +25,32 @@
}
void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
- this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
+ this->addColorProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
matrix))->unref();
}
void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
- this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
+ this->addCoverageProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
matrix))->unref();
}
void GrPaint::addColorTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
+ this->addColorProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
params))->unref();
}
void GrPaint::addCoverageTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
+ this->addCoverageProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
params))->unref();
}
bool GrPaint::isConstantBlendedColor(GrColor* color) const {
GrProcOptInfo colorProcInfo;
- colorProcInfo.calcWithInitialValues(fColorFragmentProcessors.begin(),
- this->numColorFragmentProcessors(), fColor,
+ colorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColorStages(), fColor,
kRGBA_GrColorComponentFlags, false);
GrXPFactory::InvariantBlendedColor blendedColor;
diff --git a/src/gpu/GrPendingFragmentStage.h b/src/gpu/GrPendingFragmentStage.h
new file mode 100644
index 0000000..dfa5688
--- /dev/null
+++ b/src/gpu/GrPendingFragmentStage.h
@@ -0,0 +1,27 @@
+/*
+ * 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 5e057b0..8f149f5 100644
--- a/src/gpu/GrPipeline.cpp
+++ b/src/gpu/GrPipeline.cpp
@@ -29,8 +29,8 @@
}
GrColor overrideColor = GrColor_ILLEGAL;
- if (args.fColorPOI.firstEffectiveProcessorIndex() != 0) {
- overrideColor = args.fColorPOI.inputColorToFirstEffectiveProccesor();
+ if (args.fColorPOI.firstEffectiveStageIndex() != 0) {
+ overrideColor = args.fColorPOI.inputColorToEffectiveStage();
}
GrXferProcessor::OptFlags optFlags = GrXferProcessor::kNone_OptFlags;
@@ -73,36 +73,31 @@
pipeline->fFlags |= kSnapVertices_Flag;
}
- int firstColorProcessorIdx = args.fColorPOI.firstEffectiveProcessorIndex();
+ int firstColorStageIdx = args.fColorPOI.firstEffectiveStageIndex();
- // 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;
+ // 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;
pipeline->adjustProgramFromOptimizations(builder, optFlags, args.fColorPOI, args.fCoveragePOI,
- &firstColorProcessorIdx, &firstCoverageProcessorIdx);
+ &firstColorStageIdx, &firstCoverageStageIdx);
bool usesLocalCoords = false;
- // 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);
+ // 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));
usesLocalCoords = usesLocalCoords || fp->usesLocalCoords();
fp->gatherCoordTransforms(&pipeline->fCoordTransforms);
}
- for (int i = firstCoverageProcessorIdx; i < builder.numCoverageFragmentProcessors();
- ++i, ++currFPIdx) {
- const GrFragmentProcessor* fp = builder.getCoverageFragmentProcessor(i);
- pipeline->fFragmentProcessors[currFPIdx].reset(fp);
+ 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));
usesLocalCoords = usesLocalCoords || fp->usesLocalCoords();
fp->gatherCoordTransforms(&pipeline->fCoordTransforms);
}
@@ -139,13 +134,13 @@
GrXferProcessor::OptFlags flags,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
- int* firstColorProcessorIdx,
- int* firstCoverageProcessorIdx) {
+ int* firstColorStageIdx,
+ int* firstCoverageStageIdx) {
fReadsFragPosition = fXferProcessor->willReadFragmentPosition();
if ((flags & GrXferProcessor::kIgnoreColor_OptFlag) ||
(flags & GrXferProcessor::kOverrideColor_OptFlag)) {
- *firstColorProcessorIdx = pipelineBuilder.numColorFragmentProcessors();
+ *firstColorStageIdx = pipelineBuilder.numColorFragmentStages();
} else {
if (coveragePOI.readsFragPosition()) {
fReadsFragPosition = true;
@@ -153,7 +148,7 @@
}
if (flags & GrXferProcessor::kIgnoreCoverage_OptFlag) {
- *firstCoverageProcessorIdx = pipelineBuilder.numCoverageFragmentProcessors();
+ *firstCoverageStageIdx = pipelineBuilder.numCoverageFragmentStages();
} else {
if (coveragePOI.readsFragPosition()) {
fReadsFragPosition = true;
@@ -168,8 +163,8 @@
SkASSERT(&a != &b);
if (a.getRenderTarget() != b.getRenderTarget() ||
- a.fFragmentProcessors.count() != b.fFragmentProcessors.count() ||
- a.fNumColorProcessors != b.fNumColorProcessors ||
+ a.fFragmentStages.count() != b.fFragmentStages.count() ||
+ a.fNumColorStages != b.fNumColorStages ||
a.fScissorState != b.fScissorState ||
a.fFlags != b.fFlags ||
a.fStencilSettings != b.fStencilSettings ||
@@ -181,8 +176,9 @@
return false;
}
- for (int i = 0; i < a.numFragmentProcessors(); i++) {
- if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i), ignoreCoordTransforms)) {
+ for (int i = 0; i < a.numFragmentStages(); i++) {
+ if (!a.getFragmentStage(i).processor()->isEqual(*b.getFragmentStage(i).processor(),
+ ignoreCoordTransforms)) {
return false;
}
}
diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h
index db14155..ea2ea85 100644
--- a/src/gpu/GrPipeline.h
+++ b/src/gpu/GrPipeline.h
@@ -9,10 +9,9 @@
#define GrPipeline_DEFINED
#include "GrColor.h"
-#include "GrFragmentProcessor.h"
#include "GrGpu.h"
#include "GrNonAtomicRef.h"
-#include "GrPendingProgramElement.h"
+#include "GrPendingFragmentStage.h"
#include "GrPrimitiveProcessor.h"
#include "GrProgramDesc.h"
#include "GrStencil.h"
@@ -85,26 +84,22 @@
/// @name GrFragmentProcessors
- int numColorFragmentProcessors() const { return fNumColorProcessors; }
- int numCoverageFragmentProcessors() const {
- return fFragmentProcessors.count() - fNumColorProcessors;
- }
- int numFragmentProcessors() const { return fFragmentProcessors.count(); }
+ int numColorFragmentStages() const { return fNumColorStages; }
+ int numCoverageFragmentStages() const { return fFragmentStages.count() - fNumColorStages; }
+ int numFragmentStages() const { return fFragmentStages.count(); }
const GrXferProcessor* getXferProcessor() const { return fXferProcessor.get(); }
- const GrFragmentProcessor& getColorFragmentProcessor(int idx) const {
- SkASSERT(idx < this->numColorFragmentProcessors());
- return *fFragmentProcessors[idx].get();
+ const GrPendingFragmentStage& getColorStage(int idx) const {
+ SkASSERT(idx < this->numColorFragmentStages());
+ return fFragmentStages[idx];
}
-
- const GrFragmentProcessor& getCoverageFragmentProcessor(int idx) const {
- SkASSERT(idx < this->numCoverageFragmentProcessors());
- return *fFragmentProcessors[fNumColorProcessors + idx].get();
+ const GrPendingFragmentStage& getCoverageStage(int idx) const {
+ SkASSERT(idx < this->numCoverageFragmentStages());
+ return fFragmentStages[fNumColorStages + idx];
}
-
- const GrFragmentProcessor& getFragmentProcessor(int idx) const {
- return *fFragmentProcessors[idx].get();
+ const GrPendingFragmentStage& getFragmentStage(int idx) const {
+ return fFragmentStages[idx];
}
/// @}
@@ -154,8 +149,8 @@
GrXferProcessor::OptFlags,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
- int* firstColorProcessorIdx,
- int* firstCoverageProcessorIdx);
+ int* firstColorStageIdx,
+ int* firstCoverageStageIdx);
/**
* Calculates the primary and secondary output types of the shader. For certain output types
@@ -172,8 +167,7 @@
};
typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget;
- typedef GrPendingProgramElement<const GrFragmentProcessor> PendingFragmentProcessor;
- typedef SkAutoSTArray<8, PendingFragmentProcessor> FragmentProcessorArray;
+ typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray;
typedef GrPendingProgramElement<const GrXferProcessor> ProgramXferProcessor;
RenderTarget fRenderTarget;
GrScissorState fScissorState;
@@ -181,11 +175,11 @@
GrPipelineBuilder::DrawFace fDrawFace;
uint32_t fFlags;
ProgramXferProcessor fXferProcessor;
- FragmentProcessorArray fFragmentProcessors;
+ FragmentStageArray fFragmentStages;
bool fReadsFragPosition;
- // This value is also the index in fFragmentProcessors where coverage processors begin.
- int fNumColorProcessors;
+ // This function is equivalent to the offset into fFragmentStages where coverage stages begin.
+ int fNumColorStages;
SkSTArray<8, const GrCoordTransform*, true> fCoordTransforms;
GrProgramDesc fDesc;
diff --git a/src/gpu/GrPipelineBuilder.cpp b/src/gpu/GrPipelineBuilder.cpp
index 0fb8ac0..64a1d0c 100644
--- a/src/gpu/GrPipelineBuilder.cpp
+++ b/src/gpu/GrPipelineBuilder.cpp
@@ -22,6 +22,20 @@
SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
}
+GrPipelineBuilder& GrPipelineBuilder::operator=(const GrPipelineBuilder& that) {
+ fProcDataManager.reset(SkNEW_ARGS(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;)
@@ -29,12 +43,15 @@
fProcDataManager.reset(
const_cast<GrProcessorDataManager*>(SkRef(paint.processorDataManager())));
- for (int i = 0; i < paint.numColorFragmentProcessors(); ++i) {
- fColorFragmentProcessors.push_back(SkRef(paint.getColorFragmentProcessor(i)));
+ fColorStages.reset();
+ fCoverageStages.reset();
+
+ for (int i = 0; i < paint.numColorStages(); ++i) {
+ fColorStages.push_back(paint.getColorStage(i));
}
- for (int i = 0; i < paint.numCoverageFragmentProcessors(); ++i) {
- fCoverageFragmentProcessors.push_back(SkRef(paint.getCoverageFragmentProcessor(i)));
+ for (int i = 0; i < paint.numCoverageStages(); ++i) {
+ fCoverageStages.push_back(paint.getCoverageStage(i));
}
fXPFactory.reset(SkRef(paint.getXPFactory()));
@@ -65,26 +82,21 @@
void GrPipelineBuilder::AutoRestoreFragmentProcessorState::set(
const GrPipelineBuilder* pipelineBuilder) {
if (fPipelineBuilder) {
- int m = fPipelineBuilder->numColorFragmentProcessors() - fColorEffectCnt;
+ int m = fPipelineBuilder->numColorFragmentStages() - fColorEffectCnt;
SkASSERT(m >= 0);
- for (int i = 0; i < m; ++i) {
- fPipelineBuilder->fColorFragmentProcessors.fromBack(i)->unref();
- }
- fPipelineBuilder->fColorFragmentProcessors.pop_back_n(m);
+ fPipelineBuilder->fColorStages.pop_back_n(m);
- int n = fPipelineBuilder->numCoverageFragmentProcessors() - fCoverageEffectCnt;
+ int n = fPipelineBuilder->numCoverageFragmentStages() - fCoverageEffectCnt;
SkASSERT(n >= 0);
- for (int i = 0; i < n; ++i) {
- fPipelineBuilder->fCoverageFragmentProcessors.fromBack(i)->unref();
- }
- fPipelineBuilder->fCoverageFragmentProcessors.pop_back_n(n);
+ fPipelineBuilder->fCoverageStages.pop_back_n(n);
+
SkDEBUGCODE(--fPipelineBuilder->fBlockEffectRemovalCnt;)
fPipelineBuilder->getProcessorDataManager()->restoreToSaveMarker(/*fSaveMarker*/);
}
fPipelineBuilder = const_cast<GrPipelineBuilder*>(pipelineBuilder);
if (NULL != pipelineBuilder) {
- fColorEffectCnt = pipelineBuilder->numColorFragmentProcessors();
- fCoverageEffectCnt = pipelineBuilder->numCoverageFragmentProcessors();
+ fColorEffectCnt = pipelineBuilder->numColorFragmentStages();
+ fCoverageEffectCnt = pipelineBuilder->numCoverageFragmentStages();
SkDEBUGCODE(++pipelineBuilder->fBlockEffectRemovalCnt;)
fSaveMarker = pipelineBuilder->processorDataManager()->currentSaveMarker();
}
@@ -94,33 +106,25 @@
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, fColorFragmentProcessors.begin(),
- this->numColorFragmentProcessors());
-
+ fColorProcInfo.calcColorWithPrimProc(pp, fColorStages.begin(), this->numColorFragmentStages());
}
void GrPipelineBuilder::calcCoverageInvariantOutput(const GrPrimitiveProcessor* pp) const {
- fCoverageProcInfo.calcCoverageWithPrimProc(pp, fCoverageFragmentProcessors.begin(),
- this->numCoverageFragmentProcessors());
+ fCoverageProcInfo.calcCoverageWithPrimProc(pp, fCoverageStages.begin(),
+ this->numCoverageFragmentStages());
}
void GrPipelineBuilder::calcColorInvariantOutput(const GrDrawBatch* batch) const {
- fColorProcInfo.calcColorWithBatch(batch, fColorFragmentProcessors.begin(),
- this->numColorFragmentProcessors());
+ fColorProcInfo.calcColorWithBatch(batch, fColorStages.begin(), this->numColorFragmentStages());
}
void GrPipelineBuilder::calcCoverageInvariantOutput(const GrDrawBatch* batch) const {
- fCoverageProcInfo.calcCoverageWithBatch(batch, fCoverageFragmentProcessors.begin(),
- this->numCoverageFragmentProcessors());
+ fCoverageProcInfo.calcCoverageWithBatch(batch, fCoverageStages.begin(),
+ this->numCoverageFragmentStages());
}
+
diff --git a/src/gpu/GrPipelineBuilder.h b/src/gpu/GrPipelineBuilder.h
index 47b996a..1c6eb5f 100644
--- a/src/gpu/GrPipelineBuilder.h
+++ b/src/gpu/GrPipelineBuilder.h
@@ -12,6 +12,7 @@
#include "GrCaps.h"
#include "GrClip.h"
#include "GrGpuResourceRef.h"
+#include "GrStagedProcessor.h"
#include "GrProcOptInfo.h"
#include "GrProcessorDataManager.h"
#include "GrRenderTarget.h"
@@ -28,10 +29,15 @@
class GrPaint;
class GrTexture;
-class GrPipelineBuilder : public SkNoncopyable {
+class GrPipelineBuilder {
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
@@ -52,56 +58,51 @@
/// feed their output to the GrXferProcessor which controls blending.
////
- int numColorFragmentProcessors() const { return fColorFragmentProcessors.count(); }
- int numCoverageFragmentProcessors() const { return fCoverageFragmentProcessors.count(); }
- int numFragmentProcessors() const { return this->numColorFragmentProcessors() +
- this->numCoverageFragmentProcessors(); }
+ int numColorFragmentStages() const { return fColorStages.count(); }
+ int numCoverageFragmentStages() const { return fCoverageStages.count(); }
+ int numFragmentStages() const { return this->numColorFragmentStages() +
+ this->numCoverageFragmentStages(); }
- const GrFragmentProcessor* getColorFragmentProcessor(int idx) const {
- return fColorFragmentProcessors[idx];
- }
- const GrFragmentProcessor* getCoverageFragmentProcessor(int idx) const {
- return fCoverageFragmentProcessors[idx];
+ 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* 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;
+ const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* effect) {
+ SkASSERT(effect);
+ SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrFragmentStage, (effect));
+ return effect;
}
/**
* Creates a GrSimpleTextureEffect that uses local coords as texture coordinates.
*/
void addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
- this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
- matrix))->unref();
+ this->addColorProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
+ matrix))->unref();
}
void addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
- this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
- matrix))->unref();
+ this->addCoverageProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
+ matrix))->unref();
}
void addColorTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
- matrix,
- params))->unref();
+ this->addColorProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
+ params))->unref();
}
void addCoverageTextureProcessor(GrTexture* texture,
const SkMatrix& matrix,
const GrTextureParams& params) {
- this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture,
- matrix, params))->unref();
+ this->addCoverageProcessor(GrSimpleTextureEffect::Create(fProcDataManager, texture, matrix,
+ params))->unref();
}
/**
@@ -138,9 +139,9 @@
return fPipelineBuilder->getProcessorDataManager();
}
- const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragmentProcessor* processor) {
+ const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* processor) {
SkASSERT(this->isSet());
- return fPipelineBuilder->addCoverageFragmentProcessor(processor);
+ return fPipelineBuilder->addCoverageProcessor(processor);
}
private:
@@ -384,6 +385,8 @@
///////////////////////////////////////////////////////////////////////////
+ GrPipelineBuilder& operator=(const GrPipelineBuilder& that);
+
// TODO delete when we have Batch
const GrProcOptInfo& colorProcInfo(const GrPrimitiveProcessor* pp) const {
this->calcColorInvariantOutput(pp);
@@ -436,7 +439,7 @@
// This is used to assert that this condition holds.
SkDEBUGCODE(mutable int fBlockEffectRemovalCnt;)
- typedef SkSTArray<4, const GrFragmentProcessor*, true> FragmentProcessorArray;
+ typedef SkSTArray<4, GrFragmentStage> FragmentStageArray;
SkAutoTUnref<GrProcessorDataManager> fProcDataManager;
SkAutoTUnref<GrRenderTarget> fRenderTarget;
@@ -444,8 +447,8 @@
GrStencilSettings fStencilSettings;
DrawFace fDrawFace;
mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
- FragmentProcessorArray fColorFragmentProcessors;
- FragmentProcessorArray fCoverageFragmentProcessors;
+ FragmentStageArray fColorStages;
+ FragmentStageArray fCoverageStages;
GrClip fClip;
mutable GrProcOptInfo fColorProcInfo;
diff --git a/src/gpu/GrProcOptInfo.cpp b/src/gpu/GrProcOptInfo.cpp
index 19302cc..af6b81e 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 GrFragmentProcessor* const processors[],
- int cnt) {
+ const GrFragmentStage* stages,
+ int stageCount) {
GrInitInvariantOutput out;
batch->getInvariantOutputColor(&out);
fInOut.reset(out);
- this->internalCalc(processors, cnt, batch->willReadFragmentPosition());
+ this->internalCalc(stages, stageCount, batch->willReadFragmentPosition());
}
void GrProcOptInfo::calcCoverageWithBatch(const GrDrawBatch* batch,
- const GrFragmentProcessor* const processors[],
- int cnt) {
+ const GrFragmentStage* stages,
+ int stageCount) {
GrInitInvariantOutput out;
batch->getInvariantOutputCoverage(&out);
fInOut.reset(out);
- this->internalCalc(processors, cnt, batch->willReadFragmentPosition());
+ this->internalCalc(stages, stageCount, batch->willReadFragmentPosition());
}
void GrProcOptInfo::calcColorWithPrimProc(const GrPrimitiveProcessor* primProc,
- const GrFragmentProcessor * const processors[],
- int cnt) {
+ const GrFragmentStage* stages,
+ int stageCount) {
GrInitInvariantOutput out;
primProc->getInvariantOutputColor(&out);
fInOut.reset(out);
- this->internalCalc(processors, cnt, primProc->willReadFragmentPosition());
+ this->internalCalc(stages, stageCount, primProc->willReadFragmentPosition());
}
void GrProcOptInfo::calcCoverageWithPrimProc(const GrPrimitiveProcessor* primProc,
- const GrFragmentProcessor * const processors[],
- int cnt) {
+ const GrFragmentStage* stages,
+ int stageCount) {
GrInitInvariantOutput out;
primProc->getInvariantOutputCoverage(&out);
fInOut.reset(out);
- this->internalCalc(processors, cnt, primProc->willReadFragmentPosition());
+ this->internalCalc(stages, stageCount, primProc->willReadFragmentPosition());
}
-void GrProcOptInfo::calcWithInitialValues(const GrFragmentProcessor * const processors[],
- int cnt,
+void GrProcOptInfo::calcWithInitialValues(const GrFragmentStage* stages,
+ int stageCount,
GrColor startColor,
GrColorComponentFlags flags,
bool areCoverageStages) {
@@ -57,24 +57,24 @@
out.fColor = startColor;
out.fValidFlags = flags;
fInOut.reset(out);
- this->internalCalc(processors, cnt, false);
+ this->internalCalc(stages, stageCount, false);
}
-void GrProcOptInfo::internalCalc(const GrFragmentProcessor* const processors[],
- int cnt,
+void GrProcOptInfo::internalCalc(const GrFragmentStage* stages,
+ int stageCount,
bool initWillReadFragmentPosition) {
- fFirstEffectiveProcessorIndex = 0;
+ fFirstEffectStageIndex = 0;
fInputColorIsUsed = true;
fInputColor = fInOut.color();
fReadsFragPosition = initWillReadFragmentPosition;
- for (int i = 0; i < cnt; ++i) {
- const GrFragmentProcessor* processor = processors[i];
+ for (int i = 0; i < stageCount; ++i) {
+ const GrFragmentProcessor* processor = stages[i].processor();
fInOut.resetWillUseInputColor();
processor->computeInvariantOutput(&fInOut);
SkDEBUGCODE(fInOut.validate());
if (!fInOut.willUseInputColor()) {
- fFirstEffectiveProcessorIndex = i;
+ fFirstEffectStageIndex = 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()) {
- fFirstEffectiveProcessorIndex = i + 1;
+ fFirstEffectStageIndex = 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 ad23614..cf7e350 100644
--- a/src/gpu/GrProcOptInfo.h
+++ b/src/gpu/GrProcOptInfo.h
@@ -10,6 +10,7 @@
#include "GrColor.h"
#include "GrInvariantOutput.h"
+#include "GrStagedProcessor.h"
class GrDrawBatch;
class GrFragmentProcessor;
@@ -25,22 +26,21 @@
public:
GrProcOptInfo()
: fInOut(0, static_cast<GrColorComponentFlags>(0), false)
- , fFirstEffectiveProcessorIndex(0)
+ , fFirstEffectStageIndex(0)
, fInputColorIsUsed(true)
, fInputColor(0)
, fReadsFragPosition(false) {}
- void calcWithInitialValues(const GrFragmentProcessor* const *, int cnt, GrColor startColor,
- GrColorComponentFlags, bool areCoverageStages);
+ void calcWithInitialValues(const GrFragmentStage*, int stageCount, GrColor startColor,
+ GrColorComponentFlags flags, bool areCoverageStages);
- void calcColorWithBatch(const GrDrawBatch*, const GrFragmentProcessor* const[], int cnt);
- void calcCoverageWithBatch(const GrDrawBatch*, const GrFragmentProcessor* const[], int cnt);
+ void calcColorWithBatch(const GrDrawBatch*, const GrFragmentStage*, int stagecount);
+ void calcCoverageWithBatch(const GrDrawBatch*, const GrFragmentStage*, int stagecount);
// TODO delete these when batch is everywhere
- void calcColorWithPrimProc(const GrPrimitiveProcessor*, const GrFragmentProcessor* const[],
- int cnt);
- void calcCoverageWithPrimProc(const GrPrimitiveProcessor*, const GrFragmentProcessor* const[],
- int cnt);
+ void calcColorWithPrimProc(const GrPrimitiveProcessor*, const GrFragmentStage*, int stagecount);
+ void calcCoverageWithPrimProc(const GrPrimitiveProcessor*, const GrFragmentStage*,
+ int stagecount);
bool isSolidWhite() const { return fInOut.isSolidWhite(); }
bool isOpaque() const { return fInOut.isOpaque(); }
@@ -60,38 +60,38 @@
}
/**
- * 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.
+ * 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.
*
- * 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.
+ * 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.
*/
- int firstEffectiveProcessorIndex() const { return fFirstEffectiveProcessorIndex; }
+ int firstEffectiveStageIndex() const { return fFirstEffectStageIndex; }
/**
- * True if the first effective processor reads its input, false otherwise.
+ * True if the first effective stage 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 processor.
+ * first effective stage.
*/
- GrColor inputColorToFirstEffectiveProccesor() const { return fInputColor; }
+ GrColor inputColorToEffectiveStage() const { return fInputColor; }
/**
- * Returns true if any of the processor preserved by GrProcOptInfo read the frag position.
+ * Returns true if any of the stages preserved by GrProcOptInfo read the frag position.
*/
bool readsFragPosition() const { return fReadsFragPosition; }
private:
- void internalCalc(const GrFragmentProcessor* const[], int cnt, bool initWillReadFragPosition);
+ void internalCalc(const GrFragmentStage*, int stagecount, bool initWillReadFragPosition);
GrInvariantOutput fInOut;
- int fFirstEffectiveProcessorIndex;
+ int fFirstEffectStageIndex;
bool fInputColorIsUsed;
GrColor fInputColor;
bool fReadsFragPosition;
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp
index 3cbf777..db1e2d9 100644
--- a/src/gpu/GrProcessor.cpp
+++ b/src/gpu/GrProcessor.cpp
@@ -130,12 +130,6 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
-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() ||
@@ -167,7 +161,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]->createGLInstance();
+ glFragProc->fChildProcessors[i] = fChildProcessors[i].processor()->createGLInstance();
}
return glFragProc;
}
@@ -205,7 +199,7 @@
}
int index = fChildProcessors.count();
- fChildProcessors.push_back(SkRef(child));
+ fChildProcessors.push_back(GrFragmentStage(child));
if (child->willReadFragmentPosition()) {
this->setWillReadFragmentPosition();
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index ce00ad9..f421b81 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->addCoverageFragmentProcessor(
+ pipelineBuilder->addCoverageProcessor(
GrSimpleTextureEffect::Create(pipelineBuilder->getProcessorDataManager(),
texture,
maskMatrix,
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index cb2221c..23151d4 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -963,7 +963,7 @@
}
// The bitmap read has to be first
- grPaint.addColorFragmentProcessor(fp);
+ grPaint.addColorProcessor(fp);
if (!SkPaint2GrPaintNoShader(context, renderTarget, paint, SkColor2GrColor(paint.getColor()),
false, &grPaint)) {
return;
@@ -1305,7 +1305,7 @@
SkMatrix::I(), params));
}
- grPaint.addColorFragmentProcessor(fp);
+ grPaint.addColorProcessor(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 0c29dd8..6c1ec4b 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.addColorFragmentProcessor(yuvToRgbProcessor);
+ paint.addColorProcessor(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->addColorFragmentProcessor(array[i]);
+ grPaint->addColorProcessor(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->numColorFragmentProcessors() > 0) {
+ if (skPaint.isDither() && grPaint->numColorStages() > 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->addColorFragmentProcessor(fp);
+ grPaint->addColorProcessor(fp);
grPaint->setDither(false);
}
}
@@ -863,7 +863,7 @@
return false;
}
if (fp) {
- grPaint->addColorFragmentProcessor(fp)->unref();
+ grPaint->addColorProcessor(fp)->unref();
constantColor = false;
}
}
diff --git a/src/gpu/batches/GrDrawBatch.h b/src/gpu/batches/GrDrawBatch.h
index f7c206d..ed33816 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()->numColorFragmentProcessors(); i++) {
- string.appendf("\t\t%s\n", this->pipeline()->getColorFragmentProcessor(i).name());
+ for (int i = 0; i < this->pipeline()->numColorFragmentStages(); i++) {
+ string.appendf("\t\t%s\n", this->pipeline()->getColorStage(i).processor()->name());
}
string.append("CoverageStages:\n");
- for (int i = 0; i < this->pipeline()->numCoverageFragmentProcessors(); i++) {
- string.appendf("\t%s\n", this->pipeline()->getCoverageFragmentProcessor(i).name());
+ for (int i = 0; i < this->pipeline()->numCoverageFragmentStages(); i++) {
+ string.appendf("\t%s\n", this->pipeline()->getCoverageStage(i).processor()->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 2581510..4c8813d 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -232,7 +232,7 @@
(paint3.getProcessorDataManager(), tempTex, false, *pmToUPMRule,
SkMatrix::I())));
- paint1.addColorFragmentProcessor(pmToUPM1);
+ paint1.addColorProcessor(pmToUPM1);
GrDrawContext* readDrawContext = context->drawContext();
@@ -250,7 +250,7 @@
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead);
- paint2.addColorFragmentProcessor(upmToPM);
+ paint2.addColorProcessor(upmToPM);
GrDrawContext* tempDrawContext = context->drawContext();
if (!tempDrawContext) {
@@ -264,7 +264,7 @@
kDstRect,
kSrcRect);
- paint3.addColorFragmentProcessor(pmToUPM2);
+ paint3.addColorProcessor(pmToUPM2);
readDrawContext = context->drawContext();
if (!readDrawContext) {
diff --git a/src/gpu/gl/GrGLPathProgram.cpp b/src/gpu/gl/GrGLPathProgram.cpp
index 5bcadfe..4b31f02 100644
--- a/src/gpu/gl/GrGLPathProgram.cpp
+++ b/src/gpu/gl/GrGLPathProgram.cpp
@@ -31,13 +31,13 @@
}
void GrGLPathProgram::setTransformData(const GrPrimitiveProcessor& primProc,
- const GrFragmentProcessor& processor,
+ const GrPendingFragmentStage& proc,
int index,
GrGLInstalledFragProc* ip) {
GrGLPathProcessor* pathProc =
static_cast<GrGLPathProcessor*>(fGeometryProcessor.get()->fGLProc.get());
pathProc->setTransformData(primProc, fPathProgramDataManager, index,
- processor.coordTransforms());
+ proc.processor()->coordTransforms());
}
void GrGLPathProgram::onSetRenderTargetState(const GrPrimitiveProcessor& primProc,
diff --git a/src/gpu/gl/GrGLPathProgram.h b/src/gpu/gl/GrGLPathProgram.h
index 74f43e5..c7ca3dc 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 GrFragmentProcessor&,
+ const GrPendingFragmentStage&,
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 3aaa7ea..5af84e0 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -105,24 +105,25 @@
const GrPipeline& pipeline,
SkTArray<const GrTextureAccess*>* textureBindings) {
int numProcessors = fFragmentProcessors->fProcs.count();
- for (int i = 0; i < numProcessors; ++i) {
- const GrFragmentProcessor& processor = pipeline.getFragmentProcessor(i);
- fFragmentProcessors->fProcs[i]->fGLProc->setData(fProgramDataManager, processor);
+ 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);
this->setTransformData(primProc,
- processor,
- i,
- fFragmentProcessors->fProcs[i]);
- append_texture_bindings(fFragmentProcessors->fProcs[i], processor, textureBindings);
+ stage,
+ e,
+ fFragmentProcessors->fProcs[e]);
+ append_texture_bindings(fFragmentProcessors->fProcs[e], processor, textureBindings);
}
}
void GrGLProgram::setTransformData(const GrPrimitiveProcessor& primProc,
- const GrFragmentProcessor& processor,
+ const GrPendingFragmentStage& processor,
int index,
GrGLInstalledFragProc* ip) {
GrGLGeometryProcessor* gp =
static_cast<GrGLGeometryProcessor*>(fGeometryProcessor.get()->fGLProc.get());
gp->setTransformData(primProc, fProgramDataManager, index,
- processor.coordTransforms());
+ processor.processor()->coordTransforms());
}
void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc,
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index fee6277..c8fa1b1 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 GrFragmentProcessor&,
+ const GrPendingFragmentStage&,
int index,
GrGLInstalledFragProc*);
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 6b38cc6..5365ffb 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -134,8 +134,9 @@
return false;
}
- for (int i = 0; i < pipeline.numFragmentProcessors(); ++i) {
- const GrFragmentProcessor& fp = pipeline.getFragmentProcessor(i);
+ for (int s = 0; s < pipeline.numFragmentStages(); ++s) {
+ const GrPendingFragmentStage& fps = pipeline.getFragmentStage(s);
+ const GrFragmentProcessor& fp = *fps.processor();
if (!get_frag_proc_and_meta_keys(primProc, fp, gpu->glCaps(), &b)) {
glDesc->key().reset();
return false;
@@ -166,8 +167,8 @@
header->fFragPosKey = 0;
}
header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters();
- header->fColorEffectCnt = pipeline.numColorFragmentProcessors();
- header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors();
+ header->fColorEffectCnt = pipeline.numColorFragmentStages();
+ header->fCoverageEffectCnt = pipeline.numCoverageFragmentStages();
glDesc->finalize();
return true;
}
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 547bd38..2db5686 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().numFragmentProcessors(); i++) {
- const GrFragmentProcessor& processor = this->pipeline().getFragmentProcessor(i);
+ for (int i = 0; i < this->pipeline().numFragmentStages(); i++) {
+ const GrFragmentProcessor* processor = this->pipeline().getFragmentStage(i).processor();
if (!primProc.hasTransformedLocalCoords()) {
- SkTArray<const GrCoordTransform*, true>& procCoords = fCoordTransforms.push_back();
- processor.gatherCoordTransforms(&procCoords);
+ SkSTArray<2, 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(SkNEW(GrGLInstalledFragProcs));
- int numProcs = this->pipeline().numFragmentProcessors();
- this->emitAndInstallFragProcs(0, this->pipeline().numColorFragmentProcessors(), inputColor);
- this->emitAndInstallFragProcs(this->pipeline().numColorFragmentProcessors(), numProcs,
+ int numProcs = this->pipeline().numFragmentStages();
+ this->emitAndInstallFragProcs(0, this->pipeline().numColorFragmentStages(), inputColor);
+ this->emitAndInstallFragProcs(this->pipeline().numColorFragmentStages(), 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 i = procOffset; i < numProcs; ++i) {
+ for (int e = procOffset; e < numProcs; ++e) {
GrGLSLExpr4 output;
- const GrFragmentProcessor& fp = this->pipeline().getFragmentProcessor(i);
- this->emitAndInstallProc(fp, i, *inOut, &output);
+ const GrPendingFragmentStage& stage = this->pipeline().getFragmentStage(e);
+ this->emitAndInstallProc(stage, e, *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 GrFragmentProcessor& fp,
+void GrGLProgramBuilder::emitAndInstallProc(const GrPendingFragmentStage& proc,
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, fp.name());
+ openBrace.printf("{ // Stage %d, %s\n", fStageIndex, proc.name());
fFS.codeAppend(openBrace.c_str());
- this->emitAndInstallProc(fp, index, output->c_str(), input.isOnes() ? NULL : input.c_str());
+ this->emitAndInstallProc(proc, index, output->c_str(), input.isOnes() ? NULL : input.c_str());
fFS.codeAppend("}");
}
@@ -276,12 +276,13 @@
fFS.codeAppend("}");
}
-void GrGLProgramBuilder::emitAndInstallProc(const GrFragmentProcessor& fp,
+void GrGLProgramBuilder::emitAndInstallProc(const GrPendingFragmentStage& fs,
int index,
const char* outColor,
const char* inColor) {
GrGLInstalledFragProc* ifp = SkNEW(GrGLInstalledFragProc);
+ const GrFragmentProcessor& fp = *fs.processor();
ifp->fGLProc.reset(fp.createGLInstance());
SkSTArray<4, GrGLProcessor::TextureSampler> samplers(fp.numTextures());
@@ -500,7 +501,7 @@
GrGLInstalledFragProcs::~GrGLInstalledFragProcs() {
int numProcs = fProcs.count();
- for (int i = 0; i < numProcs; ++i) {
- SkDELETE(fProcs[i]);
+ for (int e = 0; e < numProcs; ++e) {
+ SkDELETE(fProcs[e]);
}
}
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h
index 06d0fa0..bdd96d2 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.h
@@ -16,10 +16,9 @@
#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
@@ -302,7 +301,7 @@
void nameExpression(GrGLSLExpr4*, const char* baseName);
bool emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr4* inputCoverage);
void emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOut);
- void emitAndInstallProc(const GrFragmentProcessor&,
+ void emitAndInstallProc(const GrPendingFragmentStage&,
int index,
const GrGLSLExpr4& input,
GrGLSLExpr4* output);
@@ -312,7 +311,7 @@
GrGLSLExpr4* outputCoverage);
// these emit functions help to keep the createAndEmitProcessors template general
- void emitAndInstallProc(const GrFragmentProcessor&,
+ void emitAndInstallProc(const GrPendingFragmentStage&,
int index,
const char* outColor,
const char* inColor);
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index a6edd98..d172df8 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -250,9 +250,8 @@
GrPaint paint;
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
- paint.addColorFragmentProcessor(GrYUVtoRGBEffect::Create(paint.getProcessorDataManager(),
- yTex, uTex, vTex, yuvSizes,
- colorSpace))->unref();
+ paint.addColorProcessor(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 b0b7446..16745e5 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->addColorFragmentProcessor(fp);
+ pipelineBuilder->addColorProcessor(fp);
} else {
- pipelineBuilder->addCoverageFragmentProcessor(fp);
+ pipelineBuilder->addCoverageProcessor(fp);
}
++s;
}