| OLD | NEW |
| 1 | |
| 2 /* | 1 /* |
| 3 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 4 * | 3 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 7 */ | 6 */ |
| 8 | 7 |
| 9 #ifndef SkBBoxHierarchy_DEFINED | 8 #ifndef SkBBoxHierarchy_DEFINED |
| 10 #define SkBBoxHierarchy_DEFINED | 9 #define SkBBoxHierarchy_DEFINED |
| 11 | 10 |
| 12 #include "SkRect.h" | 11 #include "SkRect.h" |
| 12 #include "SkRefCnt.h" |
| 13 #include "SkTDArray.h" | 13 #include "SkTDArray.h" |
| 14 #include "SkRefCnt.h" | 14 #include "SkTemplates.h" |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * Interface for a spatial data structure that associates user data with axis-al
igned | 17 * Interface for a spatial data structure that stores axis-aligned bounding |
| 18 * bounding boxes, and allows efficient retrieval of intersections with query re
ctangles. | 18 * boxes and allows efficient retrieval of intersections with query rectangles. |
| 19 */ | 19 */ |
| 20 class SkBBoxHierarchy : public SkRefCnt { | 20 class SkBBoxHierarchy : public SkRefCnt { |
| 21 public: | 21 public: |
| 22 SK_DECLARE_INST_COUNT(SkBBoxHierarchy) | |
| 23 | |
| 24 SkBBoxHierarchy() {} | 22 SkBBoxHierarchy() {} |
| 23 virtual ~SkBBoxHierarchy() {} |
| 25 | 24 |
| 26 /** | 25 /** |
| 27 * Hint that <= opCount calls to insert() will be made. | 26 * Insert N bounding boxes into the hierarchy. |
| 27 * The SkBBoxHierarchy may take ownership of boundsArray by calling detach()
. |
| 28 */ | 28 */ |
| 29 virtual void reserve(unsigned opCount) {} | 29 virtual void insert(SkAutoTMalloc<SkRect>* boundsArray, int N) = 0; |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * Insert opIndex and corresponding bounding box. | 32 * Populate results with the indices of bounding boxes interesecting that qu
ery. |
| 33 * @param opIndex Any value, will be returned in order. | |
| 34 * @param bounds The bounding box, should not be empty. | |
| 35 * @param defer Whether or not it is acceptable to delay insertion of this e
lement (building up | |
| 36 * an entire spatial data structure at once is often faster and produ
ces better | |
| 37 * structures than repeated inserts) until flushDeferredInserts is ca
lled or the first | |
| 38 * search. | |
| 39 */ | |
| 40 virtual void insert(unsigned opIndex, const SkRect& bounds, bool defer = fal
se) = 0; | |
| 41 | |
| 42 /** | |
| 43 * If any insertions have been deferred, force them to be inserted. | |
| 44 */ | |
| 45 virtual void flushDeferredInserts() {} | |
| 46 | |
| 47 /** | |
| 48 * Populate results with sorted opIndex corresponding to bounding boxes that
intersect query. | |
| 49 */ | 33 */ |
| 50 virtual void search(const SkRect& query, SkTDArray<unsigned>* results) const
= 0; | 34 virtual void search(const SkRect& query, SkTDArray<unsigned>* results) const
= 0; |
| 51 | 35 |
| 36 SK_DECLARE_INST_COUNT(SkBBoxHierarchy) |
| 52 private: | 37 private: |
| 53 typedef SkRefCnt INHERITED; | 38 typedef SkRefCnt INHERITED; |
| 54 }; | 39 }; |
| 55 | 40 |
| 56 #endif | 41 #endif |
| OLD | NEW |