Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: src/core/SkTileGrid.cpp

Issue 658913002: Tweak out SkTileGrid::insert() loop. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: merge Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 // TODO(mtklein): can we assert this instead to save an intersection in Rele ase mode, 78 // TODO(mtklein): can we assert this instead to save an intersection in Rele ase mode,
79 // or just allow out-of-bound insertions to insert anyway (clamped to neares t tile)? 79 // or just allow out-of-bound insertions to insert anyway (clamped to neares t tile)?
80 if (!SkRect::Intersects(bounds, fGridBounds)) { 80 if (!SkRect::Intersects(bounds, fGridBounds)) {
81 return; 81 return;
82 } 82 }
83 83
84 SkIRect grid; 84 SkIRect grid;
85 this->userToGrid(bounds, &grid); 85 this->userToGrid(bounds, &grid);
86 86
87 for (int y = grid.fTop; y <= grid.fBottom; y++) { 87 // This is just a loop over y then x. This compiles to a slightly faster an d
88 for (int x = grid.fLeft; x <= grid.fRight; x++) { 88 // more compact loop than if we just did fTiles[y * fXTiles + x].push(opInde x).
89 fTiles[y * fXTiles + x].push(opIndex); 89 SkTDArray<unsigned>* row = &fTiles[grid.fTop * fXTiles + grid.fLeft];
90 for (int y = 0; y <= grid.fBottom - grid.fTop; y++) {
91 SkTDArray<unsigned>* tile = row;
92 for (int x = 0; x <= grid.fRight - grid.fLeft; x++) {
93 (tile++)->push(opIndex);
90 } 94 }
95 row += fXTiles;
91 } 96 }
92 } 97 }
93 98
94 // Number of tiles for which data is allocated on the stack in 99 // Number of tiles for which data is allocated on the stack in
95 // SkTileGrid::search. If malloc becomes a bottleneck, we may consider 100 // SkTileGrid::search. If malloc becomes a bottleneck, we may consider
96 // increasing this number. Typical large web page, say 2k x 16k, would 101 // increasing this number. Typical large web page, say 2k x 16k, would
97 // require 512 tiles of size 256 x 256 pixels. 102 // require 512 tiles of size 256 x 256 pixels.
98 static const int kStackAllocationTileCount = 1024; 103 static const int kStackAllocationTileCount = 1024;
99 104
100 void SkTileGrid::search(const SkRect& originalQuery, SkTDArray<unsigned>* result s) const { 105 void SkTileGrid::search(const SkRect& originalQuery, SkTDArray<unsigned>* result s) const {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // We did find an earliest op. Output it, and step forward every tile th at contains it. 163 // We did find an earliest op. Output it, and step forward every tile th at contains it.
159 results->push(earliest); 164 results->push(earliest);
160 for (int i = 0; i < starts.count(); i++) { 165 for (int i = 0; i < starts.count(); i++) {
161 if (starts[i] < ends[i] && *starts[i] == earliest) { 166 if (starts[i] < ends[i] && *starts[i] == earliest) {
162 starts[i]++; 167 starts[i]++;
163 } 168 }
164 } 169 }
165 } 170 }
166 } 171 }
167 172
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698