Debian Codegraph @

include/core/SkBBHFactory.h

raw
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
26 /**
27 * Insert N bounding boxes into the hierarchy.
28 */
29 virtual void insert(const SkRect[], int N) = 0;
30 virtual void insert(const SkRect[], const Metadata[], int N);
31
32 /**
33 * Populate results with the indices of bounding boxes intersecting that query.
34 */
35 virtual void search(const SkRect& query, std::vector<int>* results) const = 0;
36
37 /**
38 * Return approximate size in memory of *this.
39 */
40 virtual size_t bytesUsed() const = 0;
41
42 protected:
43 SkBBoxHierarchy() = default;
44 SkBBoxHierarchy(const SkBBoxHierarchy&) = delete;
45 SkBBoxHierarchy& operator=(const SkBBoxHierarchy&) = delete;
46 };
47
48 class SK_API SkBBHFactory {
49 public:
50 /**
51 * Allocate a new SkBBoxHierarchy. Return NULL on failure.
52 */
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:
64 sk_sp<SkBBoxHierarchy> operator()() const override;
65 };
66
67 #endif