blob: 9facfe9b37568a3e240093f6125dfe45a1354eda [file] [log] [blame]
Brian Salomon82c263f2016-12-15 09:54:06 -05001/*
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
8#ifndef GrStencilPathOp_DEFINED
9#define GrStencilPathOp_DEFINED
10
Brian Salomon82c263f2016-12-15 09:54:06 -050011#include "GrOp.h"
Brian Salomon82c263f2016-12-15 09:54:06 -050012#include "GrPath.h"
13#include "GrPathRendering.h"
Hal Canary6b20a552017-02-07 14:09:38 -050014#include "GrStencilSettings.h"
Brian Salomon82c263f2016-12-15 09:54:06 -050015
Robert Phillips7c525e62018-06-12 10:11:12 -040016class GrContext;
Robert Phillips009e9af2017-06-15 14:01:04 -040017class GrOpFlushState;
18
Brian Salomon82c263f2016-12-15 09:54:06 -050019class GrStencilPathOp final : public GrOp {
20public:
21 DEFINE_OP_CLASS_ID
22
Robert Phillips7c525e62018-06-12 10:11:12 -040023 static std::unique_ptr<GrOp> Make(GrContext* context,
24 const SkMatrix& viewMatrix,
Brian Salomonf8334782017-01-03 09:42:58 -050025 bool useHWAA,
26 GrPathRendering::FillType fillType,
27 bool hasStencilClip,
Brian Salomonf8334782017-01-03 09:42:58 -050028 const GrScissorState& scissor,
Robert Phillips7c525e62018-06-12 10:11:12 -040029 const GrPath* path);
Brian Salomon82c263f2016-12-15 09:54:06 -050030
31 const char* name() const override { return "StencilPathOp"; }
32
Brian Osman9a390ac2018-11-12 09:47:48 -050033#ifdef SK_DEBUG
Brian Salomon82c263f2016-12-15 09:54:06 -050034 SkString dumpInfo() const override {
35 SkString string;
Robert Phillipsb9a02a12017-04-06 11:08:40 -040036 string.printf("Path: 0x%p, AA: %d", fPath.get(), fUseHWAA);
Brian Salomon82c263f2016-12-15 09:54:06 -050037 string.append(INHERITED::dumpInfo());
38 return string;
39 }
Brian Osman9a390ac2018-11-12 09:47:48 -050040#endif
Brian Salomon82c263f2016-12-15 09:54:06 -050041
42private:
Robert Phillips7c525e62018-06-12 10:11:12 -040043 friend class GrOpMemoryPool; // for ctor
44
Brian Salomon82c263f2016-12-15 09:54:06 -050045 GrStencilPathOp(const SkMatrix& viewMatrix,
46 bool useHWAA,
47 GrPathRendering::FillType fillType,
48 bool hasStencilClip,
Brian Salomon82c263f2016-12-15 09:54:06 -050049 const GrScissorState& scissor,
Brian Salomon82c263f2016-12-15 09:54:06 -050050 const GrPath* path)
51 : INHERITED(ClassID())
52 , fViewMatrix(viewMatrix)
53 , fUseHWAA(useHWAA)
Robert Phillips65048132017-08-10 08:44:49 -040054 , fFillType(fillType)
55 , fHasStencilClip(hasStencilClip)
Brian Salomon82c263f2016-12-15 09:54:06 -050056 , fScissor(scissor)
Brian Salomon82c263f2016-12-15 09:54:06 -050057 , fPath(path) {
58 this->setBounds(path->getBounds(), HasAABloat::kNo, IsZeroArea::kNo);
59 }
60
Brian Salomon82c263f2016-12-15 09:54:06 -050061 void onPrepare(GrOpFlushState*) override {}
62
Brian Salomon588cec72018-11-14 13:56:37 -050063 void onExecute(GrOpFlushState*, const SkRect& chainBounds) override;
Brian Salomon82c263f2016-12-15 09:54:06 -050064
Robert Phillips2f4ddf62017-06-01 08:48:19 -040065 SkMatrix fViewMatrix;
66 bool fUseHWAA;
Robert Phillips65048132017-08-10 08:44:49 -040067 GrPathRendering::FillType fFillType;
68 bool fHasStencilClip;
Robert Phillips2f4ddf62017-06-01 08:48:19 -040069 GrScissorState fScissor;
70 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
Brian Salomon82c263f2016-12-15 09:54:06 -050071
72 typedef GrOp INHERITED;
73};
74
75#endif