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),
GrClip clip;
GrPipelineBuilder pipelineBuilder(grPaint, rt, clip);
- pipelineBuilder.addColorProcessor(fp);
+ pipelineBuilder.addColorFragmentProcessor(fp);
tt.target()->drawNonAARect(pipelineBuilder,
grPaint.getColor(),
}
GrPipelineBuilder pipelineBuilder;
- pipelineBuilder.addCoverageProcessor(fp);
+ pipelineBuilder.addCoverageFragmentProcessor(fp);
pipelineBuilder.setRenderTarget(rt);
ConvexPolyTestBatch::Geometry geometry;
}
GrPipelineBuilder pipelineBuilder;
- pipelineBuilder.addCoverageProcessor(fp);
+ pipelineBuilder.addCoverageFragmentProcessor(fp);
pipelineBuilder.setRenderTarget(rt);
ConvexPolyTestBatch::Geometry geometry;
SkAutoTUnref<GrFragmentProcessor> fp(GrRRectEffect::Create(edgeType,
rrect));
if (fp) {
- pipelineBuilder.addCoverageProcessor(fp);
+ pipelineBuilder.addCoverageFragmentProcessor(fp);
pipelineBuilder.setRenderTarget(rt);
SkRect bounds = rrect.getBounds();
}
const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y);
pipelineBuilder.setRenderTarget(rt);
- pipelineBuilder.addColorProcessor(fp);
+ pipelineBuilder.addColorFragmentProcessor(fp);
tt.target()->drawNonAARect(pipelineBuilder,
GrColor_WHITE,
SkMatrix viewMatrix;
viewMatrix.setTranslate(x, y);
pipelineBuilder.setRenderTarget(rt);
- pipelineBuilder.addColorProcessor(fp);
+ pipelineBuilder.addColorFragmentProcessor(fp);
tt.target()->drawNonAARect(pipelineBuilder,
GrColor_WHITE,
viewMatrix,
'<(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',
'<(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',
#define GrFragmentProcessor_DEFINED
#include "GrProcessor.h"
-#include "GrStagedProcessor.h"
class GrCoordTransform;
class GrGLSLCaps;
, 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);
}
}
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; }
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;
};
#define GrPaint_DEFINED
#include "GrColor.h"
-#include "GrStagedProcessor.h"
#include "GrProcessorDataManager.h"
#include "GrXferProcessor.h"
#include "effects/GrPorterDuffXferProcessor.h"
GrPaint(const GrPaint& paint) { *this = paint; }
- ~GrPaint() {}
+ ~GrPaint() { this->resetFragmentProcessors(); }
/**
* The initial color of the drawn primitive. Defaults to solid white.
/**
* 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;
}
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) {
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 < fColorFragmentProcessors.count(); ++i) {
+ fColorFragmentProcessors[i]->ref();
+ }
fXPFactory.reset(SkRef(paint.getXPFactory()));
fProcDataManager.reset(SkNEW_ARGS(GrProcessorDataManager, (*paint.processorDataManager())));
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();
+ }
+
+ 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
+++ /dev/null
-/*
- * 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
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) {
return false;
}
- grp->addCoverageProcessor(fp);
+ grp->addCoverageFragmentProcessor(fp);
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
return false;
}
- grp->addCoverageProcessor(fp);
+ grp->addCoverageFragmentProcessor(fp);
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
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);
offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset.fX),
SkIntToScalar(colorOffset.fY - displacementOffset.fY));
- paint.addColorProcessor(
+ paint.addColorFragmentProcessor(
GrDisplacementMapEffect::Create(paint.getProcessorDataManager(),
fXChannelSelector,
fYChannelSelector,
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);
}
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);
}
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);
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);
}
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));
}
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));
}
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) {
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();
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,
break;
}
if (fp) {
- arfps->addCoverageProcessor(fp);
+ arfps->addCoverageFragmentProcessor(fp);
} else {
failed = true;
break;
SkMatrix sampleM;
sampleM.setIDiv(srcMask->width(), srcMask->height());
- pipelineBuilder->addCoverageProcessor(
+ pipelineBuilder->addCoverageFragmentProcessor(
GrTextureDomainEffect::Create(pipelineBuilder->getProcessorDataManager(),
srcMask,
sampleM,
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);
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,
return false;
}
arfps.set(&pipelineBuilder);
- arfps.addCoverageProcessor(fp)->unref();
+ arfps.addCoverageFragmentProcessor(fp)->unref();
}
SkStrokeRec fillRec(SkStrokeRec::kFill_InitStyle);
return false;
}
- arfps.addCoverageProcessor(effect)->unref();
+ arfps.addCoverageFragmentProcessor(effect)->unref();
SkRect bounds = outer->getBounds();
if (applyAA) {
bounds.outset(SK_ScalarHalf, SK_ScalarHalf);
}
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;
+++ /dev/null
-/*
- * 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
}
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;
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);
}
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;
}
if (flags & GrXferProcessor::kIgnoreCoverage_OptFlag) {
- *firstCoverageStageIdx = pipelineBuilder.numCoverageFragmentStages();
+ *firstCoverageProcessorIdx = pipelineBuilder.numCoverageFragmentProcessors();
} else {
if (coveragePOI.readsFragPosition()) {
fReadsFragPosition = true;
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 ||
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;
}
}
#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"
/// @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();
}
/// @}
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
};
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;
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;
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;)
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()));
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();
}
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());
}
-
#include "GrCaps.h"
#include "GrClip.h"
#include "GrGpuResourceRef.h"
-#include "GrStagedProcessor.h"
#include "GrProcOptInfo.h"
#include "GrProcessorDataManager.h"
#include "GrRenderTarget.h"
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
/// 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* getColorFragmentProcessor(int idx) const {
+ return fColorFragmentProcessors[idx];
+ }
+ const GrFragmentProcessor* getCoverageFragmentProcessor(int idx) const {
+ return fCoverageFragmentProcessors[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* addCoverageProcessor(const GrFragmentProcessor* effect) {
- SkASSERT(effect);
- SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrFragmentStage, (effect));
- return effect;
+ 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();
}
/**
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:
///////////////////////////////////////////////////////////////////////////
- GrPipelineBuilder& operator=(const GrPipelineBuilder& that);
-
// TODO delete when we have Batch
const GrProcOptInfo& colorProcInfo(const GrPrimitiveProcessor* pp) const {
this->calcColorInvariantOutput(pp);
// 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;
GrStencilSettings fStencilSettings;
DrawFace fDrawFace;
mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
- FragmentStageArray fColorStages;
- FragmentStageArray fCoverageStages;
+ FragmentProcessorArray fColorFragmentProcessors;
+ FragmentProcessorArray fCoverageFragmentProcessors;
GrClip fClip;
mutable GrProcOptInfo fColorProcInfo;
#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) {
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;
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
#include "GrColor.h"
#include "GrInvariantOutput.h"
-#include "GrStagedProcessor.h"
class GrDrawBatch;
class GrFragmentProcessor;
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(); }
}
/**
- * 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;
///////////////////////////////////////////////////////////////////////////////////////////////////
+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() ||
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;
}
}
int index = fChildProcessors.count();
- fChildProcessors.push_back(GrFragmentStage(child));
+ fChildProcessors.push_back(SkRef(child));
if (child->willReadFragmentPosition()) {
this->setWillReadFragmentPosition();
maskMatrix.setIDiv(texture->width(), texture->height());
maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop));
- pipelineBuilder->addCoverageProcessor(
+ pipelineBuilder->addCoverageFragmentProcessor(
GrSimpleTextureEffect::Create(pipelineBuilder->getProcessorDataManager(),
texture,
maskMatrix,
}
// The bitmap read has to be first
- grPaint.addColorProcessor(fp);
+ grPaint.addColorFragmentProcessor(fp);
if (!SkPaint2GrPaintNoShader(context, renderTarget, paint, SkColor2GrColor(paint.getColor()),
false, &grPaint)) {
return;
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());
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));
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();
}
}
#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);
// 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);
}
}
return false;
}
if (fp) {
- grPaint->addColorProcessor(fp)->unref();
+ grPaint->addColorFragmentProcessor(fp)->unref();
constantColor = false;
}
}
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;
(paint3.getProcessorDataManager(), tempTex, false, *pmToUPMRule,
SkMatrix::I())));
- paint1.addColorProcessor(pmToUPM1);
+ paint1.addColorFragmentProcessor(pmToUPM1);
GrDrawContext* readDrawContext = context->drawContext();
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead);
- paint2.addColorProcessor(upmToPM);
+ paint2.addColorFragmentProcessor(upmToPM);
GrDrawContext* tempDrawContext = context->drawContext();
if (!tempDrawContext) {
kDstRect,
kSrcRect);
- paint3.addColorProcessor(pmToUPM2);
+ paint3.addColorFragmentProcessor(pmToUPM2);
readDrawContext = context->drawContext();
if (!readDrawContext) {
}
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,
private:
void didSetData() override;
virtual void setTransformData(const GrPrimitiveProcessor&,
- const GrPendingFragmentStage&,
+ const GrFragmentProcessor&,
int index,
GrGLInstalledFragProc*) override;
void onSetRenderTargetState(const GrPrimitiveProcessor&, const GrPipeline&) override;
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,
void setFragmentData(const GrPrimitiveProcessor&, const GrPipeline&,
SkTArray<const GrTextureAccess*>* textureBindings);
virtual void setTransformData(const GrPrimitiveProcessor&,
- const GrPendingFragmentStage&,
+ const GrFragmentProcessor&,
int index,
GrGLInstalledFragProc*);
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;
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;
}
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;
this->emitAndInstallProc(primProc, inputColor, inputCoverage);
fFragmentProcessors.reset(SkNEW(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;
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;
}
}
// 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) {
// 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("}");
}
fFS.codeAppend("}");
}
-void GrGLProgramBuilder::emitAndInstallProc(const GrPendingFragmentStage& fs,
+void GrGLProgramBuilder::emitAndInstallProc(const GrFragmentProcessor& fp,
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());
GrGLInstalledFragProcs::~GrGLInstalledFragProcs() {
int numProcs = fProcs.count();
- for (int e = 0; e < numProcs; ++e) {
- SkDELETE(fProcs[e]);
+ for (int i = 0; i < numProcs; ++i) {
+ SkDELETE(fProcs[i]);
}
}
#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
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);
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);
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));
// 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;
}