Home | History | Annotate | Download | only in core
      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 "SkRect.h"
     12 #include "SkRefCnt.h"
     13 #include "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:
     21     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