Revert "Revert "Remove GrPipeline from GrDrawOp.""
This reverts commit c48af934608bbb65650641f66adb51f2102d4274.
Change-Id: I4ba78fd7e5a7d406b88223ca6f7245c029b60f76
Reviewed-on: https://skia-review.googlesource.com/9981
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/ops/GrDrawPathOp.h b/src/gpu/ops/GrDrawPathOp.h
index ffe8768..cf3ce2f 100644
--- a/src/gpu/ops/GrDrawPathOp.h
+++ b/src/gpu/ops/GrDrawPathOp.h
@@ -14,45 +14,53 @@
#include "GrPath.h"
#include "GrPathProcessor.h"
#include "GrPathRendering.h"
+#include "GrProcessorSet.h"
#include "GrStencilSettings.h"
#include "SkTLList.h"
+class GrPaint;
+
class GrDrawPathOpBase : public GrDrawOp {
protected:
- GrDrawPathOpBase(uint32_t classID, const SkMatrix& viewMatrix, GrColor initialColor,
- GrPathRendering::FillType fill)
- : INHERITED(classID), fViewMatrix(viewMatrix), fColor(initialColor), fFillType(fill) {}
-
- const GrStencilSettings& stencilPassSettings() const {
- SkASSERT(!fStencilPassSettings.isDisabled()); // This shouldn't be called before onPrepare.
- return fStencilPassSettings;
+ GrDrawPathOpBase(uint32_t classID, const SkMatrix& viewMatrix, GrPaint&& paint,
+ GrPathRendering::FillType fill, GrAA aa);
+ FixedFunctionFlags fixedFunctionFlags() const override {
+ return FixedFunctionFlags::kUsesHWAA | FixedFunctionFlags::kUsesStencil;
}
+ bool xpRequiresDstTexture(const GrCaps& caps, const GrAppliedClip* clip) override {
+ return GrXPFactory::WillNeedDstTexture(fProcessorSet.xpFactory(), caps,
+ this->doFragmentProcessorAnalysis(caps, clip));
+ }
+
+ void wasRecorded() override { fProcessorSet.makePendingExecution(); }
protected:
const SkMatrix& viewMatrix() const { return fViewMatrix; }
- GrColor color() const { return fColor; }
+ GrColor color() const { return fAnalysis.inputColor(); }
GrPathRendering::FillType fillType() const { return fFillType; }
- bool xpReadsDst() const { return fXPReadsDst; }
+ const GrProcessorSet& processors() const { return fProcessorSet; }
+ GrPipelineOptimizations initPipeline(const GrOpFlushState&, GrPipeline*);
+ const GrProcessorSet::FragmentProcessorAnalysis& doFragmentProcessorAnalysis(
+ const GrCaps& caps, const GrAppliedClip* clip) {
+ if (!fAnalysis.isInitializedWithProcessorSet()) {
+ fAnalysis.init(fAnalysis.inputColor(), GrColor_WHITE, fProcessorSet, clip, caps);
+ }
+ return fAnalysis;
+ }
+ const GrProcessorSet::FragmentProcessorAnalysis& fragmentProcessorAnalysis() const {
+ SkASSERT(fAnalysis.isInitializedWithProcessorSet());
+ return fAnalysis;
+ }
private:
- void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override {
- input->colorInput()->setToConstant(fColor);
- input->coverageInput()->setToSolidCoverage();
- }
-
- void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override {
- optimizations.getOverrideColorIfSet(&fColor);
- fXPReadsDst = optimizations.xpReadsDst();
- }
-
- void onPrepare(GrOpFlushState*) override; // Initializes fStencilPassSettings.
+ void onPrepare(GrOpFlushState*) final {}
SkMatrix fViewMatrix;
- GrColor fColor;
+ GrProcessorSet fProcessorSet;
+ GrProcessorSet::FragmentProcessorAnalysis fAnalysis;
GrPathRendering::FillType fFillType;
- GrStencilSettings fStencilPassSettings;
- bool fXPReadsDst;
+ GrAA fAA;
typedef GrDrawOp INHERITED;
};
@@ -61,9 +69,9 @@
public:
DEFINE_OP_CLASS_ID
- static std::unique_ptr<GrDrawOp> Make(const SkMatrix& viewMatrix, GrColor color,
- const GrPath* path) {
- return std::unique_ptr<GrDrawOp>(new GrDrawPathOp(viewMatrix, color, path));
+ static std::unique_ptr<GrDrawOp> Make(const SkMatrix& viewMatrix, GrPaint&& paint, GrAA aa,
+ GrPath* path) {
+ return std::unique_ptr<GrDrawOp>(new GrDrawPathOp(viewMatrix, std::move(paint), aa, path));
}
const char* name() const override { return "DrawPath"; }
@@ -71,8 +79,9 @@
SkString dumpInfo() const override;
private:
- GrDrawPathOp(const SkMatrix& viewMatrix, GrColor color, const GrPath* path)
- : GrDrawPathOpBase(ClassID(), viewMatrix, color, path->getFillType()), fPath(path) {
+ GrDrawPathOp(const SkMatrix& viewMatrix, GrPaint&& paint, GrAA aa, const GrPath* path)
+ : GrDrawPathOpBase(ClassID(), viewMatrix, std::move(paint), path->getFillType(), aa)
+ , fPath(path) {
this->setTransformedBounds(path->getBounds(), viewMatrix, HasAABloat::kNo, IsZeroArea::kNo);
}
@@ -152,11 +161,12 @@
};
static std::unique_ptr<GrDrawOp> Make(const SkMatrix& viewMatrix, SkScalar scale, SkScalar x,
- SkScalar y, GrColor color, GrPathRendering::FillType fill,
+ SkScalar y, GrPaint&& paint,
+ GrPathRendering::FillType fill, GrAA aa,
GrPathRange* range, const InstanceData* instanceData,
const SkRect& bounds) {
- return std::unique_ptr<GrDrawOp>(new GrDrawPathRangeOp(viewMatrix, scale, x, y, color, fill,
- range, instanceData, bounds));
+ return std::unique_ptr<GrDrawOp>(new GrDrawPathRangeOp(
+ viewMatrix, scale, x, y, std::move(paint), fill, aa, range, instanceData, bounds));
}
const char* name() const override { return "DrawPathRange"; }
@@ -165,7 +175,7 @@
private:
GrDrawPathRangeOp(const SkMatrix& viewMatrix, SkScalar scale, SkScalar x, SkScalar y,
- GrColor color, GrPathRendering::FillType fill, GrPathRange* range,
+ GrPaint&& paint, GrPathRendering::FillType fill, GrAA aa, GrPathRange* range,
const InstanceData* instanceData, const SkRect& bounds);
TransformType transformType() const { return fDraws.head()->fInstanceData->transformType(); }