From 6f7fbc9fbb584b9b9fa6ed3a677d71ecd49aafce Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Tue, 1 Feb 2011 19:12:40 +0000 Subject: Adds ability to draw rects using a unit square vertex buffer. Useful when matrix/uniform changes are less expensive than sending new verts. Adds optional matrix parameters to GrContext drawRect and drawRectToRect so that non-axis-aligned matrices can be drawn using these functions. codereview Issue 4105049 git-svn-id: http://skia.googlecode.com/svn/trunk@749 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/SkGpuDevice.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index dca146ec5f..3afd46c37b 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -512,7 +512,10 @@ private: /////////////////////////////////////////////////////////////////////////////// +#if 0 // not currently being used so don't compile, + // can be used for positions or texture coordinates + class SkRectFanSource { public: SkRectFanSource(const SkRect& rect) : fRect(rect) {} @@ -575,6 +578,8 @@ private: const SkMatrix& fMatrix; }; +#endif + /////////////////////////////////////////////////////////////////////////////// void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { @@ -821,23 +826,16 @@ void SkGpuDevice::internalDrawBitmap(const SkDraw& draw, grPaint->setTexture(texture); grPaint->fTextureMatrix.setIdentity(); + GrRect dstRect(0, 0, GrIntToScalar(srcRect.width()), GrIntToScalar(srcRect.height())); + GrRect paintRect(GrIntToScalar(srcRect.fLeft) / texture->allocWidth(), + GrIntToScalar(srcRect.fTop) / texture->allocHeight(), + GrIntToScalar(srcRect.fRight) / texture->allocWidth(), + GrIntToScalar(srcRect.fBottom) / texture->allocHeight()); - SkRect paintRect; - paintRect.set(SkFixedToScalar((srcRect.fLeft << 16) / texture->allocWidth()), - SkFixedToScalar((srcRect.fTop << 16) / texture->allocHeight()), - SkFixedToScalar((srcRect.fRight << 16) / texture->allocWidth()), - SkFixedToScalar((srcRect.fBottom << 16)/ texture->allocHeight())); - - SkRect dstRect; - dstRect.set(SkIntToScalar(0),SkIntToScalar(0), - SkIntToScalar(srcRect.width()), SkIntToScalar(srcRect.height())); - - SkRectFanSource texSrc(paintRect); - fContext->drawCustomVertices(*grPaint, - GrDrawTarget::kTriangleFan_PrimitiveType, - SkMatRectFanSource(dstRect, m), - &texSrc); + GrMatrix grMat; + SkGr::SkMatrix2GrMatrix(m, &grMat); + fContext->drawRectToRect(*grPaint, dstRect, paintRect, &grMat); } void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, -- cgit v1.2.3