diff options
-rw-r--r-- | gpu/include/GrContext.h | 20 | ||||
-rw-r--r-- | gpu/src/GrContext.cpp | 19 |
2 files changed, 35 insertions, 4 deletions
diff --git a/gpu/include/GrContext.h b/gpu/include/GrContext.h index 3fe1a7b367..37ac1c4999 100644 --- a/gpu/include/GrContext.h +++ b/gpu/include/GrContext.h @@ -645,6 +645,7 @@ private: */ class GrAutoMatrix : GrNoncopyable { public: + GrAutoMatrix() : fContext(NULL) {} GrAutoMatrix(GrContext* ctx) : fContext(ctx) { fMatrix = ctx->getMatrix(); } @@ -652,8 +653,25 @@ public: fMatrix = ctx->getMatrix(); ctx->setMatrix(matrix); } + void set(GrContext* ctx) { + if (NULL != fContext) { + fContext->setMatrix(fMatrix); + } + fMatrix = ctx->getMatrix(); + fContext = ctx; + } + void set(GrContext* ctx, const GrMatrix& matrix) { + if (NULL != fContext) { + fContext->setMatrix(fMatrix); + } + fMatrix = ctx->getMatrix(); + ctx->setMatrix(matrix); + fContext = ctx; + } ~GrAutoMatrix() { - fContext->setMatrix(fMatrix); + if (NULL != fContext) { + fContext->setMatrix(fMatrix); + } } private: diff --git a/gpu/src/GrContext.cpp b/gpu/src/GrContext.cpp index b857dda8f7..8eb8c63e7e 100644 --- a/gpu/src/GrContext.cpp +++ b/gpu/src/GrContext.cpp @@ -590,13 +590,26 @@ void GrContext::drawPaint(const GrPaint& paint) { r.setLTRB(0, 0, GrIntToScalar(getRenderTarget()->width()), GrIntToScalar(getRenderTarget()->height())); + GrAutoMatrix am; GrMatrix inverse; - if (fGpu->getViewInverse(&inverse)) { + // We attempt to map r by the inverse matrix and draw that. mapRect will + // map the four corners and bound them with a new rect. This will not + // produce a correct result for some perspective matrices. + if (!this->getMatrix().hasPerspective() && + fGpu->getViewInverse(&inverse)) { inverse.mapRect(&r); } else { - GrPrintf("---- fGpu->getViewInverse failed\n"); + am.set(this, GrMatrix::I()); } - this->drawRect(paint, r); + GrPaint tmpPaint; + const GrPaint* p = &paint; + // by definition this fills the entire clip, no need for AA + if (paint.fAntiAlias) { + tmpPaint = paint; + tmpPaint.fAntiAlias = false; + p = &tmpPaint; + } + this->drawRect(*p, r); } //////////////////////////////////////////////////////////////////////////////// |