Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrDrawOp.h
Go to the documentation of this file.
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 GrDrawOp_DEFINED
9#define GrDrawOp_DEFINED
10
11#include <functional>
12#include "src/core/SkAAClip.h"
13#include "src/core/SkIPoint16.h"
17
18class GrAppliedClip;
19namespace skgpu {
20namespace ganesh {
22}
23} // namespace skgpu
24class GrShape;
25
26/**
27 * Base class for GrOps that draw. These ops can draw into an op list's GrRenderTarget.
28 */
29class GrDrawOp : public GrOp {
30public:
32
33 /**
34 * Called before setting up the GrAppliedClip and before finalize. This information is required
35 * to determine how to compute a GrAppliedClip from a GrClip for this op.
36 */
37 virtual bool usesMSAA() const {
39 }
40
41 /**
42 * Specifies the effect of clipToShape().
43 */
44 enum class ClipResult {
45 // No clip was applied.
46 kFail,
47 // The clip was applied to the op's actual geometry. The clip stack is free to disable the
48 // scissor test.
50 // The clip was applied via shader coverage. The clip stack will still use a scissor test
51 // in order to reduce overdraw of transparent pixels.
53 // The op can be thrown out entirely.
55 };
56
57 /**
58 * This is called while the clip is being computed, before finalize(), and before any attempts
59 * to combine with other ops. If the op knows how to clip its own geometry then it will
60 * generally be much faster than a generalized clip method.
61 */
64 const SkMatrix& /* clipMatrix */,
65 const GrShape&,
66 GrAA) {
67 return ClipResult::kFail;
68 }
69
70 /**
71 * This is called after the GrAppliedClip has been computed and just prior to recording the op
72 * or combining it with a previously recorded op. The op should convert any proxies or resources
73 * it owns to "pending io" status so that resource allocation can be more optimal. Additionally,
74 * at this time the op must report whether a copy of the destination (or destination texture
75 * itself) needs to be provided to the GrXferProcessor when this op executes.
76 */
78
79 /**
80 * Called after finalize, at which point every op should know whether it will need stencil.
81 */
82 virtual bool usesStencil() const {
84 }
85
86#ifdef SK_DEBUG
87 bool fAddDrawOpCalled = false;
88
89 void validate() const override {
90 SkASSERT(fAddDrawOpCalled);
91 }
92#endif
93
94#if defined(GR_TEST_UTILS)
95 // This is really only intended for TextureOp and FillRectOp to override
96 virtual int numQuads() const { return -1; }
97#endif
98
99protected:
100 /**
101 * DEPRECATED: This is a legacy implementation for usesMSAA() and usesStencil(). Newer ops
102 * should override those methods directly.
103 */
104 enum class FixedFunctionFlags : uint32_t {
105 kNone = 0x0,
106 /** Indices that the op will enable MSAA. */
107 kUsesHWAA = 0x1,
108 /** Indices that the op reads and/or writes the stencil buffer */
109 kUsesStencil = 0x2,
110 };
113 // Override usesMSAA() and usesStencil() instead.
114 SK_ABORT("fixedFunctionFlags() not implemented.");
115 }
116
117private:
118 friend class GrSimpleMeshDrawOpHelper; // For FixedFunctionFlags.
119 friend class GrSimpleMeshDrawOpHelperWithStencil; // For FixedFunctionFlags.
120
121 using INHERITED = GrOp;
122};
123
125
126#endif
GrClampType
GrAA
#define GR_MAKE_BITFIELD_CLASS_OPS(X)
Definition GrTypes.h:42
#define SK_ABORT(message,...)
Definition SkAssert.h:70
#define SkASSERT(cond)
Definition SkAssert.h:116
SkClipOp
Definition SkClipOp.h:13
virtual FixedFunctionFlags fixedFunctionFlags() const
Definition GrDrawOp.h:112
virtual bool usesMSAA() const
Definition GrDrawOp.h:37
virtual GrProcessorSet::Analysis finalize(const GrCaps &, const GrAppliedClip *, GrClampType)=0
virtual bool usesStencil() const
Definition GrDrawOp.h:82
virtual ClipResult clipToShape(skgpu::ganesh::SurfaceDrawContext *, SkClipOp, const SkMatrix &, const GrShape &, GrAA)
Definition GrDrawOp.h:62
GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(FixedFunctionFlags)
GrDrawOp(uint32_t classID)
Definition GrDrawOp.h:31
FixedFunctionFlags
Definition GrDrawOp.h:104
Definition GrOp.h:70
uint32_t classID() const
Definition GrOp.h:158