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

Unified Diff: src/core/SkTileGrid.cpp

Issue 642933002: Revert of Use BBH reserve hook to preallocate space for tiles. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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 | « src/core/SkTileGrid.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTileGrid.cpp
diff --git a/src/core/SkTileGrid.cpp b/src/core/SkTileGrid.cpp
index 2a3eac9ec1601e491fdf8f80c9b6f5364554b392..8b96b73fa13f895654c53d7834d28451479bd163 100644
--- a/src/core/SkTileGrid.cpp
+++ b/src/core/SkTileGrid.cpp
@@ -17,35 +17,10 @@
, 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().
« no previous file with comments | « src/core/SkTileGrid.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698