aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-24 11:24:38 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-24 11:24:38 +0000
commitac90d1d0b1a02e3dfdc8780f0a35e0e6855d6ce1 (patch)
tree27f784febf128277544041a61fc9b7ba108b26e3 /src
parent381010e5501a8d681f8f059486da74f4924f81e5 (diff)
Replacing SkTDArray with SkAutoSTArray to reduce memory allocation overhead in SkTileGrid::search
BUG=https://code.google.com/p/skia/issues/detail?id=1735 R=tomhudson@chromium.org Author: junov@chromium.org Review URL: https://codereview.chromium.org/35633002 git-svn-id: http://skia.googlecode.com/svn/trunk@11936 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkTileGrid.cpp9
-rw-r--r--src/core/SkTileGrid.h12
2 files changed, 12 insertions, 9 deletions
diff --git a/src/core/SkTileGrid.cpp b/src/core/SkTileGrid.cpp
index c39e21b356..bbed00603d 100644
--- a/src/core/SkTileGrid.cpp
+++ b/src/core/SkTileGrid.cpp
@@ -91,13 +91,8 @@ void SkTileGrid::search(const SkIRect& query, SkTDArray<void*>* results) {
*results = this->tile(tileStartX, tileStartY);
} else {
results->reset();
- SkTDArray<int> curPositions;
- curPositions.setCount(queryTileCount);
- // Note: Reserving space for 1024 tile pointers on the stack. If the
- // malloc becomes a bottleneck, we may consider increasing that number.
- // Typical large web page, say 2k x 16k, would require 512 tiles of
- // size 256 x 256 pixels.
- SkAutoSTArray<1024, SkTDArray<void *>*> storage(queryTileCount);
+ SkAutoSTArray<kStackAllocationTileCount, int> curPositions(queryTileCount);
+ SkAutoSTArray<kStackAllocationTileCount, SkTDArray<void *>*> storage(queryTileCount);
SkTDArray<void *>** tileRange = storage.get();
int tile = 0;
for (int x = tileStartX; x < tileEndX; ++x) {
diff --git a/src/core/SkTileGrid.h b/src/core/SkTileGrid.h
index e272673c63..77d972850f 100644
--- a/src/core/SkTileGrid.h
+++ b/src/core/SkTileGrid.h
@@ -25,7 +25,15 @@
*/
class SkTileGrid : public SkBBoxHierarchy {
public:
- typedef void* (*SkTileGridNextDatumFunctionPtr)(SkTDArray<void*>** tileData, SkTDArray<int>& tileIndices);
+ enum {
+ // Number of tiles for which data is allocated on the stack in
+ // SkTileGrid::search. If malloc becomes a bottleneck, we may consider
+ // increasing this number. Typical large web page, say 2k x 16k, would
+ // require 512 tiles of size 256 x 256 pixels.
+ kStackAllocationTileCount = 1024
+ };
+
+ typedef void* (*SkTileGridNextDatumFunctionPtr)(SkTDArray<void*>** tileData, SkAutoSTArray<kStackAllocationTileCount, int>& tileIndices);
SkTileGrid(int xTileCount, int yTileCount, const SkTileGridPicture::TileGridInfo& info,
SkTileGridNextDatumFunctionPtr nextDatumFunction);
@@ -91,7 +99,7 @@ private:
* such that 'a < b' is true if 'a' was inserted into the tile grid before 'b'.
*/
template <typename T>
-void* SkTileGridNextDatum(SkTDArray<void*>** tileData, SkTDArray<int>& tileIndices) {
+void* SkTileGridNextDatum(SkTDArray<void*>** tileData, SkAutoSTArray<SkTileGrid::kStackAllocationTileCount, int>& tileIndices) {
T* minVal = NULL;
int tileCount = tileIndices.count();
int minIndex = tileCount;