Skip to content

Commit

Permalink
Remove GrStagedProcessor, remove the word Stage as it applies to FPs
Browse files Browse the repository at this point in the history
  • Loading branch information
bsalomon authored and Commit bot committed Aug 27, 2015
1 parent a04c650 commit ac856c9
Show file tree
Hide file tree
Showing 44 changed files with 322 additions and 364 deletions.
2 changes: 1 addition & 1 deletion gm/bigrrectaaeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class BigRRectAAEffectGM : public GM {
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),
Expand Down
2 changes: 1 addition & 1 deletion gm/constcolorprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class ConstColorProcessor : public GM {

GrClip clip;
GrPipelineBuilder pipelineBuilder(grPaint, rt, clip);
pipelineBuilder.addColorProcessor(fp);
pipelineBuilder.addColorFragmentProcessor(fp);

tt.target()->drawNonAARect(pipelineBuilder,
grPaint.getColor(),
Expand Down
4 changes: 2 additions & 2 deletions gm/convexpolyeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class ConvexPolyEffect : public GM {
}

GrPipelineBuilder pipelineBuilder;
pipelineBuilder.addCoverageProcessor(fp);
pipelineBuilder.addCoverageFragmentProcessor(fp);
pipelineBuilder.setRenderTarget(rt);

ConvexPolyTestBatch::Geometry geometry;
Expand Down Expand Up @@ -240,7 +240,7 @@ class ConvexPolyEffect : public GM {
}

GrPipelineBuilder pipelineBuilder;
pipelineBuilder.addCoverageProcessor(fp);
pipelineBuilder.addCoverageFragmentProcessor(fp);
pipelineBuilder.setRenderTarget(rt);

ConvexPolyTestBatch::Geometry geometry;
Expand Down
2 changes: 1 addition & 1 deletion gm/rrects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class RRectGM : public GM {
SkAutoTUnref<GrFragmentProcessor> fp(GrRRectEffect::Create(edgeType,
rrect));
if (fp) {
pipelineBuilder.addCoverageProcessor(fp);
pipelineBuilder.addCoverageFragmentProcessor(fp);
pipelineBuilder.setRenderTarget(rt);

SkRect bounds = rrect.getBounds();
Expand Down
2 changes: 1 addition & 1 deletion gm/texturedomaineffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class TextureDomainEffect : public GM {
}
const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y);
pipelineBuilder.setRenderTarget(rt);
pipelineBuilder.addColorProcessor(fp);
pipelineBuilder.addColorFragmentProcessor(fp);

tt.target()->drawNonAARect(pipelineBuilder,
GrColor_WHITE,
Expand Down
2 changes: 1 addition & 1 deletion gm/yuvtorgbeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class YUVtoRGBEffect : public GM {
SkMatrix viewMatrix;
viewMatrix.setTranslate(x, y);
pipelineBuilder.setRenderTarget(rt);
pipelineBuilder.addColorProcessor(fp);
pipelineBuilder.addColorFragmentProcessor(fp);
tt.target()->drawNonAARect(pipelineBuilder,
GrColor_WHITE,
viewMatrix,
Expand Down
2 changes: 0 additions & 2 deletions gyp/gpu.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
'<(skia_include_path)/gpu/GrRenderTarget.h',
'<(skia_include_path)/gpu/GrResourceKey.h',
'<(skia_include_path)/gpu/GrShaderVar.h',
'<(skia_include_path)/gpu/GrStagedProcessor.h',
'<(skia_include_path)/gpu/GrSurface.h',
'<(skia_include_path)/gpu/GrTexture.h',
'<(skia_include_path)/gpu/GrTextureProvider.h',
Expand Down Expand Up @@ -149,7 +148,6 @@
'<(skia_src_path)/gpu/GrPathUtils.cpp',
'<(skia_src_path)/gpu/GrPathUtils.h',
'<(skia_src_path)/gpu/GrPendingProgramElement.h',
'<(skia_src_path)/gpu/GrPendingFragmentStage.h',
'<(skia_src_path)/gpu/GrPipeline.cpp',
'<(skia_src_path)/gpu/GrPipeline.h',
'<(skia_src_path)/gpu/GrPipelineBuilder.cpp',
Expand Down
13 changes: 7 additions & 6 deletions include/gpu/GrFragmentProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#define GrFragmentProcessor_DEFINED

#include "GrProcessor.h"
#include "GrStagedProcessor.h"

class GrCoordTransform;
class GrGLSLCaps;
Expand All @@ -29,12 +28,14 @@ class GrFragmentProcessor : public GrProcessor {
, 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);
}
}

Expand All @@ -60,9 +61,7 @@ class GrFragmentProcessor : public GrProcessor {

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; }
Expand Down Expand Up @@ -176,7 +175,9 @@ class GrFragmentProcessor : public GrProcessor {
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;
};
Expand Down
63 changes: 42 additions & 21 deletions include/gpu/GrPaint.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#define GrPaint_DEFINED

#include "GrColor.h"
#include "GrStagedProcessor.h"
#include "GrProcessorDataManager.h"
#include "GrXferProcessor.h"
#include "effects/GrPorterDuffXferProcessor.h"
Expand Down Expand Up @@ -44,7 +43,7 @@ class GrPaint {

GrPaint(const GrPaint& paint) { *this = paint; }

~GrPaint() {}
~GrPaint() { this->resetFragmentProcessors(); }

/**
* The initial color of the drawn primitive. Defaults to solid white.
Expand Down Expand Up @@ -78,18 +77,18 @@ class GrPaint {
/**
* 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;
}

Expand All @@ -102,9 +101,10 @@ class GrPaint {
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) {
Expand All @@ -113,17 +113,27 @@ class GrPaint {
return fXPFactory.get();
}

const GrFragmentStage& getColorStage(int s) const { return fColorStages[s]; }
const GrFragmentStage& getCoverageStage(int s) const { return fCoverageStages[s]; }
const GrFragmentProcessor* getColorFragmentProcessor(int i) const {
return fColorFragmentProcessors[i];
}
const GrFragmentProcessor* getCoverageFragmentProcessor(int i) const {
return fCoverageFragmentProcessors[i];
}

GrPaint& operator=(const GrPaint& paint) {
fAntiAlias = paint.fAntiAlias;
fDither = paint.fDither;

fColor = paint.fColor;

fColorStages = paint.fColorStages;
fCoverageStages = paint.fCoverageStages;
this->resetFragmentProcessors();
fColorFragmentProcessors = paint.fColorFragmentProcessors;
fCoverageFragmentProcessors = paint.fCoverageFragmentProcessors;
for (int i = 0; i < fColorFragmentProcessors.count(); ++i) {
fColorFragmentProcessors[i]->ref();
}
for (int i = 0; i < fCoverageFragmentProcessors.count(); ++i) {
fCoverageFragmentProcessors[i]->ref();
}

fXPFactory.reset(SkRef(paint.getXPFactory()));
fProcDataManager.reset(new GrProcessorDataManager(*paint.processorDataManager()));
Expand All @@ -144,15 +154,26 @@ class GrPaint {
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
44 changes: 0 additions & 44 deletions include/gpu/GrStagedProcessor.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/core/SkImageFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont
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) {
Expand Down
8 changes: 4 additions & 4 deletions src/effects/SkBlurMaskFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider,
return false;
}

grp->addCoverageProcessor(fp);
grp->addCoverageFragmentProcessor(fp);

SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
Expand Down Expand Up @@ -1135,7 +1135,7 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrTextureProvider* texProvid
return false;
}

grp->addCoverageProcessor(fp);
grp->addCoverageFragmentProcessor(fp);

SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
Expand Down Expand Up @@ -1211,8 +1211,8 @@ bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src,
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);
Expand Down
2 changes: 1 addition & 1 deletion src/effects/SkDisplacementMapEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src,
offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset.fX),
SkIntToScalar(colorOffset.fY - displacementOffset.fY));

paint.addColorProcessor(
paint.addColorFragmentProcessor(
GrDisplacementMapEffect::Create(paint.getProcessorDataManager(),
fXChannelSelector,
fYChannelSelector,
Expand Down
6 changes: 3 additions & 3 deletions src/effects/SkGpuBlurUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static void convolve_gaussian_1d(GrDrawContext* drawContext,
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);
}

Expand All @@ -83,7 +83,7 @@ static void convolve_gaussian_2d(GrDrawContext* drawContext,
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);
}

Expand Down Expand Up @@ -216,7 +216,7 @@ GrTexture* GaussianBlur(GrContext* context,
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);
Expand Down
2 changes: 1 addition & 1 deletion src/effects/SkLightingImageFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ void SkLightingImageFilterInternal::drawRect(GrDrawContext* drawContext,
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);
}
Expand Down
Loading

0 comments on commit ac856c9

Please sign in to comment.