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

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

Issue 452233002: Make BBH::search() const. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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
« src/core/SkTileGrid.h ('K') | « src/core/SkTileGrid.h ('k') | 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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkTileGrid.h" 9 #include "SkTileGrid.h"
10 10
(...skipping 15 matching lines...) Expand all
26 } 26 }
27 27
28 SkTileGrid::~SkTileGrid() { 28 SkTileGrid::~SkTileGrid() {
29 SkDELETE_ARRAY(fTileData); 29 SkDELETE_ARRAY(fTileData);
30 } 30 }
31 31
32 int SkTileGrid::tileCount(int x, int y) { 32 int SkTileGrid::tileCount(int x, int y) {
33 return this->tile(x, y).count(); 33 return this->tile(x, y).count();
34 } 34 }
35 35
36 SkTDArray<void *>& SkTileGrid::tile(int x, int y) { 36 SkTDArray<void *>& SkTileGrid::tile(int x, int y) const {
37 return fTileData[y * fXTileCount + x]; 37 return fTileData[y * fXTileCount + x];
38 } 38 }
39 39
40 void SkTileGrid::insert(void* data, const SkIRect& bounds, bool) { 40 void SkTileGrid::insert(void* data, const SkIRect& bounds, bool) {
41 SkASSERT(!bounds.isEmpty()); 41 SkASSERT(!bounds.isEmpty());
42 SkIRect dilatedBounds = bounds; 42 SkIRect dilatedBounds = bounds;
43 dilatedBounds.outset(fInfo.fMargin.width(), fInfo.fMargin.height()); 43 dilatedBounds.outset(fInfo.fMargin.width(), fInfo.fMargin.height());
44 dilatedBounds.offset(fInfo.fOffset); 44 dilatedBounds.offset(fInfo.fOffset);
45 if (!SkIRect::Intersects(dilatedBounds, fGridBounds)) { 45 if (!SkIRect::Intersects(dilatedBounds, fGridBounds)) {
46 return; 46 return;
(...skipping 11 matching lines...) Expand all
58 fYTileCount -1), 0); 58 fYTileCount -1), 0);
59 59
60 for (int x = minTileX; x <= maxTileX; x++) { 60 for (int x = minTileX; x <= maxTileX; x++) {
61 for (int y = minTileY; y <= maxTileY; y++) { 61 for (int y = minTileY; y <= maxTileY; y++) {
62 this->tile(x, y).push(data); 62 this->tile(x, y).push(data);
63 } 63 }
64 } 64 }
65 fInsertionCount++; 65 fInsertionCount++;
66 } 66 }
67 67
68 void SkTileGrid::search(const SkIRect& query, SkTDArray<void*>* results) { 68 void SkTileGrid::search(const SkIRect& query, SkTDArray<void*>* results) const {
69 SkIRect adjustedQuery = query; 69 SkIRect adjustedQuery = query;
70 // The inset is to counteract the outset that was applied in 'insert' 70 // The inset is to counteract the outset that was applied in 'insert'
71 // The outset/inset is to optimize for lookups of size 71 // The outset/inset is to optimize for lookups of size
72 // 'tileInterval + 2 * margin' that are aligned with the tile grid. 72 // 'tileInterval + 2 * margin' that are aligned with the tile grid.
73 adjustedQuery.inset(fInfo.fMargin.width(), fInfo.fMargin.height()); 73 adjustedQuery.inset(fInfo.fMargin.width(), fInfo.fMargin.height());
74 adjustedQuery.offset(fInfo.fOffset); 74 adjustedQuery.offset(fInfo.fOffset);
75 adjustedQuery.sort(); // in case the inset inverted the rectangle 75 adjustedQuery.sort(); // in case the inset inverted the rectangle
76 // Convert the query rectangle from device coordinates to tile coordinates 76 // Convert the query rectangle from device coordinates to tile coordinates
77 // by rounding outwards to the nearest tile boundary so that the resulting t ile 77 // by rounding outwards to the nearest tile boundary so that the resulting t ile
78 // region includes the query rectangle. (using truncating division to "floor ") 78 // region includes the query rectangle. (using truncating division to "floor ")
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 123 }
124 124
125 void SkTileGrid::rewindInserts() { 125 void SkTileGrid::rewindInserts() {
126 SkASSERT(fClient); 126 SkASSERT(fClient);
127 for (int i = 0; i < fTileCount; ++i) { 127 for (int i = 0; i < fTileCount; ++i) {
128 while (!fTileData[i].isEmpty() && fClient->shouldRewind(fTileData[i].top ())) { 128 while (!fTileData[i].isEmpty() && fClient->shouldRewind(fTileData[i].top ())) {
129 fTileData[i].pop(); 129 fTileData[i].pop();
130 } 130 }
131 } 131 }
132 } 132 }
OLDNEW
« src/core/SkTileGrid.h ('K') | « src/core/SkTileGrid.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698