Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: include/gpu/GrXferProcessor.h

Issue 1480353002: APIs which took colorPOI / coveragePOI pairs updated to take a GrPipelineOptimizations struct (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | include/gpu/effects/GrCoverageSetOpXP.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrXferProcessor_DEFINED 8 #ifndef GrXferProcessor_DEFINED
9 #define GrXferProcessor_DEFINED 9 #define GrXferProcessor_DEFINED
10 10
11 #include "GrBlend.h" 11 #include "GrBlend.h"
12 #include "GrColor.h" 12 #include "GrColor.h"
13 #include "GrProcessor.h" 13 #include "GrProcessor.h"
14 #include "GrTexture.h" 14 #include "GrTexture.h"
15 #include "GrTypes.h" 15 #include "GrTypes.h"
16 #include "SkXfermode.h" 16 #include "SkXfermode.h"
17 17
18 class GrShaderCaps; 18 class GrShaderCaps;
19 class GrGLSLCaps; 19 class GrGLSLCaps;
20 class GrGLSLXferProcessor; 20 class GrGLSLXferProcessor;
21 class GrProcOptInfo; 21 class GrProcOptInfo;
22 struct GrPipelineOptimizations;
22 23
23 /** 24 /**
24 * Barriers for blending. When a shader reads the dst directly, an Xfer barrier is sometimes 25 * Barriers for blending. When a shader reads the dst directly, an Xfer barrier is sometimes
25 * required after a pixel has been written, before it can be safely read again. 26 * required after a pixel has been written, before it can be safely read again.
26 */ 27 */
27 enum GrXferBarrierType { 28 enum GrXferBarrierType {
28 kNone_GrXferBarrierType = 0, //<! No barrier is required 29 kNone_GrXferBarrierType = 0, //<! No barrier is required
29 kTexture_GrXferBarrierType, //<! Required when a shader reads and renders t o the same texture. 30 kTexture_GrXferBarrierType, //<! Required when a shader reads and renders t o the same texture.
30 kBlend_GrXferBarrierType, //<! Required by certain blend extensions. 31 kBlend_GrXferBarrierType, //<! Required by certain blend extensions.
31 }; 32 };
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 135
135 /** 136 /**
136 * Determines which optimizations (as described by the ptFlags above) can be performed by 137 * Determines which optimizations (as described by the ptFlags above) can be performed by
137 * the draw with this xfer processor. If this function is called, the xfer p rocessor may change 138 * the draw with this xfer processor. If this function is called, the xfer p rocessor may change
138 * its state to reflected the given blend optimizations. If the XP needs to see a specific input 139 * its state to reflected the given blend optimizations. If the XP needs to see a specific input
139 * color to blend correctly, it will set the OverrideColor flag and the outp ut parameter 140 * color to blend correctly, it will set the OverrideColor flag and the outp ut parameter
140 * overrideColor will be the required value that should be passed into the X P. 141 * overrideColor will be the required value that should be passed into the X P.
141 * A caller who calls this function on a XP is required to honor the returne d OptFlags 142 * A caller who calls this function on a XP is required to honor the returne d OptFlags
142 * and color values for its draw. 143 * and color values for its draw.
143 */ 144 */
144 OptFlags getOptimizations(const GrProcOptInfo& colorPOI, 145 OptFlags getOptimizations(const GrPipelineOptimizations& optimizations,
145 const GrProcOptInfo& coveragePOI,
146 bool doesStencilWrite, 146 bool doesStencilWrite,
147 GrColor* overrideColor, 147 GrColor* overrideColor,
148 const GrCaps& caps); 148 const GrCaps& caps);
149 149
150 /** 150 /**
151 * Returns whether this XP will require an Xfer barrier on the given rt. If true, outBarrierType 151 * Returns whether this XP will require an Xfer barrier on the given rt. If true, outBarrierType
152 * is updated to contain the type of barrier needed. 152 * is updated to contain the type of barrier needed.
153 */ 153 */
154 GrXferBarrierType xferBarrierType(const GrRenderTarget* rt, const GrCaps& ca ps) const; 154 GrXferBarrierType xferBarrierType(const GrRenderTarget* rt, const GrCaps& ca ps) const;
155 155
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 return this->onIsEqual(that); 239 return this->onIsEqual(that);
240 } 240 }
241 241
242 protected: 242 protected:
243 GrXferProcessor(); 243 GrXferProcessor();
244 GrXferProcessor(const DstTexture*, bool willReadDstColor, bool hasMixedSampl es); 244 GrXferProcessor(const DstTexture*, bool willReadDstColor, bool hasMixedSampl es);
245 245
246 private: 246 private:
247 void notifyRefCntIsZero() const final {} 247 void notifyRefCntIsZero() const final {}
248 248
249 virtual OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, 249 virtual OptFlags onGetOptimizations(const GrPipelineOptimizations& optimizat ions,
250 const GrProcOptInfo& coveragePOI,
251 bool doesStencilWrite, 250 bool doesStencilWrite,
252 GrColor* overrideColor, 251 GrColor* overrideColor,
253 const GrCaps& caps) = 0; 252 const GrCaps& caps) = 0;
254 253
255 /** 254 /**
256 * Sets a unique key on the GrProcessorKeyBuilder that is directly associate d with this xfer 255 * Sets a unique key on the GrProcessorKeyBuilder that is directly associate d with this xfer
257 * processor's GL backend implementation. 256 * processor's GL backend implementation.
258 */ 257 */
259 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps, 258 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
260 GrProcessorKeyBuilder* b) const = 0; 259 GrProcessorKeyBuilder* b) const = 0;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 * draw information to create a GrXferProcessor (XP) which can implement the des ired blending for 303 * draw information to create a GrXferProcessor (XP) which can implement the des ired blending for
305 * the draw. 304 * the draw.
306 * 305 *
307 * Before the XP is created, the XPF is able to answer queries about what functi onality the XPs it 306 * Before the XP is created, the XPF is able to answer queries about what functi onality the XPs it
308 * creates will have. For example, can it create an XP that supports RGB coverag e or will the XP 307 * creates will have. For example, can it create an XP that supports RGB coverag e or will the XP
309 * blend with the destination color. 308 * blend with the destination color.
310 */ 309 */
311 class GrXPFactory : public SkRefCnt { 310 class GrXPFactory : public SkRefCnt {
312 public: 311 public:
313 typedef GrXferProcessor::DstTexture DstTexture; 312 typedef GrXferProcessor::DstTexture DstTexture;
314 GrXferProcessor* createXferProcessor(const GrProcOptInfo& colorPOI, 313 GrXferProcessor* createXferProcessor(const GrPipelineOptimizations& optimiza tions,
315 const GrProcOptInfo& coveragePOI,
316 bool hasMixedSamples, 314 bool hasMixedSamples,
317 const DstTexture*, 315 const DstTexture*,
318 const GrCaps& caps) const; 316 const GrCaps& caps) const;
319 /** 317 /**
320 * Known color information after blending, but before accounting for any cov erage. 318 * Known color information after blending, but before accounting for any cov erage.
321 */ 319 */
322 struct InvariantBlendedColor { 320 struct InvariantBlendedColor {
323 bool fWillBlendWithDst; 321 bool fWillBlendWithDst;
324 GrColor fKnownColor; 322 GrColor fKnownColor;
325 GrColorComponentFlags fKnownColorFlags; 323 GrColorComponentFlags fKnownColorFlags;
326 }; 324 };
327 325
328 /** 326 /**
329 * Returns information about the output color, produced by XPs from this fac tory, that will be 327 * Returns information about the output color, produced by XPs from this fac tory, that will be
330 * known after blending. Note that we can conflate coverage and color, so th e actual values 328 * known after blending. Note that we can conflate coverage and color, so th e actual values
331 * written to pixels with partial coverage may not always seem consistent wi th the invariant 329 * written to pixels with partial coverage may not always seem consistent wi th the invariant
332 * information returned by this function. 330 * information returned by this function.
333 */ 331 */
334 virtual void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, 332 virtual void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
335 InvariantBlendedColor*) const = 0; 333 InvariantBlendedColor*) const = 0;
336 334
337 bool willNeedDstTexture(const GrCaps& caps, const GrProcOptInfo& colorPOI, 335 bool willNeedDstTexture(const GrCaps& caps, const GrPipelineOptimizations& o ptimizations,
338 const GrProcOptInfo& coveragePOI, bool hasMixedSampl es) const; 336 bool hasMixedSamples) const;
339 337
340 bool isEqual(const GrXPFactory& that) const { 338 bool isEqual(const GrXPFactory& that) const {
341 if (this->classID() != that.classID()) { 339 if (this->classID() != that.classID()) {
342 return false; 340 return false;
343 } 341 }
344 return this->onIsEqual(that); 342 return this->onIsEqual(that);
345 } 343 }
346 344
347 /** 345 /**
348 * Helper for down-casting to a GrXPFactory subclass 346 * Helper for down-casting to a GrXPFactory subclass
349 */ 347 */
350 template <typename T> const T& cast() const { return *static_cast<const T*>( this); } 348 template <typename T> const T& cast() const { return *static_cast<const T*>( this); }
351 349
352 uint32_t classID() const { SkASSERT(kIllegalXPFClassID != fClassID); return fClassID; } 350 uint32_t classID() const { SkASSERT(kIllegalXPFClassID != fClassID); return fClassID; }
353 351
354 protected: 352 protected:
355 GrXPFactory() : fClassID(kIllegalXPFClassID) {} 353 GrXPFactory() : fClassID(kIllegalXPFClassID) {}
356 354
357 template <typename XPF_SUBCLASS> void initClassID() { 355 template <typename XPF_SUBCLASS> void initClassID() {
358 static uint32_t kClassID = GenClassID(); 356 static uint32_t kClassID = GenClassID();
359 fClassID = kClassID; 357 fClassID = kClassID;
360 } 358 }
361 359
362 uint32_t fClassID; 360 uint32_t fClassID;
363 361
364 private: 362 private:
365 virtual GrXferProcessor* onCreateXferProcessor(const GrCaps& caps, 363 virtual GrXferProcessor* onCreateXferProcessor(const GrCaps& caps,
366 const GrProcOptInfo& colorPOI , 364 const GrPipelineOptimizations & optimizations,
367 const GrProcOptInfo& coverage POI,
368 bool hasMixedSamples, 365 bool hasMixedSamples,
369 const DstTexture*) const = 0; 366 const DstTexture*) const = 0;
370 /** 367 /**
371 * Returns true if the XP generated by this factory will explicitly read ds t in the fragment 368 * Returns true if the XP generated by this factory will explicitly read ds t in the fragment
372 * shader. 369 * shader.
373 */ 370 */
374 virtual bool willReadDstColor(const GrCaps& caps, 371 virtual bool willReadDstColor(const GrCaps& caps,
375 const GrProcOptInfo& colorPOI, 372 const GrPipelineOptimizations& optimizations,
376 const GrProcOptInfo& coveragePOI,
377 bool hasMixedSamples) const = 0; 373 bool hasMixedSamples) const = 0;
378 374
379 virtual bool onIsEqual(const GrXPFactory&) const = 0; 375 virtual bool onIsEqual(const GrXPFactory&) const = 0;
380 376
381 static uint32_t GenClassID() { 377 static uint32_t GenClassID() {
382 // fCurrXPFactoryID has been initialized to kIllegalXPFactoryID. The 378 // fCurrXPFactoryID has been initialized to kIllegalXPFactoryID. The
383 // atomic inc returns the old value not the incremented value. So we add 379 // atomic inc returns the old value not the incremented value. So we add
384 // 1 to the returned value. 380 // 1 to the returned value.
385 uint32_t id = static_cast<uint32_t>(sk_atomic_inc(&gCurrXPFClassID)) + 1 ; 381 uint32_t id = static_cast<uint32_t>(sk_atomic_inc(&gCurrXPFClassID)) + 1 ;
386 if (!id) { 382 if (!id) {
387 SkFAIL("This should never wrap as it should only be called once for each GrXPFactory " 383 SkFAIL("This should never wrap as it should only be called once for each GrXPFactory "
388 "subclass."); 384 "subclass.");
389 } 385 }
390 return id; 386 return id;
391 } 387 }
392 388
393 enum { 389 enum {
394 kIllegalXPFClassID = 0, 390 kIllegalXPFClassID = 0,
395 }; 391 };
396 static int32_t gCurrXPFClassID; 392 static int32_t gCurrXPFClassID;
397 393
398 typedef GrProgramElement INHERITED; 394 typedef GrProgramElement INHERITED;
399 }; 395 };
400 396
401 #endif 397 #endif
402 398
OLDNEW
« no previous file with comments | « no previous file | include/gpu/effects/GrCoverageSetOpXP.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698