aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkCanvas.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-18 14:04:54 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-18 14:04:54 +0000
commit10f9f4a844c8d5260c0a02df94b940b6abf66b0d (patch)
tree3a844486daa7132fc317ac76e7ff8ed5b09e7db9 /src/core/SkCanvas.cpp
parenteab16dea1ce249dc8e4dc635cd76b6b1b7d0cc98 (diff)
revert 5580
git-svn-id: http://skia.googlecode.com/svn/trunk@5581 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkCanvas.cpp')
-rw-r--r--src/core/SkCanvas.cpp67
1 files changed, 31 insertions, 36 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 9ef9c25e91..0df44b66de 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1576,12 +1576,13 @@ void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
}
// this one is non-virtual, so it can be called safely by other canvas apis
-void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
+void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
const SkRect& dst, const SkPaint* paint) {
if (bitmap.width() == 0 || bitmap.height() == 0 || dst.isEmpty()) {
return;
}
+ // do this now, to avoid the cost of calling extract for RLE bitmaps
if (NULL == paint || paint->canComputeFastBounds()) {
SkRect storage;
const SkRect* bounds = &dst;
@@ -1593,45 +1594,43 @@ void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
}
}
+ const SkBitmap* bitmapPtr = &bitmap;
+
SkMatrix matrix;
- // Compute matrix from the two rectangles
- {
- SkRect tmpSrc;
- if (src) {
- tmpSrc = *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()));
+ SkRect tmpSrc;
+ 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;
}
- matrix.setRectToRect(tmpSrc, dst, SkMatrix::kFill_ScaleToFit);
+ 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);
// ensure that src is "valid" before we pass it to our internal routines
// and to SkDevice. i.e. sure it is contained inside the original bitmap.
- SkIRect isrcStorage;
- SkIRect* isrcPtr = NULL;
+ SkIRect tmpISrc;
if (src) {
- src->roundOut(&isrcStorage);
- if (!isrcStorage.intersect(0, 0, bitmap.width(), bitmap.height())) {
+ tmpISrc.set(0, 0, bitmap.width(), bitmap.height());
+ if (!tmpISrc.intersect(*src)) {
return;
}
- isrcPtr = &isrcStorage;
+ src = &tmpISrc;
}
- this->internalDrawBitmap(bitmap, isrcPtr, matrix, paint);
+ this->internalDrawBitmap(*bitmapPtr, src, matrix, paint);
}
-void SkCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
- const SkRect& dst, const SkPaint* paint) {
+void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+ const SkRect& dst, const SkPaint* paint) {
SkDEBUGCODE(bitmap.validate();)
this->internalDrawBitmapRect(bitmap, src, dst, paint);
}
@@ -1679,12 +1678,8 @@ void SkCanvas::internalDrawBitmapNine(const SkBitmap& bitmap,
c.fRight = SkPin32(center.fRight, c.fLeft, w);
c.fBottom = SkPin32(center.fBottom, c.fTop, h);
- const SkScalar srcX[4] = {
- 0, SkIntToScalar(c.fLeft), SkIntToScalar(c.fRight), w
- };
- const SkScalar srcY[4] = {
- 0, SkIntToScalar(c.fTop), SkIntToScalar(c.fBottom), h
- };
+ const int32_t srcX[4] = { 0, c.fLeft, c.fRight, w };
+ const int32_t srcY[4] = { 0, c.fTop, c.fBottom, h };
SkScalar dstX[4] = {
dst.fLeft, dst.fLeft + SkIntToScalar(c.fLeft),
dst.fRight - SkIntToScalar(w - c.fRight), dst.fRight
@@ -1704,9 +1699,9 @@ void SkCanvas::internalDrawBitmapNine(const SkBitmap& bitmap,
dstY[2] = dstY[1];
}
+ SkIRect s;
+ SkRect d;
for (int y = 0; y < 3; y++) {
- SkRect s, d;
-
s.fTop = srcY[y];
s.fBottom = srcY[y+1];
d.fTop = dstY[y];