diff options
author | 2012-07-21 17:31:40 +0000 | |
---|---|---|
committer | 2012-07-21 17:31:40 +0000 | |
commit | 80ba7964cde0f7805d76cf0170cf3b920146a007 (patch) | |
tree | f2d206957e18290d57c987ef202e2b857be27241 /tests | |
parent | fdd909ca000801aced49881558760170b5f1eb97 (diff) |
add SkTRefArray, in hopes that it will enable more sharing between pictureplaybacks
in different threads.
git-svn-id: http://skia.googlecode.com/svn/trunk@4709 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r-- | tests/RefCntTest.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/RefCntTest.cpp b/tests/RefCntTest.cpp index 4d4ae3f54a..569e4e4602 100644 --- a/tests/RefCntTest.cpp +++ b/tests/RefCntTest.cpp @@ -11,9 +11,34 @@ #include "SkRefCnt.h" #include "SkThreadUtils.h" #include "SkWeakRefCnt.h" +#include "SkTRefArray.h" /////////////////////////////////////////////////////////////////////////////// +class InstCounterClass { +public: + InstCounterClass() { gInstCounter += 1; } + ~InstCounterClass() { gInstCounter -= 1; } + + static int gInstCounter; +}; + +int InstCounterClass::gInstCounter; + +static void test_refarray(skiatest::Reporter* reporter) { + REPORTER_ASSERT(reporter, 0 == InstCounterClass::gInstCounter); + + int N = 10; + SkTRefArray<InstCounterClass>* array = SkTRefArray<InstCounterClass>::Create(N); + REPORTER_ASSERT(reporter, 1 == array->getRefCnt()); + + REPORTER_ASSERT(reporter, N == InstCounterClass::gInstCounter); + REPORTER_ASSERT(reporter, array->count() == N); + + array->unref(); + REPORTER_ASSERT(reporter, 0 == InstCounterClass::gInstCounter); +} + static void bounce_ref(void* data) { SkRefCnt* ref = static_cast<SkRefCnt*>(data); for (int i = 0; i < 100000; ++i) { @@ -89,6 +114,7 @@ static void test_weakRefCnt(skiatest::Reporter* reporter) { static void test_refCntTests(skiatest::Reporter* reporter) { test_refCnt(reporter); test_weakRefCnt(reporter); + test_refarray(reporter); } #include "TestClassDef.h" |