Index: include/core/SkCanvas.h |
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h |
index b6d0cc704af73c917b56ac7392d7a96ddacf58a1..87ca0e4d8b6042942a90261a24306e14b0dc873d 100644 |
--- a/include/core/SkCanvas.h |
+++ b/include/core/SkCanvas.h |
@@ -912,7 +912,7 @@ public: |
SrcRectConstraint = kStrict_SrcRectConstraint); |
/** |
- * Draw the bitmap stretched differentially to fit into dst. |
+ * Draw the bitmap stretched or shrunk differentially to fit into dst. |
* center is a rect within the bitmap, and logically divides the bitmap |
* into 9 sections (3x3). For example, if the middle pixel of a [5x5] |
* bitmap is the "center", then the center-rect should be [2, 2, 3, 3]. |
@@ -928,6 +928,45 @@ public: |
void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst, |
const SkPaint* paint = NULL); |
+ /** |
+ * Specifies coordinates to divide a bitmap into (xCount*yCount) patches. |
+ */ |
+ struct NinePatchDivs { |
+ // An array of x-coordinates that divide the bitmap vertically. |
+ // These must be unique, increasing, and in the set [0, width]. |
+ // Does not have ownership. |
+ uint32_t* fXDivs; |
reed1
2016/05/19 18:21:01
I would make all of these int instead of uint32_t,
|
+ |
+ // The number of fXDivs. |
+ uint32_t fXCount; |
+ |
+ // An array of y-coordinates that divide the bitmap horiztonally. |
+ // These must be unique, increasing, and in the set [0, height]. |
+ // Does not have ownership. |
+ uint32_t* fYDivs; |
+ |
+ // The number of fYDivs. |
+ uint32_t fYCount; |
+ }; |
+ |
+ /** |
+ * Draw the bitmap stretched or shrunk differentially to fit into dst. |
+ * |
+ * Moving horizontally across the bitmap alternating patches will be "scalable" |
+ * (in the x-dimension) to fit into dst or must be left "fixed". The first patch |
f(malita)
2016/05/19 19:24:20
The last patch is also fixed, right?
msarett
2016/05/19 19:30:58
In the Android implementation, it really depends o
f(malita)
2016/05/19 19:36:11
Ah, that makes sense (I didn't parse the "alternat
|
+ * is treated as "fixed", but it's possible to specify an empty first patch by |
+ * making divs.fXDivs[0] = 0. |
+ * |
+ * The scale factor for all "scalable" patches will be the same, and may be greater |
+ * than or less than 1 (meaning we can stretch or shrink). If the number of |
+ * "fixed" pixels is greater than the width of the dst, we will collapse all of |
+ * the "scalable" regions and appropriately downscale the "fixed" regions. |
+ * |
+ * The same interpretation also applies the y-dimension. |
+ */ |
+ void drawBitmapNine(const SkBitmap& bitmap, const NinePatchDivs& divs, const SkRect& dst, |
+ const SkPaint* paint = nullptr); |
+ |
/** Draw the text, with origin at (x,y), using the specified paint. |
The origin is interpreted based on the Align setting in the paint. |
@param text The text to be drawn |