From 71df2d7bc1bbc83ad4cf005f9027df4cb3b88a9b Mon Sep 17 00:00:00 2001 From: msarett Date: Fri, 30 Sep 2016 12:41:42 -0700 Subject: Add a src rect to drawImageLattice() API This will allow us to draw ninepatches directly from an asset texture without having to upload them individually. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2382893002 Review-Url: https://codereview.chromium.org/2382893002 --- include/core/SkCanvas.h | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'include/core') diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index dc4289d36f..8d98e5024f 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -948,6 +948,9 @@ public: /** * Specifies coordinates to divide a bitmap into (xCount*yCount) rects. + * + * If the lattice divs or bounds are invalid, the entire lattice + * struct will be ignored on the draw call. */ struct Lattice { enum Flags : uint8_t { @@ -956,29 +959,34 @@ public: }; // An array of x-coordinates that divide the bitmap vertically. - // These must be unique, increasing, and in the set [0, width). + // These must be unique, increasing, and in the set [fBounds.fLeft, fBounds.fRight). // Does not have ownership. - const int* fXDivs; + const int* fXDivs; // An array of y-coordinates that divide the bitmap horizontally. - // These must be unique, increasing, and in the set [0, height). + // These must be unique, increasing, and in the set [fBounds.fTop, fBounds.fBottom). // Does not have ownership. - const int* fYDivs; + const int* fYDivs; // If non-null, the length of this array must be equal to // (fXCount + 1) * (fYCount + 1). Note that we allow the first rect - // in each direction to empty (divs[0] = 0). In this case, the - // caller still must specify a flag (as a placeholder) for these - // empty rects. + // in each direction to be empty (ex: fXDivs[0] = fBounds.fLeft). + // In this case, the caller still must specify a flag (as a placeholder) + // for these empty rects. // The flags correspond to the rects in the lattice, first moving // left to right and then top to bottom. - const Flags* fFlags; + const Flags* fFlags; // The number of fXDivs. - int fXCount; + int fXCount; // The number of fYDivs. - int fYCount; + int fYCount; + + // The bound to draw from. Must be contained by the src that is being drawn, + // non-empty, and non-inverted. + // If nullptr, the bounds are the entire src. + const SkIRect* fBounds; }; /** -- cgit v1.2.3