| 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 |
| 11 #include "GrBlend.h" | 11 #include "GrBlend.h" |
| 12 #include "GrCaps.h" | 12 #include "GrCaps.h" |
| 13 #include "GrClip.h" | 13 #include "GrClip.h" |
| 14 #include "GrGpuResourceRef.h" | 14 #include "GrGpuResourceRef.h" |
| 15 #include "GrProcOptInfo.h" | 15 #include "GrProcOptInfo.h" |
| 16 #include "GrRenderTarget.h" | 16 #include "GrRenderTarget.h" |
| 17 #include "GrStencil.h" | 17 #include "GrUserStencilSettings.h" |
| 18 #include "GrXferProcessor.h" | 18 #include "GrXferProcessor.h" |
| 19 #include "SkMatrix.h" | 19 #include "SkMatrix.h" |
| 20 #include "effects/GrCoverageSetOpXP.h" | 20 #include "effects/GrCoverageSetOpXP.h" |
| 21 #include "effects/GrDisableColorXP.h" | 21 #include "effects/GrDisableColorXP.h" |
| 22 #include "effects/GrPorterDuffXferProcessor.h" | 22 #include "effects/GrPorterDuffXferProcessor.h" |
| 23 #include "effects/GrSimpleTextureEffect.h" | 23 #include "effects/GrSimpleTextureEffect.h" |
| 24 | 24 |
| 25 class GrDrawBatch; | 25 class GrDrawBatch; |
| 26 class GrCaps; | 26 class GrCaps; |
| 27 class GrPaint; | 27 class GrPaint; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 * @param target The render target to set. | 192 * @param target The render target to set. |
| 193 */ | 193 */ |
| 194 void setRenderTarget(GrRenderTarget* target) { fRenderTarget.reset(SkSafeRef
(target)); } | 194 void setRenderTarget(GrRenderTarget* target) { fRenderTarget.reset(SkSafeRef
(target)); } |
| 195 | 195 |
| 196 /// @} | 196 /// @} |
| 197 | 197 |
| 198 /////////////////////////////////////////////////////////////////////////// | 198 /////////////////////////////////////////////////////////////////////////// |
| 199 /// @name Stencil | 199 /// @name Stencil |
| 200 //// | 200 //// |
| 201 | 201 |
| 202 const GrStencilSettings& getStencil() const { return fStencilSettings; } | 202 bool hasUserStencilSettings() const { |
| 203 return &GrUserStencilSettings::kUnused != fUserStencilSettings; |
| 204 } |
| 205 const GrUserStencilSettings* getUserStencil() const { return fUserStencilSet
tings; } |
| 203 | 206 |
| 204 /** | 207 /** |
| 205 * Sets the stencil settings to use for the next draw. | 208 * Sets the user stencil settings for the next draw. |
| 206 * Changing the clip has the side-effect of possibly zeroing | 209 * This class only stores pointers to stencil settings objects. |
| 207 * out the client settable stencil bits. So multipass algorithms | 210 * The caller guarantees the pointer will remain valid until it |
| 208 * using stencil should not change the clip between passes. | 211 * changes or goes out of scope. |
| 209 * @param settings the stencil settings to use. | 212 * @param settings the stencil settings to use. |
| 210 */ | 213 */ |
| 211 void setStencil(const GrStencilSettings& settings) { fStencilSettings = sett
ings; } | 214 void setUserStencil(const GrUserStencilSettings* settings) { fUserStencilSet
tings = settings; } |
| 212 | 215 void disableUserStencil() { fUserStencilSettings = &GrUserStencilSettings::k
Unused; } |
| 213 GrStencilSettings* stencil() { return &fStencilSettings; } | |
| 214 | |
| 215 /** | |
| 216 * AutoRestoreStencil | |
| 217 * | |
| 218 * This simple struct saves and restores the stencil settings | |
| 219 * This class can transiently modify its "const" GrPipelineBuilder object bu
t will restore it | |
| 220 * when done - so it is notionally "const" correct. | |
| 221 */ | |
| 222 class AutoRestoreStencil : public ::SkNoncopyable { | |
| 223 public: | |
| 224 AutoRestoreStencil() : fPipelineBuilder(nullptr) {} | |
| 225 | |
| 226 AutoRestoreStencil(const GrPipelineBuilder& ds) : fPipelineBuilder(nullp
tr) { this->set(&ds); } | |
| 227 | |
| 228 ~AutoRestoreStencil() { this->set(nullptr); } | |
| 229 | |
| 230 void set(const GrPipelineBuilder* ds) { | |
| 231 if (fPipelineBuilder) { | |
| 232 fPipelineBuilder->setStencil(fStencilSettings); | |
| 233 } | |
| 234 fPipelineBuilder = const_cast<GrPipelineBuilder*>(ds); | |
| 235 if (ds) { | |
| 236 fStencilSettings = ds->getStencil(); | |
| 237 } | |
| 238 } | |
| 239 | |
| 240 bool isSet() const { return SkToBool(fPipelineBuilder); } | |
| 241 | |
| 242 void setStencil(const GrStencilSettings& settings) { | |
| 243 SkASSERT(this->isSet()); | |
| 244 fPipelineBuilder->setStencil(settings); | |
| 245 } | |
| 246 | |
| 247 private: | |
| 248 // notionally const (as marginalia) | |
| 249 GrPipelineBuilder* fPipelineBuilder; | |
| 250 GrStencilSettings fStencilSettings; | |
| 251 }; | |
| 252 | |
| 253 | 216 |
| 254 /// @} | 217 /// @} |
| 255 | 218 |
| 256 /////////////////////////////////////////////////////////////////////////// | 219 /////////////////////////////////////////////////////////////////////////// |
| 257 /// @name State Flags | 220 /// @name State Flags |
| 258 //// | 221 //// |
| 259 | 222 |
| 260 /** | 223 /** |
| 261 * Flags that affect rendering. Controlled using enable/disableState(). All | 224 * Flags that affect rendering. Controlled using enable/disableState(). All |
| 262 * default to disabled. | 225 * default to disabled. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 | 327 |
| 365 private: | 328 private: |
| 366 // Some of the auto restore objects assume that no effects are removed durin
g their lifetime. | 329 // Some of the auto restore objects assume that no effects are removed durin
g their lifetime. |
| 367 // This is used to assert that this condition holds. | 330 // This is used to assert that this condition holds. |
| 368 SkDEBUGCODE(mutable int fBlockEffectRemovalCnt;) | 331 SkDEBUGCODE(mutable int fBlockEffectRemovalCnt;) |
| 369 | 332 |
| 370 typedef SkSTArray<4, const GrFragmentProcessor*, true> FragmentProcessorArra
y; | 333 typedef SkSTArray<4, const GrFragmentProcessor*, true> FragmentProcessorArra
y; |
| 371 | 334 |
| 372 SkAutoTUnref<GrRenderTarget> fRenderTarget; | 335 SkAutoTUnref<GrRenderTarget> fRenderTarget; |
| 373 uint32_t fFlags; | 336 uint32_t fFlags; |
| 374 GrStencilSettings fStencilSettings; | 337 const GrUserStencilSettings* fUserStencilSettings; |
| 375 DrawFace fDrawFace; | 338 DrawFace fDrawFace; |
| 376 mutable SkAutoTUnref<const GrXPFactory> fXPFactory; | 339 mutable SkAutoTUnref<const GrXPFactory> fXPFactory; |
| 377 FragmentProcessorArray fColorFragmentProcessors; | 340 FragmentProcessorArray fColorFragmentProcessors; |
| 378 FragmentProcessorArray fCoverageFragmentProcessors; | 341 FragmentProcessorArray fCoverageFragmentProcessors; |
| 379 GrClip fClip; | 342 GrClip fClip; |
| 380 | 343 |
| 381 friend class GrPipeline; | 344 friend class GrPipeline; |
| 382 friend class GrDrawTarget; | 345 friend class GrDrawTarget; |
| 383 }; | 346 }; |
| 384 | 347 |
| 385 #endif | 348 #endif |
| OLD | NEW |