36 if (!totalBounds.
contains(latticeBounds)) {
44 if (zeroXDivs && zeroYDivs) {
58 return firstIsScalable ?
end -
start : 0;
63 if (firstIsScalable) {
71 for (;
i < numDivs;
i += 2) {
75 int right = (
i + 1 < numDivs) ? divs[
i + 1] :
end;
85static void set_points(
float*
dst,
int*
src,
const int* divs,
int divCount,
int srcFixed,
86 int srcScalable,
int srcStart,
int srcEnd,
float dstStart,
float dstEnd,
88 float dstLen = dstEnd - dstStart;
90 if (srcFixed <= dstLen) {
93 scale = (dstLen - ((
float) srcFixed)) / ((
float) srcScalable);
101 for (
int i = 0;
i < divCount;
i++) {
102 src[
i + 1] = divs[
i];
105 if (srcFixed <= dstLen) {
106 dstDelta = isScalable ?
scale * srcDelta : srcDelta;
108 dstDelta = isScalable ? 0.0f :
scale * srcDelta;
113 isScalable = !isScalable;
116 src[divCount + 1] = srcEnd;
117 dst[divCount + 1] = dstEnd;
122 const int origXCount = lattice.
fXCount;
124 const int origYCount = lattice.
fYCount;
156 int xCountFixed =
src.width() - xCountScalable;
158 int yCountFixed =
src.height() - yCountScalable;
163 src.fLeft,
src.fRight,
dst.fLeft,
dst.fRight, xIsScalable);
168 src.fTop,
src.fBottom,
dst.fTop,
dst.fBottom, yIsScalable);
172 fNumRectsToDraw = fNumRectsInLattice;
181 bool hasPadRow = (
yCount != origYCount);
182 bool hasPadCol = (
xCount != origXCount);
185 flags += origXCount + 1;
191 for (
int x = 0;
x < origXCount + 1;
x++) {
192 if (0 ==
x && hasPadCol) {
207 for (
int j = 0; j < fRectTypes.
size(); j++) {
237 fDstX[0] =
dst.fLeft;
240 fDstX[3] =
dst.fRight;
245 fDstY[3] =
dst.fBottom;
247 if (fDstX[1] > fDstX[2]) {
248 fDstX[1] = fDstX[0] + (fDstX[3] - fDstX[0]) * c.
fLeft / (
w - c.
width());
252 if (fDstY[1] > fDstY[2]) {
253 fDstY[1] = fDstY[0] + (fDstY[3] - fDstY[0]) * c.
fTop / (
h - c.
height());
258 fNumRectsInLattice = 9;
263 int currRect = fCurrX + fCurrY * (fSrcX.
size() - 1);
264 if (currRect == fNumRectsInLattice) {
268 const int x = fCurrX;
269 const int y = fCurrY;
273 if (fSrcX.
size() - 1 == ++fCurrX) {
279 return this->
next(src,
dst, isFixedColor, fixedColor);
282 src->setLTRB(fSrcX[
x], fSrcY[
y], fSrcX[
x + 1], fSrcY[
y + 1]);
283 dst->setLTRB(fDstX[
x], fDstY[
y], fDstX[
x + 1], fDstY[
y + 1]);
284 if (isFixedColor && fixedColor) {
285 *isFixedColor = !fRectTypes.
empty() &&
288 *fixedColor = fColors[currRect];
298 for (
int i = 0;
i < fDstX.
size();
i++) {
299 fDstX[
i] = fDstX[
i] * sx + tx;
304 for (
int i = 0;
i < fDstY.
size();
i++) {
305 fDstY[
i] = fDstY[
i] * sy + ty;
static float prev(float f)
static int count_scalable_pixels(const int32_t *divs, int numDivs, bool firstIsScalable, int start, int end)
static void set_points(float *dst, int *src, const int *divs, int divCount, int srcFixed, int srcScalable, int srcStart, int srcEnd, float dstStart, float dstEnd, bool isScalable)
static bool valid_divs(const int *divs, int count, int start, int end)
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
static constexpr bool SkToBool(const T &x)
static SkScalar center(float pos0, float pos1)
void mapDstScaleTranslate(const SkMatrix &matrix)
bool next(SkIRect *src, SkRect *dst, bool *isFixedColor=nullptr, SkColor *fixedColor=nullptr)
static bool Valid(int imageWidth, int imageHeight, const SkCanvas::Lattice &lattice)
SkLatticeIter(const SkCanvas::Lattice &lattice, const SkRect &dst)
FlutterSemanticsFlag flags
unsigned useCenter Optional< SkMatrix > matrix
PODArray< SkColor > colors
constexpr bool contains(std::string_view str, std::string_view needle)
int fYCount
number of y-coordinates
const SkIRect * fBounds
source bounds to draw from
@ kFixedColor
draws one of fColors into lattice rectangle
@ kTransparent
skips lattice rectangle by making it transparent
const int * fYDivs
y-axis values dividing bitmap
int fXCount
number of x-coordinates
const RectType * fRectTypes
array of fill types
const SkColor * fColors
array of colors
const int * fXDivs
x-axis values dividing bitmap
int32_t fBottom
larger y-axis bounds
constexpr int32_t height() const
int32_t fTop
smaller y-axis bounds
constexpr int32_t width() const
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
int32_t fLeft
smaller x-axis bounds
bool contains(int32_t x, int32_t y) const
int32_t fRight
larger x-axis bounds