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