aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-02-10 13:44:27 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-10 13:44:27 -0800
commitbfd5bff75c0ce27a70f02e4b5578d66aa9d6e306 (patch)
treeb4da5ee57719399580225ca5c37c8a390f1c9373
parenta0921f2563701d54e4e022de99f2705f4ada8a6e (diff)
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
-rw-r--r--bench/RTreeBench.cpp4
-rw-r--r--src/core/SkBBoxHierarchy.h3
-rw-r--r--src/core/SkRTree.cpp4
-rw-r--r--src/core/SkRTree.h2
-rw-r--r--src/core/SkRecordDraw.cpp2
-rw-r--r--tests/PictureTest.cpp2
-rw-r--r--tests/RTreeTest.cpp2
-rw-r--r--tests/RecordDrawTest.cpp4
8 files changed, 11 insertions, 12 deletions
diff --git a/bench/RTreeBench.cpp b/bench/RTreeBench.cpp
index 39c2aa116c..cdbdf35e01 100644
--- a/bench/RTreeBench.cpp
+++ b/bench/RTreeBench.cpp
@@ -43,7 +43,7 @@ protected:
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 @@ protected:
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 aee8af5d7d..f925a91940 100644
--- a/src/core/SkBBoxHierarchy.h
+++ b/src/core/SkBBoxHierarchy.h
@@ -24,9 +24,8 @@ public:
/**
* 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 13083be212..ba5843e537 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 7934324b5d..320b0bd438 100644
--- a/src/core/SkRTree.h
+++ b/src/core/SkRTree.h
@@ -41,7 +41,7 @@ public:
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 3fed8de95c..9b08426670 100644
--- a/src/core/SkRecordDraw.cpp
+++ b/src/core/SkRecordDraw.cpp
@@ -177,7 +177,7 @@ public:
// 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 18af979954..33e058cc2e 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -1255,7 +1255,7 @@ struct CountingBBH : public SkBBoxHierarchy {
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 50eaacb603..16ccb4f508 100644
--- a/tests/RTreeTest.cpp
+++ b/tests/RTreeTest.cpp
@@ -80,7 +80,7 @@ DEF_TEST(RTree, reporter) {
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 4e1ad15bf4..cf138b8d4e 100644
--- a/tests/RecordDrawTest.cpp
+++ b/tests/RecordDrawTest.cpp
@@ -123,10 +123,10 @@ DEF_TEST(RecordDraw_SetMatrixClobber, r) {
}
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;
}
}