blob: da541327de36a307e79bded5c8ebae658076aeb2 [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 Salomon5298dc82017-02-22 11:52:03 -050039 /**
Brian Salomon54d212e2017-03-21 14:22:38 -040040 * This is called after the GrAppliedClip has been computed and just prior to recording the op
Brian Salomonf86d37b2017-06-16 10:04:34 -040041 * 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.
Brian Salomon5298dc82017-02-22 11:52:03 -050045 */
Chris Dalton4b62aed2019-01-15 11:53:00 -070046 virtual GrProcessorSet::Analysis finalize(const GrCaps&, const GrAppliedClip*) = 0;
Brian Salomon5298dc82017-02-22 11:52:03 -050047
Ethan Nicholas029b22c2018-10-18 16:49:56 -040048#ifdef SK_DEBUG
49 bool fAddDrawOpCalled = false;
50
51 void validate() const override {
52 SkASSERT(fAddDrawOpCalled);
53 }
54#endif
55
bsalomon75398562015-08-17 12:55:38 -070056private:
Brian Salomon25a88092016-12-01 09:36:50 -050057 typedef GrOp INHERITED;
bsalomon16b99132015-08-13 14:55:50 -070058};
59
Brian Salomon54d212e2017-03-21 14:22:38 -040060GR_MAKE_BITFIELD_CLASS_OPS(GrDrawOp::FixedFunctionFlags);
61
bsalomon16b99132015-08-13 14:55:50 -070062#endif