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

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

Issue 404473007: Cache the return values of getBlendOpts in GrDrawState (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Review changes Created 6 years, 5 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 | « no previous file | src/gpu/GrDrawState.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 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
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 fBlendOptFlags = kInvalid_BlendOptFlag;
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
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 fBlendOptFlags = kInvalid_BlendOptFlag;
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
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 fBlendOptFlags = kInvalid_BlendOptFlag;
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
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 fBlendOptFlags = kInvalid_BlendOptFlag;
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 fBlendOptFlags = kInvalid_BlendOptFlag;
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 25 matching lines...) Expand all
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 n = fDrawState->fColorStages.count() - fColorEffectCnt;
395 SkASSERT(n >= 0); 402 SkASSERT(n >= 0);
396 fDrawState->fColorStages.pop_back_n(n); 403 fDrawState->fColorStages.pop_back_n(n);
404 if (n > 0) {
405 fBlendOptFlags = kInvalid_BlendOptFlag;
406 }
397 n = fDrawState->fCoverageStages.count() - fCoverageEffectCnt; 407 n = fDrawState->fCoverageStages.count() - fCoverageEffectCnt;
bsalomon 2014/07/17 19:53:50 int m = if (n + m > 0) ?
398 SkASSERT(n >= 0); 408 SkASSERT(n >= 0);
399 fDrawState->fCoverageStages.pop_back_n(n); 409 fDrawState->fCoverageStages.pop_back_n(n);
410 if (n > 0) {
411 fBlendOptFlags = kInvalid_BlendOptFlag;
412 }
400 SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;) 413 SkDEBUGCODE(--fDrawState->fBlockEffectRemovalCnt;)
401 } 414 }
402 fDrawState = ds; 415 fDrawState = ds;
403 if (NULL != ds) { 416 if (NULL != ds) {
404 fColorEffectCnt = ds->fColorStages.count(); 417 fColorEffectCnt = ds->fColorStages.count();
405 fCoverageEffectCnt = ds->fCoverageStages.count(); 418 fCoverageEffectCnt = ds->fCoverageStages.count();
406 SkDEBUGCODE(++ds->fBlockEffectRemovalCnt;) 419 SkDEBUGCODE(++ds->fBlockEffectRemovalCnt;)
407 } 420 }
408 } 421 }
409 422
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 * where D is the existing destination color, S is the incoming source 455 * 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() 456 * color, and D' is the new destination color that will be written. sat()
444 * is the saturation function. 457 * is the saturation function.
445 * 458 *
446 * @param srcCoef coefficient applied to the src color. 459 * @param srcCoef coefficient applied to the src color.
447 * @param dstCoef coefficient applied to the dst color. 460 * @param dstCoef coefficient applied to the dst color.
448 */ 461 */
449 void setBlendFunc(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) { 462 void setBlendFunc(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) {
450 fSrcBlend = srcCoeff; 463 fSrcBlend = srcCoeff;
451 fDstBlend = dstCoeff; 464 fDstBlend = dstCoeff;
465 fBlendOptFlags = kInvalid_BlendOptFlag;
452 #ifdef SK_DEBUG 466 #ifdef SK_DEBUG
453 if (GrBlendCoeffRefsDst(dstCoeff)) { 467 if (GrBlendCoeffRefsDst(dstCoeff)) {
454 GrPrintf("Unexpected dst blend coeff. Won't work correctly with cove rage stages.\n"); 468 GrPrintf("Unexpected dst blend coeff. Won't work correctly with cove rage stages.\n");
455 } 469 }
456 if (GrBlendCoeffRefsSrc(srcCoeff)) { 470 if (GrBlendCoeffRefsSrc(srcCoeff)) {
457 GrPrintf("Unexpected src blend coeff. Won't work correctly with cove rage stages.\n"); 471 GrPrintf("Unexpected src blend coeff. Won't work correctly with cove rage stages.\n");
458 } 472 }
459 #endif 473 #endif
460 } 474 }
461 475
462 GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlend; } 476 GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlend; }
463 GrBlendCoeff getDstBlendCoeff() const { return fDstBlend; } 477 GrBlendCoeff getDstBlendCoeff() const { return fDstBlend; }
464 478
465 void getDstBlendCoeff(GrBlendCoeff* srcBlendCoeff, 479 void getDstBlendCoeff(GrBlendCoeff* srcBlendCoeff,
466 GrBlendCoeff* dstBlendCoeff) const { 480 GrBlendCoeff* dstBlendCoeff) const {
467 *srcBlendCoeff = fSrcBlend; 481 *srcBlendCoeff = fSrcBlend;
468 *dstBlendCoeff = fDstBlend; 482 *dstBlendCoeff = fDstBlend;
469 } 483 }
470 484
471 /** 485 /**
472 * Sets the blending function constant referenced by the following blending 486 * Sets the blending function constant referenced by the following blending
473 * coefficients: 487 * coefficients:
474 * kConstC_GrBlendCoeff 488 * kConstC_GrBlendCoeff
475 * kIConstC_GrBlendCoeff 489 * kIConstC_GrBlendCoeff
476 * kConstA_GrBlendCoeff 490 * kConstA_GrBlendCoeff
477 * kIConstA_GrBlendCoeff 491 * kIConstA_GrBlendCoeff
478 * 492 *
479 * @param constant the constant to set 493 * @param constant the constant to set
480 */ 494 */
481 void setBlendConstant(GrColor constant) { fBlendConstant = constant; } 495 void setBlendConstant(GrColor constant) {
496 fBlendConstant = constant;
497 fBlendOptFlags = kInvalid_BlendOptFlag;
498 }
482 499
483 /** 500 /**
484 * Retrieves the last value set by setBlendConstant() 501 * Retrieves the last value set by setBlendConstant()
485 * @return the blending constant value 502 * @return the blending constant value
486 */ 503 */
487 GrColor getBlendConstant() const { return fBlendConstant; } 504 GrColor getBlendConstant() const { return fBlendConstant; }
488 505
489 /** 506 /**
490 * Determines whether multiplying the computed per-pixel color by the pixel' s fractional 507 * 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 508 * coverage before the blend will give the correct final destination color. In general it
(...skipping 24 matching lines...) Expand all
516 kCoverageAsAlpha_BlendOptFlag = 0x4, 533 kCoverageAsAlpha_BlendOptFlag = 0x4,
517 /** 534 /**
518 * Instead of emitting a src color, emit coverage in the alpha channel a nd r,g,b are 535 * Instead of emitting a src color, emit coverage in the alpha channel a nd r,g,b are
519 * "don't cares". 536 * "don't cares".
520 */ 537 */
521 kEmitCoverage_BlendOptFlag = 0x8, 538 kEmitCoverage_BlendOptFlag = 0x8,
522 /** 539 /**
523 * Emit transparent black instead of the src color, no need to compute c overage. 540 * Emit transparent black instead of the src color, no need to compute c overage.
524 */ 541 */
525 kEmitTransBlack_BlendOptFlag = 0x10, 542 kEmitTransBlack_BlendOptFlag = 0x10,
543 /**
544 * Flag used to invalidate the cached BlendOptFlags, OptSrcCoeff, and Op tDstCoeff cached by
545 * the get BlendOpts function.
546 */
547 kInvalid_BlendOptFlag = 0x20,
526 }; 548 };
527 GR_DECL_BITFIELD_OPS_FRIENDS(BlendOptFlags); 549 GR_DECL_BITFIELD_OPS_FRIENDS(BlendOptFlags);
528 550
529 /** 551 /**
530 * Determines what optimizations can be applied based on the blend. The coef ficients may have 552 * 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 553 * 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 554 * 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 555 * 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. 556 * determine the blend optimizations that would be used if there was partial pixel coverage.
535 * 557 *
536 * Subclasses of GrDrawTarget that actually draw (as opposed to those that j ust buffer for 558 * 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. 559 * playback) must call this function and respect the flags that replace the output color.
560 *
561 * If the cached BlendOptFlags does not have the invalidate bit set, then ge tBlendOpts will
562 * simply returned the cached flags and coefficients. Otherwise it will calc ulate the values.
538 */ 563 */
539 BlendOptFlags getBlendOpts(bool forceCoverage = false, 564 BlendOptFlags getBlendOpts(bool forceCoverage = false,
540 GrBlendCoeff* srcCoeff = NULL, 565 GrBlendCoeff* srcCoeff = NULL,
541 GrBlendCoeff* dstCoeff = NULL) const; 566 GrBlendCoeff* dstCoeff = NULL) const;
542 567
543 /// @} 568 /// @}
544 569
545 /////////////////////////////////////////////////////////////////////////// 570 ///////////////////////////////////////////////////////////////////////////
546 /// @name View Matrix 571 /// @name View Matrix
547 //// 572 ////
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 707
683 /** 708 /**
684 * Sets the stencil settings to use for the next draw. 709 * Sets the stencil settings to use for the next draw.
685 * Changing the clip has the side-effect of possibly zeroing 710 * Changing the clip has the side-effect of possibly zeroing
686 * out the client settable stencil bits. So multipass algorithms 711 * out the client settable stencil bits. So multipass algorithms
687 * using stencil should not change the clip between passes. 712 * using stencil should not change the clip between passes.
688 * @param settings the stencil settings to use. 713 * @param settings the stencil settings to use.
689 */ 714 */
690 void setStencil(const GrStencilSettings& settings) { 715 void setStencil(const GrStencilSettings& settings) {
691 fStencilSettings = settings; 716 fStencilSettings = settings;
717 fBlendOptFlags = kInvalid_BlendOptFlag;
692 } 718 }
693 719
694 /** 720 /**
695 * Shortcut to disable stencil testing and ops. 721 * Shortcut to disable stencil testing and ops.
696 */ 722 */
697 void disableStencil() { 723 void disableStencil() {
698 fStencilSettings.setDisabled(); 724 fStencilSettings.setDisabled();
725 fBlendOptFlags = kInvalid_BlendOptFlag;
699 } 726 }
700 727
701 const GrStencilSettings& getStencil() const { return fStencilSettings; } 728 const GrStencilSettings& getStencil() const { return fStencilSettings; }
702 729
703 GrStencilSettings* stencil() { return &fStencilSettings; } 730 GrStencilSettings* stencil() { return &fStencilSettings; }
704 731
705 /// @} 732 /// @}
706 733
707 /////////////////////////////////////////////////////////////////////////// 734 ///////////////////////////////////////////////////////////////////////////
708 /// @name State Flags 735 /// @name State Flags
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 */ 770 */
744 kCoverageDrawing_StateBit = 0x10, 771 kCoverageDrawing_StateBit = 0x10,
745 772
746 // Users of the class may add additional bits to the vector 773 // Users of the class may add additional bits to the vector
747 kDummyStateBit, 774 kDummyStateBit,
748 kLastPublicStateBit = kDummyStateBit-1, 775 kLastPublicStateBit = kDummyStateBit-1,
749 }; 776 };
750 777
751 void resetStateFlags() { 778 void resetStateFlags() {
752 fFlagBits = 0; 779 fFlagBits = 0;
780 fBlendOptFlags = kInvalid_BlendOptFlag;
753 } 781 }
754 782
755 /** 783 /**
756 * Enable render state settings. 784 * Enable render state settings.
757 * 785 *
758 * @param stateBits bitfield of StateBits specifying the states to enable 786 * @param stateBits bitfield of StateBits specifying the states to enable
759 */ 787 */
760 void enableState(uint32_t stateBits) { 788 void enableState(uint32_t stateBits) {
761 fFlagBits |= stateBits; 789 fFlagBits |= stateBits;
790 fBlendOptFlags = kInvalid_BlendOptFlag;
762 } 791 }
763 792
764 /** 793 /**
765 * Disable render state settings. 794 * Disable render state settings.
766 * 795 *
767 * @param stateBits bitfield of StateBits specifying the states to disable 796 * @param stateBits bitfield of StateBits specifying the states to disable
768 */ 797 */
769 void disableState(uint32_t stateBits) { 798 void disableState(uint32_t stateBits) {
770 fFlagBits &= ~(stateBits); 799 fFlagBits &= ~(stateBits);
800 fBlendOptFlags = kInvalid_BlendOptFlag;
771 } 801 }
772 802
773 /** 803 /**
774 * Enable or disable stateBits based on a boolean. 804 * Enable or disable stateBits based on a boolean.
775 * 805 *
776 * @param stateBits bitfield of StateBits to enable or disable 806 * @param stateBits bitfield of StateBits to enable or disable
777 * @param enable if true enable stateBits, otherwise disable 807 * @param enable if true enable stateBits, otherwise disable
778 */ 808 */
779 void setState(uint32_t stateBits, bool enable) { 809 void setState(uint32_t stateBits, bool enable) {
780 if (enable) { 810 if (enable) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 fDstBlend = that.fDstBlend; 915 fDstBlend = that.fDstBlend;
886 fBlendConstant = that.fBlendConstant; 916 fBlendConstant = that.fBlendConstant;
887 fFlagBits = that.fFlagBits; 917 fFlagBits = that.fFlagBits;
888 fVACount = that.fVACount; 918 fVACount = that.fVACount;
889 fVAPtr = that.fVAPtr; 919 fVAPtr = that.fVAPtr;
890 fStencilSettings = that.fStencilSettings; 920 fStencilSettings = that.fStencilSettings;
891 fCoverage = that.fCoverage; 921 fCoverage = that.fCoverage;
892 fDrawFace = that.fDrawFace; 922 fDrawFace = that.fDrawFace;
893 fColorStages = that.fColorStages; 923 fColorStages = that.fColorStages;
894 fCoverageStages = that.fCoverageStages; 924 fCoverageStages = that.fCoverageStages;
925 fOptSrcBlend = that.fOptSrcBlend;
926 fOptDstBlend = that.fOptDstBlend;
927 fBlendOptFlags = that.fBlendOptFlags;
895 928
896 memcpy(fFixedFunctionVertexAttribIndices, 929 memcpy(fFixedFunctionVertexAttribIndices,
897 that.fFixedFunctionVertexAttribIndices, 930 that.fFixedFunctionVertexAttribIndices,
898 sizeof(fFixedFunctionVertexAttribIndices)); 931 sizeof(fFixedFunctionVertexAttribIndices));
899 return *this; 932 return *this;
900 } 933 }
901 934
902 private: 935 private:
903 936
904 void onReset(const SkMatrix* initialViewMatrix) { 937 void onReset(const SkMatrix* initialViewMatrix) {
(...skipping 11 matching lines...) Expand all
916 } else { 949 } else {
917 fViewMatrix = *initialViewMatrix; 950 fViewMatrix = *initialViewMatrix;
918 } 951 }
919 fSrcBlend = kOne_GrBlendCoeff; 952 fSrcBlend = kOne_GrBlendCoeff;
920 fDstBlend = kZero_GrBlendCoeff; 953 fDstBlend = kZero_GrBlendCoeff;
921 fBlendConstant = 0x0; 954 fBlendConstant = 0x0;
922 fFlagBits = 0x0; 955 fFlagBits = 0x0;
923 fStencilSettings.setDisabled(); 956 fStencilSettings.setDisabled();
924 fCoverage = 0xffffffff; 957 fCoverage = 0xffffffff;
925 fDrawFace = kBoth_DrawFace; 958 fDrawFace = kBoth_DrawFace;
959
960 fBlendOptFlags = kInvalid_BlendOptFlag;
926 } 961 }
927 962
963 BlendOptFlags calcBlendOpts(bool forceCoverage = false,
964 GrBlendCoeff* srcCoeff = NULL,
965 GrBlendCoeff* dstCoeff = NULL) const;
928 966
929 // These fields are roughly sorted by decreasing likelihood of being differe nt in op== 967 // These fields are roughly sorted by decreasing likelihood of being differe nt in op==
930 SkAutoTUnref<GrRenderTarget> fRenderTarget; 968 SkAutoTUnref<GrRenderTarget> fRenderTarget;
931 GrColor fColor; 969 GrColor fColor;
932 SkMatrix fViewMatrix; 970 SkMatrix fViewMatrix;
933 GrBlendCoeff fSrcBlend; 971 GrBlendCoeff fSrcBlend;
934 GrBlendCoeff fDstBlend; 972 GrBlendCoeff fDstBlend;
935 GrColor fBlendConstant; 973 GrColor fBlendConstant;
936 uint32_t fFlagBits; 974 uint32_t fFlagBits;
937 const GrVertexAttrib* fVAPtr; 975 const GrVertexAttrib* fVAPtr;
938 int fVACount; 976 int fVACount;
939 GrStencilSettings fStencilSettings; 977 GrStencilSettings fStencilSettings;
940 GrColor fCoverage; 978 GrColor fCoverage;
941 DrawFace fDrawFace; 979 DrawFace fDrawFace;
942 980
943 typedef SkSTArray<4, GrEffectStage> EffectStageArray; 981 typedef SkSTArray<4, GrEffectStage> EffectStageArray;
944 EffectStageArray fColorStages; 982 EffectStageArray fColorStages;
945 EffectStageArray fCoverageStages; 983 EffectStageArray fCoverageStages;
984
985 mutable GrBlendCoeff fOptSrcBlend;
986 mutable GrBlendCoeff fOptDstBlend;
987 mutable BlendOptFlags fBlendOptFlags;
946 988
947 // This is simply a different representation of info in fVertexAttribs and t hus does 989 // This is simply a different representation of info in fVertexAttribs and t hus does
948 // not need to be compared in op==. 990 // not need to be compared in op==.
949 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt ]; 991 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt ];
950 992
951 // Some of the auto restore objects assume that no effects are removed durin g their lifetime. 993 // 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. 994 // This is used to assert that this condition holds.
953 SkDEBUGCODE(int fBlockEffectRemovalCnt;) 995 SkDEBUGCODE(int fBlockEffectRemovalCnt;)
954 996
955 /** 997 /**
956 * Sets vertex attributes for next draw. 998 * Sets vertex attributes for next draw.
957 * 999 *
958 * @param attribs the array of vertex attributes to set. 1000 * @param attribs the array of vertex attributes to set.
959 * @param count the number of attributes being set, limited to kMaxVer texAttribCnt. 1001 * @param count the number of attributes being set, limited to kMaxVer texAttribCnt.
960 */ 1002 */
961 void setVertexAttribs(const GrVertexAttrib attribs[], int count); 1003 void setVertexAttribs(const GrVertexAttrib attribs[], int count);
962 1004
963 typedef SkRefCnt INHERITED; 1005 typedef SkRefCnt INHERITED;
964 }; 1006 };
965 1007
966 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags); 1008 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags);
967 1009
968 #endif 1010 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrDrawState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698