Chromium Code Reviews| Index: src/gpu/GrInOrderDrawBuffer.cpp |
| diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp |
| index 6e5c1fe778d7b19d140a277c746e62868a52ad7e..db114678b4da164fe2d1b1fbc2b957bc7f472f8f 100644 |
| --- a/src/gpu/GrInOrderDrawBuffer.cpp |
| +++ b/src/gpu/GrInOrderDrawBuffer.cpp |
| @@ -120,11 +120,26 @@ void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds, |
| const SkMatrix* localMatrix) { |
| GrDrawState::AutoRestoreEffects are(ds); |
| + // Go to device coords to allow batching across matrix changes |
| + SkMatrix matrix = ds->getViewMatrix(); |
| + SkMatrix invert = SkMatrix::I(); |
| + |
| + // if we have explicit local coords then we do not use the localmatrix at all |
| bool hasExplicitLocalCoords = SkToBool(localRect); |
|
bsalomon
2014/12/23 20:18:40
I don't think this comment is quite right... if we
|
| - SkAutoTUnref<const GrGeometryProcessor> gp( |
| - create_rect_gp(hasExplicitLocalCoords, |
| - color, |
| - hasExplicitLocalCoords ? NULL : localMatrix)); |
| + if (!hasExplicitLocalCoords) { |
| + if (!matrix.isIdentity() && !matrix.invert(&invert)) { |
| + SkDebugf("Could not invert\n"); |
| + return; |
| + } |
| + |
| + if (localMatrix) { |
| + invert.preConcat(*localMatrix); |
| + } |
| + } |
| + |
| + SkAutoTUnref<const GrGeometryProcessor> gp(create_rect_gp(hasExplicitLocalCoords, |
| + color, |
| + &invert)); |
| size_t vstride = gp->getVertexStride(); |
| SkASSERT(vstride == sizeof(SkPoint) + sizeof(GrColor) + (SkToBool(localRect) ? sizeof(SkPoint) : |
| @@ -135,16 +150,10 @@ void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds, |
| return; |
| } |
| - // Go to device coords to allow batching across matrix changes |
| - SkMatrix matrix = ds->getViewMatrix(); |
| - |
| // When the caller has provided an explicit source rect for a stage then we don't want to |
| // modify that stage's matrix. Otherwise if the effect is generating its source rect from |
| // the vertex positions then we have to account for the view matrix change. |
| - GrDrawState::AutoViewMatrixRestore avmr; |
| - if (!avmr.setIdentity(ds)) { |
| - return; |
| - } |
| + GrDrawState::AutoViewMatrixRestore avmr(ds); |
| geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vstride); |
| matrix.mapPointsWithStride(geo.positions(), vstride, 4); |