aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@google.com>2014-10-09 13:55:20 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-09 13:55:20 -0700
commit7062a262e27d89411a7b6bcc0162d230a2b2e36c (patch)
treee3418068986c0b360799f58e2e9df88e3874eba9 /src
parentd9aa218e8152bb77dfa2efeb8843b61993e0dc56 (diff)
Revert of Use BBH reserve hook to preallocate space for tiles. (patchset #2 id:80001 of https://codereview.chromium.org/639823005/)
Reason for revert: failed assertion "fXTiles * fYTiles != 0" Original issue's description: > Use BBH reserve hook to preallocate space for tiles. > > Before getting too far into changing how SkTileGrid stores its tiles, I figured I'd > better see how much I can tweak out the existing format. Cleverly, that way > any improvements I make by changing the format will look that much less > impressive. > > This CL looks like it will be a 5-15% win in time spent recording, with no effect > on playback. > > This CL also shrinks the tiles to fit exactly when we're done inserting, > using newly added SkTDArray::shrinkToFit(). It's quite cheap to run (maybe > taking back 1-2% from those 5-15% wins), and means we'll lug around about 15% > fewer bytes in the tile grids. Note though this strategy temporarily uses up to > 30% more memory while building the tile grid. For our largest SKPs, that's > maybe 75-100K extra. > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/52455cbc02d7f480d988ae7cdacc11ad69078c2c TBR=reed@google.com,robertphillips@google.com,mtklein@chromium.org NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/642933002
Diffstat (limited to 'src')
-rw-r--r--src/core/SkTileGrid.cpp27
-rw-r--r--src/core/SkTileGrid.h3
2 files changed, 1 insertions, 29 deletions
diff --git a/src/core/SkTileGrid.cpp b/src/core/SkTileGrid.cpp
index 2a3eac9ec1..8b96b73fa1 100644
--- a/src/core/SkTileGrid.cpp
+++ b/src/core/SkTileGrid.cpp
@@ -17,37 +17,12 @@ SkTileGrid::SkTileGrid(int xTiles, int yTiles, const SkTileGridFactory::TileGrid
, fOffset(SkPoint::Make(info.fOffset.fX, info.fOffset.fY))
, fGridBounds(SkRect::MakeWH(xTiles * info.fTileInterval.width(),
yTiles * info.fTileInterval.height()))
- , fTiles(SkNEW_ARRAY(SkTDArray<unsigned>, xTiles * yTiles)) {
- SkASSERT(fXTiles * fYTiles != 0);
-}
+ , fTiles(SkNEW_ARRAY(SkTDArray<unsigned>, xTiles * yTiles)) {}
SkTileGrid::~SkTileGrid() {
SkDELETE_ARRAY(fTiles);
}
-void SkTileGrid::reserve(unsigned opCount) {
- // If we assume every op we're about to try to insert() falls within our grid bounds,
- // then every op has to hit at least one tile. In fact, a quick scan over our small
- // SKP set shows that in the average SKP, each op hits two 256x256 tiles.
-
- // If we take those observations and further assume the ops are distributed evenly
- // across the picture, we get this guess for number of ops per tile:
- const int opsPerTileGuess = (2 * opCount) / (fXTiles * fYTiles);
-
- for (SkTDArray<unsigned>* tile = fTiles; tile != fTiles + (fXTiles * fYTiles); tile++) {
- tile->setReserve(opsPerTileGuess);
- }
-
- // In practice, this heuristic means we'll temporarily allocate about 30% more bytes
- // than if we made no setReserve() calls, but time spent in insert() drops by about 50%.
-}
-
-void SkTileGrid::flushDeferredInserts() {
- for (SkTDArray<unsigned>* tile = fTiles; tile != fTiles + (fXTiles * fYTiles); tile++) {
- tile->shrinkToFit();
- }
-}
-
// Adjustments to user-provided bounds common to both insert() and search().
// Call this after making insert- or search- specific adjustments.
void SkTileGrid::commonAdjust(SkRect* rect) const {
diff --git a/src/core/SkTileGrid.h b/src/core/SkTileGrid.h
index fd7584fd9c..e8a0d96a65 100644
--- a/src/core/SkTileGrid.h
+++ b/src/core/SkTileGrid.h
@@ -39,9 +39,6 @@ public:
// For testing.
int tileCount(int x, int y) { return fTiles[y * fXTiles + x].count(); }
- virtual void reserve(unsigned opCount) SK_OVERRIDE;
- virtual void flushDeferredInserts() SK_OVERRIDE;
-
private:
void commonAdjust(SkRect*) const;
void userToGrid(const SkRect&, SkIRect* grid) const;