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 #include "TestClassDef.h" |
9 // This is a GPU-backend specific test | 10 // This is a GPU-backend specific test |
10 #if SK_SUPPORT_GPU | 11 #if SK_SUPPORT_GPU |
11 #include "GrMemoryPool.h" | 12 #include "GrMemoryPool.h" |
12 #include "SkRandom.h" | 13 #include "SkRandom.h" |
13 #include "SkTDArray.h" | 14 #include "SkTDArray.h" |
14 #include "SkTemplates.h" | 15 #include "SkTemplates.h" |
15 #include "SkInstCnt.h" | 16 #include "SkInstCnt.h" |
16 | 17 |
17 // 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 |
18 // 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 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 // suppress warning | 176 // suppress warning |
176 return NULL; | 177 return NULL; |
177 } | 178 } |
178 } | 179 } |
179 | 180 |
180 struct Rec { | 181 struct Rec { |
181 A* fInstance; | 182 A* fInstance; |
182 int fValue; | 183 int fValue; |
183 }; | 184 }; |
184 | 185 |
185 static void test_memory_pool(skiatest::Reporter* reporter) { | 186 DEF_TEST(GrMemoryPool, reporter) { |
186 // prealloc and min alloc sizes for the pool | 187 // prealloc and min alloc sizes for the pool |
187 static const size_t gSizes[][2] = { | 188 static const size_t gSizes[][2] = { |
188 {0, 0}, | 189 {0, 0}, |
189 {10 * sizeof(A), 20 * sizeof(A)}, | 190 {10 * sizeof(A), 20 * sizeof(A)}, |
190 {100 * sizeof(A), 100 * sizeof(A)}, | 191 {100 * sizeof(A), 100 * sizeof(A)}, |
191 {500 * sizeof(A), 500 * sizeof(A)}, | 192 {500 * sizeof(A), 500 * sizeof(A)}, |
192 {10000 * sizeof(A), 0}, | 193 {10000 * sizeof(A), 0}, |
193 {1, 100 * sizeof(A)}, | 194 {1, 100 * sizeof(A)}, |
194 }; | 195 }; |
195 // different percentages of creation vs deletion | 196 // different percentages of creation vs deletion |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 REPORTER_ASSERT(reporter, rec.fInstance->checkValues(rec.fValue)
); | 233 REPORTER_ASSERT(reporter, rec.fInstance->checkValues(rec.fValue)
); |
233 delete rec.fInstance; | 234 delete rec.fInstance; |
234 } | 235 } |
235 #if SK_ENABLE_INST_COUNT | 236 #if SK_ENABLE_INST_COUNT |
236 REPORTER_ASSERT(reporter, !A::GetInstanceCount()); | 237 REPORTER_ASSERT(reporter, !A::GetInstanceCount()); |
237 #endif | 238 #endif |
238 } | 239 } |
239 } | 240 } |
240 } | 241 } |
241 | 242 |
242 #include "TestClassDef.h" | |
243 DEFINE_TESTCLASS("GrMemoryPool", GrMemoryPoolClass, test_memory_pool) | |
244 | |
245 #endif | 243 #endif |
OLD | NEW |