diff options
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkCanvas.h | 22 | ||||
-rw-r--r-- | include/core/SkDevice.h | 4 |
2 files changed, 24 insertions, 2 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 7bdb6d219c..7bff02a6a9 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -792,6 +792,23 @@ public: void drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst, const SkPaint* paint = NULL); + /** + * Draw the image stretched differentially to fit into dst. + * center is a rect within the image, and logically divides the image + * into 9 sections (3x3). For example, if the middle pixel of a [5x5] + * image is the "center", then the center-rect should be [2, 2, 3, 3]. + * + * If the dst is >= the image size, then... + * - The 4 corners are not stretched at all. + * - The sides are stretched in only one axis. + * - The center is stretched in both axes. + * Else, for each axis where dst < image, + * - The corners shrink proportionally + * - The sides (along the shrink axis) and center are not drawn + */ + void drawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst, + const SkPaint* paint = NULL); + /** Draw the specified bitmap, with its top/left corner at (x,y), using the specified paint, transformed by the current matrix. Note: if the paint contains a maskfilter that generates a mask which extends beyond the @@ -1230,6 +1247,9 @@ protected: virtual void onDrawPath(const SkPath&, const SkPaint&); virtual void onDrawImage(const SkImage*, SkScalar dx, SkScalar dy, const SkPaint*); virtual void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*); + virtual void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst, + const SkPaint*); + virtual void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const SkPaint*); virtual void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*, DrawBitmapRectFlags); @@ -1347,8 +1367,6 @@ private: void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst, const SkPaint* paint, DrawBitmapRectFlags flags); - void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, - const SkRect& dst, const SkPaint* paint); void internalDrawPaint(const SkPaint& paint); void internalSaveLayer(const SkRect* bounds, const SkPaint*, SaveFlags, SaveLayerStrategy); void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*, bool isBitmapDevice); diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h index 2db685a96e..6b00c104fc 100644 --- a/include/core/SkDevice.h +++ b/include/core/SkDevice.h @@ -220,10 +220,14 @@ protected: const SkRect* srcOrNull, const SkRect& dst, const SkPaint& paint, SkCanvas::DrawBitmapRectFlags flags) = 0; + virtual void drawBitmapNine(const SkDraw&, const SkBitmap&, const SkIRect& center, + const SkRect& dst, const SkPaint&); virtual void drawImage(const SkDraw&, const SkImage*, SkScalar x, SkScalar y, const SkPaint&); virtual void drawImageRect(const SkDraw&, const SkImage*, const SkRect* src, const SkRect& dst, const SkPaint&); + virtual void drawImageNine(const SkDraw&, const SkImage*, const SkIRect& center, + const SkRect& dst, const SkPaint&); /** * Does not handle text decoration. |