| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 * the type of the attribute, its offset, and semantic binding (see GrVertex
Attrib in | 72 * the type of the attribute, its offset, and semantic binding (see GrVertex
Attrib in |
| 73 * GrTypesPriv.h). | 73 * GrTypesPriv.h). |
| 74 * | 74 * |
| 75 * The mapping of attributes with kEffect bindings to GrEffect inputs is spe
cified when | 75 * The mapping of attributes with kEffect bindings to GrEffect inputs is spe
cified when |
| 76 * setEffect is called. | 76 * setEffect is called. |
| 77 */ | 77 */ |
| 78 | 78 |
| 79 /** | 79 /** |
| 80 * Sets vertex attributes for next draw. The object driving the templatizat
ion | 80 * Sets vertex attributes for next draw. The object driving the templatizat
ion |
| 81 * should be a global GrVertexAttrib array that is never changed. | 81 * should be a global GrVertexAttrib array that is never changed. |
| 82 * |
| 83 * @param count the number of attributes being set, limited to kMaxVer
texAttribCnt. |
| 84 * @param stride the number of bytes between successive vertex data. |
| 82 */ | 85 */ |
| 83 template <const GrVertexAttrib A[]> void setVertexAttribs(int count) { | 86 template <const GrVertexAttrib A[]> void setVertexAttribs(int count, size_t
stride) { |
| 84 this->setVertexAttribs(A, count); | 87 this->internalSetVertexAttribs(A, count, stride); |
| 85 } | 88 } |
| 86 | 89 |
| 87 /** | 90 /** |
| 88 * Sets default vertex attributes for next draw. The default is a single at
tribute: | 91 * Sets default vertex attributes for next draw. The default is a single at
tribute: |
| 89 * {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribType} | 92 * {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribType} |
| 90 */ | 93 */ |
| 91 void setDefaultVertexAttribs(); | 94 void setDefaultVertexAttribs(); |
| 92 | 95 |
| 93 /** | 96 /** |
| 94 * Helper to save/restore vertex attribs | 97 * Helper to save/restore vertex attribs |
| 95 */ | 98 */ |
| 96 class AutoVertexAttribRestore { | 99 class AutoVertexAttribRestore { |
| 97 public: | 100 public: |
| 98 AutoVertexAttribRestore(GrDrawState* drawState); | 101 AutoVertexAttribRestore(GrDrawState* drawState); |
| 99 | 102 |
| 100 ~AutoVertexAttribRestore() { fDrawState->setVertexAttribs(fVAPtr, fVACo
unt); } | 103 ~AutoVertexAttribRestore() { fDrawState->internalSetVertexAttribs(fVAPt
r, fVACount, fVAStride); } |
| 101 | 104 |
| 102 private: | 105 private: |
| 103 GrDrawState* fDrawState; | 106 GrDrawState* fDrawState; |
| 104 const GrVertexAttrib* fVAPtr; | 107 const GrVertexAttrib* fVAPtr; |
| 105 int fVACount; | 108 int fVACount; |
| 109 size_t fVAStride; |
| 106 }; | 110 }; |
| 107 | 111 |
| 108 /// @} | 112 /// @} |
| 109 | 113 |
| 110 /** | 114 /** |
| 111 * Depending on features available in the underlying 3D API and the color bl
end mode requested | 115 * Depending on features available in the underlying 3D API and the color bl
end mode requested |
| 112 * it may or may not be possible to correctly blend with fractional pixel co
verage generated by | 116 * it may or may not be possible to correctly blend with fractional pixel co
verage generated by |
| 113 * the fragment shader. | 117 * the fragment shader. |
| 114 * | 118 * |
| 115 * This function considers the current draw state and the draw target's capa
bilities to | 119 * This function considers the current draw state and the draw target's capa
bilities to |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 void invalidateBlendOptFlags() { | 556 void invalidateBlendOptFlags() { |
| 553 fBlendOptFlags = kInvalid_BlendOptFlag; | 557 fBlendOptFlags = kInvalid_BlendOptFlag; |
| 554 } | 558 } |
| 555 | 559 |
| 556 uint32_t fHints; | 560 uint32_t fHints; |
| 557 | 561 |
| 558 // Some of the auto restore objects assume that no effects are removed durin
g their lifetime. | 562 // Some of the auto restore objects assume that no effects are removed durin
g their lifetime. |
| 559 // This is used to assert that this condition holds. | 563 // This is used to assert that this condition holds. |
| 560 SkDEBUGCODE(int fBlockEffectRemovalCnt;) | 564 SkDEBUGCODE(int fBlockEffectRemovalCnt;) |
| 561 | 565 |
| 562 /** | 566 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz
e_t stride); |
| 563 * Sets vertex attributes for next draw. | |
| 564 * | |
| 565 * @param attribs the array of vertex attributes to set. | |
| 566 * @param count the number of attributes being set, limited to kMaxVer
texAttribCnt. | |
| 567 */ | |
| 568 void setVertexAttribs(const GrVertexAttrib attribs[], int count); | |
| 569 | 567 |
| 570 typedef GrRODrawState INHERITED; | 568 typedef GrRODrawState INHERITED; |
| 571 }; | 569 }; |
| 572 | 570 |
| 573 #endif | 571 #endif |
| OLD | NEW |