Skia
2D Graphics Library
SkBBHFactory.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 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 SkBBHFactory_DEFINED
9 #define SkBBHFactory_DEFINED
10 
11 #include "include/core/SkRefCnt.h"
12 #include "include/core/SkTypes.h"
13 
14 // TODO(kjlubick) fix client users and then make this a forward declare
15 #include "include/core/SkRect.h" // IWYU pragma: keep
16 
17 #include <cstddef>
18 #include <vector>
19 
20 class SkBBoxHierarchy : public SkRefCnt {
21 public:
22  struct Metadata {
23  bool isDraw; // The corresponding SkRect bounds a draw command, not a pure state change.
24  };
25 
29  virtual void insert(const SkRect[], int N) = 0;
30  virtual void insert(const SkRect[], const Metadata[], int N);
31 
35  virtual void search(const SkRect& query, std::vector<int>* results) const = 0;
36 
40  virtual size_t bytesUsed() const = 0;
41 
42 protected:
43  SkBBoxHierarchy() = default;
44  SkBBoxHierarchy(const SkBBoxHierarchy&) = delete;
46 };
47 
48 class SK_API SkBBHFactory {
49 public:
53  virtual sk_sp<SkBBoxHierarchy> operator()() const = 0;
54  virtual ~SkBBHFactory() {}
55 
56 protected:
57  SkBBHFactory() = default;
58  SkBBHFactory(const SkBBHFactory&) = delete;
59  SkBBHFactory& operator=(const SkBBHFactory&) = delete;
60 };
61 
62 class SK_API SkRTreeFactory : public SkBBHFactory {
63 public:
65 };
66 
67 #endif
Definition: SkBBHFactory.h:48
SkBBHFactory(const SkBBHFactory &)=delete
virtual sk_sp< SkBBoxHierarchy > operator()() const =0
Allocate a new SkBBoxHierarchy.
SkBBHFactory()=default
SkBBHFactory & operator=(const SkBBHFactory &)=delete
virtual ~SkBBHFactory()
Definition: SkBBHFactory.h:54
Definition: SkBBHFactory.h:20
virtual void insert(const SkRect[], const Metadata[], int N)
SkBBoxHierarchy & operator=(const SkBBoxHierarchy &)=delete
virtual size_t bytesUsed() const =0
Return approximate size in memory of *this.
virtual void search(const SkRect &query, std::vector< int > *results) const =0
Populate results with the indices of bounding boxes intersecting that query.
virtual void insert(const SkRect[], int N)=0
Insert N bounding boxes into the hierarchy.
SkBBoxHierarchy()=default
SkBBoxHierarchy(const SkBBoxHierarchy &)=delete
Definition: SkBBHFactory.h:62
sk_sp< SkBBoxHierarchy > operator()() const override
Allocate a new SkBBoxHierarchy.
Definition: SkRefCnt.h:119
Definition: SkBBHFactory.h:22
bool isDraw
Definition: SkBBHFactory.h:23
SkRect holds four float coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:582