Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #ifndef SkBBoxHierarchy_DEFINED | 9 #ifndef SkBBoxHierarchy_DEFINED |
| 10 #define SkBBoxHierarchy_DEFINED | 10 #define SkBBoxHierarchy_DEFINED |
| 11 | 11 |
| 12 #include "SkRect.h" | 12 #include "SkRect.h" |
| 13 #include "SkTDArray.h" | 13 #include "SkTDArray.h" |
| 14 #include "SkRefCnt.h" | 14 #include "SkRefCnt.h" |
| 15 | 15 |
|
robertphillips
2013/03/14 18:55:44
comment
Justin Novosad
2013/03/14 20:04:14
Done.
| |
| 16 class SkBBoxHierarchyClient { | |
| 17 public: | |
| 18 virtual ~SkBBoxHierarchyClient() {} | |
| 19 | |
|
robertphillips
2013/03/14 18:55:44
Could this be something more than a void*?
Justin Novosad
2013/03/14 20:04:14
void* is used to reference SkPictureStateTree::Dra
| |
| 20 virtual bool shouldRewind(void* data) = 0; | |
| 21 }; | |
| 22 | |
| 16 /** | 23 /** |
| 17 * Interface for a spatial data structure that associates user data pointers wit h axis-aligned | 24 * Interface for a spatial data structure that associates user data pointers wit h axis-aligned |
| 18 * bounding boxes, and allows efficient retrieval of intersections with query re ctangles. | 25 * bounding boxes, and allows efficient retrieval of intersections with query re ctangles. |
| 19 */ | 26 */ |
| 20 class SkBBoxHierarchy : public SkRefCnt { | 27 class SkBBoxHierarchy : public SkRefCnt { |
| 21 public: | 28 public: |
| 22 SK_DECLARE_INST_COUNT(SkBBoxHierarchy) | 29 SK_DECLARE_INST_COUNT(SkBBoxHierarchy) |
| 23 | 30 |
| 31 SkBBoxHierarchy() : fClient(NULL) {} | |
| 32 | |
| 24 /** | 33 /** |
| 25 * Insert a data pointer and corresponding bounding box | 34 * Insert a data pointer and corresponding bounding box |
| 26 * @param data The data pointer, may be NULL | 35 * @param data The data pointer, may be NULL |
| 27 * @param bounds The bounding box, should not be empty | 36 * @param bounds The bounding box, should not be empty |
| 28 * @param defer Whether or not it is acceptable to delay insertion of this e lement (building up | 37 * @param defer Whether or not it is acceptable to delay insertion of this e lement (building up |
| 29 * an entire spatial data structure at once is often faster and produ ces better | 38 * an entire spatial data structure at once is often faster and produ ces better |
| 30 * structures than repeated inserts) until flushDeferredInserts is ca lled or the first | 39 * structures than repeated inserts) until flushDeferredInserts is ca lled or the first |
| 31 * search. | 40 * search. |
| 32 */ | 41 */ |
| 33 virtual void insert(void* data, const SkIRect& bounds, bool defer = false) = 0; | 42 virtual void insert(void* data, const SkIRect& bounds, bool defer = false) = 0; |
| 34 | 43 |
| 35 /** | 44 /** |
| 36 * If any insertions have been deferred, this forces them to be inserted | 45 * If any insertions have been deferred, this forces them to be inserted |
| 37 */ | 46 */ |
| 38 virtual void flushDeferredInserts() = 0; | 47 virtual void flushDeferredInserts() = 0; |
| 39 | 48 |
| 40 /** | 49 /** |
| 41 * Populate 'results' with data pointers corresponding to bounding boxes tha t intersect 'query' | 50 * Populate 'results' with data pointers corresponding to bounding boxes tha t intersect 'query' |
| 42 */ | 51 */ |
| 43 virtual void search(const SkIRect& query, SkTDArray<void*>* results) = 0; | 52 virtual void search(const SkIRect& query, SkTDArray<void*>* results) = 0; |
| 44 | 53 |
| 45 virtual void clear() = 0; | 54 virtual void clear() = 0; |
| 46 | 55 |
| 47 /** | 56 /** |
| 48 * Gets the number of insertions | 57 * Gets the number of insertions |
| 49 */ | 58 */ |
| 50 virtual int getCount() const = 0; | 59 virtual int getCount() const = 0; |
| 51 | 60 |
| 61 /** | |
| 62 * Rewinds all the most recently inserted data elements until an element | |
| 63 * is encountered for which client->shouldRewind(data) returns false. May | |
| 64 * not rewind elements that were inserted prior to the last call to | |
| 65 * flushDeferredInserts. | |
| 66 */ | |
| 67 virtual void rewindInserts() = 0; | |
| 68 | |
|
robertphillips
2013/03/14 18:55:44
"{ fClient = client; }" - spaces
Justin Novosad
2013/03/14 20:04:14
Done.
| |
| 69 void setClient(SkBBoxHierarchyClient* client) {fClient = client;} | |
| 70 | |
| 71 protected: | |
| 72 SkBBoxHierarchyClient* fClient; | |
| 73 | |
| 52 private: | 74 private: |
| 53 typedef SkRefCnt INHERITED; | 75 typedef SkRefCnt INHERITED; |
| 54 }; | 76 }; |
| 55 | 77 |
| 56 #endif | 78 #endif |
| OLD | NEW |