Convert GrOvalOpFactory from GrLegacyMeshDrawOp to GrMeshDrawOp using GrSimpleDrawOpHelper.
Change-Id: Ib9f59ddf1c2c3f2bd0004ae16f842e52f45df8c9 Reviewed-on: https://skia-review.googlesource.com/16832 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
ab1a34670e
commit
05441c40d6
@ -962,16 +962,14 @@ void GrRenderTargetContext::drawRRect(const GrClip& origClip,
|
||||
GrAAType aaType = this->chooseAAType(aa, GrAllowMixedSamples::kNo);
|
||||
if (GrAAType::kCoverage == aaType) {
|
||||
const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
|
||||
std::unique_ptr<GrLegacyMeshDrawOp> op =
|
||||
GrOvalOpFactory::MakeRRectOp(paint.getColor(),
|
||||
paint.usesDistanceVectorField(),
|
||||
viewMatrix,
|
||||
rrect,
|
||||
stroke,
|
||||
shaderCaps);
|
||||
std::unique_ptr<GrDrawOp> op = GrOvalOpFactory::MakeRRectOp(std::move(paint),
|
||||
paint.usesDistanceVectorField(),
|
||||
viewMatrix,
|
||||
rrect,
|
||||
stroke,
|
||||
shaderCaps);
|
||||
if (op) {
|
||||
GrPipelineBuilder pipelineBuilder(std::move(paint), aaType);
|
||||
this->addLegacyMeshDrawOp(std::move(pipelineBuilder), *clip, std::move(op));
|
||||
this->addDrawOp(*clip, std::move(op));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1185,11 +1183,10 @@ void GrRenderTargetContext::drawOval(const GrClip& clip,
|
||||
GrAAType aaType = this->chooseAAType(aa, GrAllowMixedSamples::kNo);
|
||||
if (GrAAType::kCoverage == aaType) {
|
||||
const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
|
||||
std::unique_ptr<GrLegacyMeshDrawOp> op =
|
||||
GrOvalOpFactory::MakeOvalOp(paint.getColor(), viewMatrix, oval, stroke, shaderCaps);
|
||||
std::unique_ptr<GrDrawOp> op =
|
||||
GrOvalOpFactory::MakeOvalOp(std::move(paint), viewMatrix, oval, stroke, shaderCaps);
|
||||
if (op) {
|
||||
GrPipelineBuilder pipelineBuilder(std::move(paint), aaType);
|
||||
this->addLegacyMeshDrawOp(std::move(pipelineBuilder), clip, std::move(op));
|
||||
this->addDrawOp(clip, std::move(op));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1219,17 +1216,16 @@ void GrRenderTargetContext::drawArc(const GrClip& clip,
|
||||
GrAAType aaType = this->chooseAAType(aa, GrAllowMixedSamples::kNo);
|
||||
if (GrAAType::kCoverage == aaType) {
|
||||
const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
|
||||
std::unique_ptr<GrLegacyMeshDrawOp> op = GrOvalOpFactory::MakeArcOp(paint.getColor(),
|
||||
viewMatrix,
|
||||
oval,
|
||||
startAngle,
|
||||
sweepAngle,
|
||||
useCenter,
|
||||
style,
|
||||
shaderCaps);
|
||||
std::unique_ptr<GrDrawOp> op = GrOvalOpFactory::MakeArcOp(std::move(paint),
|
||||
viewMatrix,
|
||||
oval,
|
||||
startAngle,
|
||||
sweepAngle,
|
||||
useCenter,
|
||||
style,
|
||||
shaderCaps);
|
||||
if (op) {
|
||||
GrPipelineBuilder pipelineBuilder(std::move(paint), aaType);
|
||||
this->addLegacyMeshDrawOp(std::move(pipelineBuilder), clip, std::move(op));
|
||||
this->addDrawOp(clip, std::move(op));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1371,11 +1367,10 @@ void GrRenderTargetContext::drawPath(const GrClip& clip,
|
||||
|
||||
if (isOval && !path.isInverseFillType()) {
|
||||
const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
|
||||
std::unique_ptr<GrLegacyMeshDrawOp> op = GrOvalOpFactory::MakeOvalOp(
|
||||
paint.getColor(), viewMatrix, ovalRect, style.strokeRec(), shaderCaps);
|
||||
std::unique_ptr<GrDrawOp> op = GrOvalOpFactory::MakeOvalOp(
|
||||
std::move(paint), viewMatrix, ovalRect, style.strokeRec(), shaderCaps);
|
||||
if (op) {
|
||||
GrPipelineBuilder pipelineBuilder(std::move(paint), aaType);
|
||||
this->addLegacyMeshDrawOp(std::move(pipelineBuilder), clip, std::move(op));
|
||||
this->addDrawOp(clip, std::move(op));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,9 @@
|
||||
#include "GrColor.h"
|
||||
#include "SkRefCnt.h"
|
||||
|
||||
class GrDrawOp;
|
||||
class GrLegacyMeshDrawOp;
|
||||
class GrPaint;
|
||||
class GrShaderCaps;
|
||||
class GrStyle;
|
||||
class SkMatrix;
|
||||
@ -24,26 +26,27 @@ class SkStrokeRec;
|
||||
*/
|
||||
class GrOvalOpFactory {
|
||||
public:
|
||||
static std::unique_ptr<GrLegacyMeshDrawOp> MakeOvalOp(GrColor,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& oval,
|
||||
const SkStrokeRec& stroke,
|
||||
const GrShaderCaps* shaderCaps);
|
||||
static std::unique_ptr<GrLegacyMeshDrawOp> MakeRRectOp(GrColor,
|
||||
bool needsDistance,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRRect& rrect,
|
||||
const SkStrokeRec& stroke,
|
||||
const GrShaderCaps* shaderCaps);
|
||||
static std::unique_ptr<GrDrawOp> MakeOvalOp(GrPaint&&,
|
||||
const SkMatrix&,
|
||||
const SkRect& oval,
|
||||
const SkStrokeRec&,
|
||||
const GrShaderCaps*);
|
||||
|
||||
static std::unique_ptr<GrLegacyMeshDrawOp> MakeArcOp(GrColor,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& oval,
|
||||
SkScalar startAngle,
|
||||
SkScalar sweepAngle,
|
||||
bool useCenter,
|
||||
const GrStyle&,
|
||||
const GrShaderCaps* shaderCaps);
|
||||
static std::unique_ptr<GrDrawOp> MakeRRectOp(GrPaint&&,
|
||||
bool needsDistance,
|
||||
const SkMatrix&,
|
||||
const SkRRect&,
|
||||
const SkStrokeRec&,
|
||||
const GrShaderCaps*);
|
||||
|
||||
static std::unique_ptr<GrDrawOp> MakeArcOp(GrPaint&&,
|
||||
const SkMatrix&,
|
||||
const SkRect& oval,
|
||||
SkScalar startAngle,
|
||||
SkScalar sweepAngle,
|
||||
bool useCenter,
|
||||
const GrStyle&,
|
||||
const GrShaderCaps*);
|
||||
};
|
||||
|
||||
#endif // GrOvalOpFactory_DEFINED
|
||||
|
@ -40,8 +40,10 @@ public:
|
||||
: fProcessors(args.fProcessorSet)
|
||||
, fPipelineFlags(args.fSRGBFlags)
|
||||
, fAAType((int)aaType)
|
||||
, fRequiresDstTexture(false) {
|
||||
, fRequiresDstTexture(false)
|
||||
, fUsesLocalCoords(false) {
|
||||
SkASSERT(!stencilSettings);
|
||||
SkDEBUGCODE(fDidAnalysis = false);
|
||||
if (GrAATypeIsHW(aaType)) {
|
||||
fPipelineFlags |= GrPipeline::kHWAntialias_Flag;
|
||||
}
|
||||
@ -83,6 +85,7 @@ public:
|
||||
|
||||
bool xpRequiresDstTexture(const GrCaps& caps, const GrAppliedClip* clip,
|
||||
GrProcessorAnalysisCoverage geometryCoverage, GrColor* color) {
|
||||
SkDEBUGCODE(fDidAnalysis = true);
|
||||
if (fProcessors) {
|
||||
GrProcessorAnalysisCoverage coverage = geometryCoverage;
|
||||
if (GrProcessorAnalysisCoverage::kNone == coverage) {
|
||||
@ -94,12 +97,19 @@ public:
|
||||
GrProcessorSet::Analysis analysis =
|
||||
fProcessors->finalize(*color, coverage, clip, isMixedSamples, caps, color);
|
||||
fRequiresDstTexture = analysis.requiresDstTexture();
|
||||
fUsesLocalCoords = analysis.usesLocalCoords();
|
||||
return analysis.requiresDstTexture();
|
||||
} else {
|
||||
fUsesLocalCoords = GrProcessorSet::EmptySetAnalysis().usesLocalCoords();
|
||||
return GrProcessorSet::EmptySetAnalysis().requiresDstTexture();
|
||||
}
|
||||
}
|
||||
|
||||
bool usesLocalCoords() const {
|
||||
SkASSERT(fDidAnalysis);
|
||||
return fUsesLocalCoords;
|
||||
}
|
||||
|
||||
GrPipeline* makePipeline(GrMeshDrawOp::Target* target) const {
|
||||
return target->allocPipeline(this->pipelineInitArgs(target));
|
||||
}
|
||||
@ -137,6 +147,8 @@ private:
|
||||
unsigned fPipelineFlags : 8;
|
||||
unsigned fAAType : 2;
|
||||
unsigned fRequiresDstTexture : 1;
|
||||
unsigned fUsesLocalCoords : 1;
|
||||
SkDEBUGCODE(unsigned fDidAnalysis : 1;)
|
||||
};
|
||||
|
||||
/**
|
||||
@ -170,6 +182,7 @@ public:
|
||||
}
|
||||
|
||||
using GrSimpleMeshDrawOpHelper::xpRequiresDstTexture;
|
||||
using GrSimpleMeshDrawOpHelper::usesLocalCoords;
|
||||
|
||||
bool isCompatible(const GrSimpleMeshDrawOpHelperWithStencil& that, const GrCaps& caps,
|
||||
const SkRect& aBounds, const SkRect& bBounds) const {
|
||||
|
@ -483,20 +483,20 @@ LEGACY_MESH_DRAW_OP_TEST_EXTERN(AAFlatteningConvexPathOp)
|
||||
LEGACY_MESH_DRAW_OP_TEST_EXTERN(AAHairlineOp);
|
||||
LEGACY_MESH_DRAW_OP_TEST_EXTERN(AAStrokeRectOp);
|
||||
LEGACY_MESH_DRAW_OP_TEST_EXTERN(AnalyticRectOp);
|
||||
LEGACY_MESH_DRAW_OP_TEST_EXTERN(CircleOp)
|
||||
LEGACY_MESH_DRAW_OP_TEST_EXTERN(DashOp);
|
||||
LEGACY_MESH_DRAW_OP_TEST_EXTERN(DefaultPathOp);
|
||||
LEGACY_MESH_DRAW_OP_TEST_EXTERN(DIEllipseOp);
|
||||
LEGACY_MESH_DRAW_OP_TEST_EXTERN(EllipseOp);
|
||||
LEGACY_MESH_DRAW_OP_TEST_EXTERN(GrDrawAtlasOp);
|
||||
LEGACY_MESH_DRAW_OP_TEST_EXTERN(NonAAStrokeRectOp);
|
||||
LEGACY_MESH_DRAW_OP_TEST_EXTERN(RRectOp);
|
||||
LEGACY_MESH_DRAW_OP_TEST_EXTERN(SmallPathOp);
|
||||
LEGACY_MESH_DRAW_OP_TEST_EXTERN(TesselatingPathOp);
|
||||
LEGACY_MESH_DRAW_OP_TEST_EXTERN(TextBlobOp);
|
||||
LEGACY_MESH_DRAW_OP_TEST_EXTERN(VerticesOp);
|
||||
|
||||
DRAW_OP_TEST_EXTERN(CircleOp)
|
||||
DRAW_OP_TEST_EXTERN(DIEllipseOp);
|
||||
DRAW_OP_TEST_EXTERN(EllipseOp);
|
||||
DRAW_OP_TEST_EXTERN(NonAAFillRectOp)
|
||||
DRAW_OP_TEST_EXTERN(RRectOp);
|
||||
|
||||
void GrDrawRandomOp(SkRandom* random, GrRenderTargetContext* renderTargetContext, GrPaint&& paint) {
|
||||
GrContext* context = renderTargetContext->surfPriv().getContext();
|
||||
@ -509,14 +509,10 @@ void GrDrawRandomOp(SkRandom* random, GrRenderTargetContext* renderTargetContext
|
||||
DRAW_OP_TEST_ENTRY(AAHairlineOp),
|
||||
DRAW_OP_TEST_ENTRY(AAStrokeRectOp),
|
||||
DRAW_OP_TEST_ENTRY(AnalyticRectOp),
|
||||
DRAW_OP_TEST_ENTRY(CircleOp),
|
||||
DRAW_OP_TEST_ENTRY(DashOp),
|
||||
DRAW_OP_TEST_ENTRY(DefaultPathOp),
|
||||
DRAW_OP_TEST_ENTRY(DIEllipseOp),
|
||||
DRAW_OP_TEST_ENTRY(EllipseOp),
|
||||
DRAW_OP_TEST_ENTRY(GrDrawAtlasOp),
|
||||
DRAW_OP_TEST_ENTRY(NonAAStrokeRectOp),
|
||||
DRAW_OP_TEST_ENTRY(RRectOp),
|
||||
DRAW_OP_TEST_ENTRY(SmallPathOp),
|
||||
DRAW_OP_TEST_ENTRY(TesselatingPathOp),
|
||||
DRAW_OP_TEST_ENTRY(TextBlobOp),
|
||||
@ -525,7 +521,11 @@ void GrDrawRandomOp(SkRandom* random, GrRenderTargetContext* renderTargetContext
|
||||
|
||||
using MakeDrawOpFn = std::unique_ptr<GrDrawOp>(GrPaint&&, SkRandom*, GrContext*, GrFSAAType);
|
||||
static constexpr MakeDrawOpFn* gFactories[] = {
|
||||
DRAW_OP_TEST_ENTRY(CircleOp),
|
||||
DRAW_OP_TEST_ENTRY(DIEllipseOp),
|
||||
DRAW_OP_TEST_ENTRY(EllipseOp),
|
||||
DRAW_OP_TEST_ENTRY(NonAAFillRectOp),
|
||||
DRAW_OP_TEST_ENTRY(RRectOp),
|
||||
};
|
||||
|
||||
static constexpr size_t kTotal = SK_ARRAY_COUNT(gLegacyFactories) + SK_ARRAY_COUNT(gFactories);
|
||||
|
Loading…
Reference in New Issue
Block a user