Index: src/core/SkBBoxHierarchy.h |
=================================================================== |
--- src/core/SkBBoxHierarchy.h (revision 8135) |
+++ src/core/SkBBoxHierarchy.h (working copy) |
@@ -14,6 +14,23 @@ |
#include "SkRefCnt.h" |
/** |
+ * Interface for a client class that implements utility methods needed |
+ * by SkBBoxHierarchy that require intrinsic knowledge of the data |
+ * object type that is stored in the bounding box hierarchy. |
+ */ |
+class SkBBoxHierarchyClient { |
+public: |
+ virtual ~SkBBoxHierarchyClient() {} |
+ |
+ /** |
+ * Implements a rewind stop condition used by rewindInserts |
+ * Must returns true if 'data' points to an object that should be re-wound |
+ * by rewinfInserts. |
+ */ |
+ virtual bool shouldRewind(void* data) = 0; |
+}; |
+ |
+/** |
* Interface for a spatial data structure that associates user data pointers with axis-aligned |
* bounding boxes, and allows efficient retrieval of intersections with query rectangles. |
*/ |
@@ -21,6 +38,8 @@ |
public: |
SK_DECLARE_INST_COUNT(SkBBoxHierarchy) |
+ SkBBoxHierarchy() : fClient(NULL) {} |
+ |
/** |
* Insert a data pointer and corresponding bounding box |
* @param data The data pointer, may be NULL |
@@ -49,6 +68,19 @@ |
*/ |
virtual int getCount() const = 0; |
+ /** |
+ * Rewinds all the most recently inserted data elements until an element |
+ * is encountered for which client->shouldRewind(data) returns false. May |
+ * not rewind elements that were inserted prior to the last call to |
+ * flushDeferredInserts. |
+ */ |
+ virtual void rewindInserts() = 0; |
+ |
+ void setClient(SkBBoxHierarchyClient* client) { fClient = client; } |
+ |
+protected: |
+ SkBBoxHierarchyClient* fClient; |
+ |
private: |
typedef SkRefCnt INHERITED; |
}; |