/src/skia/include/core/SkBBHFactory.h
Line | Count | Source (jump to first uncovered line) |
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/SkRect.h" |
12 | | #include "include/core/SkRefCnt.h" |
13 | | #include "include/core/SkTypes.h" |
14 | | #include <vector> |
15 | | |
16 | | class SkBBoxHierarchy : public SkRefCnt { |
17 | | public: |
18 | | struct Metadata { |
19 | | bool isDraw; // The corresponding SkRect bounds a draw command, not a pure state change. |
20 | | }; |
21 | | |
22 | | /** |
23 | | * Insert N bounding boxes into the hierarchy. |
24 | | */ |
25 | | virtual void insert(const SkRect[], int N) = 0; |
26 | | virtual void insert(const SkRect[], const Metadata[], int N); |
27 | | |
28 | | /** |
29 | | * Populate results with the indices of bounding boxes intersecting that query. |
30 | | */ |
31 | | virtual void search(const SkRect& query, std::vector<int>* results) const = 0; |
32 | | |
33 | | /** |
34 | | * Return approximate size in memory of *this. |
35 | | */ |
36 | | virtual size_t bytesUsed() const = 0; |
37 | | |
38 | | protected: |
39 | | SkBBoxHierarchy() = default; |
40 | | SkBBoxHierarchy(const SkBBoxHierarchy&) = delete; |
41 | | SkBBoxHierarchy& operator=(const SkBBoxHierarchy&) = delete; |
42 | | }; |
43 | | |
44 | | class SK_API SkBBHFactory { |
45 | | public: |
46 | | /** |
47 | | * Allocate a new SkBBoxHierarchy. Return NULL on failure. |
48 | | */ |
49 | | virtual sk_sp<SkBBoxHierarchy> operator()() const = 0; |
50 | 0 | virtual ~SkBBHFactory() {} |
51 | | |
52 | | protected: |
53 | | SkBBHFactory() = default; |
54 | | SkBBHFactory(const SkBBHFactory&) = delete; |
55 | | SkBBHFactory& operator=(const SkBBHFactory&) = delete; |
56 | | }; |
57 | | |
58 | | class SK_API SkRTreeFactory : public SkBBHFactory { |
59 | | public: |
60 | | sk_sp<SkBBoxHierarchy> operator()() const override; |
61 | | }; |
62 | | |
63 | | #endif |