2 * Copyright 2015 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkLatticeIter_DEFINED
9 #define SkLatticeIter_DEFINED
11 #include "include/core/SkCanvas.h"
12 #include "include/core/SkScalar.h"
13 #include "include/private/SkTArray.h"
19 * Disect a lattice request into an sequence of src-rect / dst-rect pairs
21 class SK_SPI SkLatticeIter {
24 static bool Valid(int imageWidth, int imageHeight, const SkCanvas::Lattice& lattice);
26 SkLatticeIter(const SkCanvas::Lattice& lattice, const SkRect& dst);
28 static bool Valid(int imageWidth, int imageHeight, const SkIRect& center);
30 SkLatticeIter(int imageWidth, int imageHeight, const SkIRect& center, const SkRect& dst);
33 * While it returns true, use src/dst to draw the image/bitmap. Optional parameters
34 * isFixedColor and fixedColor specify if the rectangle is filled with a fixed color.
35 * If (*isFixedColor) is true, then (*fixedColor) contains the rectangle color.
37 bool next(SkIRect* src, SkRect* dst, bool* isFixedColor = nullptr,
38 SkColor* fixedColor = nullptr);
40 /** Version of above that converts the integer src rect to a scalar rect. */
41 bool next(SkRect* src, SkRect* dst, bool* isFixedColor = nullptr,
42 SkColor* fixedColor = nullptr) {
44 if (this->next(&isrcR, dst, isFixedColor, fixedColor)) {
45 *src = SkRect::Make(isrcR);
52 * Apply a matrix to the dst points.
54 void mapDstScaleTranslate(const SkMatrix& matrix);
57 * Returns the number of rects that will actually be drawn.
59 int numRectsToDraw() const {
60 return fNumRectsToDraw;
66 SkTArray<SkScalar> fDstX;
67 SkTArray<SkScalar> fDstY;
68 SkTArray<SkCanvas::Lattice::RectType> fRectTypes;
69 SkTArray<SkColor> fColors;
73 int fNumRectsInLattice;