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

Side by Side Diff: src/gpu/GrPipelineBuilder.h

Issue 1230023003: Modify GrClipMaskManager to reflect logical constness (Closed) Base URL: https://skia.googlesource.com/skia.git@proctomemorypool
Patch Set: change to ref Created 5 years, 5 months 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
OLDNEW
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 AutoRestoreFragmentProcessors(GrPipelineBuilder* ds) 121 AutoRestoreFragmentProcessors(GrPipelineBuilder* ds)
122 : fPipelineBuilder(NULL) 122 : fPipelineBuilder(NULL)
123 , fColorEffectCnt(0) 123 , fColorEffectCnt(0)
124 , fCoverageEffectCnt(0) { 124 , fCoverageEffectCnt(0) {
125 this->set(ds); 125 this->set(ds);
126 } 126 }
127 127
128 ~AutoRestoreFragmentProcessors() { this->set(NULL); } 128 ~AutoRestoreFragmentProcessors() { this->set(NULL); }
129 129
130 void set(GrPipelineBuilder* ds); 130 void set(const GrPipelineBuilder* ds);
131 131
132 bool isSet() const { return SkToBool(fPipelineBuilder); } 132 bool isSet() const { return SkToBool(fPipelineBuilder); }
133 133
134 const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcesso r* processor) {
135 SkASSERT(this->isSet());
136 return fPipelineBuilder->addCoverageProcessor(processor);
137 }
138
134 private: 139 private:
135 GrPipelineBuilder* fPipelineBuilder; 140 GrPipelineBuilder* fPipelineBuilder;
136 int fColorEffectCnt; 141 int fColorEffectCnt;
137 int fCoverageEffectCnt; 142 int fCoverageEffectCnt;
138 }; 143 };
139 144
140 /// @} 145 /// @}
141 146
142 /////////////////////////////////////////////////////////////////////////// 147 ///////////////////////////////////////////////////////////////////////////
143 /// @name Blending 148 /// @name Blending
144 //// 149 ////
145 150
146 /** 151 /**
147 * Returns true if this pipeline's color output will be affected by the exis ting render target 152 * Returns true if this pipeline's color output will be affected by the exis ting render target
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 249
245 /** 250 /**
246 * AutoRestoreStencil 251 * AutoRestoreStencil
247 * 252 *
248 * This simple struct saves and restores the stencil settings 253 * This simple struct saves and restores the stencil settings
249 */ 254 */
250 class AutoRestoreStencil : public ::SkNoncopyable { 255 class AutoRestoreStencil : public ::SkNoncopyable {
251 public: 256 public:
252 AutoRestoreStencil() : fPipelineBuilder(NULL) {} 257 AutoRestoreStencil() : fPipelineBuilder(NULL) {}
253 258
254 AutoRestoreStencil(GrPipelineBuilder* ds) : fPipelineBuilder(NULL) { thi s->set(ds); } 259 AutoRestoreStencil(const GrPipelineBuilder* ds) : fPipelineBuilder(NULL) { this->set(ds); }
255 260
256 ~AutoRestoreStencil() { this->set(NULL); } 261 ~AutoRestoreStencil() { this->set(NULL); }
257 262
258 void set(GrPipelineBuilder* ds) { 263 void set(const GrPipelineBuilder* ds) {
259 if (fPipelineBuilder) { 264 if (fPipelineBuilder) {
260 fPipelineBuilder->setStencil(fStencilSettings); 265 fPipelineBuilder->setStencil(fStencilSettings);
261 } 266 }
262 fPipelineBuilder = ds; 267 fPipelineBuilder = const_cast<GrPipelineBuilder*>(ds);
263 if (ds) { 268 if (ds) {
264 fStencilSettings = ds->getStencil(); 269 fStencilSettings = ds->getStencil();
265 } 270 }
266 } 271 }
267 272
268 bool isSet() const { return SkToBool(fPipelineBuilder); } 273 bool isSet() const { return SkToBool(fPipelineBuilder); }
269 274
275 void setStencil(const GrStencilSettings& settings) {
276 SkASSERT(this->isSet());
277 fPipelineBuilder->setStencil(settings);
278 }
279
270 private: 280 private:
271 GrPipelineBuilder* fPipelineBuilder; 281 GrPipelineBuilder* fPipelineBuilder;
272 GrStencilSettings fStencilSettings; 282 GrStencilSettings fStencilSettings;
273 }; 283 };
274 284
275 285
276 /// @} 286 /// @}
277 287
278 /////////////////////////////////////////////////////////////////////////// 288 ///////////////////////////////////////////////////////////////////////////
279 /// @name State Flags 289 /// @name State Flags
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 this->calcCoverageInvariantOutput(batch); 402 this->calcCoverageInvariantOutput(batch);
393 return fCoverageProcInfo; 403 return fCoverageProcInfo;
394 } 404 }
395 405
396 void setClip(const GrClip& clip) { fClip = clip; } 406 void setClip(const GrClip& clip) { fClip = clip; }
397 const GrClip& clip() const { return fClip; } 407 const GrClip& clip() const { return fClip; }
398 408
399 GrProcessorDataManager* getProcessorDataManager() { return fProcDataManager. get(); } 409 GrProcessorDataManager* getProcessorDataManager() { return fProcDataManager. get(); }
400 const GrProcessorDataManager* processorDataManager() const { return fProcDat aManager.get(); } 410 const GrProcessorDataManager* processorDataManager() const { return fProcDat aManager.get(); }
401 411
412 /**
413 * When this object is destroyed it will remove any additions to the GrProce ssorDataManager
414 * owned by the GrPipelineBuilder
415 */
416 class AutoRestoreProcessorDataManager : public ::SkNoncopyable {
417 public:
robertphillips 2015/07/10 14:34:10 Will this entire ctor fit on one line ?
418 AutoRestoreProcessorDataManager()
419 : fPipelineBuilder(NULL)
420 , fStackHeight(0) {
421 }
422
423 AutoRestoreProcessorDataManager(GrPipelineBuilder* ds)
424 : fPipelineBuilder(NULL)
425 , fStackHeight(0) {
426 this->set(ds);
427 }
428
429 ~AutoRestoreProcessorDataManager() { this->set(NULL); }
430
431 void set(const GrPipelineBuilder* ds) {
432 if (fPipelineBuilder) {
433 fPipelineBuilder->getProcessorDataManager()->restoreHeight(fStac kHeight);
434 }
435 fPipelineBuilder = const_cast<GrPipelineBuilder*>(ds);
436 if (ds) {
robertphillips 2015/07/10 14:34:09 currentHeight -> numDataFrames, dataPlaceHolder, r
437 fStackHeight = ds->processorDataManager()->currentHeight();
438 }
439 }
440
441 bool isSet() const { return SkToBool(fPipelineBuilder); }
442
443 GrProcessorDataManager* getProcessorDataManager() {
444 SkASSERT(this->isSet());
445 return fPipelineBuilder->getProcessorDataManager();
446 }
447
448 private:
449 GrPipelineBuilder* fPipelineBuilder;
450 uint32_t fStackHeight;
451 };
452
453
402 private: 454 private:
403 // Calculating invariant color / coverage information is expensive, so we pa rtially cache the 455 // Calculating invariant color / coverage information is expensive, so we pa rtially cache the
404 // results. 456 // results.
405 // 457 //
406 // canUseFracCoveragePrimProc() - Called in regular skia draw, caches result s but only for a 458 // canUseFracCoveragePrimProc() - Called in regular skia draw, caches result s but only for a
407 // specific color and coverage. May be calle d multiple times 459 // specific color and coverage. May be calle d multiple times
408 // willColorBlendWithDst() - only called by Nvpr, does not cache results 460 // willColorBlendWithDst() - only called by Nvpr, does not cache results
409 // GrOptDrawState constructor - never caches results 461 // GrOptDrawState constructor - never caches results
410 462
411 /** 463 /**
(...skipping 16 matching lines...) Expand all
428 void calcColorInvariantOutput(GrColor) const; 480 void calcColorInvariantOutput(GrColor) const;
429 481
430 /** 482 /**
431 * If fCoverageProcInfoValid is false, function calculates the invariant out put for the coverage 483 * If fCoverageProcInfoValid is false, function calculates the invariant out put for the coverage
432 * processors and results are stored in fCoverageProcInfo. 484 * processors and results are stored in fCoverageProcInfo.
433 */ 485 */
434 void calcCoverageInvariantOutput(GrColor) const; 486 void calcCoverageInvariantOutput(GrColor) const;
435 487
436 // Some of the auto restore objects assume that no effects are removed durin g their lifetime. 488 // Some of the auto restore objects assume that no effects are removed durin g their lifetime.
437 // This is used to assert that this condition holds. 489 // This is used to assert that this condition holds.
438 SkDEBUGCODE(int fBlockEffectRemovalCnt;) 490 SkDEBUGCODE(mutable int fBlockEffectRemovalCnt;)
439 491
440 typedef SkSTArray<4, GrFragmentStage> FragmentStageArray; 492 typedef SkSTArray<4, GrFragmentStage> FragmentStageArray;
441 493
442 SkAutoTUnref<GrProcessorDataManager> fProcDataManager; 494 SkAutoTUnref<GrProcessorDataManager> fProcDataManager;
443 SkAutoTUnref<GrRenderTarget> fRenderTarget; 495 SkAutoTUnref<GrRenderTarget> fRenderTarget;
444 uint32_t fFlags; 496 uint32_t fFlags;
445 GrStencilSettings fStencilSettings; 497 GrStencilSettings fStencilSettings;
446 DrawFace fDrawFace; 498 DrawFace fDrawFace;
447 mutable SkAutoTUnref<const GrXPFactory> fXPFactory; 499 mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
448 FragmentStageArray fColorStages; 500 FragmentStageArray fColorStages;
449 FragmentStageArray fCoverageStages; 501 FragmentStageArray fCoverageStages;
450 GrClip fClip; 502 GrClip fClip;
451 503
452 mutable GrProcOptInfo fColorProcInfo; 504 mutable GrProcOptInfo fColorProcInfo;
453 mutable GrProcOptInfo fCoverageProcInfo; 505 mutable GrProcOptInfo fCoverageProcInfo;
454 mutable bool fColorProcInfoValid; 506 mutable bool fColorProcInfoValid;
455 mutable bool fCoverageProcInfoValid; 507 mutable bool fCoverageProcInfoValid;
456 mutable GrColor fColorCache; 508 mutable GrColor fColorCache;
457 mutable GrColor fCoverageCache; 509 mutable GrColor fCoverageCache;
458 510
459 friend class GrPipeline; 511 friend class GrPipeline;
460 }; 512 };
461 513
462 #endif 514 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698