aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBBoxHierarchy.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-10-09 06:49:47 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-09 06:49:47 -0700
commit208d1704c2cc1161ea337a05155f2b9a04edd351 (patch)
treeba422cfb3c49471b7fb9c535610c22a60689e06a /src/core/SkBBoxHierarchy.h
parenta9c56525f32ee0075ed8dbaff3a032b7abeed4ae (diff)
Add SkBBoxHierarchy::reserve() as an optional size hint.
I want to play around with how SkTileGrid stores its tiles. Having a cap on the number of insert() calls can be pretty handy. While I'm at it, I gave flush() a default empty impl. Like reserve(), it's really an optional hook for subclasses. BUG=skia: Review URL: https://codereview.chromium.org/639933003
Diffstat (limited to 'src/core/SkBBoxHierarchy.h')
-rw-r--r--src/core/SkBBoxHierarchy.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/core/SkBBoxHierarchy.h b/src/core/SkBBoxHierarchy.h
index 3382ac154e..7246787de8 100644
--- a/src/core/SkBBoxHierarchy.h
+++ b/src/core/SkBBoxHierarchy.h
@@ -24,9 +24,14 @@ public:
SkBBoxHierarchy() {}
/**
- * Insert opIndex and corresponding bounding box
+ * Hint that <= opCount calls to insert() will be made.
+ */
+ virtual void reserve(unsigned opCount) {}
+
+ /**
+ * Insert opIndex and corresponding bounding box.
* @param opIndex Any value, will be returned in order.
- * @param bounds The bounding box, should not be empty
+ * @param bounds The bounding box, should not be empty.
* @param defer Whether or not it is acceptable to delay insertion of this element (building up
* an entire spatial data structure at once is often faster and produces better
* structures than repeated inserts) until flushDeferredInserts is called or the first
@@ -35,9 +40,9 @@ public:
virtual void insert(unsigned opIndex, const SkRect& bounds, bool defer = false) = 0;
/**
- * If any insertions have been deferred, this forces them to be inserted
+ * If any insertions have been deferred, force them to be inserted.
*/
- virtual void flushDeferredInserts() = 0;
+ virtual void flushDeferredInserts() {}
/**
* Populate results with sorted opIndex corresponding to bounding boxes that intersect query.