OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkSurface.h" | 9 #include "SkSurface.h" |
10 | 10 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 canvas->drawImage(image, 10, 10, nullptr); | 106 canvas->drawImage(image, 10, 10, nullptr); |
107 | 107 |
108 SkScalar x = SkIntToScalar(100); | 108 SkScalar x = SkIntToScalar(100); |
109 SkScalar y = SkIntToScalar(100); | 109 SkScalar y = SkIntToScalar(100); |
110 | 110 |
111 SkCanvas::Lattice lattice; | 111 SkCanvas::Lattice lattice; |
112 lattice.fXCount = 4; | 112 lattice.fXCount = 4; |
113 lattice.fXDivs = xDivs + 1; | 113 lattice.fXDivs = xDivs + 1; |
114 lattice.fYCount = 4; | 114 lattice.fYCount = 4; |
115 lattice.fYDivs = yDivs + 1; | 115 lattice.fYDivs = yDivs + 1; |
| 116 lattice.fFlags = nullptr; |
| 117 lattice.fFlagCount = 0; |
116 | 118 |
117 for (int iy = 0; iy < 2; ++iy) { | 119 for (int iy = 0; iy < 2; ++iy) { |
118 for (int ix = 0; ix < 2; ++ix) { | 120 for (int ix = 0; ix < 2; ++ix) { |
119 int i = ix * 2 + iy; | 121 int i = ix * 2 + iy; |
120 SkRect r = SkRect::MakeXYWH(x + ix * 60, y + iy * 60, | 122 SkRect r = SkRect::MakeXYWH(x + ix * 60, y + iy * 60, |
121 size[i].width(), size[i].height()); | 123 size[i].width(), size[i].height()); |
122 canvas->drawBitmapLattice(bitmap, lattice, r); | 124 canvas->drawBitmapLattice(bitmap, lattice, r); |
123 } | 125 } |
124 } | 126 } |
125 | 127 |
126 // Include the degenerate first div. While normally the first patch is
"scalable", | 128 // Include the degenerate first div. While normally the first patch is
"scalable", |
127 // this will mean that the first non-degenerate patch is "fixed". | 129 // this will mean that the first non-degenerate patch is "fixed". |
128 lattice.fXCount = 5; | 130 lattice.fXCount = 5; |
129 lattice.fXDivs = xDivs; | 131 lattice.fXDivs = xDivs; |
130 lattice.fYCount = 5; | 132 lattice.fYCount = 5; |
131 lattice.fYDivs = yDivs; | 133 lattice.fYDivs = yDivs; |
132 | 134 |
| 135 // Let's skip a few rects. |
| 136 SkCanvas::Lattice::Flags flags[25]; |
| 137 sk_bzero(flags, 25 * sizeof(SkCanvas::Lattice::Flags)); |
| 138 flags[4] = SkCanvas::Lattice::kSkip_Flags; |
| 139 flags[9] = SkCanvas::Lattice::kSkip_Flags; |
| 140 flags[12] = SkCanvas::Lattice::kSkip_Flags; |
| 141 lattice.fFlags = flags; |
| 142 lattice.fFlagCount = 25; |
| 143 |
133 canvas->translate(400, 0); | 144 canvas->translate(400, 0); |
134 for (int iy = 0; iy < 2; ++iy) { | 145 for (int iy = 0; iy < 2; ++iy) { |
135 for (int ix = 0; ix < 2; ++ix) { | 146 for (int ix = 0; ix < 2; ++ix) { |
136 int i = ix * 2 + iy; | 147 int i = ix * 2 + iy; |
137 SkRect r = SkRect::MakeXYWH(x + ix * 60, y + iy * 60, | 148 SkRect r = SkRect::MakeXYWH(x + ix * 60, y + iy * 60, |
138 size[i].width(), size[i].height()); | 149 size[i].width(), size[i].height()); |
139 canvas->drawImageLattice(image.get(), lattice, r); | 150 canvas->drawImageLattice(image.get(), lattice, r); |
140 } | 151 } |
141 } | 152 } |
142 } | 153 } |
143 | 154 |
144 private: | 155 private: |
145 typedef skiagm::GM INHERITED; | 156 typedef skiagm::GM INHERITED; |
146 }; | 157 }; |
147 DEF_GM( return new LatticeGM; ) | 158 DEF_GM( return new LatticeGM; ) |
OLD | NEW |