OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkTileGrid.h" | 8 #include "SkTileGrid.h" |
9 | 9 |
10 SkTileGrid::SkTileGrid(int xTiles, int yTiles, const SkTileGridFactory::TileGrid
Info& info) | 10 SkTileGrid::SkTileGrid(int xTiles, int yTiles, const SkTileGridFactory::TileGrid
Info& info) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // Note: SkIRects are non-inclusive of the right() column and bottom() row, | 45 // Note: SkIRects are non-inclusive of the right() column and bottom() row, |
46 // hence the "-1"s in the computations of maxX and maxY. | 46 // hence the "-1"s in the computations of maxX and maxY. |
47 int minX = SkMax32(0, SkMin32(dilatedBounds.left() / fInfo.fTileInterval.wid
th(), fXTiles - 1)); | 47 int minX = SkMax32(0, SkMin32(dilatedBounds.left() / fInfo.fTileInterval.wid
th(), fXTiles - 1)); |
48 int minY = SkMax32(0, SkMin32(dilatedBounds.top() / fInfo.fTileInterval.heig
ht(), fYTiles - 1)); | 48 int minY = SkMax32(0, SkMin32(dilatedBounds.top() / fInfo.fTileInterval.heig
ht(), fYTiles - 1)); |
49 int maxX = SkMax32(0, SkMin32((dilatedBounds.right() - 1) / fInfo.fTileInte
rval.width(), | 49 int maxX = SkMax32(0, SkMin32((dilatedBounds.right() - 1) / fInfo.fTileInte
rval.width(), |
50 fXTiles - 1)); | 50 fXTiles - 1)); |
51 int maxY = SkMax32(0, SkMin32((dilatedBounds.bottom() - 1) / fInfo.fTileInte
rval.height(), | 51 int maxY = SkMax32(0, SkMin32((dilatedBounds.bottom() - 1) / fInfo.fTileInte
rval.height(), |
52 fYTiles - 1)); | 52 fYTiles - 1)); |
53 | 53 |
54 Entry entry = { fCount++, data }; | 54 Entry entry = { fCount++, data }; |
55 for (int x = minX; x <= maxX; x++) { | 55 for (int y = minY; y <= maxY; y++) { |
56 for (int y = minY; y <= maxY; y++) { | 56 for (int x = minX; x <= maxX; x++) { |
57 fTiles[y * fXTiles + x].push(entry); | 57 fTiles[y * fXTiles + x].push(entry); |
58 } | 58 } |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 static int divide_ceil(int x, int y) { | 62 static int divide_ceil(int x, int y) { |
63 return (x + y - 1) / y; | 63 return (x + y - 1) / y; |
64 } | 64 } |
65 | 65 |
66 // Number of tiles for which data is allocated on the stack in | 66 // Number of tiles for which data is allocated on the stack in |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } | 160 } |
161 | 161 |
162 void SkTileGrid::rewindInserts() { | 162 void SkTileGrid::rewindInserts() { |
163 SkASSERT(fClient); | 163 SkASSERT(fClient); |
164 for (int i = 0; i < fXTiles * fYTiles; i++) { | 164 for (int i = 0; i < fXTiles * fYTiles; i++) { |
165 while (!fTiles[i].isEmpty() && fClient->shouldRewind(fTiles[i].top().dat
a)) { | 165 while (!fTiles[i].isEmpty() && fClient->shouldRewind(fTiles[i].top().dat
a)) { |
166 fTiles[i].pop(); | 166 fTiles[i].pop(); |
167 } | 167 } |
168 } | 168 } |
169 } | 169 } |
OLD | NEW |