aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-10-15 18:51:46 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-10-15 18:51:46 +0000
commitfead49e3c43e67cf9648ec1999b34da959e1e36b (patch)
tree0f25747b072f34e3ae620d7983ee9c2489fda537 /src
parent7f6e1e9caa4ced154c23701768e6c618dfe6ad48 (diff)
fix drawBitmapRect to not clip the src rect when computing the matrix
git-svn-id: http://skia.googlecode.com/svn/trunk@387 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkCanvas.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 23031c534a..ce4a624ec7 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1112,15 +1112,32 @@ void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
bitmapPtr = &tmp;
}
- SkScalar width = SkIntToScalar(bitmapPtr->width());
- SkScalar height = SkIntToScalar(bitmapPtr->height());
SkMatrix matrix;
-
+#if 0
+ SkScalar width = SkIntToScalar(bitmapPtr->width());
+ SkScalar height = SkIntToScalar(bitmapPtr->height());
if (dst.width() == width && dst.height() == height) {
matrix.setTranslate(dst.fLeft, dst.fTop);
- } else {
+ } else
+#endif
+ {
SkRect tmpSrc;
- tmpSrc.set(0, 0, width, height);
+ if (src) {
+ tmpSrc.set(*src);
+ // if the extract process clipped off the top or left of the
+ // original, we adjust for that here to get the position right.
+ if (tmpSrc.fLeft > 0) {
+ tmpSrc.fRight -= tmpSrc.fLeft;
+ tmpSrc.fLeft = 0;
+ }
+ if (tmpSrc.fTop > 0) {
+ tmpSrc.fBottom -= tmpSrc.fTop;
+ tmpSrc.fTop = 0;
+ }
+ } else {
+ tmpSrc.set(0, 0, SkIntToScalar(bitmap.width()),
+ SkIntToScalar(bitmap.height()));
+ }
matrix.setRectToRect(tmpSrc, dst, SkMatrix::kFill_ScaleToFit);
}
this->internalDrawBitmap(*bitmapPtr, matrix, paint);