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 #include "GrBackendEffectFactory.h" | 11 #include "GrBackendEffectFactory.h" |
12 #include "GrBlend.h" | 12 #include "GrBlend.h" |
13 #include "GrColor.h" | 13 #include "GrColor.h" |
14 #include "GrEffectStage.h" | 14 #include "GrEffectStage.h" |
15 #include "GrPaint.h" | 15 #include "GrPaint.h" |
16 #include "GrPoint.h" | 16 #include "GrPoint.h" |
17 #include "GrRenderTarget.h" | 17 #include "GrRenderTarget.h" |
18 #include "GrStencil.h" | 18 #include "GrStencil.h" |
19 #include "GrTemplates.h" | 19 #include "GrTemplates.h" |
20 #include "GrTexture.h" | 20 #include "GrTexture.h" |
21 #include "GrTypesPriv.h" | 21 #include "GrTypesPriv.h" |
22 #include "effects/GrSimpleTextureEffect.h" | 22 #include "effects/GrSimpleTextureEffect.h" |
23 | 23 |
24 #include "SkMatrix.h" | 24 #include "SkMatrix.h" |
| 25 #include "SkTypes.h" |
25 #include "SkXfermode.h" | 26 #include "SkXfermode.h" |
26 | 27 |
27 class GrDrawState : public SkRefCnt { | 28 class GrDrawState : public SkRefCnt { |
28 public: | 29 public: |
29 SK_DECLARE_INST_COUNT(GrDrawState) | 30 SK_DECLARE_INST_COUNT(GrDrawState) |
30 | 31 |
31 GrDrawState() { | 32 GrDrawState() { |
32 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) | 33 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;) |
33 this->reset(); | 34 this->reset(); |
34 } | 35 } |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 fCommon.fColorFilterColor = c; | 273 fCommon.fColorFilterColor = c; |
273 fCommon.fColorFilterMode = mode; | 274 fCommon.fColorFilterMode = mode; |
274 } | 275 } |
275 | 276 |
276 GrColor getColorFilterColor() const { return fCommon.fColorFilterColor; } | 277 GrColor getColorFilterColor() const { return fCommon.fColorFilterColor; } |
277 SkXfermode::Mode getColorFilterMode() const { return fCommon.fColorFilterMod
e; } | 278 SkXfermode::Mode getColorFilterMode() const { return fCommon.fColorFilterMod
e; } |
278 | 279 |
279 /** | 280 /** |
280 * Constructor sets the color to be 'color' which is undone by the destructo
r. | 281 * Constructor sets the color to be 'color' which is undone by the destructo
r. |
281 */ | 282 */ |
282 class AutoColorRestore : public ::GrNoncopyable { | 283 class AutoColorRestore : public ::SkNoncopyable { |
283 public: | 284 public: |
284 AutoColorRestore() : fDrawState(NULL), fOldColor(0) {} | 285 AutoColorRestore() : fDrawState(NULL), fOldColor(0) {} |
285 | 286 |
286 AutoColorRestore(GrDrawState* drawState, GrColor color) { | 287 AutoColorRestore(GrDrawState* drawState, GrColor color) { |
287 fDrawState = NULL; | 288 fDrawState = NULL; |
288 this->set(drawState, color); | 289 this->set(drawState, color); |
289 } | 290 } |
290 | 291 |
291 void reset() { | 292 void reset() { |
292 if (NULL != fDrawState) { | 293 if (NULL != fDrawState) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 const SkMatrix& matrix, | 394 const SkMatrix& matrix, |
394 const GrTextureParams& params) { | 395 const GrTextureParams& params) { |
395 GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix, par
ams); | 396 GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix, par
ams); |
396 this->addCoverageEffect(effect)->unref(); | 397 this->addCoverageEffect(effect)->unref(); |
397 } | 398 } |
398 | 399 |
399 /** | 400 /** |
400 * When this object is destroyed it will remove any effects from the draw st
ate that were added | 401 * When this object is destroyed it will remove any effects from the draw st
ate that were added |
401 * after its constructor. | 402 * after its constructor. |
402 */ | 403 */ |
403 class AutoRestoreEffects : public ::GrNoncopyable { | 404 class AutoRestoreEffects : public ::SkNoncopyable { |
404 public: | 405 public: |
405 AutoRestoreEffects() : fDrawState(NULL), fColorEffectCnt(0), fCoverageEf
fectCnt(0) {} | 406 AutoRestoreEffects() : fDrawState(NULL), fColorEffectCnt(0), fCoverageEf
fectCnt(0) {} |
406 | 407 |
407 AutoRestoreEffects(GrDrawState* ds) : fDrawState(NULL), fColorEffectCnt(
0), fCoverageEffectCnt(0) { | 408 AutoRestoreEffects(GrDrawState* ds) : fDrawState(NULL), fColorEffectCnt(
0), fCoverageEffectCnt(0) { |
408 this->set(ds); | 409 this->set(ds); |
409 } | 410 } |
410 | 411 |
411 ~AutoRestoreEffects() { this->set(NULL); } | 412 ~AutoRestoreEffects() { this->set(NULL); } |
412 | 413 |
413 void set(GrDrawState* ds) { | 414 void set(GrDrawState* ds) { |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 } | 599 } |
599 return false; | 600 return false; |
600 } | 601 } |
601 | 602 |
602 //////////////////////////////////////////////////////////////////////////// | 603 //////////////////////////////////////////////////////////////////////////// |
603 | 604 |
604 /** | 605 /** |
605 * Preconcats the current view matrix and restores the previous view matrix
in the destructor. | 606 * Preconcats the current view matrix and restores the previous view matrix
in the destructor. |
606 * Effect matrices are automatically adjusted to compensate and adjusted bac
k in the destructor. | 607 * Effect matrices are automatically adjusted to compensate and adjusted bac
k in the destructor. |
607 */ | 608 */ |
608 class AutoViewMatrixRestore : public ::GrNoncopyable { | 609 class AutoViewMatrixRestore : public ::SkNoncopyable { |
609 public: | 610 public: |
610 AutoViewMatrixRestore() : fDrawState(NULL) {} | 611 AutoViewMatrixRestore() : fDrawState(NULL) {} |
611 | 612 |
612 AutoViewMatrixRestore(GrDrawState* ds, const SkMatrix& preconcatMatrix)
{ | 613 AutoViewMatrixRestore(GrDrawState* ds, const SkMatrix& preconcatMatrix)
{ |
613 fDrawState = NULL; | 614 fDrawState = NULL; |
614 this->set(ds, preconcatMatrix); | 615 this->set(ds, preconcatMatrix); |
615 } | 616 } |
616 | 617 |
617 ~AutoViewMatrixRestore() { this->restore(); } | 618 ~AutoViewMatrixRestore() { this->restore(); } |
618 | 619 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 } | 653 } |
653 | 654 |
654 /** | 655 /** |
655 * Retrieves the currently set render-target. | 656 * Retrieves the currently set render-target. |
656 * | 657 * |
657 * @return The currently set render target. | 658 * @return The currently set render target. |
658 */ | 659 */ |
659 const GrRenderTarget* getRenderTarget() const { return fRenderTarget.get();
} | 660 const GrRenderTarget* getRenderTarget() const { return fRenderTarget.get();
} |
660 GrRenderTarget* getRenderTarget() { return fRenderTarget.get(); } | 661 GrRenderTarget* getRenderTarget() { return fRenderTarget.get(); } |
661 | 662 |
662 class AutoRenderTargetRestore : public ::GrNoncopyable { | 663 class AutoRenderTargetRestore : public ::SkNoncopyable { |
663 public: | 664 public: |
664 AutoRenderTargetRestore() : fDrawState(NULL), fSavedTarget(NULL) {} | 665 AutoRenderTargetRestore() : fDrawState(NULL), fSavedTarget(NULL) {} |
665 AutoRenderTargetRestore(GrDrawState* ds, GrRenderTarget* newTarget) { | 666 AutoRenderTargetRestore(GrDrawState* ds, GrRenderTarget* newTarget) { |
666 fDrawState = NULL; | 667 fDrawState = NULL; |
667 fSavedTarget = NULL; | 668 fSavedTarget = NULL; |
668 this->set(ds, newTarget); | 669 this->set(ds, newTarget); |
669 } | 670 } |
670 ~AutoRenderTargetRestore() { this->restore(); } | 671 ~AutoRenderTargetRestore() { this->restore(); } |
671 | 672 |
672 void restore() { | 673 void restore() { |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 * @param count the number of attributes being set, limited to kMaxVer
texAttribCnt. | 1076 * @param count the number of attributes being set, limited to kMaxVer
texAttribCnt. |
1076 */ | 1077 */ |
1077 void setVertexAttribs(const GrVertexAttrib attribs[], int count); | 1078 void setVertexAttribs(const GrVertexAttrib attribs[], int count); |
1078 | 1079 |
1079 typedef SkRefCnt INHERITED; | 1080 typedef SkRefCnt INHERITED; |
1080 }; | 1081 }; |
1081 | 1082 |
1082 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags); | 1083 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags); |
1083 | 1084 |
1084 #endif | 1085 #endif |
OLD | NEW |