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 "GrBatch.h" | 11 #include "GrBatch.h" |
12 #include "GrBlend.h" | 12 #include "GrBlend.h" |
| 13 #include "GrClip.h" |
13 #include "GrDrawTargetCaps.h" | 14 #include "GrDrawTargetCaps.h" |
14 #include "GrGpuResourceRef.h" | 15 #include "GrGpuResourceRef.h" |
15 #include "GrFragmentStage.h" | 16 #include "GrFragmentStage.h" |
16 #include "GrProcOptInfo.h" | 17 #include "GrProcOptInfo.h" |
17 #include "GrRenderTarget.h" | 18 #include "GrRenderTarget.h" |
18 #include "GrStencil.h" | 19 #include "GrStencil.h" |
19 #include "GrXferProcessor.h" | 20 #include "GrXferProcessor.h" |
20 #include "SkMatrix.h" | 21 #include "SkMatrix.h" |
21 #include "effects/GrCoverageSetOpXP.h" | 22 #include "effects/GrCoverageSetOpXP.h" |
22 #include "effects/GrDisableColorXP.h" | 23 #include "effects/GrDisableColorXP.h" |
(...skipping 14 matching lines...) Expand all Loading... |
37 } | 38 } |
38 | 39 |
39 virtual ~GrPipelineBuilder(); | 40 virtual ~GrPipelineBuilder(); |
40 | 41 |
41 /** | 42 /** |
42 * Initializes the GrPipelineBuilder based on a GrPaint, view matrix and ren
der target. Note | 43 * Initializes the GrPipelineBuilder based on a GrPaint, view matrix and ren
der target. Note |
43 * that GrPipelineBuilder encompasses more than GrPaint. Aspects of GrPipeli
neBuilder that have | 44 * that GrPipelineBuilder encompasses more than GrPaint. Aspects of GrPipeli
neBuilder that have |
44 * no GrPaint equivalents are set to default values with the exception of ve
rtex attribute state | 45 * no GrPaint equivalents are set to default values with the exception of ve
rtex attribute state |
45 * which is unmodified by this function and clipping which will be enabled. | 46 * which is unmodified by this function and clipping which will be enabled. |
46 */ | 47 */ |
47 void setFromPaint(const GrPaint&, GrRenderTarget*); | 48 void setFromPaint(const GrPaint&, GrRenderTarget*, const GrClip*); |
48 | 49 |
49 /// @} | 50 /// @} |
50 | 51 |
51 /** | 52 /** |
52 * This function returns true if the render target destination pixel values
will be read for | 53 * This function returns true if the render target destination pixel values
will be read for |
53 * blending during draw. | 54 * blending during draw. |
54 */ | 55 */ |
55 bool willBlendWithDst(const GrPrimitiveProcessor*) const; | 56 bool willBlendWithDst(const GrPrimitiveProcessor*) const; |
56 | 57 |
57 /////////////////////////////////////////////////////////////////////////// | 58 /////////////////////////////////////////////////////////////////////////// |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 /** | 287 /** |
287 * Perform dithering. TODO: Re-evaluate whether we need this bit | 288 * Perform dithering. TODO: Re-evaluate whether we need this bit |
288 */ | 289 */ |
289 kDither_StateBit = 0x01, | 290 kDither_StateBit = 0x01, |
290 /** | 291 /** |
291 * Perform HW anti-aliasing. This means either HW FSAA, if supported by
the render target, | 292 * Perform HW anti-aliasing. This means either HW FSAA, if supported by
the render target, |
292 * or smooth-line rendering if a line primitive is drawn and line smooth
ing is supported by | 293 * or smooth-line rendering if a line primitive is drawn and line smooth
ing is supported by |
293 * the 3D API. | 294 * the 3D API. |
294 */ | 295 */ |
295 kHWAntialias_StateBit = 0x02, | 296 kHWAntialias_StateBit = 0x02, |
296 /** | |
297 * Draws will respect the clip, otherwise the clip is ignored. | |
298 */ | |
299 kClip_StateBit = 0x04, | |
300 | 297 |
301 kLast_StateBit = kClip_StateBit, | 298 kLast_StateBit = kHWAntialias_StateBit, |
302 }; | 299 }; |
303 | 300 |
304 bool isClipState() const { return 0 != (fFlagBits & kClip_StateBit); } | |
305 bool isDither() const { return 0 != (fFlagBits & kDither_StateBit); } | 301 bool isDither() const { return 0 != (fFlagBits & kDither_StateBit); } |
306 bool isHWAntialias() const { return 0 != (fFlagBits & kHWAntialias_StateBit)
; } | 302 bool isHWAntialias() const { return 0 != (fFlagBits & kHWAntialias_StateBit)
; } |
307 | 303 |
308 /** | 304 /** |
309 * Enable render state settings. | 305 * Enable render state settings. |
310 * | 306 * |
311 * @param stateBits bitfield of StateBits specifying the states to enable | 307 * @param stateBits bitfield of StateBits specifying the states to enable |
312 */ | 308 */ |
313 void enableState(uint32_t stateBits) { fFlagBits |= stateBits; } | 309 void enableState(uint32_t stateBits) { fFlagBits |= stateBits; } |
314 | 310 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 | 378 |
383 const GrProcOptInfo& colorProcInfo(const GrBatch* batch) const { | 379 const GrProcOptInfo& colorProcInfo(const GrBatch* batch) const { |
384 this->calcColorInvariantOutput(batch); | 380 this->calcColorInvariantOutput(batch); |
385 return fColorProcInfo; | 381 return fColorProcInfo; |
386 } | 382 } |
387 | 383 |
388 const GrProcOptInfo& coverageProcInfo(const GrBatch* batch) const { | 384 const GrProcOptInfo& coverageProcInfo(const GrBatch* batch) const { |
389 this->calcCoverageInvariantOutput(batch); | 385 this->calcCoverageInvariantOutput(batch); |
390 return fCoverageProcInfo; | 386 return fCoverageProcInfo; |
391 } | 387 } |
| 388 |
| 389 void setClip(const GrClip& clip) { fClip = clip; } |
| 390 const GrClip& clip() const { return fClip; } |
| 391 |
392 private: | 392 private: |
393 // Calculating invariant color / coverage information is expensive, so we pa
rtially cache the | 393 // Calculating invariant color / coverage information is expensive, so we pa
rtially cache the |
394 // results. | 394 // results. |
395 // | 395 // |
396 // canUseFracCoveragePrimProc() - Called in regular skia draw, caches result
s but only for a | 396 // canUseFracCoveragePrimProc() - Called in regular skia draw, caches result
s but only for a |
397 // specific color and coverage. May be calle
d multiple times | 397 // specific color and coverage. May be calle
d multiple times |
398 // willBlendWithDst() - only called by Nvpr, does not cache results | 398 // willBlendWithDst() - only called by Nvpr, does not cache results |
399 // GrOptDrawState constructor - never caches results | 399 // GrOptDrawState constructor - never caches results |
400 | 400 |
401 /** | 401 /** |
(...skipping 27 matching lines...) Expand all Loading... |
429 | 429 |
430 typedef SkSTArray<4, GrFragmentStage> FragmentStageArray; | 430 typedef SkSTArray<4, GrFragmentStage> FragmentStageArray; |
431 | 431 |
432 SkAutoTUnref<GrRenderTarget> fRenderTarget; | 432 SkAutoTUnref<GrRenderTarget> fRenderTarget; |
433 uint32_t fFlagBits; | 433 uint32_t fFlagBits; |
434 GrStencilSettings fStencilSettings; | 434 GrStencilSettings fStencilSettings; |
435 DrawFace fDrawFace; | 435 DrawFace fDrawFace; |
436 mutable SkAutoTUnref<const GrXPFactory> fXPFactory; | 436 mutable SkAutoTUnref<const GrXPFactory> fXPFactory; |
437 FragmentStageArray fColorStages; | 437 FragmentStageArray fColorStages; |
438 FragmentStageArray fCoverageStages; | 438 FragmentStageArray fCoverageStages; |
| 439 GrClip fClip; |
439 | 440 |
440 mutable GrProcOptInfo fColorProcInfo; | 441 mutable GrProcOptInfo fColorProcInfo; |
441 mutable GrProcOptInfo fCoverageProcInfo; | 442 mutable GrProcOptInfo fCoverageProcInfo; |
442 mutable bool fColorProcInfoValid; | 443 mutable bool fColorProcInfoValid; |
443 mutable bool fCoverageProcInfoValid; | 444 mutable bool fCoverageProcInfoValid; |
444 mutable GrColor fColorCache; | 445 mutable GrColor fColorCache; |
445 mutable GrColor fCoverageCache; | 446 mutable GrColor fCoverageCache; |
446 | 447 |
447 friend class GrPipeline; | 448 friend class GrPipeline; |
448 }; | 449 }; |
449 | 450 |
450 #endif | 451 #endif |
OLD | NEW |