aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrDrawState.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/GrDrawState.h')
-rw-r--r--src/gpu/GrDrawState.h103
1 files changed, 24 insertions, 79 deletions
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 2203e889e3..ffa7b093bb 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -257,38 +257,26 @@ public:
/**
* 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 @@ public:
// 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 @@ public:
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 @@ public:
/**
* 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 @@ public:
}
/**
- * 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 @@ public:
}
/**
- * 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) {
- 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;
+ void localCoordChange(const SkMatrix& oldToNew) {
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:
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 @@ public:
*/
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 @@ public:
* 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 @@ public:
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;
}