blob: 3016fd7272d75db3f7ecadd022e8649225501ad8 [file] [log] [blame]
bsalomonadd79ef2015-08-19 13:26:49 -07001/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
Brian Salomon82c263f2016-12-15 09:54:06 -05008#ifndef GrDrawPathOp_DEFINED
9#define GrDrawPathOp_DEFINED
bsalomonadd79ef2015-08-19 13:26:49 -070010
Brian Salomon9afd3712016-12-01 10:59:09 -050011#include "GrDrawOp.h"
Brian Salomon742e31d2016-12-07 17:06:19 -050012#include "GrOpFlushState.h"
bsalomonadd79ef2015-08-19 13:26:49 -070013#include "GrPath.h"
bsalomonadd79ef2015-08-19 13:26:49 -070014#include "GrPathProcessor.h"
Brian Salomon742e31d2016-12-07 17:06:19 -050015#include "GrPathRendering.h"
Brian Salomon54d212e2017-03-21 14:22:38 -040016#include "GrProcessorSet.h"
csmartdaltonc633abb2016-11-01 08:55:55 -070017#include "GrStencilSettings.h"
bsalomonadd79ef2015-08-19 13:26:49 -070018
Brian Salomon54d212e2017-03-21 14:22:38 -040019class GrPaint;
20
Brian Salomon82c263f2016-12-15 09:54:06 -050021class GrDrawPathOpBase : public GrDrawOp {
bsalomon1fcc01c2015-09-09 09:48:06 -070022protected:
Brian Salomon48d1b4c2017-04-08 07:38:53 -040023 GrDrawPathOpBase(uint32_t classID, const SkMatrix& viewMatrix, GrPaint&&,
24 GrPathRendering::FillType, GrAAType);
Robert Phillipsb493eeb2017-09-13 13:10:52 -040025
Brian Salomon54d212e2017-03-21 14:22:38 -040026 FixedFunctionFlags fixedFunctionFlags() const override {
Brian Salomon48d1b4c2017-04-08 07:38:53 -040027 if (GrAATypeIsHW(fAAType)) {
28 return FixedFunctionFlags::kUsesHWAA | FixedFunctionFlags::kUsesStencil;
29 }
30 return FixedFunctionFlags::kUsesStencil;
Brian Salomonc48af932017-03-16 19:51:42 +000031 }
Brian Osman532b3f92018-07-11 10:02:07 -040032 RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override {
33 return this->doProcessorAnalysis(caps, clip).requiresDstTexture()
Brian Osman9a725dd2017-09-20 09:53:22 -040034 ? RequiresDstTexture::kYes : RequiresDstTexture::kNo;
Brian Salomon54d212e2017-03-21 14:22:38 -040035 }
36
Robert Phillipsf1748f52017-09-14 14:11:24 -040037 void visitProxies(const VisitProxyFunc& func) const override {
Robert Phillipsb493eeb2017-09-13 13:10:52 -040038 fProcessorSet.visitProxies(func);
39 }
40
Brian Salomon92aee3d2016-12-21 09:20:25 -050041protected:
joshualittf2384692015-09-10 11:00:51 -070042 const SkMatrix& viewMatrix() const { return fViewMatrix; }
Brian Salomon48d1b4c2017-04-08 07:38:53 -040043 GrColor color() const { return fInputColor; }
cdalton193d9cf2016-05-12 11:52:02 -070044 GrPathRendering::FillType fillType() const { return fFillType; }
Brian Salomon54d212e2017-03-21 14:22:38 -040045 const GrProcessorSet& processors() const { return fProcessorSet; }
Brian Salomon91326c32017-08-09 16:02:19 -040046 GrProcessorSet detachProcessors() { return std::move(fProcessorSet); }
Brian Salomon972b2f62017-07-31 12:37:02 -040047 inline GrPipeline::InitArgs pipelineInitArgs(const GrOpFlushState&);
Brian Salomona811b122017-03-30 08:21:32 -040048 const GrProcessorSet::Analysis& doProcessorAnalysis(const GrCaps& caps,
Brian Osman532b3f92018-07-11 10:02:07 -040049 const GrAppliedClip* clip) {
Brian Salomon48d1b4c2017-04-08 07:38:53 -040050 bool isMixedSamples = GrAAType::kMixedSamples == fAAType;
51 fAnalysis = fProcessorSet.finalize(fInputColor, GrProcessorAnalysisCoverage::kNone, clip,
Brian Osman532b3f92018-07-11 10:02:07 -040052 isMixedSamples, caps, &fInputColor);
Brian Salomon54d212e2017-03-21 14:22:38 -040053 return fAnalysis;
54 }
Brian Salomona811b122017-03-30 08:21:32 -040055 const GrProcessorSet::Analysis& processorAnalysis() const {
Brian Salomon48d1b4c2017-04-08 07:38:53 -040056 SkASSERT(fAnalysis.isInitialized());
Brian Salomon54d212e2017-03-21 14:22:38 -040057 return fAnalysis;
58 }
joshualittf2384692015-09-10 11:00:51 -070059
bsalomon1fcc01c2015-09-09 09:48:06 -070060private:
Brian Salomon54d212e2017-03-21 14:22:38 -040061 void onPrepare(GrOpFlushState*) final {}
cdalton193d9cf2016-05-12 11:52:02 -070062
Brian Salomon82c263f2016-12-15 09:54:06 -050063 SkMatrix fViewMatrix;
Brian Salomon48d1b4c2017-04-08 07:38:53 -040064 GrColor fInputColor;
Brian Salomona811b122017-03-30 08:21:32 -040065 GrProcessorSet::Analysis fAnalysis;
Brian Salomon82c263f2016-12-15 09:54:06 -050066 GrPathRendering::FillType fFillType;
Brian Salomon48d1b4c2017-04-08 07:38:53 -040067 GrAAType fAAType;
Brian Salomon611572c2017-04-28 08:57:12 -040068 GrProcessorSet fProcessorSet;
bsalomon1fcc01c2015-09-09 09:48:06 -070069
Brian Salomon9afd3712016-12-01 10:59:09 -050070 typedef GrDrawOp INHERITED;
bsalomon1fcc01c2015-09-09 09:48:06 -070071};
72
Brian Salomon82c263f2016-12-15 09:54:06 -050073class GrDrawPathOp final : public GrDrawPathOpBase {
bsalomon1fcc01c2015-09-09 09:48:06 -070074public:
Brian Salomon25a88092016-12-01 09:36:50 -050075 DEFINE_OP_CLASS_ID
reed1b55a962015-09-17 20:16:13 -070076
Robert Phillips7c525e62018-06-12 10:11:12 -040077 static std::unique_ptr<GrDrawOp> Make(GrContext*,
78 const SkMatrix& viewMatrix,
79 GrPaint&&,
80 GrAAType,
81 GrPath*);
bsalomonadd79ef2015-08-19 13:26:49 -070082
83 const char* name() const override { return "DrawPath"; }
84
bsalomon1fcc01c2015-09-09 09:48:06 -070085 SkString dumpInfo() const override;
bsalomonadd79ef2015-08-19 13:26:49 -070086
87private:
Robert Phillips7c525e62018-06-12 10:11:12 -040088 friend class GrOpMemoryPool; // for ctor
89
Brian Salomon48d1b4c2017-04-08 07:38:53 -040090 GrDrawPathOp(const SkMatrix& viewMatrix, GrPaint&& paint, GrAAType aaType, const GrPath* path)
91 : GrDrawPathOpBase(ClassID(), viewMatrix, std::move(paint), path->getFillType(), aaType)
Brian Salomon54d212e2017-03-21 14:22:38 -040092 , fPath(path) {
bsalomon88cf17d2016-07-08 06:40:56 -070093 this->setTransformedBounds(path->getBounds(), viewMatrix, HasAABloat::kNo, IsZeroArea::kNo);
bsalomonadd79ef2015-08-19 13:26:49 -070094 }
stephana1dc17212016-04-25 07:01:22 -070095
Brian Salomon9e50f7b2017-03-06 12:02:34 -050096 void onExecute(GrOpFlushState* state) override;
bsalomon1fcc01c2015-09-09 09:48:06 -070097
98 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
stephana1dc17212016-04-25 07:01:22 -070099
Brian Salomon82c263f2016-12-15 09:54:06 -0500100 typedef GrDrawPathOpBase INHERITED;
bsalomon1fcc01c2015-09-09 09:48:06 -0700101};
102
bsalomonadd79ef2015-08-19 13:26:49 -0700103#endif