diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-02-01 19:12:40 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-02-01 19:12:40 +0000 |
commit | 6f7fbc9fbb584b9b9fa6ed3a677d71ecd49aafce (patch) | |
tree | 4c5cc5e7e00780b179bfd3995eb6f2cfc64797df /src | |
parent | fb697e7a37adf34cbafaedb94cc373e7b6d1fa57 (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
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, |