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
|
|
|
|
|
|
|
|
#include "SkSize.h"
|
2014-11-19 16:04:34 +00:00
|
|
|
#include "SkRect.h"
|
2014-04-18 18:04:41 +00:00
|
|
|
|
|
|
|
class SkBBoxHierarchy;
|
|
|
|
|
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.
|
|
|
|
*/
|
2014-11-19 16:04:34 +00:00
|
|
|
virtual SkBBoxHierarchy* operator()(const SkRect& bounds) const = 0;
|
2014-04-18 18:04:41 +00:00
|
|
|
virtual ~SkBBHFactory() {};
|
|
|
|
};
|
|
|
|
|
2014-04-22 13:33:16 +00:00
|
|
|
class SK_API SkRTreeFactory : public SkBBHFactory {
|
2014-04-18 18:04:41 +00:00
|
|
|
public:
|
2014-11-19 16:04:34 +00:00
|
|
|
virtual SkBBoxHierarchy* operator()(const SkRect& bounds) const SK_OVERRIDE;
|
2014-04-18 18:04:41 +00:00
|
|
|
private:
|
|
|
|
typedef SkBBHFactory INHERITED;
|
|
|
|
};
|
|
|
|
|
2014-04-22 13:33:16 +00:00
|
|
|
class SK_API SkTileGridFactory : public SkBBHFactory {
|
2014-04-18 18:04:41 +00:00
|
|
|
public:
|
|
|
|
struct TileGridInfo {
|
|
|
|
/** Tile placement interval */
|
|
|
|
SkISize fTileInterval;
|
|
|
|
|
|
|
|
/** Pixel coverage overlap between adjacent tiles */
|
|
|
|
SkISize fMargin;
|
|
|
|
|
|
|
|
/** Offset added to device-space bounding box positions to convert
|
|
|
|
* them to tile-grid space. This can be used to adjust the "phase"
|
|
|
|
* of the tile grid to match probable query rectangles that will be
|
|
|
|
* used to search into the tile grid. As long as the offset is smaller
|
|
|
|
* or equal to the margin, there is no need to extend the domain of
|
|
|
|
* the tile grid to prevent data loss.
|
|
|
|
*/
|
|
|
|
SkIPoint fOffset;
|
|
|
|
};
|
|
|
|
|
|
|
|
SkTileGridFactory(const TileGridInfo& info) : fInfo(info) { }
|
|
|
|
|
2014-11-19 16:04:34 +00:00
|
|
|
virtual SkBBoxHierarchy* operator()(const SkRect& bounds) const SK_OVERRIDE;
|
2014-04-18 18:04:41 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
TileGridInfo fInfo;
|
|
|
|
|
|
|
|
typedef SkBBHFactory INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|