Demote getCount, getDepth, and clear to RTree-only methods.
We use them only to test RTree. BUG=skia: Review URL: https://codereview.chromium.org/622773003
This commit is contained in:
parent
ed48ebe39e
commit
8f8c25eabb
@ -24,7 +24,7 @@ typedef SkRect (*MakeRectProc)(SkRandom&, int, int);
|
||||
class RTreeBuildBench : public Benchmark {
|
||||
public:
|
||||
RTreeBuildBench(const char* name, MakeRectProc proc, bool bulkLoad,
|
||||
SkBBoxHierarchy* tree)
|
||||
SkRTree* tree)
|
||||
: fTree(tree)
|
||||
, fProc(proc)
|
||||
, fBulkLoad(bulkLoad) {
|
||||
@ -58,7 +58,7 @@ protected:
|
||||
}
|
||||
}
|
||||
private:
|
||||
SkBBoxHierarchy* fTree;
|
||||
SkRTree* fTree;
|
||||
MakeRectProc fProc;
|
||||
SkString fName;
|
||||
bool fBulkLoad;
|
||||
@ -76,7 +76,7 @@ public:
|
||||
};
|
||||
|
||||
RTreeQueryBench(const char* name, MakeRectProc proc, bool bulkLoad,
|
||||
QueryType q, SkBBoxHierarchy* tree)
|
||||
QueryType q, SkRTree* tree)
|
||||
: fTree(tree)
|
||||
, fProc(proc)
|
||||
, fBulkLoad(bulkLoad)
|
||||
|
@ -44,23 +44,6 @@ public:
|
||||
*/
|
||||
virtual void search(const SkRect& query, SkTDArray<unsigned>* results) const = 0;
|
||||
|
||||
virtual void clear() = 0;
|
||||
|
||||
/**
|
||||
* Gets the number of insertions actually made (does not include deferred insertions)
|
||||
*/
|
||||
virtual int getCount() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the depth of the currently allocated tree. The root node counts for 1 level,
|
||||
* so it should be 1 or more if there's a root node. This information provides details
|
||||
* about the underlying structure, which is useful mainly for testing purposes.
|
||||
*
|
||||
* Returns 0 if there are currently no nodes in the tree.
|
||||
* Returns -1 if the structure isn't a tree.
|
||||
*/
|
||||
virtual int getDepth() const = 0;
|
||||
|
||||
private:
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
@ -79,22 +79,14 @@ public:
|
||||
*/
|
||||
virtual void search(const SkRect& query, SkTDArray<unsigned>* results) const SK_OVERRIDE;
|
||||
|
||||
virtual void clear() SK_OVERRIDE;
|
||||
bool isEmpty() const { return 0 == fCount; }
|
||||
|
||||
/**
|
||||
* Gets the depth of the tree structure
|
||||
*/
|
||||
virtual int getDepth() const SK_OVERRIDE {
|
||||
return this->isEmpty() ? 0 : fRoot.fChild.subtree->fLevel + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets the insertion count (rather than the node count)
|
||||
*/
|
||||
virtual int getCount() const SK_OVERRIDE { return fCount; }
|
||||
void clear();
|
||||
// Return the depth of the tree structure.
|
||||
int getDepth() const { return this->isEmpty() ? 0 : fRoot.fChild.subtree->fLevel + 1; }
|
||||
// Insertion count (not overall node count, which may be greater).
|
||||
int getCount() const { return fCount; }
|
||||
|
||||
private:
|
||||
bool isEmpty() const { return 0 == this->getCount(); }
|
||||
|
||||
struct Node;
|
||||
|
||||
|
@ -11,7 +11,6 @@ SkTileGrid::SkTileGrid(int xTiles, int yTiles, const SkTileGridFactory::TileGrid
|
||||
: fXTiles(xTiles)
|
||||
, fYTiles(yTiles)
|
||||
, fInfo(info)
|
||||
, fCount(0)
|
||||
, fTiles(SkNEW_ARRAY(SkTDArray<unsigned>, xTiles * yTiles)) {
|
||||
// Margin is offset by 1 as a provision for AA and
|
||||
// to cancel-out the outset applied by getClipDeviceBounds.
|
||||
@ -146,9 +145,3 @@ void SkTileGrid::search(const SkRect& query, SkTDArray<unsigned>* results) const
|
||||
}
|
||||
}
|
||||
|
||||
void SkTileGrid::clear() {
|
||||
for (int i = 0; i < fXTiles * fYTiles; i++) {
|
||||
fTiles[i].reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,19 +38,12 @@ public:
|
||||
*/
|
||||
virtual void search(const SkRect& query, SkTDArray<unsigned>* results) const SK_OVERRIDE;
|
||||
|
||||
virtual void clear() SK_OVERRIDE;
|
||||
|
||||
virtual int getCount() const SK_OVERRIDE { return fCount; }
|
||||
|
||||
virtual int getDepth() const SK_OVERRIDE { return -1; }
|
||||
|
||||
// For testing.
|
||||
int tileCount(int x, int y) { return fTiles[y * fXTiles + x].count(); }
|
||||
|
||||
private:
|
||||
const int fXTiles, fYTiles;
|
||||
SkTileGridFactory::TileGridInfo fInfo;
|
||||
size_t fCount;
|
||||
|
||||
// (fXTiles * fYTiles) SkTDArrays, each listing ops overlapping that tile in order.
|
||||
SkTDArray<unsigned>* fTiles;
|
||||
|
@ -1872,9 +1872,6 @@ struct CountingBBH : public SkBBoxHierarchy {
|
||||
// All other methods unimplemented.
|
||||
virtual void insert(unsigned opIndex, const SkRect& bounds, bool defer) SK_OVERRIDE {}
|
||||
virtual void flushDeferredInserts() SK_OVERRIDE {}
|
||||
virtual void clear() SK_OVERRIDE {}
|
||||
virtual int getCount() const SK_OVERRIDE { return 0; }
|
||||
virtual int getDepth() const SK_OVERRIDE { return 0; }
|
||||
};
|
||||
|
||||
class SpoonFedBBHFactory : public SkBBHFactory {
|
||||
|
@ -102,13 +102,9 @@ struct TestBBH : public SkBBoxHierarchy {
|
||||
Entry e = { opIndex, bounds };
|
||||
fEntries.push(e);
|
||||
}
|
||||
virtual int getCount() const SK_OVERRIDE { return fEntries.count(); }
|
||||
|
||||
virtual void flushDeferredInserts() SK_OVERRIDE {}
|
||||
|
||||
virtual void search(const SkRect& query, SkTDArray<unsigned>* results) const SK_OVERRIDE {}
|
||||
virtual void clear() SK_OVERRIDE {}
|
||||
virtual int getDepth() const SK_OVERRIDE { return -1; }
|
||||
|
||||
struct Entry {
|
||||
unsigned opIndex;
|
||||
|
Loading…
Reference in New Issue
Block a user