aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-18 15:14:33 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-18 15:14:33 +0000
commit7112173c3c4cd1b1e7da8cdf971d71f01dd91299 (patch)
tree854ffd9e48edda9dd70b2f7ad3d788000b8f7def /src
parentacfb30e5bb797249f4ec41edda4c4d4b86e0e5d0 (diff)
re-re-land 5578
will follow w/ new .skp files to keep the waterfall green (I hope) git-svn-id: http://skia.googlecode.com/svn/trunk@5584 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBBoxRecord.cpp4
-rw-r--r--src/core/SkBBoxRecord.h2
-rw-r--r--src/core/SkCanvas.cpp67
-rw-r--r--src/core/SkPicture.cpp3
-rw-r--r--src/core/SkPictureFlat.h2
-rw-r--r--src/core/SkPicturePlayback.cpp6
-rw-r--r--src/core/SkPictureRecord.cpp6
-rw-r--r--src/core/SkPictureRecord.h4
-rw-r--r--src/pipe/SkGPipePriv.h2
-rw-r--r--src/pipe/SkGPipeRead.cpp6
-rw-r--r--src/pipe/SkGPipeWrite.cpp11
-rw-r--r--src/utils/SkDeferredCanvas.cpp10
-rw-r--r--src/utils/SkDumpCanvas.cpp10
-rw-r--r--src/utils/SkNWayCanvas.cpp4
-rw-r--r--src/utils/SkProxyCanvas.cpp4
15 files changed, 72 insertions, 69 deletions
diff --git a/src/core/SkBBoxRecord.cpp b/src/core/SkBBoxRecord.cpp
index 41f6b95516..52e5dd3f44 100644
--- a/src/core/SkBBoxRecord.cpp
+++ b/src/core/SkBBoxRecord.cpp
@@ -101,10 +101,10 @@ void SkBBoxRecord::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar to
}
}
-void SkBBoxRecord::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+void SkBBoxRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst, const SkPaint* paint) {
if (this->transformBounds(dst, paint)) {
- INHERITED::drawBitmapRect(bitmap, src, dst, paint);
+ INHERITED::drawBitmapRectToRect(bitmap, src, dst, paint);
}
}
diff --git a/src/core/SkBBoxRecord.h b/src/core/SkBBoxRecord.h
index 5cf8a50625..c13a7f01c4 100644
--- a/src/core/SkBBoxRecord.h
+++ b/src/core/SkBBoxRecord.h
@@ -38,7 +38,7 @@ public:
const SkPaint& paint) SK_OVERRIDE;
virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
const SkPaint* paint = NULL) SK_OVERRIDE;
- virtual void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+ virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst, const SkPaint* paint) SK_OVERRIDE;
virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& mat,
const SkPaint* paint) SK_OVERRIDE;
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 0df44b66de..9ef9c25e91 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1576,13 +1576,12 @@ 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 SkIRect* src,
+void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* 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;
@@ -1594,43 +1593,45 @@ void SkCanvas::internalDrawBitmapRect(const SkBitmap& bitmap, const SkIRect* src
}
}
- const SkBitmap* bitmapPtr = &bitmap;
-
SkMatrix matrix;
- 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;
- }
- if (tmpSrc.fTop > 0) {
- tmpSrc.fBottom -= tmpSrc.fTop;
- tmpSrc.fTop = 0;
+ // 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()));
}
- } else {
- tmpSrc.set(0, 0, SkIntToScalar(bitmap.width()),
- SkIntToScalar(bitmap.height()));
+ matrix.setRectToRect(tmpSrc, dst, SkMatrix::kFill_ScaleToFit);
}
- 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 tmpISrc;
+ SkIRect isrcStorage;
+ SkIRect* isrcPtr = NULL;
if (src) {
- tmpISrc.set(0, 0, bitmap.width(), bitmap.height());
- if (!tmpISrc.intersect(*src)) {
+ src->roundOut(&isrcStorage);
+ if (!isrcStorage.intersect(0, 0, bitmap.width(), bitmap.height())) {
return;
}
- src = &tmpISrc;
+ isrcPtr = &isrcStorage;
}
- this->internalDrawBitmap(*bitmapPtr, src, matrix, paint);
+ this->internalDrawBitmap(bitmap, isrcPtr, matrix, paint);
}
-void SkCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
- const SkRect& dst, const SkPaint* paint) {
+void SkCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
+ const SkRect& dst, const SkPaint* paint) {
SkDEBUGCODE(bitmap.validate();)
this->internalDrawBitmapRect(bitmap, src, dst, paint);
}
@@ -1678,8 +1679,12 @@ void SkCanvas::internalDrawBitmapNine(const SkBitmap& bitmap,
c.fRight = SkPin32(center.fRight, c.fLeft, w);
c.fBottom = SkPin32(center.fBottom, c.fTop, h);
- const int32_t srcX[4] = { 0, c.fLeft, c.fRight, w };
- const int32_t srcY[4] = { 0, c.fTop, c.fBottom, 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
+ };
SkScalar dstX[4] = {
dst.fLeft, dst.fLeft + SkIntToScalar(c.fLeft),
dst.fRight - SkIntToScalar(w - c.fRight), dst.fRight
@@ -1699,9 +1704,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];
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index 4c7ccf7c0f..7e8b371b58 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -240,7 +240,8 @@ void SkPicture::draw(SkCanvas* surface) {
// V4 : move SkPictInfo to be the header
// V5 : don't read/write FunctionPtr on cross-process (we can detect that)
// V6 : added serialization of SkPath's bounds (and packed its flags tighter)
-#define PICTURE_VERSION 6
+// V7 : changed drawBitmapRect(IRect) to drawBitmapRectToRect(Rect)
+#define PICTURE_VERSION 7
SkPicture::SkPicture(SkStream* stream, bool* success) : SkRefCnt() {
if (success) {
diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h
index 6671f1bdf9..2c8aa2c18e 100644
--- a/src/core/SkPictureFlat.h
+++ b/src/core/SkPictureFlat.h
@@ -33,7 +33,7 @@ enum DrawType {
DRAW_BITMAP,
DRAW_BITMAP_MATRIX,
DRAW_BITMAP_NINE,
- DRAW_BITMAP_RECT,
+ DRAW_BITMAP_RECT_TO_RECT,
DRAW_CLEAR,
DRAW_DATA,
DRAW_PAINT,
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index e3181d0cb9..3bff5ea925 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -672,12 +672,12 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
const SkPoint& loc = reader.skipT<SkPoint>();
canvas.drawBitmap(bitmap, loc.fX, loc.fY, paint);
} break;
- case DRAW_BITMAP_RECT: {
+ case DRAW_BITMAP_RECT_TO_RECT: {
const SkPaint* paint = getPaint(reader);
const SkBitmap& bitmap = getBitmap(reader);
- const SkIRect* src = this->getIRectPtr(reader); // may be null
+ const SkRect* src = this->getRectPtr(reader); // may be null
const SkRect& dst = reader.skipT<SkRect>(); // required
- canvas.drawBitmapRect(bitmap, src, dst, paint);
+ canvas.drawBitmapRectToRect(bitmap, src, dst, paint);
} break;
case DRAW_BITMAP_MATRIX: {
const SkPaint* paint = getPaint(reader);
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index 73a3ab549a..944fd1898f 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -426,12 +426,12 @@ void SkPictureRecord::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar
validate();
}
-void SkPictureRecord::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+void SkPictureRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst, const SkPaint* paint) {
- addDraw(DRAW_BITMAP_RECT);
+ addDraw(DRAW_BITMAP_RECT_TO_RECT);
addPaintPtr(paint);
addBitmap(bitmap);
- addIRectPtr(src); // may be null
+ addRectPtr(src); // may be null
addRect(dst);
validate();
}
diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h
index a6e0b68050..fec1a829f3 100644
--- a/src/core/SkPictureRecord.h
+++ b/src/core/SkPictureRecord.h
@@ -46,8 +46,8 @@ public:
virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE;
virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top,
const SkPaint*) SK_OVERRIDE;
- virtual void drawBitmapRect(const SkBitmap&, const SkIRect* src,
- const SkRect& dst, const SkPaint*) SK_OVERRIDE;
+ virtual void drawBitmapRectToRect(const SkBitmap&, const SkRect* src,
+ const SkRect& dst, const SkPaint*) SK_OVERRIDE;
virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&,
const SkPaint*) SK_OVERRIDE;
virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
diff --git a/src/pipe/SkGPipePriv.h b/src/pipe/SkGPipePriv.h
index 207a3bdc8a..31803ea9b5 100644
--- a/src/pipe/SkGPipePriv.h
+++ b/src/pipe/SkGPipePriv.h
@@ -41,7 +41,7 @@ enum DrawOps {
kDrawBitmap_DrawOp,
kDrawBitmapMatrix_DrawOp,
kDrawBitmapNine_DrawOp,
- kDrawBitmapRect_DrawOp,
+ kDrawBitmapRectToRect_DrawOp,
kDrawClear_DrawOp,
kDrawData_DrawOp,
kDrawPaint_DrawOp,
diff --git a/src/pipe/SkGPipeRead.cpp b/src/pipe/SkGPipeRead.cpp
index 803685a07d..137ecb7062 100644
--- a/src/pipe/SkGPipeRead.cpp
+++ b/src/pipe/SkGPipeRead.cpp
@@ -490,14 +490,14 @@ static void drawBitmapRect_rp(SkCanvas* canvas, SkReader32* reader,
unsigned flags = DrawOp_unpackFlags(op32);
bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag);
bool hasSrc = SkToBool(flags & kDrawBitmap_HasSrcRect_DrawOpFlag);
- const SkIRect* src;
+ const SkRect* src;
if (hasSrc) {
- src = skip<SkIRect>(reader);
+ src = skip<SkRect>(reader);
} else {
src = NULL;
}
const SkRect* dst = skip<SkRect>(reader);
- canvas->drawBitmapRect(*holder.getBitmap(), src, *dst, hasPaint ? &state->paint() : NULL);
+ canvas->drawBitmapRectToRect(*holder.getBitmap(), src, *dst, hasPaint ? &state->paint() : NULL);
}
static void drawSprite_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp
index b41ebb72fd..f0b4e0aee6 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -221,7 +221,7 @@ public:
virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE;
virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top,
const SkPaint*) SK_OVERRIDE;
- virtual void drawBitmapRect(const SkBitmap&, const SkIRect* src,
+ virtual void drawBitmapRectToRect(const SkBitmap&, const SkRect* src,
const SkRect& dst, const SkPaint*) SK_OVERRIDE;
virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&,
const SkPaint*) SK_OVERRIDE;
@@ -732,7 +732,7 @@ void SkGPipeCanvas::drawBitmap(const SkBitmap& bm, SkScalar left, SkScalar top,
}
}
-void SkGPipeCanvas::drawBitmapRect(const SkBitmap& bm, const SkIRect* src,
+void SkGPipeCanvas::drawBitmapRectToRect(const SkBitmap& bm, const SkRect* src,
const SkRect& dst, const SkPaint* paint) {
NOTIFY_SETUP(this);
size_t opBytesNeeded = sizeof(SkRect);
@@ -745,12 +745,9 @@ void SkGPipeCanvas::drawBitmapRect(const SkBitmap& bm, const SkIRect* src,
flags = 0;
}
- if (this->commonDrawBitmap(bm, kDrawBitmapRect_DrawOp, flags, opBytesNeeded, paint)) {
+ if (this->commonDrawBitmap(bm, kDrawBitmapRectToRect_DrawOp, flags, opBytesNeeded, paint)) {
if (hasSrc) {
- fWriter.write32(src->fLeft);
- fWriter.write32(src->fTop);
- fWriter.write32(src->fRight);
- fWriter.write32(src->fBottom);
+ fWriter.writeRect(*src);
}
fWriter.writeRect(dst);
}
diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index bbd3ae8801..ef2c0bde29 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/utils/SkDeferredCanvas.cpp
@@ -856,10 +856,10 @@ void SkDeferredCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar left,
this->recordedDrawCommand();
}
-void SkDeferredCanvas::drawBitmapRect(const SkBitmap& bitmap,
- const SkIRect* src,
- const SkRect& dst,
- const SkPaint* paint) {
+void SkDeferredCanvas::drawBitmapRectToRect(const SkBitmap& bitmap,
+ const SkRect* src,
+ const SkRect& dst,
+ const SkPaint* paint) {
if (fDeferredDrawing &&
this->isFullFrame(&dst, paint) &&
isPaintOpaque(paint, &bitmap)) {
@@ -867,7 +867,7 @@ void SkDeferredCanvas::drawBitmapRect(const SkBitmap& bitmap,
}
AutoImmediateDrawIfNeeded autoDraw(*this, &bitmap, paint);
- this->drawingCanvas()->drawBitmapRect(bitmap, src, dst, paint);
+ this->drawingCanvas()->drawBitmapRectToRect(bitmap, src, dst, paint);
this->recordedDrawCommand();
}
diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp
index 755a39bd4d..f1af88fc1f 100644
--- a/src/utils/SkDumpCanvas.cpp
+++ b/src/utils/SkDumpCanvas.cpp
@@ -318,21 +318,21 @@ void SkDumpCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
SkScalarToFloat(x), SkScalarToFloat(y));
}
-void SkDumpCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
- const SkRect& dst, const SkPaint* paint) {
+void SkDumpCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
+ const SkRect& dst, const SkPaint* paint) {
SkString bs, rs;
toString(bitmap, &bs);
toString(dst, &rs);
// show the src-rect only if its not everything
if (src && (src->fLeft > 0 || src->fTop > 0 ||
- src->fRight < bitmap.width() ||
- src->fBottom < bitmap.height())) {
+ src->fRight < SkIntToScalar(bitmap.width()) ||
+ src->fBottom < SkIntToScalar(bitmap.height()))) {
SkString ss;
toString(*src, &ss);
rs.prependf("%s ", ss.c_str());
}
- this->dump(kDrawBitmap_Verb, paint, "drawBitmapRect(%s %s)",
+ this->dump(kDrawBitmap_Verb, paint, "drawBitmapRectToRect(%s %s)",
bs.c_str(), rs.c_str());
}
diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp
index 9f6ebc68bc..2ca80ce2d1 100644
--- a/src/utils/SkNWayCanvas.cpp
+++ b/src/utils/SkNWayCanvas.cpp
@@ -194,11 +194,11 @@ void SkNWayCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
}
}
-void SkNWayCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+void SkNWayCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst, const SkPaint* paint) {
Iter iter(fList);
while (iter.next()) {
- iter->drawBitmapRect(bitmap, src, dst, paint);
+ iter->drawBitmapRectToRect(bitmap, src, dst, paint);
}
}
diff --git a/src/utils/SkProxyCanvas.cpp b/src/utils/SkProxyCanvas.cpp
index bc21d52649..e245c73272 100644
--- a/src/utils/SkProxyCanvas.cpp
+++ b/src/utils/SkProxyCanvas.cpp
@@ -92,9 +92,9 @@ void SkProxyCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
fProxy->drawBitmap(bitmap, x, y, paint);
}
-void SkProxyCanvas::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+void SkProxyCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
const SkRect& dst, const SkPaint* paint) {
- fProxy->drawBitmapRect(bitmap, src, dst, paint);
+ fProxy->drawBitmapRectToRect(bitmap, src, dst, paint);
}
void SkProxyCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,