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 "SkTemplates.h" | 14 #include "SkTemplates.h" |
15 #include "SkInstCnt.h" | 15 #include "SkInstCnt.h" |
16 | 16 |
17 namespace { | |
18 // A is the top of an inheritance tree of classes that overload op new and | 17 // 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 | 18 // and delete to use a GrMemoryPool. The objects have values of different types |
20 // that can be set and checked. | 19 // that can be set and checked. |
21 class A { | 20 class A { |
22 public: | 21 public: |
23 A() {}; | 22 A() {}; |
24 virtual void setValues(int v) { | 23 virtual void setValues(int v) { |
25 fChar = static_cast<char>(v); | 24 fChar = static_cast<char>(v); |
26 } | 25 } |
27 virtual bool checkValues(int v) { | 26 virtual bool checkValues(int v) { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 return new C; | 169 return new C; |
171 case 3: | 170 case 3: |
172 return new D; | 171 return new D; |
173 case 4: | 172 case 4: |
174 return new E; | 173 return new E; |
175 default: | 174 default: |
176 // suppress warning | 175 // suppress warning |
177 return NULL; | 176 return NULL; |
178 } | 177 } |
179 } | 178 } |
180 } | 179 |
181 struct Rec { | 180 struct Rec { |
182 A* fInstance; | 181 A* fInstance; |
183 int fValue; | 182 int fValue; |
184 }; | 183 }; |
185 | 184 |
186 static void test_memory_pool(skiatest::Reporter* reporter) { | 185 static void test_memory_pool(skiatest::Reporter* reporter) { |
187 // prealloc and min alloc sizes for the pool | 186 // prealloc and min alloc sizes for the pool |
188 static const size_t gSizes[][2] = { | 187 static const size_t gSizes[][2] = { |
189 {0, 0}, | 188 {0, 0}, |
190 {10 * sizeof(A), 20 * sizeof(A)}, | 189 {10 * sizeof(A), 20 * sizeof(A)}, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 REPORTER_ASSERT(reporter, !A::GetInstanceCount()); | 236 REPORTER_ASSERT(reporter, !A::GetInstanceCount()); |
238 #endif | 237 #endif |
239 } | 238 } |
240 } | 239 } |
241 } | 240 } |
242 | 241 |
243 #include "TestClassDef.h" | 242 #include "TestClassDef.h" |
244 DEFINE_TESTCLASS("GrMemoryPool", GrMemoryPoolClass, test_memory_pool) | 243 DEFINE_TESTCLASS("GrMemoryPool", GrMemoryPoolClass, test_memory_pool) |
245 | 244 |
246 #endif | 245 #endif |
OLD | NEW |