OLD | NEW |
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 tileEndX = SkPin32(tileEndX, tileStartX+1, fXTileCount); | 84 tileEndX = SkPin32(tileEndX, tileStartX+1, fXTileCount); |
85 tileStartY = SkPin32(tileStartY, 0, fYTileCount - 1); | 85 tileStartY = SkPin32(tileStartY, 0, fYTileCount - 1); |
86 tileEndY = SkPin32(tileEndY, tileStartY+1, fYTileCount); | 86 tileEndY = SkPin32(tileEndY, tileStartY+1, fYTileCount); |
87 | 87 |
88 int queryTileCount = (tileEndX - tileStartX) * (tileEndY - tileStartY); | 88 int queryTileCount = (tileEndX - tileStartX) * (tileEndY - tileStartY); |
89 SkASSERT(queryTileCount); | 89 SkASSERT(queryTileCount); |
90 if (queryTileCount == 1) { | 90 if (queryTileCount == 1) { |
91 *results = this->tile(tileStartX, tileStartY); | 91 *results = this->tile(tileStartX, tileStartY); |
92 } else { | 92 } else { |
93 results->reset(); | 93 results->reset(); |
94 SkTDArray<int> curPositions; | 94 SkAutoSTArray<kStackAllocationTileCount, int> curPositions(queryTileCoun
t); |
95 curPositions.setCount(queryTileCount); | 95 SkAutoSTArray<kStackAllocationTileCount, SkTDArray<void *>*> storage(que
ryTileCount); |
96 // Note: Reserving space for 1024 tile pointers on the stack. If the | |
97 // malloc becomes a bottleneck, we may consider increasing that number. | |
98 // Typical large web page, say 2k x 16k, would require 512 tiles of | |
99 // size 256 x 256 pixels. | |
100 SkAutoSTArray<1024, SkTDArray<void *>*> storage(queryTileCount); | |
101 SkTDArray<void *>** tileRange = storage.get(); | 96 SkTDArray<void *>** tileRange = storage.get(); |
102 int tile = 0; | 97 int tile = 0; |
103 for (int x = tileStartX; x < tileEndX; ++x) { | 98 for (int x = tileStartX; x < tileEndX; ++x) { |
104 for (int y = tileStartY; y < tileEndY; ++y) { | 99 for (int y = tileStartY; y < tileEndY; ++y) { |
105 tileRange[tile] = &this->tile(x, y); | 100 tileRange[tile] = &this->tile(x, y); |
106 curPositions[tile] = tileRange[tile]->count() ? 0 : kTileFinishe
d; | 101 curPositions[tile] = tileRange[tile]->count() ? 0 : kTileFinishe
d; |
107 ++tile; | 102 ++tile; |
108 } | 103 } |
109 } | 104 } |
110 void *nextElement; | 105 void *nextElement; |
(...skipping 14 matching lines...) Expand all Loading... |
125 } | 120 } |
126 | 121 |
127 void SkTileGrid::rewindInserts() { | 122 void SkTileGrid::rewindInserts() { |
128 SkASSERT(fClient); | 123 SkASSERT(fClient); |
129 for (int i = 0; i < fTileCount; ++i) { | 124 for (int i = 0; i < fTileCount; ++i) { |
130 while (!fTileData[i].isEmpty() && fClient->shouldRewind(fTileData[i].top
())) { | 125 while (!fTileData[i].isEmpty() && fClient->shouldRewind(fTileData[i].top
())) { |
131 fTileData[i].pop(); | 126 fTileData[i].pop(); |
132 } | 127 } |
133 } | 128 } |
134 } | 129 } |
OLD | NEW |