aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrAAConvexPathRenderer.cpp13
-rw-r--r--src/gpu/GrDefaultGeoProcFactory.cpp13
-rw-r--r--src/gpu/GrGeometryProcessor.h33
-rw-r--r--src/gpu/GrOptDrawState.cpp12
-rw-r--r--src/gpu/GrOptDrawState.h2
-rw-r--r--src/gpu/GrOvalRenderer.cpp36
-rw-r--r--src/gpu/effects/GrBezierEffect.cpp64
-rw-r--r--src/gpu/effects/GrCustomCoordsTextureEffect.cpp11
-rw-r--r--src/gpu/effects/GrDashingEffect.cpp48
-rwxr-xr-xsrc/gpu/effects/GrDistanceFieldTextureEffect.cpp38
-rw-r--r--src/gpu/gl/GrGLGeometryProcessor.h13
-rw-r--r--src/gpu/gl/GrGLProcessor.h23
-rw-r--r--src/gpu/gl/GrGLProgram.cpp3
-rw-r--r--src/gpu/gl/GrGLProgramDesc.cpp8
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.cpp5
15 files changed, 243 insertions, 79 deletions
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp
index b5ad44adc0..3108b0472e 100644
--- a/src/gpu/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/GrAAConvexPathRenderer.cpp
@@ -527,7 +527,9 @@ public:
class GLProcessor : public GrGLGeometryProcessor {
public:
- GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
+ GLProcessor(const GrBackendProcessorFactory& factory,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&)
: INHERITED (factory) {}
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
@@ -571,9 +573,14 @@ public:
fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
}
- static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {}
+ static inline void GenKey(const GrGeometryProcessor&,
+ const GrBatchTracker&,
+ const GrGLCaps&,
+ GrProcessorKeyBuilder*) {}
- virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {}
+ virtual void setData(const GrGLProgramDataManager&,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&) SK_OVERRIDE {}
private:
typedef GrGLGeometryProcessor INHERITED;
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp
index ab28a579e7..ddaa809f06 100644
--- a/src/gpu/GrDefaultGeoProcFactory.cpp
+++ b/src/gpu/GrDefaultGeoProcFactory.cpp
@@ -75,7 +75,9 @@ public:
class GLProcessor : public GrGLGeometryProcessor {
public:
- GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
+ GLProcessor(const GrBackendProcessorFactory& factory,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&)
: INHERITED (factory) {}
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
@@ -109,12 +111,17 @@ public:
fs->codeAppendf("%s = vec4(alpha);", args.fOutputCoverage);
}
- static inline void GenKey(const GrProcessor& gp, const GrGLCaps&, GrProcessorKeyBuilder* b) {
+ static inline void GenKey(const GrGeometryProcessor& gp,
+ const GrBatchTracker&,
+ const GrGLCaps&,
+ GrProcessorKeyBuilder* b) {
const DefaultGeoProc& def = gp.cast<DefaultGeoProc>();
b->add32(def.fFlags);
}
- virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {}
+ virtual void setData(const GrGLProgramDataManager&,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&) SK_OVERRIDE {}
private:
typedef GrGLGeometryProcessor INHERITED;
diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h
index 17344d2bb4..27383a4df4 100644
--- a/src/gpu/GrGeometryProcessor.h
+++ b/src/gpu/GrGeometryProcessor.h
@@ -12,6 +12,30 @@
#include "GrProcessor.h"
#include "GrShaderVar.h"
+/*
+ * A struct for tracking batching decisions. While this lives on GrOptState, it is managed
+ * entirely by the derived classes of the GP.
+ */
+class GrBatchTracker {
+public:
+ template <typename T> const T& cast() const {
+ SkASSERT(sizeof(T) <= kMaxSize);
+ return *reinterpret_cast<const T*>(fData);
+ }
+
+ template <typename T> T* cast() {
+ SkASSERT(sizeof(T) <= kMaxSize);
+ return reinterpret_cast<T*>(fData);
+ }
+
+ static const size_t kMaxSize = 32;
+
+private:
+ uint8_t fData[kMaxSize];
+};
+
+class GrOptDrawState;
+
/**
* A GrGeometryProcessor is used to perform computation in the vertex shader and
* add support for custom vertex attributes. A GrGemeotryProcessor is typically
@@ -73,6 +97,15 @@ public:
return this->onIsEqual(that);
}
+ struct InitBT {
+ bool fOutputColor;
+ bool fOutputCoverage;
+ GrColor fColor;
+ GrColor fCoverage;
+ };
+
+ virtual void initBatchTracker(GrBatchTracker*, const InitBT&) const {}
+
// TODO this is a total hack until the gp can own whether or not it uses uniform
// color / coverage
bool hasVertexColor() const { return fHasVertexColor; }
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp
index 6eee0c25a3..20057acee7 100644
--- a/src/gpu/GrOptDrawState.cpp
+++ b/src/gpu/GrOptDrawState.cpp
@@ -117,7 +117,17 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
}
this->setOutputStateInfo(drawState, blendOpt, caps);
-};
+
+ // let the GP init the batch tracker
+ if (drawState.hasGeometryProcessor()) {
+ GrGeometryProcessor::InitBT init;
+ init.fOutputColor = fDescInfo.fInputColorIsUsed;
+ init.fOutputCoverage = fDescInfo.fInputCoverageIsUsed;
+ init.fColor = this->getColor();
+ init.fCoverage = this->getCoverage();
+ fGeometryProcessor->initBatchTracker(&fBatchTracker, init);
+ }
+}
void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds,
GrDrawState::BlendOpt blendOpt,
diff --git a/src/gpu/GrOptDrawState.h b/src/gpu/GrOptDrawState.h
index 25a3a49995..45501b49dd 100644
--- a/src/gpu/GrOptDrawState.h
+++ b/src/gpu/GrOptDrawState.h
@@ -84,6 +84,7 @@ public:
bool hasGeometryProcessor() const { return SkToBool(fGeometryProcessor.get()); }
const GrGeometryProcessor* getGeometryProcessor() const { return fGeometryProcessor.get(); }
+ const GrBatchTracker& getBatchTracker() const { return fBatchTracker; }
const GrXferProcessor* getXferProcessor() const { return fXferProcessor.get(); }
@@ -233,6 +234,7 @@ private:
GrBlendCoeff fDstBlend;
uint32_t fFlags;
ProgramGeometryProcessor fGeometryProcessor;
+ GrBatchTracker fBatchTracker;
ProgramXferProcessor fXferProcessor;
FragmentStageArray fFragmentStages;
GrGpu::DrawType fDrawType;
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index a9dda840aa..c6586120a9 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -91,7 +91,9 @@ public:
class GLProcessor : public GrGLGeometryProcessor {
public:
- GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
+ GLProcessor(const GrBackendProcessorFactory& factory,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&)
: INHERITED (factory) {}
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
@@ -122,13 +124,17 @@ public:
fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
}
- static void GenKey(const GrProcessor& processor, const GrGLCaps&,
+ static void GenKey(const GrGeometryProcessor& processor,
+ const GrBatchTracker&,
+ const GrGLCaps&,
GrProcessorKeyBuilder* b) {
const CircleEdgeEffect& circleEffect = processor.cast<CircleEdgeEffect>();
b->add32(circleEffect.isStroked());
}
- virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {}
+ virtual void setData(const GrGLProgramDataManager&,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&) SK_OVERRIDE {}
private:
typedef GrGLGeometryProcessor INHERITED;
@@ -212,7 +218,9 @@ public:
class GLProcessor : public GrGLGeometryProcessor {
public:
- GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
+ GLProcessor(const GrBackendProcessorFactory& factory,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&)
: INHERITED (factory) {}
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
@@ -265,13 +273,17 @@ public:
fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
}
- static void GenKey(const GrProcessor& processor, const GrGLCaps&,
+ static void GenKey(const GrGeometryProcessor& processor,
+ const GrBatchTracker&,
+ const GrGLCaps&,
GrProcessorKeyBuilder* b) {
const EllipseEdgeEffect& ellipseEffect = processor.cast<EllipseEdgeEffect>();
b->add32(ellipseEffect.isStroked());
}
- virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {
+ virtual void setData(const GrGLProgramDataManager&,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&) SK_OVERRIDE {
}
private:
@@ -364,7 +376,9 @@ public:
class GLProcessor : public GrGLGeometryProcessor {
public:
- GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&)
+ GLProcessor(const GrBackendProcessorFactory& factory,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&)
: INHERITED (factory) {}
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
@@ -431,14 +445,18 @@ public:
fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
}
- static void GenKey(const GrProcessor& processor, const GrGLCaps&,
+ static void GenKey(const GrGeometryProcessor& processor,
+ const GrBatchTracker&,
+ const GrGLCaps&,
GrProcessorKeyBuilder* b) {
const DIEllipseEdgeEffect& ellipseEffect = processor.cast<DIEllipseEdgeEffect>();
b->add32(ellipseEffect.getMode());
}
- virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {
+ virtual void setData(const GrGLProgramDataManager&,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&) SK_OVERRIDE {
}
private:
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index 1b14d349dd..0bcfc75bef 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -15,13 +15,20 @@
class GrGLConicEffect : public GrGLGeometryProcessor {
public:
- GrGLConicEffect(const GrBackendProcessorFactory&, const GrProcessor&);
+ GrGLConicEffect(const GrBackendProcessorFactory&,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&);
virtual void emitCode(const EmitArgs&) SK_OVERRIDE;
- static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
+ static inline void GenKey(const GrGeometryProcessor&,
+ const GrBatchTracker&,
+ const GrGLCaps&,
+ GrProcessorKeyBuilder*);
- virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {}
+ virtual void setData(const GrGLProgramDataManager&,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&) SK_OVERRIDE {}
private:
GrPrimitiveEdgeType fEdgeType;
@@ -30,9 +37,10 @@ private:
};
GrGLConicEffect::GrGLConicEffect(const GrBackendProcessorFactory& factory,
- const GrProcessor& effect)
+ const GrGeometryProcessor& processor,
+ const GrBatchTracker& bt)
: INHERITED (factory) {
- const GrConicEffect& ce = effect.cast<GrConicEffect>();
+ const GrConicEffect& ce = processor.cast<GrConicEffect>();
fEdgeType = ce.getEdgeType();
}
@@ -112,7 +120,9 @@ void GrGLConicEffect::emitCode(const EmitArgs& args) {
fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
}
-void GrGLConicEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
+void GrGLConicEffect::GenKey(const GrGeometryProcessor& processor,
+ const GrBatchTracker&,
+ const GrGLCaps&,
GrProcessorKeyBuilder* b) {
const GrConicEffect& ce = processor.cast<GrConicEffect>();
uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
@@ -162,13 +172,20 @@ GrGeometryProcessor* GrConicEffect::TestCreate(SkRandom* random,
class GrGLQuadEffect : public GrGLGeometryProcessor {
public:
- GrGLQuadEffect(const GrBackendProcessorFactory&, const GrProcessor&);
+ GrGLQuadEffect(const GrBackendProcessorFactory&,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&);
virtual void emitCode(const EmitArgs&) SK_OVERRIDE;
- static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
+ static inline void GenKey(const GrGeometryProcessor&,
+ const GrBatchTracker&,
+ const GrGLCaps&,
+ GrProcessorKeyBuilder*);
- virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {}
+ virtual void setData(const GrGLProgramDataManager&,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&) SK_OVERRIDE {}
private:
GrPrimitiveEdgeType fEdgeType;
@@ -177,9 +194,10 @@ private:
};
GrGLQuadEffect::GrGLQuadEffect(const GrBackendProcessorFactory& factory,
- const GrProcessor& effect)
+ const GrGeometryProcessor& processor,
+ const GrBatchTracker& bt)
: INHERITED (factory) {
- const GrQuadEffect& ce = effect.cast<GrQuadEffect>();
+ const GrQuadEffect& ce = processor.cast<GrQuadEffect>();
fEdgeType = ce.getEdgeType();
}
@@ -245,7 +263,9 @@ void GrGLQuadEffect::emitCode(const EmitArgs& args) {
fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage);
}
-void GrGLQuadEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
+void GrGLQuadEffect::GenKey(const GrGeometryProcessor& processor,
+ const GrBatchTracker&,
+ const GrGLCaps&,
GrProcessorKeyBuilder* b) {
const GrQuadEffect& ce = processor.cast<GrQuadEffect>();
uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
@@ -295,13 +315,20 @@ GrGeometryProcessor* GrQuadEffect::TestCreate(SkRandom* random,
class GrGLCubicEffect : public GrGLGeometryProcessor {
public:
- GrGLCubicEffect(const GrBackendProcessorFactory&, const GrProcessor&);
+ GrGLCubicEffect(const GrBackendProcessorFactory&,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&);
virtual void emitCode(const EmitArgs&) SK_OVERRIDE;
- static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
+ static inline void GenKey(const GrGeometryProcessor&,
+ const GrBatchTracker&,
+ const GrGLCaps&,
+ GrProcessorKeyBuilder*);
- virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {}
+ virtual void setData(const GrGLProgramDataManager&,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&) SK_OVERRIDE {}
private:
GrPrimitiveEdgeType fEdgeType;
@@ -310,7 +337,8 @@ private:
};
GrGLCubicEffect::GrGLCubicEffect(const GrBackendProcessorFactory& factory,
- const GrProcessor& processor)
+ const GrGeometryProcessor& processor,
+ const GrBatchTracker&)
: INHERITED (factory) {
const GrCubicEffect& ce = processor.cast<GrCubicEffect>();
fEdgeType = ce.getEdgeType();
@@ -419,7 +447,9 @@ void GrGLCubicEffect::emitCode(const EmitArgs& args) {
fsBuilder->codeAppendf("%s = vec4(%s);", args.fOutputCoverage, edgeAlpha.c_str());
}
-void GrGLCubicEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
+void GrGLCubicEffect::GenKey(const GrGeometryProcessor& processor,
+ const GrBatchTracker&,
+ const GrGLCaps&,
GrProcessorKeyBuilder* b) {
const GrCubicEffect& ce = processor.cast<GrCubicEffect>();
uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
diff --git a/src/gpu/effects/GrCustomCoordsTextureEffect.cpp b/src/gpu/effects/GrCustomCoordsTextureEffect.cpp
index 45c3008889..637d442d13 100644
--- a/src/gpu/effects/GrCustomCoordsTextureEffect.cpp
+++ b/src/gpu/effects/GrCustomCoordsTextureEffect.cpp
@@ -17,7 +17,9 @@
class GrGLCustomCoordsTextureEffect : public GrGLGeometryProcessor {
public:
- GrGLCustomCoordsTextureEffect(const GrBackendProcessorFactory& factory, const GrProcessor&)
+ GrGLCustomCoordsTextureEffect(const GrBackendProcessorFactory& factory,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&)
: INHERITED (factory) {}
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
@@ -49,9 +51,12 @@ public:
}
virtual void setData(const GrGLProgramDataManager&,
- const GrProcessor&) SK_OVERRIDE {}
+ const GrGeometryProcessor&,
+ const GrBatchTracker&) SK_OVERRIDE {}
- static inline void GenKey(const GrProcessor& proc, const GrGLCaps&,
+ static inline void GenKey(const GrGeometryProcessor& proc,
+ const GrBatchTracker&,
+ const GrGLCaps&,
GrProcessorKeyBuilder* b) {
const GrCustomCoordsTextureEffect& gp = proc.cast<GrCustomCoordsTextureEffect>();
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp
index 95760e62e5..fec1551ef5 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -504,13 +504,20 @@ private:
class GLDashingCircleEffect : public GrGLGeometryProcessor {
public:
- GLDashingCircleEffect(const GrBackendProcessorFactory&, const GrProcessor&);
+ GLDashingCircleEffect(const GrBackendProcessorFactory&,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&);
virtual void emitCode(const EmitArgs&) SK_OVERRIDE;
- static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
+ static inline void GenKey(const GrGeometryProcessor&,
+ const GrBatchTracker&,
+ const GrGLCaps&,
+ GrProcessorKeyBuilder*);
- virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&) SK_OVERRIDE;
private:
GrGLProgramDataManager::UniformHandle fParamUniform;
@@ -521,7 +528,8 @@ private:
};
GLDashingCircleEffect::GLDashingCircleEffect(const GrBackendProcessorFactory& factory,
- const GrProcessor&)
+ const GrGeometryProcessor&,
+ const GrBatchTracker&)
: INHERITED (factory) {
fPrevRadius = SK_ScalarMin;
fPrevCenterX = SK_ScalarMin;
@@ -570,8 +578,9 @@ void GLDashingCircleEffect::emitCode(const EmitArgs& args) {
fsBuilder->codeAppendf("%s = vec4(alpha);", args.fOutputCoverage);
}
-void GLDashingCircleEffect::setData(const GrGLProgramDataManager& pdman
- , const GrProcessor& processor) {
+void GLDashingCircleEffect::setData(const GrGLProgramDataManager& pdman,
+ const GrGeometryProcessor& processor,
+ const GrBatchTracker&) {
const DashingCircleEffect& dce = processor.cast<DashingCircleEffect>();
SkScalar radius = dce.getRadius();
SkScalar centerX = dce.getCenterX();
@@ -584,7 +593,9 @@ void GLDashingCircleEffect::setData(const GrGLProgramDataManager& pdman
}
}
-void GLDashingCircleEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
+void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& processor,
+ const GrBatchTracker&,
+ const GrGLCaps&,
GrProcessorKeyBuilder* b) {
const DashingCircleEffect& dce = processor.cast<DashingCircleEffect>();
b->add32(dce.getEdgeType());
@@ -712,13 +723,20 @@ private:
class GLDashingLineEffect : public GrGLGeometryProcessor {
public:
- GLDashingLineEffect(const GrBackendProcessorFactory&, const GrProcessor&);
+ GLDashingLineEffect(const GrBackendProcessorFactory&,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&);
virtual void emitCode(const EmitArgs&) SK_OVERRIDE;
- static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*);
+ static inline void GenKey(const GrGeometryProcessor&,
+ const GrBatchTracker&,
+ const GrGLCaps&,
+ GrProcessorKeyBuilder*);
- virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE;
+ virtual void setData(const GrGLProgramDataManager&,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&) SK_OVERRIDE;
private:
GrGLProgramDataManager::UniformHandle fRectUniform;
@@ -729,7 +747,8 @@ private:
};
GLDashingLineEffect::GLDashingLineEffect(const GrBackendProcessorFactory& factory,
- const GrProcessor&)
+ const GrGeometryProcessor&,
+ const GrBatchTracker&)
: INHERITED (factory) {
fPrevRect.fLeft = SK_ScalarNaN;
fPrevIntervalLength = SK_ScalarMax;
@@ -792,7 +811,8 @@ void GLDashingLineEffect::emitCode(const EmitArgs& args) {
}
void GLDashingLineEffect::setData(const GrGLProgramDataManager& pdman,
- const GrProcessor& processor) {
+ const GrGeometryProcessor& processor,
+ const GrBatchTracker&) {
const DashingLineEffect& de = processor.cast<DashingLineEffect>();
const SkRect& rect = de.getRect();
SkScalar intervalLength = de.getIntervalLength();
@@ -805,7 +825,9 @@ void GLDashingLineEffect::setData(const GrGLProgramDataManager& pdman,
}
}
-void GLDashingLineEffect::GenKey(const GrProcessor& processor, const GrGLCaps&,
+void GLDashingLineEffect::GenKey(const GrGeometryProcessor& processor,
+ const GrBatchTracker&,
+ const GrGLCaps&,
GrProcessorKeyBuilder* b) {
const DashingLineEffect& de = processor.cast<DashingLineEffect>();
b->add32(de.getEdgeType());
diff --git a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
index 5e1bc9968c..53f85907e4 100755
--- a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
+++ b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
@@ -23,7 +23,8 @@
class GrGLDistanceFieldTextureEffect : public GrGLGeometryProcessor {
public:
GrGLDistanceFieldTextureEffect(const GrBackendProcessorFactory& factory,
- const GrProcessor&)
+ const GrGeometryProcessor&,
+ const GrBatchTracker&)
: INHERITED (factory)
, fTextureSize(SkISize::Make(-1,-1))
#ifdef SK_GAMMA_APPLY_TO_A8
@@ -124,10 +125,11 @@ public:
}
virtual void setData(const GrGLProgramDataManager& pdman,
- const GrProcessor& effect) SK_OVERRIDE {
+ const GrGeometryProcessor& proc,
+ const GrBatchTracker&) SK_OVERRIDE {
SkASSERT(fTextureSizeUni.isValid());
- GrTexture* texture = effect.texture(0);
+ GrTexture* texture = proc.texture(0);
if (texture->width() != fTextureSize.width() ||
texture->height() != fTextureSize.height()) {
fTextureSize = SkISize::Make(texture->width(), texture->height());
@@ -137,7 +139,7 @@ public:
}
#ifdef SK_GAMMA_APPLY_TO_A8
const GrDistanceFieldTextureEffect& dfTexEffect =
- effect.cast<GrDistanceFieldTextureEffect>();
+ proc.cast<GrDistanceFieldTextureEffect>();
float luminance = dfTexEffect.getLuminance();
if (luminance != fLuminance) {
pdman.set1f(fLuminanceUni, luminance);
@@ -146,7 +148,9 @@ public:
#endif
}
- static inline void GenKey(const GrProcessor& processor, const GrGLCaps&,
+ static inline void GenKey(const GrGeometryProcessor& processor,
+ const GrBatchTracker&,
+ const GrGLCaps&,
GrProcessorKeyBuilder* b) {
const GrDistanceFieldTextureEffect& dfTexEffect =
processor.cast<GrDistanceFieldTextureEffect>();
@@ -255,7 +259,8 @@ GrGeometryProcessor* GrDistanceFieldTextureEffect::TestCreate(SkRandom* random,
class GrGLDistanceFieldNoGammaTextureEffect : public GrGLGeometryProcessor {
public:
GrGLDistanceFieldNoGammaTextureEffect(const GrBackendProcessorFactory& factory,
- const GrProcessor& effect)
+ const GrGeometryProcessor&,
+ const GrBatchTracker&)
: INHERITED(factory)
, fTextureSize(SkISize::Make(-1, -1)) {}
@@ -338,10 +343,11 @@ public:
}
virtual void setData(const GrGLProgramDataManager& pdman,
- const GrProcessor& effect) SK_OVERRIDE {
+ const GrGeometryProcessor& proc,
+ const GrBatchTracker&) SK_OVERRIDE {
SkASSERT(fTextureSizeUni.isValid());
- GrTexture* texture = effect.texture(0);
+ GrTexture* texture = proc.texture(0);
if (texture->width() != fTextureSize.width() ||
texture->height() != fTextureSize.height()) {
fTextureSize = SkISize::Make(texture->width(), texture->height());
@@ -351,10 +357,12 @@ public:
}
}
- static inline void GenKey(const GrProcessor& effect, const GrGLCaps&,
+ static inline void GenKey(const GrGeometryProcessor& proc,
+ const GrBatchTracker&,
+ const GrGLCaps&,
GrProcessorKeyBuilder* b) {
const GrDistanceFieldNoGammaTextureEffect& dfTexEffect =
- effect.cast<GrDistanceFieldNoGammaTextureEffect>();
+ proc.cast<GrDistanceFieldNoGammaTextureEffect>();
b->add32(dfTexEffect.getFlags());
}
@@ -430,7 +438,8 @@ GrGeometryProcessor* GrDistanceFieldNoGammaTextureEffect::TestCreate(SkRandom* r
class GrGLDistanceFieldLCDTextureEffect : public GrGLGeometryProcessor {
public:
GrGLDistanceFieldLCDTextureEffect(const GrBackendProcessorFactory& factory,
- const GrProcessor&)
+ const GrGeometryProcessor&,
+ const GrBatchTracker&)
: INHERITED (factory)
, fTextureSize(SkISize::Make(-1,-1))
, fTextColor(GrColor_ILLEGAL) {}
@@ -563,7 +572,8 @@ public:
}
virtual void setData(const GrGLProgramDataManager& pdman,
- const GrProcessor& processor) SK_OVERRIDE {
+ const GrGeometryProcessor& processor,
+ const GrBatchTracker&) SK_OVERRIDE {
SkASSERT(fTextureSizeUni.isValid());
SkASSERT(fTextColorUni.isValid());
@@ -594,7 +604,9 @@ public:
}
}
- static inline void GenKey(const GrProcessor& processor, const GrGLCaps&,
+ static inline void GenKey(const GrGeometryProcessor& processor,
+ const GrBatchTracker&,
+ const GrGLCaps&,
GrProcessorKeyBuilder* b) {
const GrDistanceFieldLCDTextureEffect& dfTexEffect =
processor.cast<GrDistanceFieldLCDTextureEffect>();
diff --git a/src/gpu/gl/GrGLGeometryProcessor.h b/src/gpu/gl/GrGLGeometryProcessor.h
index c3bee95266..a172904ac6 100644
--- a/src/gpu/gl/GrGLGeometryProcessor.h
+++ b/src/gpu/gl/GrGLGeometryProcessor.h
@@ -10,6 +10,7 @@
#include "GrGLProcessor.h"
+class GrBatchTracker;
class GrGLGPBuilder;
/**
@@ -25,16 +26,19 @@ public:
struct EmitArgs {
EmitArgs(GrGLGPBuilder* pb,
const GrGeometryProcessor& gp,
+ const GrBatchTracker& bt,
const char* outputColor,
const char* outputCoverage,
const TextureSamplerArray& samplers)
: fPB(pb)
, fGP(gp)
+ , fBT(bt)
, fOutputColor(outputColor)
, fOutputCoverage(outputCoverage)
, fSamplers(samplers) {}
GrGLGPBuilder* fPB;
const GrGeometryProcessor& fGP;
+ const GrBatchTracker& fBT;
const char* fOutputColor;
const char* fOutputCoverage;
const TextureSamplerArray& fSamplers;
@@ -45,6 +49,15 @@ public:
*/
virtual void emitCode(const EmitArgs&) = 0;
+ /** A GrGLGeometryProcessor instance can be reused with any GrGLGeometryProcessor that produces
+ the same stage key; this function reads data from a GrGLGeometryProcessor and uploads any
+ uniform variables required by the shaders created in emitCode(). The GrGeometryProcessor
+ parameter is guaranteed to be of the same type that created this GrGLGeometryProcessor and
+ to have an identical processor key as the one that created this GrGLGeometryProcessor. */
+ virtual void setData(const GrGLProgramDataManager&,
+ const GrGeometryProcessor&,
+ const GrBatchTracker&) = 0;
+
private:
typedef GrGLProcessor INHERITED;
};
diff --git a/src/gpu/gl/GrGLProcessor.h b/src/gpu/gl/GrGLProcessor.h
index ca4fa2459f..6401e2b324 100644
--- a/src/gpu/gl/GrGLProcessor.h
+++ b/src/gpu/gl/GrGLProcessor.h
@@ -22,7 +22,7 @@
that their GrGLProcessors would emit the same GLSL code.
The GrGLProcessor subclass must also have a constructor of the form:
- EffectSubclass::EffectSubclass(const GrBackendProcessorFactory&, const GrProcessor&)
+ ProcessorSubclass::ProcessorSubclass(const GrBackendProcessorFactory&, const GrProcessor&)
These objects are created by the factory object returned by the GrProcessor::getFactory().
*/
@@ -70,13 +70,6 @@ public:
virtual ~GrGLProcessor() {}
- /** A GrGLProcessor instance can be reused with any GrProcessor that produces the same stage
- key; this function reads data from a GrProcessor and uploads any uniform variables required
- by the shaders created in emitCode(). The GrProcessor parameter is guaranteed to be of the
- same type that created this GrGLProcessor and to have an identical effect key as the one
- that created this GrGLProcessor. */
- virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) {}
-
const char* name() const { return fFactory.name(); }
static void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*) {}
@@ -100,7 +93,7 @@ public:
stages.
@param builder Interface used to emit code in the shaders.
- @param effect The effect that generated this program stage.
+ @param processor The processor that generated this program stage.
@param key The key that was computed by GenKey() from the generating GrProcessor.
@param outputColor A predefined vec4 in the FS in which the stage should place its output
color (or coverage).
@@ -108,19 +101,27 @@ public:
NULL in which case the implied input is solid white (all ones).
TODO: Better system for communicating optimization info (e.g. input
color is solid white, trans black, known to be opaque, etc.) that allows
- the effect to communicate back similar known info about its output.
+ the processor to communicate back similar known info about its output.
@param samplers Contains one entry for each GrTextureAccess of the GrProcessor. These
can be passed to the builder to emit texture reads in the generated
code.
TODO this should take a struct
*/
virtual void emitCode(GrGLFPBuilder* builder,
- const GrFragmentProcessor& effect,
+ const GrFragmentProcessor&,
const char* outputColor,
const char* inputColor,
const TransformedCoordsArray& coords,
const TextureSamplerArray& samplers) = 0;
+ /** A GrGLFragmentProcessor instance can be reused with any GrFragmentProcessor that produces
+ the same stage key; this function reads data from a GrFragmentProcessor and uploads any
+ uniform variables required by the shaders created in emitCode(). The GrFragmentProcessor
+ parameter is guaranteed to be of the same type that created this GrGLFragmentProcessor and
+ to have an identical processor key as the one that created this GrGLFragmentProcessor. */
+ // TODO update this to pass in GrFragmentProcessor
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) {}
+
private:
typedef GrGLProcessor INHERITED;
};
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 3b04edb8c8..29c44ac56c 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -158,7 +158,8 @@ void GrGLProgram::setData(const GrOptDrawState& optState) {
if (fGeometryProcessor.get()) {
SkASSERT(optState.hasGeometryProcessor());
const GrGeometryProcessor& gp = *optState.getGeometryProcessor();
- fGeometryProcessor->fGLProc->setData(fProgramDataManager, gp);
+ const GrBatchTracker& bt = optState.getBatchTracker();
+ fGeometryProcessor->fGLProc->setData(fProgramDataManager, gp, bt);
this->bindTextures(fGeometryProcessor, gp);
}
this->setFragmentData(optState);
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index f8dbbc26f9..474f7026e4 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -123,9 +123,6 @@ static bool get_meta_key(const GrProcessor& proc,
uint32_t transformKey,
uint32_t attribKey,
GrProcessorKeyBuilder* b) {
- const GrBackendProcessorFactory& factory = proc.getFactory();
- factory.getGLProcessorKey(proc, caps, b);
-
size_t processorKeySize = b->size();
uint32_t textureKey = gen_texture_key(proc, caps);
uint32_t classID = proc.getFactory().classID();
@@ -170,6 +167,8 @@ bool GrGLProgramDescBuilder::Build(const GrOptDrawState& optState,
if (optState.hasGeometryProcessor()) {
const GrGeometryProcessor& gp = *optState.getGeometryProcessor();
GrProcessorKeyBuilder b(&desc->fKey);
+ const GrBackendGeometryProcessorFactory& factory = gp.getFactory();
+ factory.getGLProcessorKey(gp, optState.getBatchTracker(), gpu->glCaps(), &b);
if (!get_meta_key(gp, gpu->glCaps(), 0, gen_attrib_key(gp), &b)) {
desc->fKey.reset();
return false;
@@ -178,7 +177,10 @@ bool GrGLProgramDescBuilder::Build(const GrOptDrawState& optState,
for (int s = 0; s < optState.numFragmentStages(); ++s) {
const GrPendingFragmentStage& fps = optState.getFragmentStage(s);
+ const GrFragmentProcessor& fp = *fps.getProcessor();
GrProcessorKeyBuilder b(&desc->fKey);
+ const GrBackendFragmentProcessorFactory& factory = fp.getFactory();
+ factory.getGLProcessorKey(fp, gpu->glCaps(), &b);
if (!get_meta_key(*fps.getProcessor(), gpu->glCaps(),
gen_transform_key(fps, requiresLocalCoordAttrib), 0, &b)) {
desc->fKey.reset();
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index aa9e40c3f2..2f4329ae04 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -359,12 +359,13 @@ void GrGLProgramBuilder::emitAndInstallProc(const GrGeometryProcessor& gp,
SkASSERT(!fGeometryProcessor);
fGeometryProcessor = SkNEW(GrGLInstalledGeoProc);
- fGeometryProcessor->fGLProc.reset(gp.getFactory().createGLInstance(gp));
+ const GrBatchTracker& bt = fOptState.getBatchTracker();
+ fGeometryProcessor->fGLProc.reset(gp.getFactory().createGLInstance(gp, bt));
SkSTArray<4, GrGLProcessor::TextureSampler> samplers(gp.numTextures());
this->emitSamplers(gp, &samplers, fGeometryProcessor);
- GrGLGeometryProcessor::EmitArgs args(this, gp, outColor, outCoverage, samplers);
+ GrGLGeometryProcessor::EmitArgs args(this, gp, bt, outColor, outCoverage, samplers);
fGeometryProcessor->fGLProc->emitCode(args);
// We have to check that effects and the code they emit are consistent, ie if an effect