Chromium Code Reviews| Index: src/gpu/GrDrawState.h |
| =================================================================== |
| --- src/gpu/GrDrawState.h (revision 8216) |
| +++ 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) */ |
|
jvanverth1
2013/03/19 15:11:59
It may not matter, but for consistency's sake it'd
bsalomon
2013/03/19 15:22:25
Can do... but if we're about to get rid of them is
jvanverth1
2013/03/19 15:36:51
Well, like I said, it may not matter... :)
|
| + 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; |
| @@ -492,7 +469,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()); |
| @@ -551,42 +528,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; |
| } |
| /// @} |
| @@ -827,11 +778,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(); } |
| @@ -841,9 +790,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; } |
| @@ -870,15 +817,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 |
| @@ -1195,8 +1141,7 @@ |
| return false; |
| } |
| for (int i = 0; i < kAttribIndexCount; ++i) { |
| - if ((i == kPosition_AttribIndex || |
| - s.fCommon.fAttribBindings & kAttribIndexMasks[i]) && |
|
jvanverth1
2013/03/19 15:11:59
Can we get rid of kAttribIndexMasks now? It was on
bsalomon
2013/03/19 15:22:25
Yes, I was planning to do that in a follow-up chan
|
| + if ((i == kPosition_AttribIndex || s.fCommon.fAttribBindings & (1 << i)) && |
| fAttribIndices[i] != s.fAttribIndices[i]) { |
| return false; |
| } |