Revert "Make DashOp a non-legacy GrMeshDrawOp."

This reverts commit ebb38256c6.

Reason for revert: Assertions on ANGLE bots

Original change's description:
> Make DashOp a non-legacy GrMeshDrawOp.
> 
> Change-Id: I84ee3c64a5af8889e9a122cbc08d70ed6b25fbab
> Reviewed-on: https://skia-review.googlesource.com/22210
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>

TBR=egdaniel@google.com,bsalomon@google.com

Change-Id: I886a0bd75221f05d737d8b27c6b3d8d6cce5573c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/22680
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Salomon 2017-07-12 16:58:54 +00:00 committed by Skia Commit-Bot
parent 1c8bb8a4c6
commit beae8a9faa
5 changed files with 64 additions and 116 deletions

View File

@ -245,18 +245,6 @@ public:
return this->state()->allocPipeline(std::forward<Args>(args)...); return this->state()->allocPipeline(std::forward<Args>(args)...);
} }
GrPipeline* makePipeline(uint32_t pipelineFlags, const GrProcessorSet* processorSet) {
GrPipeline::InitArgs pipelineArgs;
pipelineArgs.fFlags = pipelineFlags;
pipelineArgs.fProcessors = processorSet;
pipelineArgs.fRenderTarget = this->renderTarget();
pipelineArgs.fAppliedClip = this->clip();
pipelineArgs.fDstProxy = this->dstProxy();
pipelineArgs.fCaps = &this->caps();
pipelineArgs.fResourceProvider = this->resourceProvider();
return this->allocPipeline(pipelineArgs);
}
private: private:
GrMeshDrawOp* meshDrawOp() { return static_cast<GrMeshDrawOp*>(this->op()); } GrMeshDrawOp* meshDrawOp() { return static_cast<GrMeshDrawOp*>(this->op()); }
typedef GrDrawOp::Target INHERITED; typedef GrDrawOp::Target INHERITED;

View File

@ -46,12 +46,16 @@ bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
} }
SkPoint pts[2]; SkPoint pts[2];
SkAssertResult(args.fShape->asLine(pts, nullptr)); SkAssertResult(args.fShape->asLine(pts, nullptr));
std::unique_ptr<GrDrawOp> op = std::unique_ptr<GrLegacyMeshDrawOp> op = GrDashOp::MakeDashLineOp(
GrDashOp::MakeDashLineOp(std::move(args.fPaint), *args.fViewMatrix, pts, aaMode, args.fPaint.getColor(), *args.fViewMatrix, pts, aaMode, args.fShape->style());
args.fShape->style(), args.fUserStencilSettings);
if (!op) { if (!op) {
return false; return false;
} }
args.fRenderTargetContext->addDrawOp(*args.fClip, std::move(op));
GrPipelineBuilder pipelineBuilder(std::move(args.fPaint), args.fAAType);
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
args.fRenderTargetContext->addLegacyMeshDrawOp(
std::move(pipelineBuilder), *args.fClip, std::move(op));
return true; return true;
} }

View File

