Debian Codegraph @

src/core/SkLatticeIter.h

raw
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkLatticeIter_DEFINED
9 #define SkLatticeIter_DEFINED
10
11 #include "include/core/SkCanvas.h"
12 #include "include/core/SkColor.h"
13 #include "include/core/SkRect.h"
14 #include "include/core/SkScalar.h"
15 #include "include/private/base/SkAPI.h"
16 #include "include/private/base/SkTArray.h"
17
18 class SkMatrix;
19
20 /**
21 * Disect a lattice request into an sequence of src-rect / dst-rect pairs
22 */
23 class SK_SPI SkLatticeIter {
24 public:
25
26 static bool Valid(int imageWidth, int imageHeight, const SkCanvas::Lattice& lattice);
27
28 SkLatticeIter(const SkCanvas::Lattice& lattice, const SkRect& dst);
29
30 static bool Valid(int imageWidth, int imageHeight, const SkIRect& center);
31
32 SkLatticeIter(int imageWidth, int imageHeight, const SkIRect& center, const SkRect& dst);
33
34 /**
35 * While it returns true, use src/dst to draw the image/bitmap. Optional parameters
36 * isFixedColor and fixedColor specify if the rectangle is filled with a fixed color.
37 * If (*isFixedColor) is true, then (*fixedColor) contains the rectangle color.
38 */
39 bool next(SkIRect* src, SkRect* dst, bool* isFixedColor = nullptr,
40 SkColor* fixedColor = nullptr);
41
42 /** Version of above that converts the integer src rect to a scalar rect. */
43 bool next(SkRect* src, SkRect* dst, bool* isFixedColor = nullptr,
44 SkColor* fixedColor = nullptr) {
45 SkIRect isrcR;
46 if (this->next(&isrcR, dst, isFixedColor, fixedColor)) {
47 *src = SkRect::Make(isrcR);
48 return true;
49 }
50 return false;
51 }
52
53 /**
54 * Apply a matrix to the dst points.
55 */
56 void mapDstScaleTranslate(const SkMatrix& matrix);
57
58 /**
59 * Returns the number of rects that will actually be drawn.
60 */
61 int numRectsToDraw() const {
62 return fNumRectsToDraw;
63 }
64
65 private:
66 skia_private::TArray<int> fSrcX;
67 skia_private::TArray<int> fSrcY;
68 skia_private::TArray<SkScalar> fDstX;
69 skia_private::TArray<SkScalar> fDstY;
70 skia_private::TArray<SkCanvas::Lattice::RectType> fRectTypes;
71 skia_private::TArray<SkColor> fColors;
72
73 int fCurrX;
74 int fCurrY;
75 int fNumRectsInLattice;
76 int fNumRectsToDraw;
77 };
78
79 #endif