diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-09-18 12:59:44 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-09-18 12:59:44 +0000 |
commit | f1ab723033a186dc53434104a636c2dfac5fc863 (patch) | |
tree | b3e9f1224fdaa890072b22a953df589fdb80fd58 /include | |
parent | 54339a826e460c2371f946224cca4db8482d8f5b (diff) |
Change drawBitmapRect to take a float-src-rect instead of integer-src-rect. This
allows the client more control over the scaling. Because of virtual overrides
and wanting to keep the old call-sites up and running, this CL renames the
virtual entry-point to drawBitmapRectToRect, and downgrades drawBitmapRect to
a non-virtual helper function.
The implementation is to use the float-rect for computing the matrix, but still
cons-up an integer rect for the purposes of subsetting the original bitmap. We
do this by calling float_src->roundOut(&int_src) so that we include all
(partially) covered src pixels.
No change needed on SkDevice, since that signature is explicitly passed the
computed matrix.
Review URL: https://codereview.appspot.com/6501140
git-svn-id: http://skia.googlecode.com/svn/trunk@5578 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkCanvas.h | 23 | ||||
-rw-r--r-- | include/utils/SkDeferredCanvas.h | 2 | ||||
-rw-r--r-- | include/utils/SkDumpCanvas.h | 2 | ||||
-rw-r--r-- | include/utils/SkNWayCanvas.h | 2 | ||||
-rw-r--r-- | include/utils/SkProxyCanvas.h | 2 |
5 files changed, 24 insertions, 7 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 1f29e1c00a..4696c9f20b 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -644,9 +644,26 @@ public: image will be drawn @param paint The paint used to draw the bitmap, or NULL */ - virtual void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src, - const SkRect& dst, const SkPaint* paint = NULL); + virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, + const SkRect& dst, + const SkPaint* paint); + + void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, + const SkPaint* paint) { + this->drawBitmapRectToRect(bitmap, NULL, dst, paint); + } + void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* isrc, + const SkRect& dst, const SkPaint* paint = NULL) { + SkRect realSrcStorage; + SkRect* realSrcPtr = NULL; + if (isrc) { + realSrcStorage.set(*isrc); + realSrcPtr = &realSrcStorage; + } + this->drawBitmapRectToRect(bitmap, realSrcPtr, dst, paint); + } + virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, const SkPaint* paint = NULL); @@ -993,7 +1010,7 @@ private: // canvas apis, without confusing subclasses (like SkPictureRecording) void internalDrawBitmap(const SkBitmap&, const SkIRect*, const SkMatrix& m, const SkPaint* paint); - void internalDrawBitmapRect(const SkBitmap& bitmap, const SkIRect* src, + void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst, const SkPaint* paint); void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst, const SkPaint* paint); diff --git a/include/utils/SkDeferredCanvas.h b/include/utils/SkDeferredCanvas.h index 8779df96b2..5e8920024a 100644 --- a/include/utils/SkDeferredCanvas.h +++ b/include/utils/SkDeferredCanvas.h @@ -138,7 +138,7 @@ public: virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, const SkPaint* paint) 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; diff --git a/include/utils/SkDumpCanvas.h b/include/utils/SkDumpCanvas.h index bae84c6e84..4eb1f25fcc 100644 --- a/include/utils/SkDumpCanvas.h +++ b/include/utils/SkDumpCanvas.h @@ -87,7 +87,7 @@ public: virtual void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE; virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, const SkPaint* paint) 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& m, const SkPaint* paint) SK_OVERRIDE; diff --git a/include/utils/SkNWayCanvas.h b/include/utils/SkNWayCanvas.h index dbf4a589f7..065adf0a47 100644 --- a/include/utils/SkNWayCanvas.h +++ b/include/utils/SkNWayCanvas.h @@ -45,7 +45,7 @@ public: virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE; virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, const SkPaint*) 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*) SK_OVERRIDE; virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, const SkPaint*) SK_OVERRIDE; diff --git a/include/utils/SkProxyCanvas.h b/include/utils/SkProxyCanvas.h index 720436bc42..aa4708544f 100644 --- a/include/utils/SkProxyCanvas.h +++ b/include/utils/SkProxyCanvas.h @@ -50,7 +50,7 @@ public: virtual void drawPath(const SkPath& path, 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 = NULL) SK_OVERRIDE; virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, const SkPaint* paint = NULL) SK_OVERRIDE; |