@ -6,7 +6,7 @@
*/ */
#include "GrDashOp.h" #include "GrDashOp.h"
#include "GrAppliedClip.h"
#include "GrCaps.h" #include "GrCaps.h"
#include "GrContext.h" #include "GrContext.h"
#include "GrCoordTransform.h" #include "GrCoordTransform.h"
@ -240,7 +240,7 @@ static sk_sp<GrGeometryProcessor> make_dash_gp(GrColor,
const SkMatrix& localMatrix, const SkMatrix& localMatrix,
bool usesLocalCoords); bool usesLocalCoords);
class DashOp final : public GrMeshDrawOp { class DashOp final : public GrLegacyMeshDrawOp {
public: public:
DEFINE_OP_CLASS_ID DEFINE_OP_CLASS_ID
struct LineData { struct LineData {
@ -254,11 +254,11 @@ public:
SkScalar fPerpendicularScale; SkScalar fPerpendicularScale;
}; };
static std::unique_ptr<GrDrawOp> Make(GrPaint&& paint, const LineData& geometry, static std::unique_ptr<GrLegacyMeshDrawOp> Make(const LineData& geometry, GrColor color,
SkPaint::Cap cap, AAMode aaMode, bool fullDash, SkPaint::Cap cap, AAMode aaMode,
const GrUserStencilSettings* stencilSettings) { bool fullDash) {
return std::unique_ptr<GrDrawOp>( return std::unique_ptr<GrLegacyMeshDrawOp>(
new DashOp(std::move(paint), geometry, cap, aaMode, fullDash, stencilSettings)); new DashOp(geometry, color, cap, aaMode, fullDash));
} }
const char* name() const override { return "DashOp"; } const char* name() const override { return "DashOp"; }
@ -275,49 +275,14 @@ public:
geo.fIntervals[1], geo.fIntervals[1],
geo.fPhase); geo.fPhase);
} }
string += fProcessorSet.dumpProcessors(); string.append(DumpPipelineInfo(*this->pipeline()));
string += INHERITED::dumpInfo(); string.append(INHERITED::dumpInfo());
return string; return string;
} }
FixedFunctionFlags fixedFunctionFlags() const override {
FixedFunctionFlags flags = FixedFunctionFlags::kNone;
if (AAMode::kCoverageWithMSAA == fAAMode) {
flags |= FixedFunctionFlags::kUsesHWAA;
}
if (fStencilSettings) {
flags |= FixedFunctionFlags::kUsesStencil;
}
return flags;
}
RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override {
GrProcessorAnalysisCoverage coverage;
if (AAMode::kNone == fAAMode && !clip->clipCoverageFragmentProcessor()) {
coverage = GrProcessorAnalysisCoverage::kNone;
} else {
coverage = GrProcessorAnalysisCoverage::kSingleChannel;
}
auto analysis = fProcessorSet.finalize(fColor, coverage, clip, false, caps, &fColor);
fDisallowCombineOnTouchOrOverlap = analysis.requiresDstTexture() ||
(fProcessorSet.xferProcessor() &&
fProcessorSet.xferProcessor()->xferBarrierType(caps));
fUsesLocalCoords = analysis.usesLocalCoords();
return analysis.requiresDstTexture() ? RequiresDstTexture::kYes : RequiresDstTexture::kNo;
}
private: private:
DashOp(GrPaint&& paint, const LineData& geometry, SkPaint::Cap cap, AAMode aaMode, DashOp(const LineData& geometry, GrColor color, SkPaint::Cap cap, AAMode aaMode, bool fullDash)
bool fullDash, const GrUserStencilSettings* stencilSettings) : INHERITED(ClassID()), fColor(color), fCap(cap), fAAMode(aaMode), fFullDash(fullDash) {
: INHERITED(ClassID())
, fColor(paint.getColor())
, fAllowsSRGBInputs(paint.getAllowSRGBInputs())
, fDisableSRGBOutputConversion(paint.getDisableOutputConversionToSRGB())
, fCap(cap)
, fFullDash(fullDash)
, fAAMode(aaMode)
, fProcessorSet(std::move(paint))
, fStencilSettings(stencilSettings) {
fLines.push_back(geometry); fLines.push_back(geometry);
// compute bounds // compute bounds
@ -336,6 +301,18 @@ private:
this->setTransformedBounds(bounds, combinedMatrix, aaBloat, zeroArea); this->setTransformedBounds(bounds, combinedMatrix, aaBloat, zeroArea);
} }
void getProcessorAnalysisInputs(GrProcessorAnalysisColor* color,
GrProcessorAnalysisCoverage* coverage) const override {
color->setToConstant(fColor);
*coverage = GrProcessorAnalysisCoverage::kSingleChannel;
}
void applyPipelineOptimizations(const PipelineOptimizations& optimizations) override {
optimizations.getOverrideColorIfSet(&fColor);
fUsesLocalCoords = optimizations.readsLocalCoords();
}
struct DashDraw { struct DashDraw {
DashDraw(const LineData& geo) { DashDraw(const LineData& geo) {
memcpy(fPtsRot, geo.fPtsRot, sizeof(geo.fPtsRot)); memcpy(fPtsRot, geo.fPtsRot, sizeof(geo.fPtsRot));
@ -365,13 +342,14 @@ private:
sk_sp<GrGeometryProcessor> gp; sk_sp<GrGeometryProcessor> gp;
if (this->fullDash()) { if (this->fullDash()) {
gp = make_dash_gp(this->color(), this->aaMode(), capType, this->viewMatrix(), gp = make_dash_gp(this->color(), this->aaMode(), capType, this->viewMatrix(),
fUsesLocalCoords); this->usesLocalCoords());
} else { } else {
// Set up the vertex data for the line and start/end dashes // Set up the vertex data for the line and start/end dashes
using namespace GrDefaultGeoProcFactory; using namespace GrDefaultGeoProcFactory;
Color color(this->color()); Color color(this->color());
LocalCoords::Type localCoordsType = LocalCoords::Type localCoordsType = this->usesLocalCoords()
fUsesLocalCoords ? LocalCoords::kUsePosition_Type : LocalCoords::kUnused_Type; ? LocalCoords::kUsePosition_Type
: LocalCoords::kUnused_Type;
gp = MakeForDeviceSpace(color, Coverage::kSolid_Type, localCoordsType, gp = MakeForDeviceSpace(color, Coverage::kSolid_Type, localCoordsType,
this->viewMatrix()); this->viewMatrix());
} }
@ -652,27 +630,13 @@ private:
rectIndex++; rectIndex++;
} }
SkASSERT(0 == (curVIdx % 4) && (curVIdx / 4) == totalRectCount); SkASSERT(0 == (curVIdx % 4) && (curVIdx / 4) == totalRectCount);
uint32_t pipelineFlags = 0; helper.recordDraw(target, gp.get(), this->pipeline());
if (AAMode::kCoverageWithMSAA == fAAMode) {
pipelineFlags |= GrPipeline::kHWAntialias_Flag;
}
if (fDisableSRGBOutputConversion) {
pipelineFlags |= GrPipeline::kDisableOutputConversionToSRGB_Flag;
}
if (fAllowsSRGBInputs) {
pipelineFlags |= GrPipeline::kAllowSRGBInputs_Flag;
}
const GrPipeline* pipeline = target->makePipeline(pipelineFlags, &fProcessorSet);
helper.recordDraw(target, gp.get(), pipeline);
} }
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
DashOp* that = t->cast<DashOp>(); DashOp* that = t->cast<DashOp>();
if (fProcessorSet != that->fProcessorSet) { if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(),
return false; that->bounds(), caps)) {
}
if (fDisallowCombineOnTouchOrOverlap &&
GrRectsTouchOrOverlap(this->bounds(), that->bounds())) {
return false; return false;
} }
@ -693,7 +657,8 @@ private:
return false; return false;
} }
if (fUsesLocalCoords && !this->viewMatrix().cheapEqualTo(that->viewMatrix())) { SkASSERT(this->usesLocalCoords() == that->usesLocalCoords());
if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->viewMatrix())) {
return false; return false;
} }
@ -703,6 +668,7 @@ private:
} }
GrColor color() const { return fColor; } GrColor color() const { return fColor; }
bool usesLocalCoords() const { return fUsesLocalCoords; }
const SkMatrix& viewMatrix() const { return fLines[0].fViewMatrix; } const SkMatrix& viewMatrix() const { return fLines[0].fViewMatrix; }
AAMode aaMode() const { return fAAMode; } AAMode aaMode() const { return fAAMode; }
bool fullDash() const { return fFullDash; } bool fullDash() const { return fFullDash; }
@ -711,27 +677,21 @@ private:
static const int kVertsPerDash = 4; static const int kVertsPerDash = 4;
static const int kIndicesPerDash = 6; static const int kIndicesPerDash = 6;
SkSTArray<1, LineData, true> fLines;
GrColor fColor; GrColor fColor;
bool fAllowsSRGBInputs : 1; bool fUsesLocalCoords;
bool fDisableSRGBOutputConversion : 1; SkPaint::Cap fCap;
bool fDisallowCombineOnTouchOrOverlap : 1;
bool fUsesLocalCoords : 1;
SkPaint::Cap fCap : 2;
bool fFullDash : 1;
AAMode fAAMode; AAMode fAAMode;
GrProcessorSet fProcessorSet; bool fFullDash;
const GrUserStencilSettings* fStencilSettings; SkSTArray<1, LineData, true> fLines;
typedef GrMeshDrawOp INHERITED; typedef GrLegacyMeshDrawOp INHERITED;
}; };
std::unique_ptr<GrDrawOp> GrDashOp::MakeDashLineOp(GrPaint&& paint, std::unique_ptr<GrLegacyMeshDrawOp> GrDashOp::MakeDashLineOp(GrColor color,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const SkPoint pts[2], const SkPoint pts[2],
AAMode aaMode, AAMode aaMode,
const GrStyle& style, const GrStyle& style) {
const GrUserStencilSettings* stencilSettings) {
SkASSERT(GrDashOp::CanDrawDashLine(pts, style, viewMatrix)); SkASSERT(GrDashOp::CanDrawDashLine(pts, style, viewMatrix));
const SkScalar* intervals = style.dashIntervals(); const SkScalar* intervals = style.dashIntervals();
SkScalar phase = style.dashPhase(); SkScalar phase = style.dashPhase();
@ -777,7 +737,7 @@ std::unique_ptr<GrDrawOp> GrDashOp::MakeDashLineOp(GrPaint&& paint,
lineData.fIntervals[0] = intervals[0]; lineData.fIntervals[0] = intervals[0];
lineData.fIntervals[1] = intervals[1]; lineData.fIntervals[1] = intervals[1];
return DashOp::Make(std::move(paint), lineData, cap, aaMode, fullDash, stencilSettings); return DashOp::Make(lineData, color, cap, aaMode, fullDash);
} }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@ -1238,12 +1198,10 @@ static sk_sp<GrGeometryProcessor> make_dash_gp(GrColor color,
#if GR_TEST_UTILS #if GR_TEST_UTILS
GR_DRAW_OP_TEST_DEFINE(DashOp) { GR_LEGACY_MESH_DRAW_OP_TEST_DEFINE(DashOp) {
GrColor color = GrRandomColor(random);
SkMatrix viewMatrix = GrTest::TestMatrixPreservesRightAngles(random); SkMatrix viewMatrix = GrTest::TestMatrixPreservesRightAngles(random);
AAMode aaMode; AAMode aaMode = static_cast<AAMode>(random->nextULessThan(GrDashOp::kAAModeCnt));
do {
aaMode = static_cast<AAMode>(random->nextULessThan(GrDashOp::kAAModeCnt));
} while (AAMode::kCoverageWithMSAA == aaMode && GrFSAAType::kUnifiedMSAA != fsaaType);
// We can only dash either horizontal or vertical lines // We can only dash either horizontal or vertical lines
SkPoint pts[2]; SkPoint pts[2];
@ -1308,8 +1266,7 @@ GR_DRAW_OP_TEST_DEFINE(DashOp) {
GrStyle style(p); GrStyle style(p);
return GrDashOp::MakeDashLineOp(std::move(paint), viewMatrix, pts, aaMode, style, return GrDashOp::MakeDashLineOp(color, viewMatrix, pts, aaMode, style);
GrGetRandomStencil(random, context));
} }
#endif #endif

View File

@ -8,13 +8,12 @@
#ifndef GrDashOp_DEFINED #ifndef GrDashOp_DEFINED
#define GrDashOp_DEFINED #define GrDashOp_DEFINED
#include "GrTypes.h" #include "GrColor.h"
#include "GrTypesPriv.h"
#include "SkPathEffect.h" #include "SkPathEffect.h"
class GrDrawOp; class GrLegacyMeshDrawOp;
class GrPaint;
class GrStyle; class GrStyle;
struct GrUserStencilSettings;
namespace GrDashOp { namespace GrDashOp {
enum class AAMode { enum class AAMode {
@ -24,9 +23,9 @@ enum class AAMode {
}; };
static const int kAAModeCnt = static_cast<int>(AAMode::kCoverageWithMSAA) + 1; static const int kAAModeCnt = static_cast<int>(AAMode::kCoverageWithMSAA) + 1;
std::unique_ptr<GrDrawOp> MakeDashLineOp(GrPaint&&, const SkMatrix& viewMatrix, std::unique_ptr<GrLegacyMeshDrawOp> MakeDashLineOp(GrColor, const SkMatrix& viewMatrix,
const SkPoint pts[2], AAMode, const GrStyle& style, const SkPoint pts[2], AAMode,
const GrUserStencilSettings*); const GrStyle& style);
bool CanDrawDashLine(const SkPoint pts[2], const GrStyle& style, const SkMatrix& viewMatrix); bool CanDrawDashLine(const SkPoint pts[2], const GrStyle& style, const SkMatrix& viewMatrix);
} }

View File

@ -315,6 +315,7 @@ void GrDrawingManager::testingOnly_removeOnFlushCallbackObject(GrOnFlushCallback
LEGACY_MESH_DRAW_OP_TEST_EXTERN(AAFlatteningConvexPathOp); LEGACY_MESH_DRAW_OP_TEST_EXTERN(AAFlatteningConvexPathOp);
LEGACY_MESH_DRAW_OP_TEST_EXTERN(AnalyticRectOp); LEGACY_MESH_DRAW_OP_TEST_EXTERN(AnalyticRectOp);
LEGACY_MESH_DRAW_OP_TEST_EXTERN(DashOp);
LEGACY_MESH_DRAW_OP_TEST_EXTERN(DefaultPathOp); LEGACY_MESH_DRAW_OP_TEST_EXTERN(DefaultPathOp);
LEGACY_MESH_DRAW_OP_TEST_EXTERN(GrDrawAtlasOp); LEGACY_MESH_DRAW_OP_TEST_EXTERN(GrDrawAtlasOp);
LEGACY_MESH_DRAW_OP_TEST_EXTERN(TextBlobOp); LEGACY_MESH_DRAW_OP_TEST_EXTERN(TextBlobOp);
@ -325,7 +326,6 @@ DRAW_OP_TEST_EXTERN(AAFillRectOp);
DRAW_OP_TEST_EXTERN(AAHairlineOp); DRAW_OP_TEST_EXTERN(AAHairlineOp);
DRAW_OP_TEST_EXTERN(AAStrokeRectOp); DRAW_OP_TEST_EXTERN(AAStrokeRectOp);
DRAW_OP_TEST_EXTERN(CircleOp); DRAW_OP_TEST_EXTERN(CircleOp);
DRAW_OP_TEST_EXTERN(DashOp);
DRAW_OP_TEST_EXTERN(DIEllipseOp); DRAW_OP_TEST_EXTERN(DIEllipseOp);
DRAW_OP_TEST_EXTERN(EllipseOp); DRAW_OP_TEST_EXTERN(EllipseOp);
DRAW_OP_TEST_EXTERN(NonAAFillRectOp); DRAW_OP_TEST_EXTERN(NonAAFillRectOp);
@ -341,6 +341,7 @@ void GrDrawRandomOp(SkRandom* random, GrRenderTargetContext* renderTargetContext
static constexpr MakeTestLegacyMeshDrawOpFn* gLegacyFactories[] = { static constexpr MakeTestLegacyMeshDrawOpFn* gLegacyFactories[] = {
DRAW_OP_TEST_ENTRY(AAFlatteningConvexPathOp), DRAW_OP_TEST_ENTRY(AAFlatteningConvexPathOp),
DRAW_OP_TEST_ENTRY(AnalyticRectOp), DRAW_OP_TEST_ENTRY(AnalyticRectOp),
DRAW_OP_TEST_ENTRY(DashOp),
DRAW_OP_TEST_ENTRY(DefaultPathOp), DRAW_OP_TEST_ENTRY(DefaultPathOp),
DRAW_OP_TEST_ENTRY(GrDrawAtlasOp), DRAW_OP_TEST_ENTRY(GrDrawAtlasOp),
DRAW_OP_TEST_ENTRY(TextBlobOp), DRAW_OP_TEST_ENTRY(TextBlobOp),
@ -354,7 +355,6 @@ void GrDrawRandomOp(SkRandom* random, GrRenderTargetContext* renderTargetContext
DRAW_OP_TEST_ENTRY(AAHairlineOp), DRAW_OP_TEST_ENTRY(AAHairlineOp),
DRAW_OP_TEST_ENTRY(AAStrokeRectOp), DRAW_OP_TEST_ENTRY(AAStrokeRectOp),
DRAW_OP_TEST_ENTRY(CircleOp), DRAW_OP_TEST_ENTRY(CircleOp),
DRAW_OP_TEST_ENTRY(DashOp),
DRAW_OP_TEST_ENTRY(DIEllipseOp), DRAW_OP_TEST_ENTRY(DIEllipseOp),
DRAW_OP_TEST_ENTRY(EllipseOp), DRAW_OP_TEST_ENTRY(EllipseOp),
DRAW_OP_TEST_ENTRY(NonAAFillRectOp), DRAW_OP_TEST_ENTRY(NonAAFillRectOp),