aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar rileya@google.com <rileya@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-11 15:41:50 +0000
committerGravatar rileya@google.com <rileya@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-11 15:41:50 +0000
commit4813458d89fb276680168848bd861b307cf83f51 (patch)
treeb6f1f71891ea40c8857d8a66603a267a16674c3e /src
parent9fd7f8d2906365637dc25f98ffdede87d631ef71 (diff)
Make BBoxHierarchy ref-counted, fix leak in RTreeTest.
Review URL: https://codereview.appspot.com/6489108 git-svn-id: http://skia.googlecode.com/svn/trunk@5484 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBBoxHierarchy.cpp12
-rw-r--r--src/core/SkBBoxHierarchy.h8
-rw-r--r--src/core/SkRTree.cpp2
-rw-r--r--src/core/SkRTree.h2
4 files changed, 22 insertions, 2 deletions
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