1/*
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
11#include "src/gpu/GrPath.h"
12#include "src/gpu/GrPathRendering.h"
13#include "src/gpu/GrScissorState.h"
14#include "src/gpu/GrStencilSettings.h"
15#include "src/gpu/ops/GrOp.h"
16
17class GrOpFlushState;
18class GrRecordingContext;
19
20class GrStencilPathOp final : public GrOp {
21public:
22 DEFINE_OP_CLASS_ID
23
24 static std::unique_ptr<GrOp> Make(GrRecordingContext* context,
25 const SkMatrix& viewMatrix,
26 bool useHWAA,
27 bool hasStencilClip,
28 const GrScissorState& scissor,
29 sk_sp<const GrPath> path);
30
31 const char* name() const override { return "StencilPathOp"; }
32
33private:
34 friend class GrOpMemoryPool; // for ctor
35
36 GrStencilPathOp(const SkMatrix& viewMatrix,
37 bool useHWAA,
38 bool hasStencilClip,
39 const GrScissorState& scissor,
40 sk_sp<const GrPath> path)
41 : INHERITED(ClassID())
42 , fViewMatrix(viewMatrix)
43 , fUseHWAA(useHWAA)
44 , fHasStencilClip(hasStencilClip)
45 , fScissor(scissor)
46 , fPath(std::move(path)) {
47 this->setBounds(fPath->getBounds(), HasAABloat::kNo, IsHairline::kNo);
48 }
49
50 void onPrePrepare(GrRecordingContext*,
51 const GrSurfaceProxyView* writeView,
52 GrAppliedClip*,
53 const GrXferProcessor::DstProxyView&) override {}
54
55 void onPrepare(GrOpFlushState*) override {}
56
57 void onExecute(GrOpFlushState*, const SkRect& chainBounds) override;
58
59#if GR_TEST_UTILS
60 SkString onDumpInfo() const override {
61 return SkStringPrintf("Path: 0x%p, AA: %d", fPath.get(), fUseHWAA);
62 }
63#endif
64
65 SkMatrix fViewMatrix;
66 bool fUseHWAA;
67 bool fHasStencilClip;
68 GrScissorState fScissor;
69 sk_sp<const GrPath> fPath;
70
71 typedef GrOp INHERITED;
72};
73
74#endif
75