SkBBoxHierarchy.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #ifndef SkBBoxHierarchy_DEFINED
  8. #define SkBBoxHierarchy_DEFINED
  9. #include "include/core/SkRect.h"
  10. #include "include/core/SkRefCnt.h"
  11. #include "include/private/SkTDArray.h"
  12. /**
  13. * Interface for a spatial data structure that stores axis-aligned bounding
  14. * boxes and allows efficient retrieval of intersections with query rectangles.
  15. */
  16. class SkBBoxHierarchy : public SkRefCnt {
  17. public:
  18. SkBBoxHierarchy() {}
  19. virtual ~SkBBoxHierarchy() {}
  20. /**
  21. * Insert N bounding boxes into the hierarchy.
  22. */
  23. virtual void insert(const SkRect[], int N) = 0;
  24. /**
  25. * Populate results with the indices of bounding boxes interesecting that query.
  26. */
  27. virtual void search(const SkRect& query, SkTDArray<int>* results) const = 0;
  28. virtual size_t bytesUsed() const = 0;
  29. // Get the root bound.
  30. virtual SkRect getRootBound() const = 0;
  31. private:
  32. typedef SkRefCnt INHERITED;
  33. };
  34. #endif