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

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

Issue 1969693003: Revert of Separate user and raw stencil settings (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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/GrPipeline.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
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 "GrUserStencilSettings.h" 17 #include "GrStencil.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
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 bool hasUserStencilSettings() const { 202 const GrStencilSettings& getStencil() const { return fStencilSettings; }
203 return &GrUserStencilSettings::kUnused != fUserStencilSettings;
204 }
205 const GrUserStencilSettings* getUserStencil() const { return fUserStencilSet tings; }
206 203
207 /** 204 /**
208 * Sets the user stencil settings for the next draw. 205 * Sets the stencil settings to use for the next draw.
209 * This class only stores pointers to stencil settings objects. 206 * Changing the clip has the side-effect of possibly zeroing
210 * The caller guarantees the pointer will remain valid until it 207 * out the client settable stencil bits. So multipass algorithms
211 * changes or goes out of scope. 208 * using stencil should not change the clip between passes.
212 * @param settings the stencil settings to use. 209 * @param settings the stencil settings to use.
213 */ 210 */
214 void setUserStencil(const GrUserStencilSettings* settings) { fUserStencilSet tings = settings; } 211 void setStencil(const GrStencilSettings& settings) { fStencilSettings = sett ings; }
215 void disableUserStencil() { fUserStencilSettings = &GrUserStencilSettings::k Unused; } 212
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
216 253
217 /// @} 254 /// @}
218 255
219 /////////////////////////////////////////////////////////////////////////// 256 ///////////////////////////////////////////////////////////////////////////
220 /// @name State Flags 257 /// @name State Flags
221 //// 258 ////
222 259
223 /** 260 /**
224 * Flags that affect rendering. Controlled using enable/disableState(). All 261 * Flags that affect rendering. Controlled using enable/disableState(). All
225 * default to disabled. 262 * default to disabled.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 364
328 private: 365 private:
329 // Some of the auto restore objects assume that no effects are removed durin g their lifetime. 366 // Some of the auto restore objects assume that no effects are removed durin g their lifetime.
330 // This is used to assert that this condition holds. 367 // This is used to assert that this condition holds.
331 SkDEBUGCODE(mutable int fBlockEffectRemovalCnt;) 368 SkDEBUGCODE(mutable int fBlockEffectRemovalCnt;)
332 369
333 typedef SkSTArray<4, const GrFragmentProcessor*, true> FragmentProcessorArra y; 370 typedef SkSTArray<4, const GrFragmentProcessor*, true> FragmentProcessorArra y;
334 371
335 SkAutoTUnref<GrRenderTarget> fRenderTarget; 372 SkAutoTUnref<GrRenderTarget> fRenderTarget;
336 uint32_t fFlags; 373 uint32_t fFlags;
337 const GrUserStencilSettings* fUserStencilSettings; 374 GrStencilSettings fStencilSettings;
338 DrawFace fDrawFace; 375 DrawFace fDrawFace;
339 mutable SkAutoTUnref<const GrXPFactory> fXPFactory; 376 mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
340 FragmentProcessorArray fColorFragmentProcessors; 377 FragmentProcessorArray fColorFragmentProcessors;
341 FragmentProcessorArray fCoverageFragmentProcessors; 378 FragmentProcessorArray fCoverageFragmentProcessors;
342 GrClip fClip; 379 GrClip fClip;
343 380
344 friend class GrPipeline; 381 friend class GrPipeline;
345 friend class GrDrawTarget; 382 friend class GrDrawTarget;
346 }; 383 };
347 384
348 #endif 385 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrPipeline.cpp ('k') | src/gpu/GrPipelineBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698