23 C() : fID(-1) { ++gInstCnt; }
24 C(
int id) : fID(
id) { ++gInstCnt; }
25 C(
C&& c) :
C(c.fID) {}
26 C(
const C& c) :
C(c.fID) {}
28 C& operator=(
C&&) =
default;
29 C& operator=(
const C&) =
default;
54 return (
size_t) list.fAllocator->scratchBlockSize();
62 static constexpr size_t kAddressAlign = SkBlockAllocator::kAddressAlign;
75 for (
const C& c : allocator->
items()) {
87 for (
i = 0;
i < popCnt; ++
i) {
96 const std::vector<C*>& expected,
102 for (
const C& c : cAlloc->
items()) {
110 for (
C& c : allocator->
items()) {
117 i = (
int) expected.size() - 1;
118 for (
const C& c : cAlloc->
ritems()) {
125 i = (
int) expected.size() - 1;
126 for (
C& c : allocator->
ritems()) {
133 for (
i = 0;
i < allocator->
count(); ++
i) {
144 enum ItemInitializer :
int {
151 static constexpr int kInitCount = (
int) kEmplace + 1;
155 std::vector<C*> items;
156 for (
int i = 0;
i < cnt; ++
i) {
157 switch((ItemInitializer) (
i % kInitCount)) {
174 items.push_back(&allocator->
back());
194template<
int N1,
int N2>
200 for (
int i = 0;
i < aCount; ++
i) {
203 for (
int i = 0;
i < bCount; ++
i) {
211 listA.
concat(std::move(listB));
220 for (
const C& item : listA.
items()) {
228template<
int N1,
int N2>
237 for (
int i = 0;
i < aCount; ++
i) {
240 for (
int i = 0;
i < bCount; ++
i) {
246 listA.
concat(std::move(listB));
251 for (
const D& item : listA.
items()) {
261 constexpr int kItemsPerBlock =
N + 4;
266 for (
int i = 0;
i <
N; ++
i) {
272 list.
reserve(2 * kItemsPerBlock);
277 for (
int i = 0;
i < 2 * kItemsPerBlock; ++
i) {
283 for (
int i = 0;
i <
N; ++
i) {
289 list.
reserve(2 * kItemsPerBlock);
290 int extraReservedCount = kItemsPerBlock +
N;
294 extraReservedCount *
sizeof(
C));
297 for (
int i = 0;
i < 2 * kItemsPerBlock; ++
i) {
305 kItemsPerBlock *
sizeof(
C));
308 int expectedInstanceCount = 2 * (
N + 2 * kItemsPerBlock);
355 run_concat_test<1, 1>(
reporter, 10, 10);
356 run_concat_test<5, 1>(
reporter, 50, 10);
357 run_concat_test<1, 5>(
reporter, 10, 50);
358 run_concat_test<5, 5>(
reporter, 100, 100);
360 run_concat_trivial_test<1, 1>(
reporter, 10, 10);
361 run_concat_trivial_test<5, 1>(
reporter, 50, 10);
362 run_concat_trivial_test<1, 5>(
reporter, 10, 50);
363 run_concat_trivial_test<5, 5>(
reporter, 100, 100);
static constexpr size_t SkAlignTo(size_t x, size_t alignment)
DEF_TEST(SkTBlockList, reporter)
static void check_allocator_helper(SkTBlockList< C, N > *allocator, int cnt, int popCnt, skiatest::Reporter *reporter)
void run_large_increment_test(skiatest::Reporter *reporter)
static void run_allocator_test(SkTBlockList< C, N > *allocator, skiatest::Reporter *reporter)
static void run_concat_trivial_test(skiatest::Reporter *reporter, int aCount, int bCount)
static void check_allocator(SkTBlockList< C, N > *allocator, int cnt, int popCnt, skiatest::Reporter *reporter)
static void run_reserve_test(skiatest::Reporter *reporter)
static void check_iterator_helper(SkTBlockList< C, N > *allocator, const std::vector< C * > &expected, skiatest::Reporter *reporter)
static void run_concat_test(skiatest::Reporter *reporter, int aCount, int bCount)
#define REPORTER_ASSERT(r, cond,...)
T & emplace_back(Args &&... args)
void concat(SkTBlockList< T, SI > &&other)
static constexpr size_t kAddressAlign
static size_t ScratchBlockSize(SkTBlockList< C, N > &list)
static size_t TotalSize(SkTBlockList< C, N > &list)
static float max(float r, float g, float b)