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 "GrDeferredUpload.h"
13#include "GrOp.h"
14#include "GrPipeline.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    enum class RequiresDstTexture : bool { kNo = false, kYes = true };
40    /**
41     * This is called after the GrAppliedClip has been computed and just prior to recording the op
42     * or combining it with a previously recorded op. The op should convert any proxies or resources
43     * it owns to "pending io" status so that resource allocation can be more optimal. Additionally,
44     * at this time the op must report whether a copy of the destination (or destination texture
45     * itself) needs to be provided to the GrXferProcessor when this op executes.
46     */
47    virtual RequiresDstTexture finalize(const GrCaps&, const GrAppliedClip*,
48                                        GrPixelConfigIsClamped) = 0;
49
50private:
51    typedef GrOp INHERITED;
52};
53
54GR_MAKE_BITFIELD_CLASS_OPS(GrDrawOp::FixedFunctionFlags);
55
56#endif
57