OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 GrPipelineBuilder_DEFINED | 8 #ifndef GrPipelineBuilder_DEFINED |
9 #define GrPipelineBuilder_DEFINED | 9 #define GrPipelineBuilder_DEFINED |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragmentProc
essor* processor) { | 73 const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragmentProc
essor* processor) { |
74 SkASSERT(processor); | 74 SkASSERT(processor); |
75 fCoverageFragmentProcessors.push_back(SkRef(processor)); | 75 fCoverageFragmentProcessors.push_back(SkRef(processor)); |
76 return processor; | 76 return processor; |
77 } | 77 } |
78 | 78 |
79 /** | 79 /** |
80 * Creates a GrSimpleTextureEffect that uses local coords as texture coordin
ates. | 80 * Creates a GrSimpleTextureEffect that uses local coords as texture coordin
ates. |
81 */ | 81 */ |
82 void addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) { | 82 void addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) { |
83 this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataM
anager, texture, | 83 this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(&fProcData
Manager, texture, |
84 matrix))->
unref(); | 84 matrix))->
unref(); |
85 } | 85 } |
86 | 86 |
87 void addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix)
{ | 87 void addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix)
{ |
88 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(fProcDa
taManager, texture, | 88 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(&fProcD
ataManager, texture, |
89 matrix)
)->unref(); | 89 matrix)
)->unref(); |
90 } | 90 } |
91 | 91 |
92 void addColorTextureProcessor(GrTexture* texture, | 92 void addColorTextureProcessor(GrTexture* texture, |
93 const SkMatrix& matrix, | 93 const SkMatrix& matrix, |
94 const GrTextureParams& params) { | 94 const GrTextureParams& params) { |
95 this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(fProcDataM
anager, texture, | 95 this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(&fProcData
Manager, texture, |
96 matrix, | 96 matrix, |
97 params))->
unref(); | 97 params))->
unref(); |
98 } | 98 } |
99 | 99 |
100 void addCoverageTextureProcessor(GrTexture* texture, | 100 void addCoverageTextureProcessor(GrTexture* texture, |
101 const SkMatrix& matrix, | 101 const SkMatrix& matrix, |
102 const GrTextureParams& params) { | 102 const GrTextureParams& params) { |
103 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(fProcDa
taManager, texture, | 103 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(&fProcD
ataManager, texture, |
104 matrix,
params))->unref(); | 104 matrix,
params))->unref(); |
105 } | 105 } |
106 | 106 |
107 /** | 107 /** |
108 * When this object is destroyed it will remove any color/coverage FPs from
the pipeline builder | 108 * When this object is destroyed it will remove any color/coverage FPs from
the pipeline builder |
109 * and also remove any additions to the GrProcessorDataManager that were add
ed after its | 109 * and also remove any additions to the GrProcessorDataManager that were add
ed after its |
110 * constructor. | 110 * constructor. |
111 * This class can transiently modify its "const" GrPipelineBuilder object bu
t will restore it | 111 * This class can transiently modify its "const" GrPipelineBuilder object bu
t will restore it |
112 * when done - so it is notionally "const" correct. | 112 * when done - so it is notionally "const" correct. |
113 */ | 113 */ |
114 class AutoRestoreFragmentProcessorState : public ::SkNoncopyable { | 114 class AutoRestoreFragmentProcessorState : public ::SkNoncopyable { |
115 public: | 115 public: |
116 AutoRestoreFragmentProcessorState() | 116 AutoRestoreFragmentProcessorState() |
117 : fPipelineBuilder(nullptr) | 117 : fPipelineBuilder(nullptr) |
118 , fColorEffectCnt(0) | 118 , fColorEffectCnt(0) |
119 , fCoverageEffectCnt(0) | 119 , fCoverageEffectCnt(0) {} |
120 , fSaveMarker(0) {} | |
121 | 120 |
122 AutoRestoreFragmentProcessorState(const GrPipelineBuilder& ds) | 121 AutoRestoreFragmentProcessorState(const GrPipelineBuilder& ds) |
123 : fPipelineBuilder(nullptr) | 122 : fPipelineBuilder(nullptr) |
124 , fColorEffectCnt(0) | 123 , fColorEffectCnt(0) |
125 , fCoverageEffectCnt(0) | 124 , fCoverageEffectCnt(0) { |
126 , fSaveMarker(0) { | |
127 this->set(&ds); | 125 this->set(&ds); |
128 } | 126 } |
129 | 127 |
130 ~AutoRestoreFragmentProcessorState() { this->set(nullptr); } | 128 ~AutoRestoreFragmentProcessorState() { this->set(nullptr); } |
131 | 129 |
132 void set(const GrPipelineBuilder* ds); | 130 void set(const GrPipelineBuilder* ds); |
133 | 131 |
134 bool isSet() const { return SkToBool(fPipelineBuilder); } | 132 bool isSet() const { return SkToBool(fPipelineBuilder); } |
135 | 133 |
136 GrProcessorDataManager* getProcessorDataManager() { | 134 GrProcessorDataManager* getProcessorDataManager() { |
137 SkASSERT(this->isSet()); | 135 SkASSERT(this->isSet()); |
138 return fPipelineBuilder->getProcessorDataManager(); | 136 return fPipelineBuilder->getProcessorDataManager(); |
139 } | 137 } |
140 | 138 |
141 const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragment
Processor* processor) { | 139 const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragment
Processor* processor) { |
142 SkASSERT(this->isSet()); | 140 SkASSERT(this->isSet()); |
143 return fPipelineBuilder->addCoverageFragmentProcessor(processor); | 141 return fPipelineBuilder->addCoverageFragmentProcessor(processor); |
144 } | 142 } |
145 | 143 |
146 private: | 144 private: |
147 // notionally const (as marginalia) | 145 // notionally const (as marginalia) |
148 GrPipelineBuilder* fPipelineBuilder; | 146 GrPipelineBuilder* fPipelineBuilder; |
149 int fColorEffectCnt; | 147 int fColorEffectCnt; |
150 int fCoverageEffectCnt; | 148 int fCoverageEffectCnt; |
151 uint32_t fSaveMarker; | |
152 }; | 149 }; |
153 | 150 |
154 /// @} | 151 /// @} |
155 | 152 |
156 /////////////////////////////////////////////////////////////////////////// | 153 /////////////////////////////////////////////////////////////////////////// |
157 /// @name Blending | 154 /// @name Blending |
158 //// | 155 //// |
159 | 156 |
160 /** | 157 /** |
161 * Installs a GrXPFactory. This object controls how src color, fractional pi
xel coverage, | 158 * Installs a GrXPFactory. This object controls how src color, fractional pi
xel coverage, |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 } | 398 } |
402 | 399 |
403 const GrProcOptInfo& coverageProcInfo(const GrDrawBatch* batch) const { | 400 const GrProcOptInfo& coverageProcInfo(const GrDrawBatch* batch) const { |
404 this->calcCoverageInvariantOutput(batch); | 401 this->calcCoverageInvariantOutput(batch); |
405 return fCoverageProcInfo; | 402 return fCoverageProcInfo; |
406 } | 403 } |
407 | 404 |
408 void setClip(const GrClip& clip) { fClip = clip; } | 405 void setClip(const GrClip& clip) { fClip = clip; } |
409 const GrClip& clip() const { return fClip; } | 406 const GrClip& clip() const { return fClip; } |
410 | 407 |
411 GrProcessorDataManager* getProcessorDataManager() { return fProcDataManager.
get(); } | 408 GrProcessorDataManager* getProcessorDataManager() { return &fProcDataManager
; } |
412 const GrProcessorDataManager* processorDataManager() const { return fProcDat
aManager.get(); } | 409 const GrProcessorDataManager* processorDataManager() const { return &fProcDa
taManager; } |
413 | 410 |
414 private: | 411 private: |
415 // Calculating invariant color / coverage information is expensive, so we pa
rtially cache the | 412 // Calculating invariant color / coverage information is expensive, so we pa
rtially cache the |
416 // results. | 413 // results. |
417 // | 414 // |
418 // canUseFracCoveragePrimProc() - Called in regular skia draw, caches result
s but only for a | 415 // canUseFracCoveragePrimProc() - Called in regular skia draw, caches result
s but only for a |
419 // specific color and coverage. May be calle
d multiple times | 416 // specific color and coverage. May be calle
d multiple times |
420 // GrOptDrawState constructor - never caches results | 417 // GrOptDrawState constructor - never caches results |
421 | 418 |
422 /** | 419 /** |
423 * Primproc variants of the calc functions | 420 * Primproc variants of the calc functions |
424 * TODO remove these when batch is everywhere | 421 * TODO remove these when batch is everywhere |
425 */ | 422 */ |
426 void calcColorInvariantOutput(const GrPrimitiveProcessor*) const; | 423 void calcColorInvariantOutput(const GrPrimitiveProcessor*) const; |
427 void calcCoverageInvariantOutput(const GrPrimitiveProcessor*) const; | 424 void calcCoverageInvariantOutput(const GrPrimitiveProcessor*) const; |
428 | 425 |
429 /** | 426 /** |
430 * GrBatch provides the initial seed for these loops based off of its initia
l geometry data | 427 * GrBatch provides the initial seed for these loops based off of its initia
l geometry data |
431 */ | 428 */ |
432 void calcColorInvariantOutput(const GrDrawBatch*) const; | 429 void calcColorInvariantOutput(const GrDrawBatch*) const; |
433 void calcCoverageInvariantOutput(const GrDrawBatch*) const; | 430 void calcCoverageInvariantOutput(const GrDrawBatch*) const; |
434 | 431 |
435 // Some of the auto restore objects assume that no effects are removed durin
g their lifetime. | 432 // Some of the auto restore objects assume that no effects are removed durin
g their lifetime. |
436 // This is used to assert that this condition holds. | 433 // This is used to assert that this condition holds. |
437 SkDEBUGCODE(mutable int fBlockEffectRemovalCnt;) | 434 SkDEBUGCODE(mutable int fBlockEffectRemovalCnt;) |
438 | 435 |
439 typedef SkSTArray<4, const GrFragmentProcessor*, true> FragmentProcessorArra
y; | 436 typedef SkSTArray<4, const GrFragmentProcessor*, true> FragmentProcessorArra
y; |
440 | 437 |
441 SkAutoTUnref<GrProcessorDataManager> fProcDataManager; | 438 GrProcessorDataManager fProcDataManager; |
442 SkAutoTUnref<GrRenderTarget> fRenderTarget; | 439 SkAutoTUnref<GrRenderTarget> fRenderTarget; |
443 uint32_t fFlags; | 440 uint32_t fFlags; |
444 GrStencilSettings fStencilSettings; | 441 GrStencilSettings fStencilSettings; |
445 DrawFace fDrawFace; | 442 DrawFace fDrawFace; |
446 mutable SkAutoTUnref<const GrXPFactory> fXPFactory; | 443 mutable SkAutoTUnref<const GrXPFactory> fXPFactory; |
447 FragmentProcessorArray fColorFragmentProcessors; | 444 FragmentProcessorArray fColorFragmentProcessors; |
448 FragmentProcessorArray fCoverageFragmentProcessors; | 445 FragmentProcessorArray fCoverageFragmentProcessors; |
449 GrClip fClip; | 446 GrClip fClip; |
450 | 447 |
451 mutable GrProcOptInfo fColorProcInfo; | 448 mutable GrProcOptInfo fColorProcInfo; |
452 mutable GrProcOptInfo fCoverageProcInfo; | 449 mutable GrProcOptInfo fCoverageProcInfo; |
453 | 450 |
454 friend class GrPipeline; | 451 friend class GrPipeline; |
455 }; | 452 }; |
456 | 453 |
457 #endif | 454 #endif |
OLD | NEW |