aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkDevice.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-27 15:46:45 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-27 15:46:45 +0000
commit34dc9a2dae8e9a5c4d3366a6957724e7289391e3 (patch)
treee8c9ddd62946d4ea7728195d2dd8c2a5e28cf597 /src/core/SkDevice.cpp
parente229e92ea51e9bc7c11033e2099d3ef275621115 (diff)
allow chrome to use old drawBitmapRect beahvior for now, using SK_SUPPORT_INT_SRCRECT_DRAWBITMAPRECT
git-svn-id: http://skia.googlecode.com/svn/trunk@5710 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkDevice.cpp')
-rw-r--r--src/core/SkDevice.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index a2cfe211ff..721d70e3c7 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -352,6 +352,44 @@ void SkDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap,
void SkDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
const SkRect* src, const SkRect& dst,
const SkPaint& paint) {
+#ifdef SK_SUPPORT_INT_SRCRECT_DRAWBITMAPRECT
+ 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()));
+ }
+ 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;
+ if (src) {
+ src->roundOut(&isrcStorage);
+ if (!isrcStorage.intersect(0, 0, bitmap.width(), bitmap.height())) {
+ return;
+ }
+ isrcPtr = &isrcStorage;
+ }
+
+ this->drawBitmap(draw, bitmap, isrcPtr, matrix, paint);
+#else
SkMatrix matrix;
SkRect bitmapBounds, tmpSrc, tmpDst;
SkBitmap tmpBitmap;
@@ -421,6 +459,7 @@ void SkDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
// Call ourself, in case the subclass wanted to share this setup code
// but handle the drawRect code themselves.
this->drawRect(draw, *dstPtr, paintWithShader);
+#endif
}
void SkDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,