OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Test.h" | 8 #include "Test.h" |
9 // This is a GPU-backend specific test | 9 // This is a GPU-backend specific test |
10 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
11 #include "GrMemoryPool.h" | 11 #include "GrMemoryPool.h" |
12 #include "SkRandom.h" | 12 #include "SkRandom.h" |
13 #include "SkTDArray.h" | 13 #include "SkTDArray.h" |
14 #include "SkTScopedPtr.h" | 14 #include "SkTemplates.h" |
15 #include "SkInstCnt.h" | 15 #include "SkInstCnt.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 // A is the top of an inheritance tree of classes that overload op new and | 18 // A is the top of an inheritance tree of classes that overload op new and |
19 // and delete to use a GrMemoryPool. The objects have values of different types | 19 // and delete to use a GrMemoryPool. The objects have values of different types |
20 // that can be set and checked. | 20 // that can be set and checked. |
21 class A { | 21 class A { |
22 public: | 22 public: |
23 A() {}; | 23 A() {}; |
24 virtual void setValues(int v) { | 24 virtual void setValues(int v) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 | 59 |
60 static void ResetAllocator() { | 60 static void ResetAllocator() { |
61 #if SK_ENABLE_INST_COUNT | 61 #if SK_ENABLE_INST_COUNT |
62 SkASSERT(0 == GetInstanceCount()); | 62 SkASSERT(0 == GetInstanceCount()); |
63 #endif | 63 #endif |
64 gPool.reset(NULL); | 64 gPool.reset(NULL); |
65 } | 65 } |
66 | 66 |
67 private: | 67 private: |
68 static SkTScopedPtr<GrMemoryPool> gPool; | 68 static SkAutoTDelete<GrMemoryPool> gPool; |
69 char fChar; | 69 char fChar; |
70 }; | 70 }; |
71 SK_DEFINE_INST_COUNT(A); | 71 SK_DEFINE_INST_COUNT(A); |
72 SkTScopedPtr<GrMemoryPool> A::gPool; | 72 SkAutoTDelete<GrMemoryPool> A::gPool; |
73 | 73 |
74 class B : public A { | 74 class B : public A { |
75 public: | 75 public: |
76 B() {}; | 76 B() {}; |
77 virtual void setValues(int v) { | 77 virtual void setValues(int v) { |
78 fDouble = static_cast<double>(v); | 78 fDouble = static_cast<double>(v); |
79 this->INHERITED::setValues(v); | 79 this->INHERITED::setValues(v); |
80 } | 80 } |
81 virtual bool checkValues(int v) { | 81 virtual bool checkValues(int v) { |
82 return fDouble == static_cast<double>(v) && | 82 return fDouble == static_cast<double>(v) && |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 REPORTER_ASSERT(reporter, !A::GetInstanceCount()); | 237 REPORTER_ASSERT(reporter, !A::GetInstanceCount()); |
238 #endif | 238 #endif |
239 } | 239 } |
240 } | 240 } |
241 } | 241 } |
242 | 242 |
243 #include "TestClassDef.h" | 243 #include "TestClassDef.h" |
244 DEFINE_TESTCLASS("GrMemoryPool", GrMemoryPoolClass, test_memory_pool) | 244 DEFINE_TESTCLASS("GrMemoryPool", GrMemoryPoolClass, test_memory_pool) |
245 | 245 |
246 #endif | 246 #endif |
OLD | NEW |