Simplify SkBBH::insert API
No one's exploiting the ability to take ownership of the array anymore.
BUG=skia:
Review URL: https://codereview.chromium.org/913833002
diff --git a/bench/RTreeBench.cpp b/bench/RTreeBench.cpp
index 39c2aa1..cdbdf35 100644
--- a/bench/RTreeBench.cpp
+++ b/bench/RTreeBench.cpp
@@ -43,7 +43,7 @@
for (int i = 0; i < loops; ++i) {
SkRTree tree;
- tree.insert(&rects, NUM_BUILD_RECTS);
+ tree.insert(rects.get(), NUM_BUILD_RECTS);
SkASSERT(rects != NULL); // It'd break this bench if the tree took ownership of rects.
}
}
@@ -73,7 +73,7 @@
for (int i = 0; i < NUM_QUERY_RECTS; ++i) {
rects[i] = fProc(rand, i, NUM_QUERY_RECTS);
}
- fTree.insert(&rects, NUM_QUERY_RECTS);
+ fTree.insert(rects.get(), NUM_QUERY_RECTS);
}
void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
diff --git a/src/core/SkBBoxHierarchy.h b/src/core/SkBBoxHierarchy.h
index aee8af5..f925a91 100644
--- a/src/core/SkBBoxHierarchy.h
+++ b/src/core/SkBBoxHierarchy.h
@@ -24,9 +24,8 @@
/**
* Insert N bounding boxes into the hierarchy.
- * The SkBBoxHierarchy may take ownership of boundsArray by calling detach().
*/
- virtual void insert(SkAutoTMalloc<SkRect>* boundsArray, int N) = 0;
+ virtual void insert(const SkRect[], int N) = 0;
/**
* Populate results with the indices of bounding boxes interesecting that query.
diff --git a/src/core/SkRTree.cpp b/src/core/SkRTree.cpp
index 13083be..ba5843e 100644
--- a/src/core/SkRTree.cpp
+++ b/src/core/SkRTree.cpp
@@ -9,14 +9,14 @@
SkRTree::SkRTree(SkScalar aspectRatio) : fCount(0), fAspectRatio(aspectRatio) {}
-void SkRTree::insert(SkAutoTMalloc<SkRect>* boundsArray, int N) {
+void SkRTree::insert(const SkRect boundsArray[], int N) {
SkASSERT(0 == fCount);
SkTDArray<Branch> branches;
branches.setReserve(N);
for (int i = 0; i < N; i++) {
- const SkRect& bounds = (*boundsArray)[i];
+ const SkRect& bounds = boundsArray[i];
if (bounds.isEmpty()) {
continue;
}
diff --git a/src/core/SkRTree.h b/src/core/SkRTree.h
index 7934324..320b0bd 100644
--- a/src/core/SkRTree.h
+++ b/src/core/SkRTree.h
@@ -41,7 +41,7 @@
explicit SkRTree(SkScalar aspectRatio = 1);
virtual ~SkRTree() {}
- void insert(SkAutoTMalloc<SkRect>* boundsArray, int N) SK_OVERRIDE;
+ void insert(const SkRect[], int N) SK_OVERRIDE;
void search(const SkRect& query, SkTDArray<unsigned>* results) const SK_OVERRIDE;
size_t bytesUsed() const SK_OVERRIDE;
diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp
index 3fed8de..9b08426 100644
--- a/src/core/SkRecordDraw.cpp
+++ b/src/core/SkRecordDraw.cpp
@@ -177,7 +177,7 @@
// Finally feed all stored bounds into the BBH. They'll be returned in this order.
if (bbh) {
- bbh->insert(&fBounds, fNumRecords);
+ bbh->insert(fBounds.get(), fNumRecords);
}
}
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index 18af979..33e058c 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -1255,7 +1255,7 @@
this->searchCalls++;
}
- void insert(SkAutoTMalloc<SkRect>*, int) SK_OVERRIDE {}
+ void insert(const SkRect[], int) SK_OVERRIDE {}
virtual size_t bytesUsed() const SK_OVERRIDE { return 0; }
};
diff --git a/tests/RTreeTest.cpp b/tests/RTreeTest.cpp
index 50eaacb..16ccb4f 100644
--- a/tests/RTreeTest.cpp
+++ b/tests/RTreeTest.cpp
@@ -80,7 +80,7 @@
rects[j] = random_rect(rand);
}
- rtree.insert(&rects, NUM_RECTS);
+ rtree.insert(rects.get(), NUM_RECTS);
SkASSERT(rects); // SkRTree doesn't take ownership of rects.
run_queries(reporter, rand, rects, rtree);
diff --git a/tests/RecordDrawTest.cpp b/tests/RecordDrawTest.cpp
index 4e1ad15..cf138b8 100644
--- a/tests/RecordDrawTest.cpp
+++ b/tests/RecordDrawTest.cpp
@@ -123,10 +123,10 @@
}
struct TestBBH : public SkBBoxHierarchy {
- void insert(SkAutoTMalloc<SkRect>* boundsArray, int N) SK_OVERRIDE {
+ void insert(const SkRect boundsArray[], int N) SK_OVERRIDE {
fEntries.setCount(N);
for (int i = 0; i < N; i++) {
- Entry e = { (unsigned)i, (*boundsArray)[i] };
+ Entry e = { (unsigned)i, boundsArray[i] };
fEntries[i] = e;
}
}