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
diff --git a/tests/RefCntTest.cpp b/tests/RefCntTest.cpp
index 4d4ae3f..569e4e4 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_refCntTests(skiatest::Reporter* reporter) {
     test_refCnt(reporter);
     test_weakRefCnt(reporter);
+    test_refarray(reporter);
 }
 
 #include "TestClassDef.h"