Index: src/gpu/GrDrawState.h |
=================================================================== |
--- src/gpu/GrDrawState.h (revision 8241) |
+++ src/gpu/GrDrawState.h (working copy) |
@@ -257,38 +257,26 @@ |
/** |
* The vertex data used by the current program is represented as a bitfield |
* of flags. Programs always use positions and may also use texture |
- * coordinates, per-vertex colors, per-vertex coverage and edge data. Each |
- * stage can use the explicit texture coordinates as its input texture |
- * coordinates or it may use the positions as texture coordinates. |
+ * coordinates, per-vertex colors, per-vertex coverage and edge data. The |
+ * local coords accessible by effects may either come from positions or |
+ * be specified explicitly. |
*/ |
/** |
- * Generates a bit indicating that a texture stage uses texture coordinates |
- * |
- * @param stageIdx the stage that will use texture coordinates. |
- * |
- * @return the bit to add to a GrAttribBindings bitfield. |
- */ |
- static int ExplicitTexCoordAttribBindingsBit(int stageIdx) { |
- GrAssert(stageIdx < kNumStages); |
- return (1 << stageIdx); |
- } |
- |
- static bool StageBindsExplicitTexCoords(GrAttribBindings bindings, int stageIdx); |
- |
- /** |
* Additional Bits that can be specified in GrAttribBindings. |
*/ |
enum AttribBindingsBits { |
+ /** explicit local coords are provided (instead of using pre-view-matrix positions) */ |
+ kLocalCoords_AttribBindingsBit = 0x1, |
/* program uses colors (GrColor) */ |
- kColor_AttribBindingsBit = 1 << (kNumStages + 0), |
+ kColor_AttribBindingsBit = 0x2, |
/* program uses coverage (GrColor) |
*/ |
- kCoverage_AttribBindingsBit = 1 << (kNumStages + 1), |
+ kCoverage_AttribBindingsBit = 0x4, |
/* program uses edge data. Distance to the edge is used to |
* compute a coverage. See GrDrawState::setVertexEdgeType(). |
*/ |
- kEdge_AttribBindingsBit = 1 << (kNumStages + 2), |
+ kEdge_AttribBindingsBit = 0x8, |
// for below assert |
kDummyAttribBindingsBit, |
kHighAttribBindingsBit = kDummyAttribBindingsBit - 1 |
@@ -313,17 +301,6 @@ |
// Helpers for picking apart attribute bindings |
/** |
- * Helper function to determine if program uses explicit texture |
- * coordinates. |
- * |
- * @param bindings attribute bindings to query |
- * |
- * @return true if program uses texture coordinates, |
- * false otherwise. |
- */ |
- static bool AttributesBindExplicitTexCoords(GrAttribBindings bindings); |
- |
- /** |
* Determines whether src alpha is guaranteed to be one for all src pixels |
*/ |
bool srcAlphaWillBeOne(GrAttribBindings) const; |
@@ -356,9 +333,9 @@ |
kColor_AttribIndex, |
kCoverage_AttribIndex, |
kEdge_AttribIndex, |
- kTexCoord_AttribIndex, |
+ kLocalCoords_AttribIndex, |
- kLast_AttribIndex = kTexCoord_AttribIndex |
+ kLast_AttribIndex = kLocalCoords_AttribIndex |
}; |
static const int kAttribIndexCount = kLast_AttribIndex + 1; |
@@ -410,7 +387,7 @@ |
/** |
* Add a color filter that can be represented by a color and a mode. Applied |
- * after color-computing texture stages. |
+ * after color-computing effect stages. |
*/ |
void setColorFilter(GrColor c, SkXfermode::Mode mode) { |
fCommon.fColorFilterColor = c; |
@@ -497,7 +474,7 @@ |
} |
/** |
- * Creates a GrSimpleTextureEffect. |
+ * Creates a GrSimpleTextureEffect that uses local coords as texture coordinates. |
*/ |
void createTextureEffect(int stageIdx, GrTexture* texture, const SkMatrix& matrix) { |
GrAssert(!this->getStage(stageIdx).getEffect()); |
@@ -556,42 +533,16 @@ |
} |
/** |
- * Called when the source coord system is changing. preConcat gives the transformation from the |
- * old coord system to the new coord system. |
+ * Called when the source coord system is changing. This ensures that effects will see the |
+ * correct local coordinates. oldToNew gives the transformation from the old coord system in |
+ * which the geometry was specified to the new coordinate system from which it will be rendered. |
*/ |
- void preConcatStageMatrices(const SkMatrix& preConcat) { |
- this->preConcatStageMatrices(~0U, preConcat); |
- } |
- /** |
- * Version of above that applies the update matrix selectively to stages via a mask. |
- */ |
- void preConcatStageMatrices(uint32_t stageMask, const SkMatrix& preConcat) { |
+ void localCoordChange(const SkMatrix& oldToNew) { |
for (int i = 0; i < kNumStages; ++i) { |
- if (((1 << i) & stageMask) && this->isStageEnabled(i)) { |
- fStages[i].preConcatCoordChange(preConcat); |
- } |
- } |
- } |
- |
- /** |
- * Called when the source coord system is changing. preConcatInverse is the inverse of the |
- * transformation from the old coord system to the new coord system. Returns false if the matrix |
- * cannot be inverted. |
- */ |
- bool preConcatStageMatricesWithInverse(const SkMatrix& preConcatInverse) { |
- SkMatrix inv; |
- bool computed = false; |
- for (int i = 0; i < kNumStages; ++i) { |
if (this->isStageEnabled(i)) { |
- if (!computed && !preConcatInverse.invert(&inv)) { |
- return false; |
- } else { |
- computed = true; |
- } |
- fStages[i].preConcatCoordChange(preConcatInverse); |
+ fStages[i].localCoordChange(oldToNew); |
} |
} |
- return true; |
} |
/// @} |
@@ -832,11 +783,9 @@ |
public: |
AutoViewMatrixRestore() : fDrawState(NULL) {} |
- AutoViewMatrixRestore(GrDrawState* ds, |
- const SkMatrix& preconcatMatrix, |
- uint32_t explicitCoordStageMask = 0) { |
+ AutoViewMatrixRestore(GrDrawState* ds, const SkMatrix& preconcatMatrix) { |
fDrawState = NULL; |
- this->set(ds, preconcatMatrix, explicitCoordStageMask); |
+ this->set(ds, preconcatMatrix); |
} |
~AutoViewMatrixRestore() { this->restore(); } |
@@ -846,9 +795,7 @@ |
*/ |
void restore(); |
- void set(GrDrawState* drawState, |
- const SkMatrix& preconcatMatrix, |
- uint32_t explicitCoordStageMask = 0); |
+ void set(GrDrawState* drawState, const SkMatrix& preconcatMatrix); |
bool isSet() const { return NULL != fDrawState; } |
@@ -875,15 +822,14 @@ |
* positions, then we don't want to modify its matrix. The explicitCoordStageMask is used |
* to specify such stages. |
*/ |
- AutoDeviceCoordDraw(GrDrawState* drawState, |
- uint32_t explicitCoordStageMask = 0) { |
+ AutoDeviceCoordDraw(GrDrawState* drawState) { |
fDrawState = NULL; |
- this->set(drawState, explicitCoordStageMask); |
+ this->set(drawState); |
} |
~AutoDeviceCoordDraw() { this->restore(); } |
- bool set(GrDrawState* drawState, uint32_t explicitCoordStageMask = 0); |
+ bool set(GrDrawState* drawState); |
/** |
* Returns true if this object was successfully initialized on to a GrDrawState. It may |
@@ -1197,8 +1143,7 @@ |
return false; |
} |
for (int i = 0; i < kAttribIndexCount; ++i) { |
- if ((i == kPosition_AttribIndex || |
- s.fCommon.fAttribBindings & kAttribIndexMasks[i]) && |
+ if ((i == kPosition_AttribIndex || s.fCommon.fAttribBindings & (1 << i)) && |
fAttribIndices[i] != s.fAttribIndices[i]) { |
return false; |
} |