OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 GrDrawState_DEFINED | 8 #ifndef GrDrawState_DEFINED |
9 #define GrDrawState_DEFINED | 9 #define GrDrawState_DEFINED |
10 | 10 |
11 | 11 |
12 #include "GrBlend.h" | 12 #include "GrBlend.h" |
13 #include "GrDrawTargetCaps.h" | 13 #include "GrDrawTargetCaps.h" |
14 #include "GrGeometryProcessor.h" | 14 #include "GrGeometryProcessor.h" |
15 #include "GrGpuResourceRef.h" | 15 #include "GrGpuResourceRef.h" |
16 #include "GrFragmentStage.h" | 16 #include "GrFragmentStage.h" |
17 #include "GrProcOptInfo.h" | 17 #include "GrProcOptInfo.h" |
18 #include "GrRenderTarget.h" | 18 #include "GrRenderTarget.h" |
19 #include "GrStencil.h" | 19 #include "GrStencil.h" |
20 #include "GrXferProcessor.h" | 20 #include "GrXferProcessor.h" |
21 #include "SkMatrix.h" | 21 #include "SkMatrix.h" |
22 #include "effects/GrCoverageSetOpXP.h" | 22 #include "effects/GrCoverageSetOpXP.h" |
| 23 #include "effects/GrDisableColorXP.h" |
23 #include "effects/GrPorterDuffXferProcessor.h" | 24 #include "effects/GrPorterDuffXferProcessor.h" |
24 #include "effects/GrSimpleTextureEffect.h" | 25 #include "effects/GrSimpleTextureEffect.h" |
25 | 26 |
26 class GrDrawTargetCaps; | 27 class GrDrawTargetCaps; |
27 class GrPaint; | 28 class GrPaint; |
28 class GrTexture; | 29 class GrTexture; |
29 | 30 |
30 class GrDrawState { | 31 class GrDrawState { |
31 public: | 32 public: |
32 GrDrawState() { | 33 GrDrawState() { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 } | 138 } |
138 | 139 |
139 void setPorterDuffXPFactory(GrBlendCoeff src, GrBlendCoeff dst) { | 140 void setPorterDuffXPFactory(GrBlendCoeff src, GrBlendCoeff dst) { |
140 fXPFactory.reset(GrPorterDuffXPFactory::Create(src, dst)); | 141 fXPFactory.reset(GrPorterDuffXPFactory::Create(src, dst)); |
141 } | 142 } |
142 | 143 |
143 void setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage =
false) { | 144 void setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage =
false) { |
144 fXPFactory.reset(GrCoverageSetOpXPFactory::Create(regionOp, invertCovera
ge)); | 145 fXPFactory.reset(GrCoverageSetOpXPFactory::Create(regionOp, invertCovera
ge)); |
145 } | 146 } |
146 | 147 |
| 148 void setDisableColorXPFactory() { |
| 149 fXPFactory.reset(GrDisableColorXPFactory::Create()); |
| 150 } |
| 151 |
147 const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* effe
ct) { | 152 const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* effe
ct) { |
148 SkASSERT(effect); | 153 SkASSERT(effect); |
149 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrFragmentStage, (effect)); | 154 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrFragmentStage, (effect)); |
150 fColorProcInfoValid = false; | 155 fColorProcInfoValid = false; |
151 return effect; | 156 return effect; |
152 } | 157 } |
153 | 158 |
154 const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* e
ffect) { | 159 const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* e
ffect) { |
155 SkASSERT(effect); | 160 SkASSERT(effect); |
156 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrFragmentStage, (effect)); | 161 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrFragmentStage, (effect)); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 /** | 408 /** |
404 * Perform HW anti-aliasing. This means either HW FSAA, if supported by
the render target, | 409 * Perform HW anti-aliasing. This means either HW FSAA, if supported by
the render target, |
405 * or smooth-line rendering if a line primitive is drawn and line smooth
ing is supported by | 410 * or smooth-line rendering if a line primitive is drawn and line smooth
ing is supported by |
406 * the 3D API. | 411 * the 3D API. |
407 */ | 412 */ |
408 kHWAntialias_StateBit = 0x02, | 413 kHWAntialias_StateBit = 0x02, |
409 /** | 414 /** |
410 * Draws will respect the clip, otherwise the clip is ignored. | 415 * Draws will respect the clip, otherwise the clip is ignored. |
411 */ | 416 */ |
412 kClip_StateBit = 0x04, | 417 kClip_StateBit = 0x04, |
413 /** | |
414 * Disables writing to the color buffer. Useful when performing stencil | |
415 * operations. | |
416 */ | |
417 kNoColorWrites_StateBit = 0x08, | |
418 | 418 |
419 kLast_StateBit = kNoColorWrites_StateBit, | 419 kLast_StateBit = kClip_StateBit, |
420 }; | 420 }; |
421 | 421 |
422 bool isClipState() const { return 0 != (fFlagBits & kClip_StateBit); } | 422 bool isClipState() const { return 0 != (fFlagBits & kClip_StateBit); } |
423 bool isColorWriteDisabled() const { return 0 != (fFlagBits & kNoColorWrites_
StateBit); } | |
424 bool isDither() const { return 0 != (fFlagBits & kDither_StateBit); } | 423 bool isDither() const { return 0 != (fFlagBits & kDither_StateBit); } |
425 bool isHWAntialias() const { return 0 != (fFlagBits & kHWAntialias_StateBit)
; } | 424 bool isHWAntialias() const { return 0 != (fFlagBits & kHWAntialias_StateBit)
; } |
426 | 425 |
427 /** | 426 /** |
428 * Enable render state settings. | 427 * Enable render state settings. |
429 * | 428 * |
430 * @param stateBits bitfield of StateBits specifying the states to enable | 429 * @param stateBits bitfield of StateBits specifying the states to enable |
431 */ | 430 */ |
432 void enableState(uint32_t stateBits) { fFlagBits |= stateBits; } | 431 void enableState(uint32_t stateBits) { fFlagBits |= stateBits; } |
433 | 432 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 mutable bool fCoverageProcInfoValid; | 547 mutable bool fCoverageProcInfoValid; |
549 mutable GrColor fColorCache; | 548 mutable GrColor fColorCache; |
550 mutable GrColor fCoverageCache; | 549 mutable GrColor fCoverageCache; |
551 mutable const GrPrimitiveProcessor* fColorPrimProc; | 550 mutable const GrPrimitiveProcessor* fColorPrimProc; |
552 mutable const GrPrimitiveProcessor* fCoveragePrimProc; | 551 mutable const GrPrimitiveProcessor* fCoveragePrimProc; |
553 | 552 |
554 friend class GrOptDrawState; | 553 friend class GrOptDrawState; |
555 }; | 554 }; |
556 | 555 |
557 #endif | 556 #endif |
OLD | NEW |