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/gpu/GrDeferredUpload.h"
13#include "src/gpu/GrPipeline.h"
14#include "src/gpu/ops/GrOp.h"
15
16class GrAppliedClip;
17
18/**
19 * Base class for GrOps that draw. These ops can draw into an op list's GrRenderTarget.
20 */
21class GrDrawOp : public GrOp {
22public:
23 GrDrawOp(uint32_t classID) : INHERITED(classID) {}
24
25 /**
26 * This information is required to determine how to compute a GrAppliedClip from a GrClip for
27 * this op.
28 */
29 enum class FixedFunctionFlags : uint32_t {
30 kNone = 0x0,
31 /** Indices that the op will enable MSAA or mixed samples rendering. */
32 kUsesHWAA = 0x1,
33 /** Indices that the op reads and/or writes the stencil buffer */
34 kUsesStencil = 0x2,
35 };
36 GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(FixedFunctionFlags);
37 virtual FixedFunctionFlags fixedFunctionFlags() const = 0;
38
39 /**
40 * This is called after the GrAppliedClip has been computed and just prior to recording the op
41 * or combining it with a previously recorded op. The op should convert any proxies or resources
42 * it owns to "pending io" status so that resource allocation can be more optimal. Additionally,
43 * at this time the op must report whether a copy of the destination (or destination texture
44 * itself) needs to be provided to the GrXferProcessor when this op executes.
45 */
46 virtual GrProcessorSet::Analysis finalize(
47 const GrCaps&, const GrAppliedClip*, bool hasMixedSampledCoverage, GrClampType) = 0;
48
49#ifdef SK_DEBUG
50 bool fAddDrawOpCalled = false;
51
52 void validate() const override {
53 SkASSERT(fAddDrawOpCalled);
54 }
55#endif
56
57#if GR_TEST_UTILS
58 // This is really only intended for GrTextureOp and GrFillRectOp to override
59 virtual int numQuads() const { return -1; }
60#endif
61
62private:
63 typedef GrOp INHERITED;
64};
65
66GR_MAKE_BITFIELD_CLASS_OPS(GrDrawOp::FixedFunctionFlags);
67
68#endif
69