aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-10-02 09:53:04 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-02 09:53:04 -0700
commit8f8c25eabb97da8eda488895f04f2d12cb5ea4cf (patch)
treeb72d7effb991556b669b9ccadba9ab33e43ff7e6
parented48ebe39e7f06ed00b851abea1270318947c2b8 (diff)
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
-rw-r--r--bench/RTreeBench.cpp6
-rw-r--r--src/core/SkBBoxHierarchy.h17
-rw-r--r--src/core/SkRTree.h20
-rw-r--r--src/core/SkTileGrid.cpp7
-rw-r--r--src/core/SkTileGrid.h7
-rw-r--r--tests/PictureTest.cpp3
-rw-r--r--tests/RecordDrawTest.cpp4
7 files changed, 9 insertions, 55 deletions
diff --git a/bench/RTreeBench.cpp b/bench/RTreeBench.cpp
index 21c1d79a94..08d6bf4bdb 100644
--- a/bench/RTreeBench.cpp
+++ b/bench/RTreeBench.cpp
@@ -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)
diff --git a/src/core/SkBBoxHierarchy.h b/src/core/SkBBoxHierarchy.h
index 53eabc8b88..3382ac154e 100644
--- a/src/core/SkBBoxHierarchy.h
+++ b/src/core/SkBBoxHierarchy.h
@@ -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;
};
diff --git a/src/core/SkRTree.h b/src/core/SkRTree.h
index 85469ccc4c..0d88804c30 100644
--- a/src/core/SkRTree.h
+++ b/src/core/SkRTree.h
@@ -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;
diff --git a/src/core/SkTileGrid.cpp b/src/core/SkTileGrid.cpp
index 317d74a2d7..ea51797f53 100644
--- a/src/core/SkTileGrid.cpp
+++ b/src/core/SkTileGrid.cpp
@@ -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();
- }
-}
-
diff --git a/src/core/SkTileGrid.h b/src/core/SkTileGrid.h
index 97564c64ad..df0a746a3c 100644
--- a/src/core/SkTileGrid.h
+++ b/src/core/SkTileGrid.h
@@ -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;
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index 0518dd3333..0d13a428e7 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -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 {
diff --git a/tests/RecordDrawTest.cpp b/tests/RecordDrawTest.cpp
index ac3883b2d6..ca75fc9058 100644
--- a/tests/RecordDrawTest.cpp
+++ b/tests/RecordDrawTest.cpp
@@ -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;