blob: 958c5c06de44a7a20508dd5b7606ef21898095b6 [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "src/gpu/GrPath.h"
12#include "src/gpu/GrPathRendering.h"
13#include "src/gpu/GrStencilSettings.h"
14#include "src/gpu/ops/GrOp.h"
Brian Salomon82c263f2016-12-15 09:54:06 -050015
Robert Phillips009e9af2017-06-15 14:01:04 -040016class GrOpFlushState;
Robert Phillipsb97da532019-02-12 15:24:12 -050017class GrRecordingContext;
Robert Phillips009e9af2017-06-15 14:01:04 -040018
Brian Salomon82c263f2016-12-15 09:54:06 -050019class GrStencilPathOp final : public GrOp {
20public:
21 DEFINE_OP_CLASS_ID
22
Robert Phillipsb97da532019-02-12 15:24:12 -050023 static std::unique_ptr<GrOp> Make(GrRecordingContext* context,
Robert Phillips7c525e62018-06-12 10:11:12 -040024 const SkMatrix& viewMatrix,
Brian Salomonf8334782017-01-03 09:42:58 -050025 bool useHWAA,
Brian Salomonf8334782017-01-03 09:42:58 -050026 bool hasStencilClip,
Brian Salomonf8334782017-01-03 09:42:58 -050027 const GrScissorState& scissor,
Robert Phillipse1efd382019-08-21 10:07:10 -040028 sk_sp<const GrPath> path);
Brian Salomon82c263f2016-12-15 09:54:06 -050029
30 const char* name() const override { return "StencilPathOp"; }
31
Brian Osman9a390ac2018-11-12 09:47:48 -050032#ifdef SK_DEBUG
Brian Salomon82c263f2016-12-15 09:54:06 -050033 SkString dumpInfo() const override {
34 SkString string;
Robert Phillipsb9a02a12017-04-06 11:08:40 -040035 string.printf("Path: 0x%p, AA: %d", fPath.get(), fUseHWAA);
Brian Salomon82c263f2016-12-15 09:54:06 -050036 string.append(INHERITED::dumpInfo());
37 return string;
38 }
Brian Osman9a390ac2018-11-12 09:47:48 -050039#endif
Brian Salomon82c263f2016-12-15 09:54:06 -050040
41private:
Robert Phillips7c525e62018-06-12 10:11:12 -040042 friend class GrOpMemoryPool; // for ctor
43
Brian Salomon82c263f2016-12-15 09:54:06 -050044 GrStencilPathOp(const SkMatrix& viewMatrix,
45 bool useHWAA,
Brian Salomon82c263f2016-12-15 09:54:06 -050046 bool hasStencilClip,
Brian Salomon82c263f2016-12-15 09:54:06 -050047 const GrScissorState& scissor,
Robert Phillipse1efd382019-08-21 10:07:10 -040048 sk_sp<const GrPath> path)
Brian Salomon82c263f2016-12-15 09:54:06 -050049 : INHERITED(ClassID())
50 , fViewMatrix(viewMatrix)
51 , fUseHWAA(useHWAA)
Robert Phillips65048132017-08-10 08:44:49 -040052 , fHasStencilClip(hasStencilClip)
Brian Salomon82c263f2016-12-15 09:54:06 -050053 , fScissor(scissor)
Robert Phillipse1efd382019-08-21 10:07:10 -040054 , fPath(std::move(path)) {
55 this->setBounds(fPath->getBounds(), HasAABloat::kNo, IsZeroArea::kNo);
Brian Salomon82c263f2016-12-15 09:54:06 -050056 }
57
Brian Salomon82c263f2016-12-15 09:54:06 -050058 void onPrepare(GrOpFlushState*) override {}
59
Brian Salomon588cec72018-11-14 13:56:37 -050060 void onExecute(GrOpFlushState*, const SkRect& chainBounds) override;
Brian Salomon82c263f2016-12-15 09:54:06 -050061
Robert Phillipse1efd382019-08-21 10:07:10 -040062 SkMatrix fViewMatrix;
63 bool fUseHWAA;
64 bool fHasStencilClip;
65 GrScissorState fScissor;
66 sk_sp<const GrPath> fPath;
Brian Salomon82c263f2016-12-15 09:54:06 -050067
68 typedef GrOp INHERITED;
69};
70
71#endif