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 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 GrDrawState(const GrDrawState& state, const SkMatrix& preConcatMatrix) { | 52 GrDrawState(const GrDrawState& state, const SkMatrix& preConcatMatrix) { |
53 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) | 53 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) |
54 *this = state; | 54 *this = state; |
55 if (!preConcatMatrix.isIdentity()) { | 55 if (!preConcatMatrix.isIdentity()) { |
56 for (int i = 0; i < fColorStages.count(); ++i) { | 56 for (int i = 0; i < fColorStages.count(); ++i) { |
57 fColorStages[i].localCoordChange(preConcatMatrix); | 57 fColorStages[i].localCoordChange(preConcatMatrix); |
58 } | 58 } |
59 for (int i = 0; i < fCoverageStages.count(); ++i) { | 59 for (int i = 0; i < fCoverageStages.count(); ++i) { |
60 fCoverageStages[i].localCoordChange(preConcatMatrix); | 60 fCoverageStages[i].localCoordChange(preConcatMatrix); |
61 } | 61 } |
| 62 this->invalidateBlendOptFlags(); |
62 } | 63 } |
63 } | 64 } |
64 | 65 |
65 virtual ~GrDrawState() { SkASSERT(0 == fBlockEffectRemovalCnt); } | 66 virtual ~GrDrawState() { SkASSERT(0 == fBlockEffectRemovalCnt); } |
66 | 67 |
67 /** | 68 /** |
68 * Resets to the default state. GrEffects will be removed from all stages. | 69 * Resets to the default state. GrEffects will be removed from all stages. |
69 */ | 70 */ |
70 void reset() { this->onReset(NULL); } | 71 void reset() { this->onReset(NULL); } |
71 | 72 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 243 |
243 /////////////////////////////////////////////////////////////////////////// | 244 /////////////////////////////////////////////////////////////////////////// |
244 /// @name Color | 245 /// @name Color |
245 //// | 246 //// |
246 | 247 |
247 /** | 248 /** |
248 * Sets color for next draw to a premultiplied-alpha color. | 249 * Sets color for next draw to a premultiplied-alpha color. |
249 * | 250 * |
250 * @param color the color to set. | 251 * @param color the color to set. |
251 */ | 252 */ |
252 void setColor(GrColor color) { fColor = color; } | 253 void setColor(GrColor color) { |
| 254 fColor = color; |
| 255 this->invalidateBlendOptFlags(); |
| 256 } |
253 | 257 |
254 GrColor getColor() const { return fColor; } | 258 GrColor getColor() const { return fColor; } |
255 | 259 |
256 /** | 260 /** |
257 * Sets the color to be used for the next draw to be | 261 * Sets the color to be used for the next draw to be |
258 * (r,g,b,a) = (alpha, alpha, alpha, alpha). | 262 * (r,g,b,a) = (alpha, alpha, alpha, alpha). |
259 * | 263 * |
260 * @param alpha The alpha value to set as the color. | 264 * @param alpha The alpha value to set as the color. |
261 */ | 265 */ |
262 void setAlpha(uint8_t a) { | 266 void setAlpha(uint8_t a) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 /// @name Coverage | 305 /// @name Coverage |
302 //// | 306 //// |
303 | 307 |
304 /** | 308 /** |
305 * Sets a constant fractional coverage to be applied to the draw. The | 309 * Sets a constant fractional coverage to be applied to the draw. The |
306 * initial value (after construction or reset()) is 0xff. The constant | 310 * initial value (after construction or reset()) is 0xff. The constant |
307 * coverage is ignored when per-vertex coverage is provided. | 311 * coverage is ignored when per-vertex coverage is provided. |
308 */ | 312 */ |
309 void setCoverage(uint8_t coverage) { | 313 void setCoverage(uint8_t coverage) { |
310 fCoverage = GrColorPackRGBA(coverage, coverage, coverage, coverage); | 314 fCoverage = GrColorPackRGBA(coverage, coverage, coverage, coverage); |
| 315 this->invalidateBlendOptFlags(); |
311 } | 316 } |
312 | 317 |
313 uint8_t getCoverage() const { | 318 uint8_t getCoverage() const { |
314 return GrColorUnpackR(fCoverage); | 319 return GrColorUnpackR(fCoverage); |
315 } | 320 } |
316 | 321 |
317 GrColor getCoverageColor() const { | 322 GrColor getCoverageColor() const { |
318 return fCoverage; | 323 return fCoverage; |
319 } | 324 } |
320 | 325 |
(...skipping 15 matching lines...) Expand all Loading... |
336 /// per-vertex colors. The input to the first coverage stage is either a con
stant coverage | 341 /// per-vertex colors. The input to the first coverage stage is either a con
stant coverage |
337 /// (usually full-coverage) or interpolated per-vertex coverage. | 342 /// (usually full-coverage) or interpolated per-vertex coverage. |
338 /// | 343 /// |
339 /// See the documentation of kCoverageDrawing_StateBit for information about
disabling the | 344 /// See the documentation of kCoverageDrawing_StateBit for information about
disabling the |
340 /// the color / coverage distinction. | 345 /// the color / coverage distinction. |
341 //// | 346 //// |
342 | 347 |
343 const GrEffect* addColorEffect(const GrEffect* effect, int attr0 = -1, int a
ttr1 = -1) { | 348 const GrEffect* addColorEffect(const GrEffect* effect, int attr0 = -1, int a
ttr1 = -1) { |
344 SkASSERT(NULL != effect); | 349 SkASSERT(NULL != effect); |
345 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrEffectStage, (effect, attr0, att
r1)); | 350 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrEffectStage, (effect, attr0, att
r1)); |
| 351 this->invalidateBlendOptFlags(); |
346 return effect; | 352 return effect; |
347 } | 353 } |
348 | 354 |
349 const GrEffect* addCoverageEffect(const GrEffect* effect, int attr0 = -1, in
t attr1 = -1) { | 355 const GrEffect* addCoverageEffect(const GrEffect* effect, int attr0 = -1, in
t attr1 = -1) { |
350 SkASSERT(NULL != effect); | 356 SkASSERT(NULL != effect); |
351 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrEffectStage, (effect, attr0,
attr1)); | 357 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrEffectStage, (effect, attr0,
attr1)); |
| 358 this->invalidateBlendOptFlags(); |
352 return effect; | 359 return effect; |
353 } | 360 } |
354 | 361 |
355 /** | 362 /** |
356 * Creates a GrSimpleTextureEffect that uses local coords as texture coordin
ates. | 363 * Creates a GrSimpleTextureEffect that uses local coords as texture coordin
ates. |
357 */ | 364 */ |
358 void addColorTextureEffect(GrTexture* texture, const SkMatrix& matrix) { | 365 void addColorTextureEffect(GrTexture* texture, const SkMatrix& matrix) { |
359 this->addColorEffect(GrSimpleTextureEffect::Create(texture, matrix))->un
ref(); | 366 this->addColorEffect(GrSimpleTextureEffect::Create(texture, matrix))->un
ref(); |
360 } | 367 } |
361 | 368 |
(...skipping 22 matching lines...) Expand all Loading... |
384 AutoRestoreEffects() : fDrawState(NULL), fColorEffectCnt(0), fCoverageEf
fectCnt(0) {} | 391 AutoRestoreEffects() : fDrawState(NULL), fColorEffectCnt(0), fCoverageEf
fectCnt(0) {} |
385 | 392 |
386 AutoRestoreEffects(GrDrawState* ds) : fDrawState(NULL), fColorEffectCnt(
0), fCoverageEffectCnt(0) { | 393 AutoRestoreEffects(GrDrawState* ds) : fDrawState(NULL), fColorEffectCnt(
0), fCoverageEffectCnt(0) { |
387 this->set(ds); | 394 this->set(ds); |
388 } | 395 } |
389 | 396 |
390 ~AutoRestoreEffects() { this->set(NULL); } | 397 ~AutoRestoreEffects() { this->set(NULL); } |
391 | 398 |
392 void set(GrDrawState* ds) { | 399 void set(GrDrawState* ds) { |
393 if (NULL != fDrawState) { | 400 if (NULL != fDrawState) { |
394 int n = fDrawState->fColorStages.count() - fColorEffectCnt; | 401 int m = fDrawState->fColorStages.count() - fColorEffectCnt; |
395 SkASSERT(n >= 0); | 402 SkASSERT(m >= 0); |
396 fDrawState->fColorStages.pop_back_n(n); | 403 fDrawState->fColorStages.pop_back_n(m); |
397 n = fDrawState->fCoverageStages.count() - fCoverageEffectCnt; | 404 |
| 405 int n = fDrawState->fCoverageStages.count() - fCoverageEffectCnt
; |
398 SkASSERT(n >= 0); | 406 SkASSERT(n >= 0); |
399 fDrawState->fCoverageStages.pop_back_n(n); | 407 fDrawState->fCoverageStages.pop_back_n(n); |
| 408 if (m + n > 0) { |
| 409 fDrawState->invalidateBlendOptFlags(); |
| 410 } |
400 SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;) | 411 SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;) |
401 } | 412 } |
402 fDrawState = ds; | 413 fDrawState = ds; |
403 if (NULL != ds) { | 414 if (NULL != ds) { |
404 fColorEffectCnt = ds->fColorStages.count(); | 415 fColorEffectCnt = ds->fColorStages.count(); |
405 fCoverageEffectCnt = ds->fCoverageStages.count(); | 416 fCoverageEffectCnt = ds->fCoverageStages.count(); |
406 SkDEBUGCODE(++ds->fBlockEffectRemovalCnt;) | 417 SkDEBUGCODE(++ds->fBlockEffectRemovalCnt;) |
407 } | 418 } |
408 } | 419 } |
409 | 420 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 * where D is the existing destination color, S is the incoming source | 453 * where D is the existing destination color, S is the incoming source |
443 * color, and D' is the new destination color that will be written. sat() | 454 * color, and D' is the new destination color that will be written. sat() |
444 * is the saturation function. | 455 * is the saturation function. |
445 * | 456 * |
446 * @param srcCoef coefficient applied to the src color. | 457 * @param srcCoef coefficient applied to the src color. |
447 * @param dstCoef coefficient applied to the dst color. | 458 * @param dstCoef coefficient applied to the dst color. |
448 */ | 459 */ |
449 void setBlendFunc(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) { | 460 void setBlendFunc(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) { |
450 fSrcBlend = srcCoeff; | 461 fSrcBlend = srcCoeff; |
451 fDstBlend = dstCoeff; | 462 fDstBlend = dstCoeff; |
| 463 this->invalidateBlendOptFlags(); |
452 #ifdef SK_DEBUG | 464 #ifdef SK_DEBUG |
453 if (GrBlendCoeffRefsDst(dstCoeff)) { | 465 if (GrBlendCoeffRefsDst(dstCoeff)) { |
454 GrPrintf("Unexpected dst blend coeff. Won't work correctly with cove
rage stages.\n"); | 466 GrPrintf("Unexpected dst blend coeff. Won't work correctly with cove
rage stages.\n"); |
455 } | 467 } |
456 if (GrBlendCoeffRefsSrc(srcCoeff)) { | 468 if (GrBlendCoeffRefsSrc(srcCoeff)) { |
457 GrPrintf("Unexpected src blend coeff. Won't work correctly with cove
rage stages.\n"); | 469 GrPrintf("Unexpected src blend coeff. Won't work correctly with cove
rage stages.\n"); |
458 } | 470 } |
459 #endif | 471 #endif |
460 } | 472 } |
461 | 473 |
462 GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlend; } | 474 GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlend; } |
463 GrBlendCoeff getDstBlendCoeff() const { return fDstBlend; } | 475 GrBlendCoeff getDstBlendCoeff() const { return fDstBlend; } |
464 | 476 |
465 void getDstBlendCoeff(GrBlendCoeff* srcBlendCoeff, | 477 void getDstBlendCoeff(GrBlendCoeff* srcBlendCoeff, |
466 GrBlendCoeff* dstBlendCoeff) const { | 478 GrBlendCoeff* dstBlendCoeff) const { |
467 *srcBlendCoeff = fSrcBlend; | 479 *srcBlendCoeff = fSrcBlend; |
468 *dstBlendCoeff = fDstBlend; | 480 *dstBlendCoeff = fDstBlend; |
469 } | 481 } |
470 | 482 |
471 /** | 483 /** |
472 * Sets the blending function constant referenced by the following blending | 484 * Sets the blending function constant referenced by the following blending |
473 * coefficients: | 485 * coefficients: |
474 * kConstC_GrBlendCoeff | 486 * kConstC_GrBlendCoeff |
475 * kIConstC_GrBlendCoeff | 487 * kIConstC_GrBlendCoeff |
476 * kConstA_GrBlendCoeff | 488 * kConstA_GrBlendCoeff |
477 * kIConstA_GrBlendCoeff | 489 * kIConstA_GrBlendCoeff |
478 * | 490 * |
479 * @param constant the constant to set | 491 * @param constant the constant to set |
480 */ | 492 */ |
481 void setBlendConstant(GrColor constant) { fBlendConstant = constant; } | 493 void setBlendConstant(GrColor constant) { |
| 494 fBlendConstant = constant; |
| 495 this->invalidateBlendOptFlags(); |
| 496 } |
482 | 497 |
483 /** | 498 /** |
484 * Retrieves the last value set by setBlendConstant() | 499 * Retrieves the last value set by setBlendConstant() |
485 * @return the blending constant value | 500 * @return the blending constant value |
486 */ | 501 */ |
487 GrColor getBlendConstant() const { return fBlendConstant; } | 502 GrColor getBlendConstant() const { return fBlendConstant; } |
488 | 503 |
489 /** | 504 /** |
490 * Determines whether multiplying the computed per-pixel color by the pixel'
s fractional | 505 * Determines whether multiplying the computed per-pixel color by the pixel'
s fractional |
491 * coverage before the blend will give the correct final destination color.
In general it | 506 * coverage before the blend will give the correct final destination color.
In general it |
(...skipping 24 matching lines...) Expand all Loading... |
516 kCoverageAsAlpha_BlendOptFlag = 0x4, | 531 kCoverageAsAlpha_BlendOptFlag = 0x4, |
517 /** | 532 /** |
518 * Instead of emitting a src color, emit coverage in the alpha channel a
nd r,g,b are | 533 * Instead of emitting a src color, emit coverage in the alpha channel a
nd r,g,b are |
519 * "don't cares". | 534 * "don't cares". |
520 */ | 535 */ |
521 kEmitCoverage_BlendOptFlag = 0x8, | 536 kEmitCoverage_BlendOptFlag = 0x8, |
522 /** | 537 /** |
523 * Emit transparent black instead of the src color, no need to compute c
overage. | 538 * Emit transparent black instead of the src color, no need to compute c
overage. |
524 */ | 539 */ |
525 kEmitTransBlack_BlendOptFlag = 0x10, | 540 kEmitTransBlack_BlendOptFlag = 0x10, |
| 541 /** |
| 542 * Flag used to invalidate the cached BlendOptFlags, OptSrcCoeff, and Op
tDstCoeff cached by |
| 543 * the get BlendOpts function. |
| 544 */ |
| 545 kInvalid_BlendOptFlag = 0x20, |
526 }; | 546 }; |
527 GR_DECL_BITFIELD_OPS_FRIENDS(BlendOptFlags); | 547 GR_DECL_BITFIELD_OPS_FRIENDS(BlendOptFlags); |
528 | 548 |
| 549 void invalidateBlendOptFlags() { |
| 550 fBlendOptFlags = kInvalid_BlendOptFlag; |
| 551 } |
| 552 |
529 /** | 553 /** |
530 * Determines what optimizations can be applied based on the blend. The coef
ficients may have | 554 * Determines what optimizations can be applied based on the blend. The coef
ficients may have |
531 * to be tweaked in order for the optimization to work. srcCoeff and dstCoef
f are optional | 555 * to be tweaked in order for the optimization to work. srcCoeff and dstCoef
f are optional |
532 * params that receive the tweaked coefficients. Normally the function looks
at the current | 556 * params that receive the tweaked coefficients. Normally the function looks
at the current |
533 * state to see if coverage is enabled. By setting forceCoverage the caller
can speculatively | 557 * state to see if coverage is enabled. By setting forceCoverage the caller
can speculatively |
534 * determine the blend optimizations that would be used if there was partial
pixel coverage. | 558 * determine the blend optimizations that would be used if there was partial
pixel coverage. |
535 * | 559 * |
536 * Subclasses of GrDrawTarget that actually draw (as opposed to those that j
ust buffer for | 560 * Subclasses of GrDrawTarget that actually draw (as opposed to those that j
ust buffer for |
537 * playback) must call this function and respect the flags that replace the
output color. | 561 * playback) must call this function and respect the flags that replace the
output color. |
| 562 * |
| 563 * If the cached BlendOptFlags does not have the invalidate bit set, then ge
tBlendOpts will |
| 564 * simply returned the cached flags and coefficients. Otherwise it will calc
ulate the values. |
538 */ | 565 */ |
539 BlendOptFlags getBlendOpts(bool forceCoverage = false, | 566 BlendOptFlags getBlendOpts(bool forceCoverage = false, |
540 GrBlendCoeff* srcCoeff = NULL, | 567 GrBlendCoeff* srcCoeff = NULL, |
541 GrBlendCoeff* dstCoeff = NULL) const; | 568 GrBlendCoeff* dstCoeff = NULL) const; |
542 | 569 |
543 /// @} | 570 /// @} |
544 | 571 |
545 /////////////////////////////////////////////////////////////////////////// | 572 /////////////////////////////////////////////////////////////////////////// |
546 /// @name View Matrix | 573 /// @name View Matrix |
547 //// | 574 //// |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 | 709 |
683 /** | 710 /** |
684 * Sets the stencil settings to use for the next draw. | 711 * Sets the stencil settings to use for the next draw. |
685 * Changing the clip has the side-effect of possibly zeroing | 712 * Changing the clip has the side-effect of possibly zeroing |
686 * out the client settable stencil bits. So multipass algorithms | 713 * out the client settable stencil bits. So multipass algorithms |
687 * using stencil should not change the clip between passes. | 714 * using stencil should not change the clip between passes. |
688 * @param settings the stencil settings to use. | 715 * @param settings the stencil settings to use. |
689 */ | 716 */ |
690 void setStencil(const GrStencilSettings& settings) { | 717 void setStencil(const GrStencilSettings& settings) { |
691 fStencilSettings = settings; | 718 fStencilSettings = settings; |
| 719 this->invalidateBlendOptFlags(); |
692 } | 720 } |
693 | 721 |
694 /** | 722 /** |
695 * Shortcut to disable stencil testing and ops. | 723 * Shortcut to disable stencil testing and ops. |
696 */ | 724 */ |
697 void disableStencil() { | 725 void disableStencil() { |
698 fStencilSettings.setDisabled(); | 726 fStencilSettings.setDisabled(); |
| 727 this->invalidateBlendOptFlags(); |
699 } | 728 } |
700 | 729 |
701 const GrStencilSettings& getStencil() const { return fStencilSettings; } | 730 const GrStencilSettings& getStencil() const { return fStencilSettings; } |
702 | 731 |
703 GrStencilSettings* stencil() { return &fStencilSettings; } | 732 GrStencilSettings* stencil() { return &fStencilSettings; } |
704 | 733 |
705 /// @} | 734 /// @} |
706 | 735 |
707 /////////////////////////////////////////////////////////////////////////// | 736 /////////////////////////////////////////////////////////////////////////// |
708 /// @name State Flags | 737 /// @name State Flags |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 */ | 772 */ |
744 kCoverageDrawing_StateBit = 0x10, | 773 kCoverageDrawing_StateBit = 0x10, |
745 | 774 |
746 // Users of the class may add additional bits to the vector | 775 // Users of the class may add additional bits to the vector |
747 kDummyStateBit, | 776 kDummyStateBit, |
748 kLastPublicStateBit = kDummyStateBit-1, | 777 kLastPublicStateBit = kDummyStateBit-1, |
749 }; | 778 }; |
750 | 779 |
751 void resetStateFlags() { | 780 void resetStateFlags() { |
752 fFlagBits = 0; | 781 fFlagBits = 0; |
| 782 this->invalidateBlendOptFlags(); |
753 } | 783 } |
754 | 784 |
755 /** | 785 /** |
756 * Enable render state settings. | 786 * Enable render state settings. |
757 * | 787 * |
758 * @param stateBits bitfield of StateBits specifying the states to enable | 788 * @param stateBits bitfield of StateBits specifying the states to enable |
759 */ | 789 */ |
760 void enableState(uint32_t stateBits) { | 790 void enableState(uint32_t stateBits) { |
761 fFlagBits |= stateBits; | 791 fFlagBits |= stateBits; |
| 792 this->invalidateBlendOptFlags(); |
762 } | 793 } |
763 | 794 |
764 /** | 795 /** |
765 * Disable render state settings. | 796 * Disable render state settings. |
766 * | 797 * |
767 * @param stateBits bitfield of StateBits specifying the states to disable | 798 * @param stateBits bitfield of StateBits specifying the states to disable |
768 */ | 799 */ |
769 void disableState(uint32_t stateBits) { | 800 void disableState(uint32_t stateBits) { |
770 fFlagBits &= ~(stateBits); | 801 fFlagBits &= ~(stateBits); |
| 802 this->invalidateBlendOptFlags(); |
771 } | 803 } |
772 | 804 |
773 /** | 805 /** |
774 * Enable or disable stateBits based on a boolean. | 806 * Enable or disable stateBits based on a boolean. |
775 * | 807 * |
776 * @param stateBits bitfield of StateBits to enable or disable | 808 * @param stateBits bitfield of StateBits to enable or disable |
777 * @param enable if true enable stateBits, otherwise disable | 809 * @param enable if true enable stateBits, otherwise disable |
778 */ | 810 */ |
779 void setState(uint32_t stateBits, bool enable) { | 811 void setState(uint32_t stateBits, bool enable) { |
780 if (enable) { | 812 if (enable) { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 fDstBlend = that.fDstBlend; | 917 fDstBlend = that.fDstBlend; |
886 fBlendConstant = that.fBlendConstant; | 918 fBlendConstant = that.fBlendConstant; |
887 fFlagBits = that.fFlagBits; | 919 fFlagBits = that.fFlagBits; |
888 fVACount = that.fVACount; | 920 fVACount = that.fVACount; |
889 fVAPtr = that.fVAPtr; | 921 fVAPtr = that.fVAPtr; |
890 fStencilSettings = that.fStencilSettings; | 922 fStencilSettings = that.fStencilSettings; |
891 fCoverage = that.fCoverage; | 923 fCoverage = that.fCoverage; |
892 fDrawFace = that.fDrawFace; | 924 fDrawFace = that.fDrawFace; |
893 fColorStages = that.fColorStages; | 925 fColorStages = that.fColorStages; |
894 fCoverageStages = that.fCoverageStages; | 926 fCoverageStages = that.fCoverageStages; |
| 927 fOptSrcBlend = that.fOptSrcBlend; |
| 928 fOptDstBlend = that.fOptDstBlend; |
| 929 fBlendOptFlags = that.fBlendOptFlags; |
895 | 930 |
896 memcpy(fFixedFunctionVertexAttribIndices, | 931 memcpy(fFixedFunctionVertexAttribIndices, |
897 that.fFixedFunctionVertexAttribIndices, | 932 that.fFixedFunctionVertexAttribIndices, |
898 sizeof(fFixedFunctionVertexAttribIndices)); | 933 sizeof(fFixedFunctionVertexAttribIndices)); |
899 return *this; | 934 return *this; |
900 } | 935 } |
901 | 936 |
902 private: | 937 private: |
903 | 938 |
904 void onReset(const SkMatrix* initialViewMatrix) { | 939 void onReset(const SkMatrix* initialViewMatrix) { |
(...skipping 11 matching lines...) Expand all Loading... |
916 } else { | 951 } else { |
917 fViewMatrix = *initialViewMatrix; | 952 fViewMatrix = *initialViewMatrix; |
918 } | 953 } |
919 fSrcBlend = kOne_GrBlendCoeff; | 954 fSrcBlend = kOne_GrBlendCoeff; |
920 fDstBlend = kZero_GrBlendCoeff; | 955 fDstBlend = kZero_GrBlendCoeff; |
921 fBlendConstant = 0x0; | 956 fBlendConstant = 0x0; |
922 fFlagBits = 0x0; | 957 fFlagBits = 0x0; |
923 fStencilSettings.setDisabled(); | 958 fStencilSettings.setDisabled(); |
924 fCoverage = 0xffffffff; | 959 fCoverage = 0xffffffff; |
925 fDrawFace = kBoth_DrawFace; | 960 fDrawFace = kBoth_DrawFace; |
| 961 |
| 962 this->invalidateBlendOptFlags(); |
926 } | 963 } |
927 | 964 |
| 965 BlendOptFlags calcBlendOpts(bool forceCoverage = false, |
| 966 GrBlendCoeff* srcCoeff = NULL, |
| 967 GrBlendCoeff* dstCoeff = NULL) const; |
928 | 968 |
929 // These fields are roughly sorted by decreasing likelihood of being differe
nt in op== | 969 // These fields are roughly sorted by decreasing likelihood of being differe
nt in op== |
930 SkAutoTUnref<GrRenderTarget> fRenderTarget; | 970 SkAutoTUnref<GrRenderTarget> fRenderTarget; |
931 GrColor fColor; | 971 GrColor fColor; |
932 SkMatrix fViewMatrix; | 972 SkMatrix fViewMatrix; |
933 GrBlendCoeff fSrcBlend; | 973 GrBlendCoeff fSrcBlend; |
934 GrBlendCoeff fDstBlend; | 974 GrBlendCoeff fDstBlend; |
935 GrColor fBlendConstant; | 975 GrColor fBlendConstant; |
936 uint32_t fFlagBits; | 976 uint32_t fFlagBits; |
937 const GrVertexAttrib* fVAPtr; | 977 const GrVertexAttrib* fVAPtr; |
938 int fVACount; | 978 int fVACount; |
939 GrStencilSettings fStencilSettings; | 979 GrStencilSettings fStencilSettings; |
940 GrColor fCoverage; | 980 GrColor fCoverage; |
941 DrawFace fDrawFace; | 981 DrawFace fDrawFace; |
942 | 982 |
943 typedef SkSTArray<4, GrEffectStage> EffectStageArray; | 983 typedef SkSTArray<4, GrEffectStage> EffectStageArray; |
944 EffectStageArray fColorStages; | 984 EffectStageArray fColorStages; |
945 EffectStageArray fCoverageStages; | 985 EffectStageArray fCoverageStages; |
| 986 |
| 987 mutable GrBlendCoeff fOptSrcBlend; |
| 988 mutable GrBlendCoeff fOptDstBlend; |
| 989 mutable BlendOptFlags fBlendOptFlags; |
946 | 990 |
947 // This is simply a different representation of info in fVertexAttribs and t
hus does | 991 // This is simply a different representation of info in fVertexAttribs and t
hus does |
948 // not need to be compared in op==. | 992 // not need to be compared in op==. |
949 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt
]; | 993 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt
]; |
950 | 994 |
951 // Some of the auto restore objects assume that no effects are removed durin
g their lifetime. | 995 // Some of the auto restore objects assume that no effects are removed durin
g their lifetime. |
952 // This is used to assert that this condition holds. | 996 // This is used to assert that this condition holds. |
953 SkDEBUGCODE(int fBlockEffectRemovalCnt;) | 997 SkDEBUGCODE(int fBlockEffectRemovalCnt;) |
954 | 998 |
955 /** | 999 /** |
956 * Sets vertex attributes for next draw. | 1000 * Sets vertex attributes for next draw. |
957 * | 1001 * |
958 * @param attribs the array of vertex attributes to set. | 1002 * @param attribs the array of vertex attributes to set. |
959 * @param count the number of attributes being set, limited to kMaxVer
texAttribCnt. | 1003 * @param count the number of attributes being set, limited to kMaxVer
texAttribCnt. |
960 */ | 1004 */ |
961 void setVertexAttribs(const GrVertexAttrib attribs[], int count); | 1005 void setVertexAttribs(const GrVertexAttrib attribs[], int count); |
962 | 1006 |
963 typedef SkRefCnt INHERITED; | 1007 typedef SkRefCnt INHERITED; |
964 }; | 1008 }; |
965 | 1009 |
966 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags); | 1010 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags); |
967 | 1011 |
968 #endif | 1012 #endif |
OLD | NEW |