Index: include/core/SkCanvas.h |
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h |
index 97aa3c7d8e343e06a1464615fb6edc788afc8148..df382add2acfe080100d37075a4dc8976320d96d 100644 |
--- a/include/core/SkCanvas.h |
+++ b/include/core/SkCanvas.h |
@@ -919,7 +919,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]. |
@@ -935,6 +935,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 { |
reed1
2016/08/01 16:26:02
drawBitmapLattice
msarett
2016/08/01 23:25:09
Done.
|
+ // 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. |
+ int* fXDivs; |
reed1
2016/08/01 16:26:02
const
msarett
2016/08/01 23:25:09
Done.
|
+ |
+ // The number of fXDivs. |
+ int 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. |
+ int* fYDivs; |
+ |
+ // The number of fYDivs. |
+ int 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 |
+ * 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 to the y-dimension. |
+ */ |
+ void drawBitmapNine(const SkBitmap& bitmap, const NinePatchDivs& divs, const SkRect& dst, |
reed1
2016/07/15 16:27:04
"Nine" is sort of a misnomer here
msarett
2016/08/01 23:25:09
Acknowledged.
|
+ 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 |
@@ -1376,6 +1415,8 @@ protected: |
SrcRectConstraint); |
virtual void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst, |
const SkPaint*); |
+ virtual void onDrawBitmapNine(const SkBitmap&, const NinePatchDivs& divs, const SkRect& dst, |
+ const SkPaint*); |
enum ClipEdgeStyle { |
kHard_ClipEdgeStyle, |