diff options
Diffstat (limited to 'src/core/SkPtrRecorder.cpp')
-rw-r--r-- | src/core/SkPtrRecorder.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/core/SkPtrRecorder.cpp b/src/core/SkPtrRecorder.cpp index 4f774ec..6d5d95d 100644 --- a/src/core/SkPtrRecorder.cpp +++ b/src/core/SkPtrRecorder.cpp @@ -1,7 +1,7 @@ #include "SkPtrRecorder.h" #include "SkTSearch.h" -void SkPtrRecorder::reset() { +void SkPtrSet::reset() { Pair* p = fList.begin(); Pair* stop = fList.end(); while (p < stop) { @@ -11,11 +11,27 @@ void SkPtrRecorder::reset() { fList.reset(); } -int SkPtrRecorder::Cmp(const Pair& a, const Pair& b) { +int SkPtrSet::Cmp(const Pair& a, const Pair& b) { return (char*)a.fPtr - (char*)b.fPtr; } -uint32_t SkPtrRecorder::recordPtr(void* ptr) { +uint32_t SkPtrSet::find(void* ptr) const { + if (NULL == ptr) { + return 0; + } + + int count = fList.count(); + Pair pair; + pair.fPtr = ptr; + + int index = SkTSearch<Pair>(fList.begin(), count, pair, sizeof(pair), &Cmp); + if (index < 0) { + return 0; + } + return fList[index].fIndex; +} + +uint32_t SkPtrSet::add(void* ptr) { if (NULL == ptr) { return 0; } @@ -36,7 +52,7 @@ uint32_t SkPtrRecorder::recordPtr(void* ptr) { } } -void SkPtrRecorder::getPtrs(void* array[]) const { +void SkPtrSet::copyToArray(void* array[]) const { int count = fList.count(); if (count > 0) { SkASSERT(array); |