blob: 7295b3b86175a188206576de0ddb5f0b468929b1 [file] [log] [blame]
bsalomon16b99132015-08-13 14:55:50 -07001/*
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
Brian Salomon53e4c3c2016-12-21 11:38:53 -05008#ifndef GrDrawOp_DEFINED
9#define GrDrawOp_DEFINED
bsalomon16b99132015-08-13 14:55:50 -070010
bsalomon342bfc22016-04-01 06:06:20 -070011#include <functional>
Brian Salomon943ed792017-10-30 09:37:55 -040012#include "GrDeferredUpload.h"
Brian Salomon25a88092016-12-01 09:36:50 -050013#include "GrOp.h"
bsalomon16b99132015-08-13 14:55:50 -070014#include "GrPipeline.h"
15
Brian Salomon54d212e2017-03-21 14:22:38 -040016class GrAppliedClip;
17
bsalomon16b99132015-08-13 14:55:50 -070018/**
Brian Salomon29b60c92017-10-31 14:42:10 -040019 * Base class for GrOps that draw. These ops can draw into an op list's GrRenderTarget.
bsalomon16b99132015-08-13 14:55:50 -070020 */
Brian Salomon9afd3712016-12-01 10:59:09 -050021class GrDrawOp : public GrOp {
bsalomon16b99132015-08-13 14:55:50 -070022public:
Brian Salomonb5cb6832017-02-24 11:01:15 -050023 GrDrawOp(uint32_t classID) : INHERITED(classID) {}
bsalomon16b99132015-08-13 14:55:50 -070024
Brian Salomon54d212e2017-03-21 14:22:38 -040025 /**
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;
bsalomon16b99132015-08-13 14:55:50 -070038
Brian Salomonf86d37b2017-06-16 10:04:34 -040039 enum class RequiresDstTexture : bool { kNo = false, kYes = true };
Brian Salomon5298dc82017-02-22 11:52:03 -050040 /**
Brian Salomon54d212e2017-03-21 14:22:38 -040041 * This is called after the GrAppliedClip has been computed and just prior to recording the op
Brian Salomonf86d37b2017-06-16 10:04:34 -040042 * 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.
Brian Salomon5298dc82017-02-22 11:52:03 -050046 */
Brian Osman532b3f92018-07-11 10:02:07 -040047 virtual RequiresDstTexture finalize(const GrCaps&, const GrAppliedClip*) = 0;
Brian Salomon5298dc82017-02-22 11:52:03 -050048
bsalomon75398562015-08-17 12:55:38 -070049private:
Brian Salomon25a88092016-12-01 09:36:50 -050050 typedef GrOp INHERITED;
bsalomon16b99132015-08-13 14:55:50 -070051};
52
Brian Salomon54d212e2017-03-21 14:22:38 -040053GR_MAKE_BITFIELD_CLASS_OPS(GrDrawOp::FixedFunctionFlags);
54
bsalomon16b99132015-08-13 14:55:50 -070055#endif