2014-04-18 18:04:41 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkBBHFactory_DEFINED
|
|
|
|
#define SkBBHFactory_DEFINED
|
|
|
|
|
2020-02-12 15:45:41 +00:00
|
|
|
#include "include/core/SkRect.h"
|
2020-01-21 16:34:55 +00:00
|
|
|
#include "include/core/SkRefCnt.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkTypes.h"
|
2020-02-12 15:45:41 +00:00
|
|
|
#include <vector>
|
2020-01-21 16:34:55 +00:00
|
|
|
|
2020-01-21 17:16:37 +00:00
|
|
|
class SkBBoxHierarchy : public SkRefCnt {
|
|
|
|
public:
|
|
|
|
SkBBoxHierarchy() {}
|
|
|
|
virtual ~SkBBoxHierarchy() {}
|
|
|
|
|
2020-02-26 16:30:29 +00:00
|
|
|
struct Metadata {
|
|
|
|
bool isDraw; // The corresponding SkRect bounds a draw command, not a pure state change.
|
|
|
|
};
|
|
|
|
|
2020-02-12 15:45:41 +00:00
|
|
|
/**
|
|
|
|
* Insert N bounding boxes into the hierarchy.
|
|
|
|
*/
|
|
|
|
virtual void insert(const SkRect[], int N) = 0;
|
2020-02-26 16:30:29 +00:00
|
|
|
virtual void insert(const SkRect[], const Metadata[], int N);
|
2020-02-12 15:45:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Populate results with the indices of bounding boxes intersecting that query.
|
|
|
|
*/
|
|
|
|
virtual void search(const SkRect& query, std::vector<int>* results) const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return approximate size in memory of *this.
|
|
|
|
*/
|
|
|
|
virtual size_t bytesUsed() const = 0;
|
2020-01-21 17:16:37 +00:00
|
|
|
};
|
2014-04-18 18:04:41 +00:00
|
|
|
|
2014-04-22 13:33:16 +00:00
|
|
|
class SK_API SkBBHFactory {
|
2014-04-18 18:04:41 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Allocate a new SkBBoxHierarchy. Return NULL on failure.
|
|
|
|
*/
|
2020-01-21 16:34:55 +00:00
|
|
|
virtual sk_sp<SkBBoxHierarchy> operator()() const = 0;
|
2016-09-27 13:34:10 +00:00
|
|
|
virtual ~SkBBHFactory() {}
|
2014-04-18 18:04:41 +00:00
|
|
|
};
|
|
|
|
|
2014-04-22 13:33:16 +00:00
|
|
|
class SK_API SkRTreeFactory : public SkBBHFactory {
|
2014-04-18 18:04:41 +00:00
|
|
|
public:
|
2020-01-21 16:34:55 +00:00
|
|
|
sk_sp<SkBBoxHierarchy> operator()() const override;
|
2014-04-18 18:04:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|