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

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

Issue 1228763005: small cleanups after fixing const of GrPipelineBuilder on DrawTarget (Closed) Base URL: https://skia.googlesource.com/skia.git@const-fix3
Patch Set: tweaks 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
« no previous file with comments | « src/gpu/GrOvalRenderer.cpp ('k') | src/gpu/GrPipelineBuilder.cpp » ('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 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 void addCoverageTextureProcessor(GrTexture* texture, 103 void addCoverageTextureProcessor(GrTexture* texture,
104 const SkMatrix& matrix, 104 const SkMatrix& matrix,
105 const GrTextureParams& params) { 105 const GrTextureParams& params) {
106 this->addCoverageProcessor(GrSimpleTextureEffect::Create(fProcDataManage r, texture, matrix, 106 this->addCoverageProcessor(GrSimpleTextureEffect::Create(fProcDataManage r, texture, matrix,
107 params))->unref (); 107 params))->unref ();
108 } 108 }
109 109
110 /** 110 /**
111 * When this object is destroyed it will remove any color/coverage FPs from the pipeline builder 111 * When this object is destroyed it will remove any color/coverage FPs from the pipeline builder
112 * that were added after its constructor. 112 * and also remove any additions to the GrProcessorDataManager that were add ed after its
113 * constructor.
113 * This class can transiently modify its "const" GrPipelineBuilder object bu t will restore it 114 * This class can transiently modify its "const" GrPipelineBuilder object bu t will restore it
114 * when done - so it is notionally "const" correct. 115 * when done - so it is notionally "const" correct.
115 */ 116 */
116 class AutoRestoreFragmentProcessors : public ::SkNoncopyable { 117 class AutoRestoreFragmentProcessorState : public ::SkNoncopyable {
117 public: 118 public:
118 AutoRestoreFragmentProcessors() 119 AutoRestoreFragmentProcessorState()
119 : fPipelineBuilder(NULL) 120 : fPipelineBuilder(NULL)
120 , fColorEffectCnt(0) 121 , fColorEffectCnt(0)
121 , fCoverageEffectCnt(0) {} 122 , fCoverageEffectCnt(0)
123 , fSaveMarker(0) {}
122 124
123 AutoRestoreFragmentProcessors(GrPipelineBuilder* ds) 125 AutoRestoreFragmentProcessorState(const GrPipelineBuilder& ds)
124 : fPipelineBuilder(NULL) 126 : fPipelineBuilder(NULL)
125 , fColorEffectCnt(0) 127 , fColorEffectCnt(0)
126 , fCoverageEffectCnt(0) { 128 , fCoverageEffectCnt(0)
127 this->set(ds); 129 , fSaveMarker(0) {
130 this->set(&ds);
128 } 131 }
129 132
130 ~AutoRestoreFragmentProcessors() { this->set(NULL); } 133 ~AutoRestoreFragmentProcessorState() { this->set(NULL); }
131 134
132 void set(const GrPipelineBuilder* ds); 135 void set(const GrPipelineBuilder* ds);
133 136
134 bool isSet() const { return SkToBool(fPipelineBuilder); } 137 bool isSet() const { return SkToBool(fPipelineBuilder); }
135 138
139 GrProcessorDataManager* getProcessorDataManager() {
140 SkASSERT(this->isSet());
141 return fPipelineBuilder->getProcessorDataManager();
142 }
143
136 const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcesso r* processor) { 144 const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcesso r* processor) {
137 SkASSERT(this->isSet()); 145 SkASSERT(this->isSet());
138 return fPipelineBuilder->addCoverageProcessor(processor); 146 return fPipelineBuilder->addCoverageProcessor(processor);
139 } 147 }
140 148
141 private: 149 private:
142 // notionally const (as marginalia) 150 // notionally const (as marginalia)
143 GrPipelineBuilder* fPipelineBuilder; 151 GrPipelineBuilder* fPipelineBuilder;
144 int fColorEffectCnt; 152 int fColorEffectCnt;
145 int fCoverageEffectCnt; 153 int fCoverageEffectCnt;
154 uint32_t fSaveMarker;
146 }; 155 };
147 156
148 /// @} 157 /// @}
149 158
150 /////////////////////////////////////////////////////////////////////////// 159 ///////////////////////////////////////////////////////////////////////////
151 /// @name Blending 160 /// @name Blending
152 //// 161 ////
153 162
154 /** 163 /**
155 * Returns true if this pipeline's color output will be affected by the exis ting render target 164 * Returns true if this pipeline's color output will be affected by the exis ting render target
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 * AutoRestoreStencil 263 * AutoRestoreStencil
255 * 264 *
256 * This simple struct saves and restores the stencil settings 265 * This simple struct saves and restores the stencil settings
257 * This class can transiently modify its "const" GrPipelineBuilder object bu t will restore it 266 * This class can transiently modify its "const" GrPipelineBuilder object bu t will restore it
258 * when done - so it is notionally "const" correct. 267 * when done - so it is notionally "const" correct.
259 */ 268 */
260 class AutoRestoreStencil : public ::SkNoncopyable { 269 class AutoRestoreStencil : public ::SkNoncopyable {
261 public: 270 public:
262 AutoRestoreStencil() : fPipelineBuilder(NULL) {} 271 AutoRestoreStencil() : fPipelineBuilder(NULL) {}
263 272
264 AutoRestoreStencil(const GrPipelineBuilder* ds) : fPipelineBuilder(NULL) { this->set(ds); } 273 AutoRestoreStencil(const GrPipelineBuilder& ds) : fPipelineBuilder(NULL) { this->set(&ds); }
265 274
266 ~AutoRestoreStencil() { this->set(NULL); } 275 ~AutoRestoreStencil() { this->set(NULL); }
267 276
268 void set(const GrPipelineBuilder* ds) { 277 void set(const GrPipelineBuilder* ds) {
269 if (fPipelineBuilder) { 278 if (fPipelineBuilder) {
270 fPipelineBuilder->setStencil(fStencilSettings); 279 fPipelineBuilder->setStencil(fStencilSettings);
271 } 280 }
272 fPipelineBuilder = const_cast<GrPipelineBuilder*>(ds); 281 fPipelineBuilder = const_cast<GrPipelineBuilder*>(ds);
273 if (ds) { 282 if (ds) {
274 fStencilSettings = ds->getStencil(); 283 fStencilSettings = ds->getStencil();
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 this->calcCoverageInvariantOutput(batch); 417 this->calcCoverageInvariantOutput(batch);
409 return fCoverageProcInfo; 418 return fCoverageProcInfo;
410 } 419 }
411 420
412 void setClip(const GrClip& clip) { fClip = clip; } 421 void setClip(const GrClip& clip) { fClip = clip; }
413 const GrClip& clip() const { return fClip; } 422 const GrClip& clip() const { return fClip; }
414 423
415 GrProcessorDataManager* getProcessorDataManager() { return fProcDataManager. get(); } 424 GrProcessorDataManager* getProcessorDataManager() { return fProcDataManager. get(); }
416 const GrProcessorDataManager* processorDataManager() const { return fProcDat aManager.get(); } 425 const GrProcessorDataManager* processorDataManager() const { return fProcDat aManager.get(); }
417 426
418 /**
419 * When this object is destroyed it will remove any additions to the GrProce ssorDataManager
420 * owned by the GrPipelineBuilder
421 * This class can transiently modify its "const" GrPipelineBuilder object bu t will restore it
422 * when done - so it is notionally "const" correct.
423 */
424 class AutoRestoreProcessorDataManager : public ::SkNoncopyable {
425 public:
426 AutoRestoreProcessorDataManager() : fPipelineBuilder(NULL), fSaveMarker( 0) {}
427
428 AutoRestoreProcessorDataManager(GrPipelineBuilder* ds)
429 : fPipelineBuilder(NULL)
430 , fSaveMarker(0) {
431 this->set(ds);
432 }
433
434 ~AutoRestoreProcessorDataManager() { this->set(NULL); }
435
436 void set(const GrPipelineBuilder* ds) {
437 if (fPipelineBuilder) {
438 fPipelineBuilder->getProcessorDataManager()->restoreToSaveMarker (/*fSaveMarker*/);
439 }
440 fPipelineBuilder = const_cast<GrPipelineBuilder*>(ds);
441 if (ds) {
442 fSaveMarker = ds->processorDataManager()->currentSaveMarker();
443 }
444 }
445
446 bool isSet() const { return SkToBool(fPipelineBuilder); }
447
448 GrProcessorDataManager* getProcessorDataManager() {
449 SkASSERT(this->isSet());
450 return fPipelineBuilder->getProcessorDataManager();
451 }
452
453 private:
454 // notionally const (as marginalia)
455 GrPipelineBuilder* fPipelineBuilder;
456 uint32_t fSaveMarker;
457 };
458
459
460 private: 427 private:
461 // Calculating invariant color / coverage information is expensive, so we pa rtially cache the 428 // Calculating invariant color / coverage information is expensive, so we pa rtially cache the
462 // results. 429 // results.
463 // 430 //
464 // canUseFracCoveragePrimProc() - Called in regular skia draw, caches result s but only for a 431 // canUseFracCoveragePrimProc() - Called in regular skia draw, caches result s but only for a
465 // specific color and coverage. May be calle d multiple times 432 // specific color and coverage. May be calle d multiple times
466 // willColorBlendWithDst() - only called by Nvpr, does not cache results 433 // willColorBlendWithDst() - only called by Nvpr, does not cache results
467 // GrOptDrawState constructor - never caches results 434 // GrOptDrawState constructor - never caches results
468 435
469 /** 436 /**
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 mutable GrProcOptInfo fCoverageProcInfo; 478 mutable GrProcOptInfo fCoverageProcInfo;
512 mutable bool fColorProcInfoValid; 479 mutable bool fColorProcInfoValid;
513 mutable bool fCoverageProcInfoValid; 480 mutable bool fCoverageProcInfoValid;
514 mutable GrColor fColorCache; 481 mutable GrColor fColorCache;
515 mutable GrColor fCoverageCache; 482 mutable GrColor fCoverageCache;
516 483
517 friend class GrPipeline; 484 friend class GrPipeline;
518 }; 485 };
519 486
520 #endif 487 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrOvalRenderer.cpp ('k') | src/gpu/GrPipelineBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698