Tweak out SkTileGrid::insert() loop.

BUG=skia:

Review URL: https://codereview.chromium.org/658913002
This commit is contained in:
mtklein 2014-10-16 09:23:21 -07:00 committed by Commit bot
parent 71b5628a37
commit 4ba7686eb7

View File

@ -84,10 +84,15 @@ void SkTileGrid::insert(unsigned opIndex, const SkRect& originalBounds, bool) {
SkIRect grid; SkIRect grid;
this->userToGrid(bounds, &grid); this->userToGrid(bounds, &grid);
for (int y = grid.fTop; y <= grid.fBottom; y++) { // This is just a loop over y then x. This compiles to a slightly faster and
for (int x = grid.fLeft; x <= grid.fRight; x++) { // more compact loop than if we just did fTiles[y * fXTiles + x].push(opIndex).
fTiles[y * fXTiles + x].push(opIndex); SkTDArray<unsigned>* row = &fTiles[grid.fTop * fXTiles + grid.fLeft];
for (int y = 0; y <= grid.fBottom - grid.fTop; y++) {
SkTDArray<unsigned>* tile = row;
for (int x = 0; x <= grid.fRight - grid.fLeft; x++) {
(tile++)->push(opIndex);
} }
row += fXTiles;
} }
} }