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

Unified Diff: src/core/SkTileGrid.h

Issue 35633002: Replacing SkTDArray with SkAutoSTArray to reduce memory allocation overhead in SkTileGrid::search (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkTileGrid.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTileGrid.h
diff --git a/src/core/SkTileGrid.h b/src/core/SkTileGrid.h
index e272673c638f255d320e676c0e4fdfd60bb2f511..77d972850fe7bb70fb14ca657bb92c3842e72968 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;
« no previous file with comments | « no previous file | src/core/SkTileGrid.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698