diff options
-rw-r--r-- | bench/RTreeBench.cpp | 4 | ||||
-rw-r--r-- | gyp/core.gypi | 1 | ||||
-rw-r--r-- | src/core/SkBBoxHierarchy.cpp | 12 | ||||
-rw-r--r-- | src/core/SkBBoxHierarchy.h | 8 | ||||
-rw-r--r-- | src/core/SkRTree.cpp | 2 | ||||
-rw-r--r-- | src/core/SkRTree.h | 2 | ||||
-rw-r--r-- | tests/RTreeTest.cpp | 1 |
7 files changed, 26 insertions, 4 deletions
diff --git a/bench/RTreeBench.cpp b/bench/RTreeBench.cpp index edea57d10a..d13d88704c 100644 --- a/bench/RTreeBench.cpp +++ b/bench/RTreeBench.cpp @@ -37,7 +37,7 @@ public: } } virtual ~BBoxBuildBench() { - delete fTree; + fTree->unref(); } protected: virtual const char* onGetName() { @@ -93,7 +93,7 @@ public: fTree->flushDeferredInserts(); } virtual ~BBoxQueryBench() { - delete fTree; + fTree->unref(); } protected: virtual const char* onGetName() { diff --git a/gyp/core.gypi b/gyp/core.gypi index 80b1939999..b30a973aa5 100644 --- a/gyp/core.gypi +++ b/gyp/core.gypi @@ -14,6 +14,7 @@ '<(skia_src_path)/core/SkAdvancedTypefaceMetrics.cpp', '<(skia_src_path)/core/SkAlphaRuns.cpp', '<(skia_src_path)/core/SkAntiRun.h', + '<(skia_src_path)/core/SkBBoxHierarchy.cpp', '<(skia_src_path)/core/SkBBoxHierarchy.h', '<(skia_src_path)/core/SkBBoxRecord.cpp', '<(skia_src_path)/core/SkBBoxRecord.h', diff --git a/src/core/SkBBoxHierarchy.cpp b/src/core/SkBBoxHierarchy.cpp new file mode 100644 index 0000000000..a99bb9d97c --- /dev/null +++ b/src/core/SkBBoxHierarchy.cpp @@ -0,0 +1,12 @@ +
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkBBoxHierarchy.h"
+
+SK_DEFINE_INST_COUNT(SkBBoxHierarchy)
+
diff --git a/src/core/SkBBoxHierarchy.h b/src/core/SkBBoxHierarchy.h index 347871f87b..6625a846fe 100644 --- a/src/core/SkBBoxHierarchy.h +++ b/src/core/SkBBoxHierarchy.h @@ -11,14 +11,15 @@ #include "SkRect.h" #include "SkTDArray.h" +#include "SkRefCnt.h" /** * Interface for a spatial data structure that associates user data pointers with axis-aligned * bounding boxes, and allows efficient retrieval of intersections with query rectangles. */ -class SkBBoxHierarchy { +class SkBBoxHierarchy : public SkRefCnt { public: - virtual ~SkBBoxHierarchy() { } + SK_DECLARE_INST_COUNT(SkBBoxHierarchy) /** * Insert a data pointer and corresponding bounding box @@ -47,6 +48,9 @@ public: * Gets the number of insertions */ virtual int getCount() const = 0; + +private: + typedef SkRefCnt INHERITED; }; #endif diff --git a/src/core/SkRTree.cpp b/src/core/SkRTree.cpp index b6ff29b8c4..96f6b18c81 100644 --- a/src/core/SkRTree.cpp +++ b/src/core/SkRTree.cpp @@ -19,6 +19,8 @@ static inline void join_no_empty_check(const SkIRect& joinWith, SkIRect* out); /////////////////////////////////////////////////////////////////////////////////////////////////// +SK_DEFINE_INST_COUNT(SkRTree) + SkRTree* SkRTree::Create(int minChildren, int maxChildren, SkScalar aspectRatio) { if (minChildren < maxChildren && (maxChildren + 1) / 2 >= minChildren && minChildren > 0 && maxChildren < static_cast<int>(SK_MaxU16)) { diff --git a/src/core/SkRTree.h b/src/core/SkRTree.h index 96881596c3..1f166489a1 100644 --- a/src/core/SkRTree.h +++ b/src/core/SkRTree.h @@ -42,6 +42,7 @@ */ class SkRTree : public SkBBoxHierarchy { public: + SK_DECLARE_INST_COUNT(SkRTree) /** * Create a new R-Tree with specified min/max child counts. @@ -175,6 +176,7 @@ private: Node* allocateNode(uint16_t level); + typedef SkBBoxHierarchy INHERITED; }; #endif diff --git a/tests/RTreeTest.cpp b/tests/RTreeTest.cpp index 61e6b675ad..d60bf0c08a 100644 --- a/tests/RTreeTest.cpp +++ b/tests/RTreeTest.cpp @@ -82,6 +82,7 @@ static void TestRTree(skiatest::Reporter* reporter) { DataRect rects[NUM_RECTS]; SkRandom rand; SkRTree* rtree = SkRTree::Create(MIN_CHILDREN, MAX_CHILDREN); + SkAutoUnref au(rtree); REPORTER_ASSERT(reporter, NULL != rtree); int expectedDepthMin = -1; |