• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2012 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkBBoxHierarchy_DEFINED
9 #define SkBBoxHierarchy_DEFINED
10 
11 #include "include/core/SkRect.h"
12 #include "include/core/SkRefCnt.h"
13 #include "include/private/SkTDArray.h"
14 
15 /**
16  * Interface for a spatial data structure that stores axis-aligned bounding
17  * boxes and allows efficient retrieval of intersections with query rectangles.
18  */
19 class SkBBoxHierarchy : public SkRefCnt {
20 public:
SkBBoxHierarchy()21     SkBBoxHierarchy() {}
~SkBBoxHierarchy()22     virtual ~SkBBoxHierarchy() {}
23 
24     /**
25      * Insert N bounding boxes into the hierarchy.
26      */
27     virtual void insert(const SkRect[], int N) = 0;
28 
29     /**
30      * Populate results with the indices of bounding boxes interesecting that query.
31      */
32     virtual void search(const SkRect& query, SkTDArray<int>* results) const = 0;
33 
34     virtual size_t bytesUsed() const = 0;
35 
36     // Get the root bound.
37     virtual SkRect getRootBound() const = 0;
38 
39 private:
40     typedef SkRefCnt INHERITED;
41 };
42 
43 #endif
44