egdaniel | 378092f | 2014-12-03 10:40:13 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 GrXferProcessor_DEFINED |
| 9 | #define GrXferProcessor_DEFINED |
| 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/gpu/GrTypes.h" |
Brian Salomon | 096b091 | 2019-08-14 16:56:13 -0400 | [diff] [blame] | 12 | #include "src/gpu/GrBlend.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "src/gpu/GrNonAtomicRef.h" |
| 14 | #include "src/gpu/GrProcessor.h" |
| 15 | #include "src/gpu/GrProcessorAnalysis.h" |
egdaniel | 378092f | 2014-12-03 10:40:13 -0800 | [diff] [blame] | 16 | |
egdaniel | fa4cc8b | 2015-11-13 08:34:52 -0800 | [diff] [blame] | 17 | class GrGLSLXferProcessor; |
Hal Canary | ce78bad | 2017-05-04 14:15:40 -0400 | [diff] [blame] | 18 | class GrProcessorSet; |
| 19 | class GrShaderCaps; |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 20 | |
egdaniel | 378092f | 2014-12-03 10:40:13 -0800 | [diff] [blame] | 21 | /** |
cdalton | 9954bc3 | 2015-04-29 14:17:00 -0700 | [diff] [blame] | 22 | * Barriers for blending. When a shader reads the dst directly, an Xfer barrier is sometimes |
| 23 | * required after a pixel has been written, before it can be safely read again. |
| 24 | */ |
| 25 | enum GrXferBarrierType { |
bsalomon | cb02b38 | 2015-08-12 11:14:50 -0700 | [diff] [blame] | 26 | kNone_GrXferBarrierType = 0, //<! No barrier is required |
| 27 | kTexture_GrXferBarrierType, //<! Required when a shader reads and renders to the same texture. |
| 28 | kBlend_GrXferBarrierType, //<! Required by certain blend extensions. |
cdalton | 9954bc3 | 2015-04-29 14:17:00 -0700 | [diff] [blame] | 29 | }; |
bsalomon | cb02b38 | 2015-08-12 11:14:50 -0700 | [diff] [blame] | 30 | /** Should be able to treat kNone as false in boolean expressions */ |
| 31 | GR_STATIC_ASSERT(SkToBool(kNone_GrXferBarrierType) == false); |
cdalton | 9954bc3 | 2015-04-29 14:17:00 -0700 | [diff] [blame] | 32 | |
| 33 | /** |
egdaniel | 378092f | 2014-12-03 10:40:13 -0800 | [diff] [blame] | 34 | * GrXferProcessor is responsible for implementing the xfer mode that blends the src color and dst |
cdalton | edbb31f | 2015-06-08 12:14:44 -0700 | [diff] [blame] | 35 | * color, and for applying any coverage. It does this by emitting fragment shader code and |
| 36 | * controlling the fixed-function blend state. When dual-source blending is available, it may also |
| 37 | * write a seconday fragment shader output color. GrXferProcessor has two modes of operation: |
| 38 | * |
| 39 | * Dst read: When allowed by the backend API, or when supplied a texture of the destination, the |
| 40 | * GrXferProcessor may read the destination color. While operating in this mode, the subclass only |
| 41 | * provides shader code that blends the src and dst colors, and the base class applies coverage. |
| 42 | * |
| 43 | * No dst read: When not performing a dst read, the subclass is given full control of the fixed- |
| 44 | * function blend state and/or secondary output, and is responsible to apply coverage on its own. |
egdaniel | 378092f | 2014-12-03 10:40:13 -0800 | [diff] [blame] | 45 | * |
| 46 | * A GrXferProcessor is never installed directly into our draw state, but instead is created from a |
| 47 | * GrXPFactory once we have finalized the state of our draw. |
| 48 | */ |
Brian Salomon | d61c9d9 | 2017-04-10 10:54:25 -0400 | [diff] [blame] | 49 | class GrXferProcessor : public GrProcessor, public GrNonAtomicRef<GrXferProcessor> { |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 50 | public: |
| 51 | /** |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 52 | * A texture that contains the dst pixel values and an integer coord offset from device space |
| 53 | * to the space of the texture. Depending on GPU capabilities a DstTexture may be used by a |
| 54 | * GrXferProcessor for blending in the fragment shader. |
| 55 | */ |
Robert Phillips | bb581ce | 2017-05-29 15:05:15 -0400 | [diff] [blame] | 56 | class DstProxy { |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 57 | public: |
Robert Phillips | bb581ce | 2017-05-29 15:05:15 -0400 | [diff] [blame] | 58 | DstProxy() { fOffset.set(0, 0); } |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 59 | |
Robert Phillips | bb581ce | 2017-05-29 15:05:15 -0400 | [diff] [blame] | 60 | DstProxy(const DstProxy& other) { |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 61 | *this = other; |
| 62 | } |
| 63 | |
Robert Phillips | bb581ce | 2017-05-29 15:05:15 -0400 | [diff] [blame] | 64 | DstProxy(sk_sp<GrTextureProxy> proxy, const SkIPoint& offset) |
| 65 | : fProxy(std::move(proxy)) { |
| 66 | if (fProxy) { |
| 67 | fOffset = offset; |
| 68 | } else { |
| 69 | fOffset.set(0, 0); |
| 70 | } |
| 71 | } |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 72 | |
Robert Phillips | bb581ce | 2017-05-29 15:05:15 -0400 | [diff] [blame] | 73 | DstProxy& operator=(const DstProxy& other) { |
| 74 | fProxy = other.fProxy; |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 75 | fOffset = other.fOffset; |
| 76 | return *this; |
| 77 | } |
| 78 | |
Robert Phillips | bb581ce | 2017-05-29 15:05:15 -0400 | [diff] [blame] | 79 | bool operator==(const DstProxy& that) const { |
| 80 | return fProxy == that.fProxy && fOffset == that.fOffset; |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 81 | } |
Robert Phillips | bb581ce | 2017-05-29 15:05:15 -0400 | [diff] [blame] | 82 | bool operator!=(const DstProxy& that) const { return !(*this == that); } |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 83 | |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 84 | const SkIPoint& offset() const { return fOffset; } |
| 85 | |
| 86 | void setOffset(const SkIPoint& offset) { fOffset = offset; } |
| 87 | void setOffset(int ox, int oy) { fOffset.set(ox, oy); } |
| 88 | |
Robert Phillips | bb581ce | 2017-05-29 15:05:15 -0400 | [diff] [blame] | 89 | GrTextureProxy* proxy() const { return fProxy.get(); } |
Robert Phillips | 80bff5b | 2019-08-20 16:56:18 -0400 | [diff] [blame] | 90 | sk_sp<GrTextureProxy> refProxy() const { return fProxy; } |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 91 | |
Robert Phillips | bb581ce | 2017-05-29 15:05:15 -0400 | [diff] [blame] | 92 | void setProxy(sk_sp<GrTextureProxy> proxy) { |
| 93 | fProxy = std::move(proxy); |
| 94 | if (!fProxy) { |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 95 | fOffset = {0, 0}; |
| 96 | } |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | private: |
Robert Phillips | bb581ce | 2017-05-29 15:05:15 -0400 | [diff] [blame] | 100 | sk_sp<GrTextureProxy> fProxy; |
| 101 | SkIPoint fOffset; |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 102 | }; |
| 103 | |
| 104 | /** |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 105 | * Sets a unique key on the GrProcessorKeyBuilder calls onGetGLSLProcessorKey(...) to get the |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 106 | * specific subclass's key. |
Brian Salomon | 18dfa98 | 2017-04-03 16:57:43 -0400 | [diff] [blame] | 107 | */ |
| 108 | void getGLSLProcessorKey(const GrShaderCaps&, |
| 109 | GrProcessorKeyBuilder*, |
| 110 | const GrSurfaceOrigin* originIfDstTexture) const; |
egdaniel | c230414 | 2014-12-11 13:15:13 -0800 | [diff] [blame] | 111 | |
| 112 | /** Returns a new instance of the appropriate *GL* implementation class |
| 113 | for the given GrXferProcessor; caller is responsible for deleting |
| 114 | the object. */ |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 115 | virtual GrGLSLXferProcessor* createGLSLInstance() const = 0; |
egdaniel | c230414 | 2014-12-11 13:15:13 -0800 | [diff] [blame] | 116 | |
| 117 | /** |
Brian Salomon | 18dfa98 | 2017-04-03 16:57:43 -0400 | [diff] [blame] | 118 | * Returns the barrier type, if any, that this XP will require. Note that the possibility |
| 119 | * that a kTexture type barrier is required is handled by the GrPipeline and need not be |
| 120 | * considered by subclass overrides of this function. |
cdalton | 9954bc3 | 2015-04-29 14:17:00 -0700 | [diff] [blame] | 121 | */ |
Brian Salomon | 18dfa98 | 2017-04-03 16:57:43 -0400 | [diff] [blame] | 122 | virtual GrXferBarrierType xferBarrierType(const GrCaps& caps) const { |
| 123 | return kNone_GrXferBarrierType; |
| 124 | } |
cdalton | 9954bc3 | 2015-04-29 14:17:00 -0700 | [diff] [blame] | 125 | |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 126 | struct BlendInfo { |
bsalomon | f7cc877 | 2015-05-11 11:21:14 -0700 | [diff] [blame] | 127 | SkDEBUGCODE(SkString dump() const;) |
| 128 | |
Chris Dalton | bbb3f64 | 2019-07-24 12:25:08 -0400 | [diff] [blame] | 129 | GrBlendEquation fEquation = kAdd_GrBlendEquation; |
| 130 | GrBlendCoeff fSrcBlend = kOne_GrBlendCoeff; |
| 131 | GrBlendCoeff fDstBlend = kZero_GrBlendCoeff; |
| 132 | SkPMColor4f fBlendConstant = SK_PMColor4fTRANSPARENT; |
| 133 | bool fWriteColor = true; |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 134 | }; |
| 135 | |
Chris Dalton | bbb3f64 | 2019-07-24 12:25:08 -0400 | [diff] [blame] | 136 | inline BlendInfo getBlendInfo() const { |
| 137 | BlendInfo blendInfo; |
| 138 | if (!this->willReadDstColor()) { |
| 139 | this->onGetBlendInfo(&blendInfo); |
| 140 | } else if (this->dstReadUsesMixedSamples()) { |
| 141 | blendInfo.fDstBlend = kIS2A_GrBlendCoeff; |
| 142 | } |
| 143 | return blendInfo; |
| 144 | } |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 145 | |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 146 | bool willReadDstColor() const { return fWillReadDstColor; } |
| 147 | |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 148 | /** |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 149 | * If we are performing a dst read, returns whether the base class will use mixed samples to |
| 150 | * antialias the shader's final output. If not doing a dst read, the subclass is responsible |
| 151 | * for antialiasing and this returns false. |
| 152 | */ |
| 153 | bool dstReadUsesMixedSamples() const { return fDstReadUsesMixedSamples; } |
| 154 | |
| 155 | /** |
egdaniel | c230414 | 2014-12-11 13:15:13 -0800 | [diff] [blame] | 156 | * Returns whether or not this xferProcossor will set a secondary output to be used with dual |
| 157 | * source blending. |
| 158 | */ |
cdalton | edbb31f | 2015-06-08 12:14:44 -0700 | [diff] [blame] | 159 | bool hasSecondaryOutput() const; |
egdaniel | c230414 | 2014-12-11 13:15:13 -0800 | [diff] [blame] | 160 | |
Greg Daniel | 6ebe4b9 | 2017-05-19 10:56:46 -0400 | [diff] [blame] | 161 | bool isLCD() const { return fIsLCD; } |
| 162 | |
egdaniel | c230414 | 2014-12-11 13:15:13 -0800 | [diff] [blame] | 163 | /** Returns true if this and other processor conservatively draw identically. It can only return |
| 164 | true when the two processor are of the same subclass (i.e. they return the same object from |
| 165 | from getFactory()). |
| 166 | |
| 167 | A return value of true from isEqual() should not be used to test whether the processor would |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 168 | generate the same shader code. To test for identical code generation use getGLSLProcessorKey |
| 169 | */ |
Greg Daniel | 6ebe4b9 | 2017-05-19 10:56:46 -0400 | [diff] [blame] | 170 | |
egdaniel | c230414 | 2014-12-11 13:15:13 -0800 | [diff] [blame] | 171 | bool isEqual(const GrXferProcessor& that) const { |
| 172 | if (this->classID() != that.classID()) { |
| 173 | return false; |
| 174 | } |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 175 | if (this->fWillReadDstColor != that.fWillReadDstColor) { |
| 176 | return false; |
| 177 | } |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 178 | if (this->fDstReadUsesMixedSamples != that.fDstReadUsesMixedSamples) { |
| 179 | return false; |
| 180 | } |
Greg Daniel | 6ebe4b9 | 2017-05-19 10:56:46 -0400 | [diff] [blame] | 181 | if (fIsLCD != that.fIsLCD) { |
| 182 | return false; |
| 183 | } |
egdaniel | c230414 | 2014-12-11 13:15:13 -0800 | [diff] [blame] | 184 | return this->onIsEqual(that); |
| 185 | } |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 186 | |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 187 | protected: |
Ethan Nicholas | abff956 | 2017-10-09 10:54:08 -0400 | [diff] [blame] | 188 | GrXferProcessor(ClassID classID); |
| 189 | GrXferProcessor(ClassID classID, bool willReadDstColor, bool hasMixedSamples, |
| 190 | GrProcessorAnalysisCoverage); |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 191 | |
egdaniel | 378092f | 2014-12-03 10:40:13 -0800 | [diff] [blame] | 192 | private: |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 193 | /** |
| 194 | * Sets a unique key on the GrProcessorKeyBuilder that is directly associated with this xfer |
| 195 | * processor's GL backend implementation. |
| 196 | */ |
Brian Salomon | 94efbf5 | 2016-11-29 13:43:05 -0500 | [diff] [blame] | 197 | virtual void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const = 0; |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 198 | |
cdalton | f4f2b44 | 2015-04-23 09:40:23 -0700 | [diff] [blame] | 199 | /** |
cdalton | edbb31f | 2015-06-08 12:14:44 -0700 | [diff] [blame] | 200 | * If we are not performing a dst read, returns whether the subclass will set a secondary |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 201 | * output. When using dst reads, the base class controls the secondary output and this method |
cdalton | edbb31f | 2015-06-08 12:14:44 -0700 | [diff] [blame] | 202 | * will not be called. |
| 203 | */ |
| 204 | virtual bool onHasSecondaryOutput() const { return false; } |
| 205 | |
| 206 | /** |
| 207 | * If we are not performing a dst read, retrieves the fixed-function blend state required by the |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 208 | * subclass. When using dst reads, the base class controls the fixed-function blend state and |
| 209 | * this method will not be called. The BlendInfo struct comes initialized to "no blending". |
cdalton | f4f2b44 | 2015-04-23 09:40:23 -0700 | [diff] [blame] | 210 | */ |
| 211 | virtual void onGetBlendInfo(BlendInfo*) const {} |
| 212 | |
egdaniel | c230414 | 2014-12-11 13:15:13 -0800 | [diff] [blame] | 213 | virtual bool onIsEqual(const GrXferProcessor&) const = 0; |
egdaniel | 378092f | 2014-12-03 10:40:13 -0800 | [diff] [blame] | 214 | |
Greg Daniel | 6ebe4b9 | 2017-05-19 10:56:46 -0400 | [diff] [blame] | 215 | bool fWillReadDstColor; |
| 216 | bool fDstReadUsesMixedSamples; |
| 217 | bool fIsLCD; |
egdaniel | 9513143 | 2014-12-09 11:15:43 -0800 | [diff] [blame] | 218 | |
Ethan Nicholas | abff956 | 2017-10-09 10:54:08 -0400 | [diff] [blame] | 219 | typedef GrProcessor INHERITED; |
egdaniel | 378092f | 2014-12-03 10:40:13 -0800 | [diff] [blame] | 220 | }; |
| 221 | |
| 222 | /** |
| 223 | * We install a GrXPFactory (XPF) early on in the pipeline before all the final draw information is |
| 224 | * known (e.g. whether there is fractional pixel coverage, will coverage be 1 or 4 channel, is the |
| 225 | * draw opaque, etc.). Once the state of the draw is finalized, we use the XPF along with all the |
| 226 | * draw information to create a GrXferProcessor (XP) which can implement the desired blending for |
| 227 | * the draw. |
| 228 | * |
| 229 | * Before the XP is created, the XPF is able to answer queries about what functionality the XPs it |
| 230 | * creates will have. For example, can it create an XP that supports RGB coverage or will the XP |
| 231 | * blend with the destination color. |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 232 | * |
| 233 | * GrXPFactories are intended to be static immutable objects. We pass them around as raw pointers |
| 234 | * and expect the pointers to always be valid and for the factories to be reusable and thread safe. |
| 235 | * Equality is tested for using pointer comparison. GrXPFactory destructors must be no-ops. |
egdaniel | 378092f | 2014-12-03 10:40:13 -0800 | [diff] [blame] | 236 | */ |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 237 | |
| 238 | // In order to construct GrXPFactory subclass instances as constexpr the subclass, and therefore |
| 239 | // GrXPFactory, must be a literal type. One requirement is having a trivial destructor. This is ok |
| 240 | // since these objects have no need for destructors. However, GCC and clang throw a warning when a |
| 241 | // class has virtual functions and a non-virtual destructor. We suppress that warning here and |
| 242 | // for the subclasses. |
Chris Dalton | 1ef8094 | 2017-12-04 12:01:30 -0700 | [diff] [blame] | 243 | #if defined(__GNUC__) |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 244 | #pragma GCC diagnostic push |
| 245 | #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" |
| 246 | #endif |
Chris Dalton | 1ef8094 | 2017-12-04 12:01:30 -0700 | [diff] [blame] | 247 | #if defined(__clang__) |
| 248 | #pragma clang diagnostic push |
| 249 | #pragma clang diagnostic ignored "-Wnon-virtual-dtor" |
| 250 | #endif |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 251 | class GrXPFactory { |
egdaniel | 378092f | 2014-12-03 10:40:13 -0800 | [diff] [blame] | 252 | public: |
Robert Phillips | bb581ce | 2017-05-29 15:05:15 -0400 | [diff] [blame] | 253 | typedef GrXferProcessor::DstProxy DstProxy; |
Brian Salomon | 5be6c95 | 2017-01-20 19:06:29 +0000 | [diff] [blame] | 254 | |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 255 | enum class AnalysisProperties : unsigned { |
| 256 | kNone = 0x0, |
Brian Salomon | 4fc7740 | 2017-03-30 16:48:26 -0400 | [diff] [blame] | 257 | /** |
| 258 | * The fragment shader will require the destination color. |
| 259 | */ |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 260 | kReadsDstInShader = 0x1, |
Brian Salomon | 4fc7740 | 2017-03-30 16:48:26 -0400 | [diff] [blame] | 261 | /** |
| 262 | * The op may apply coverage as alpha and still blend correctly. |
| 263 | */ |
Brian Osman | 605c6d5 | 2019-03-15 12:10:35 -0400 | [diff] [blame] | 264 | kCompatibleWithCoverageAsAlpha = 0x2, |
Brian Salomon | 4fc7740 | 2017-03-30 16:48:26 -0400 | [diff] [blame] | 265 | /** |
| 266 | * The color input to the GrXferProcessor will be ignored. |
| 267 | */ |
| 268 | kIgnoresInputColor = 0x4, |
| 269 | /** |
Brian Salomon | 4fc7740 | 2017-03-30 16:48:26 -0400 | [diff] [blame] | 270 | * The destination color will be provided to the fragment processor using a texture. This is |
| 271 | * additional information about the implementation of kReadsDstInShader. |
| 272 | */ |
| 273 | kRequiresDstTexture = 0x10, |
| 274 | /** |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 275 | * If set, each pixel can only be touched once during a draw (e.g., because we have a dst |
| 276 | * texture or because we need an xfer barrier). |
Brian Salomon | 4fc7740 | 2017-03-30 16:48:26 -0400 | [diff] [blame] | 277 | */ |
Chris Dalton | 945ee65 | 2019-01-23 09:10:36 -0700 | [diff] [blame] | 278 | kRequiresNonOverlappingDraws = 0x20, |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 279 | }; |
| 280 | GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(AnalysisProperties); |
egdaniel | 080e673 | 2014-12-22 07:35:52 -0800 | [diff] [blame] | 281 | |
Brian Salomon | d61c9d9 | 2017-04-10 10:54:25 -0400 | [diff] [blame] | 282 | static sk_sp<const GrXferProcessor> MakeXferProcessor(const GrXPFactory*, |
| 283 | const GrProcessorAnalysisColor&, |
| 284 | GrProcessorAnalysisCoverage, |
| 285 | bool hasMixedSamples, |
Brian Osman | 5ced0bf | 2019-03-15 10:15:29 -0400 | [diff] [blame] | 286 | const GrCaps& caps, |
| 287 | GrClampType); |
Brian Salomon | a076d87 | 2017-04-04 15:17:03 -0400 | [diff] [blame] | 288 | |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 289 | static AnalysisProperties GetAnalysisProperties(const GrXPFactory*, |
Brian Salomon | a811b12 | 2017-03-30 08:21:32 -0400 | [diff] [blame] | 290 | const GrProcessorAnalysisColor&, |
| 291 | const GrProcessorAnalysisCoverage&, |
Brian Osman | 5ced0bf | 2019-03-15 10:15:29 -0400 | [diff] [blame] | 292 | const GrCaps&, |
| 293 | GrClampType); |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 294 | |
egdaniel | 915187b | 2014-12-05 12:58:28 -0800 | [diff] [blame] | 295 | protected: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 296 | constexpr GrXPFactory() {} |
egdaniel | 915187b | 2014-12-05 12:58:28 -0800 | [diff] [blame] | 297 | |
egdaniel | 378092f | 2014-12-03 10:40:13 -0800 | [diff] [blame] | 298 | private: |
Brian Salomon | d61c9d9 | 2017-04-10 10:54:25 -0400 | [diff] [blame] | 299 | virtual sk_sp<const GrXferProcessor> makeXferProcessor(const GrProcessorAnalysisColor&, |
| 300 | GrProcessorAnalysisCoverage, |
| 301 | bool hasMixedSamples, |
Brian Osman | 5ced0bf | 2019-03-15 10:15:29 -0400 | [diff] [blame] | 302 | const GrCaps&, |
| 303 | GrClampType) const = 0; |
ethannicholas | 2279325 | 2016-01-30 09:59:10 -0800 | [diff] [blame] | 304 | |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 305 | /** |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 306 | * Subclass analysis implementation. This should not return kNeedsDstInTexture as that will be |
| 307 | * inferred by the base class based on kReadsDstInShader and the caps. |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 308 | */ |
Brian Salomon | a811b12 | 2017-03-30 08:21:32 -0400 | [diff] [blame] | 309 | virtual AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&, |
| 310 | const GrProcessorAnalysisCoverage&, |
Brian Osman | 5ced0bf | 2019-03-15 10:15:29 -0400 | [diff] [blame] | 311 | const GrCaps&, |
| 312 | GrClampType) const = 0; |
egdaniel | 378092f | 2014-12-03 10:40:13 -0800 | [diff] [blame] | 313 | }; |
Chris Dalton | 1ef8094 | 2017-12-04 12:01:30 -0700 | [diff] [blame] | 314 | #if defined(__GNUC__) |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 315 | #pragma GCC diagnostic pop |
| 316 | #endif |
Chris Dalton | 1ef8094 | 2017-12-04 12:01:30 -0700 | [diff] [blame] | 317 | #if defined(__clang__) |
| 318 | #pragma clang diagnostic pop |
| 319 | #endif |
egdaniel | 378092f | 2014-12-03 10:40:13 -0800 | [diff] [blame] | 320 | |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 321 | GR_MAKE_BITFIELD_CLASS_OPS(GrXPFactory::AnalysisProperties); |
egdaniel | 378092f | 2014-12-03 10:40:13 -0800 | [diff] [blame] | 322 | |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 323 | #endif |