aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-11-13 12:41:14 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-13 12:41:14 -0800
commitf2950b1c4538fa638a594af6beacd3d1434eb74d (patch)
treeae71e205e2ff3f74cf5a12b412d83958df99356d /tests
parentb2db898573e3cdcc8234eebf51961bfc4977ebbc (diff)
Deparameterize SkVarAlloc.
SkRecord performance is not sensitive to these values, so we can cut some storage. This rearranges the space-remaining logic to use a count of bytes left rather than a pointer to the end, cutting memory usage a little more. An SkVarAlloc used to weigh 20 or 32 bytes which now becomes 16 or 24. I think if I think about it a bit more I can trim off that Block* too, getting us to 12 or 16 bytes. Because we now just always grow by doubling, this CL switches from storing fSmallest to its log base 2. This has the nice effect of never having to worry about it overflowing, and means we can probably squeeze it down into a byte if we want, even 6 bits. BUG=skia: Committed: https://skia.googlesource.com/skia/+/bc415389855888af5a1282ca4b6bee30afa3d69d CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu12-ShuttleA-GTX660-x86-Debug-Trybot Review URL: https://codereview.chromium.org/721313002
Diffstat (limited to 'tests')
-rw-r--r--tests/RecordTest.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/tests/RecordTest.cpp b/tests/RecordTest.cpp
index 2a0e615516..49efc28d2c 100644
--- a/tests/RecordTest.cpp
+++ b/tests/RecordTest.cpp
@@ -85,21 +85,15 @@ static bool is_aligned(const T* p) {
DEF_TEST(Record_Alignment, r) {
SkRecord record;
-
- // Of course a byte's always aligned.
REPORTER_ASSERT(r, is_aligned(record.alloc<uint8_t>()));
-
- // (If packed tightly, the rest below here would be off by one.)
-
- // It happens that the first implementation always aligned to 4 bytes,
- // so these two were always correct.
REPORTER_ASSERT(r, is_aligned(record.alloc<uint16_t>()));
REPORTER_ASSERT(r, is_aligned(record.alloc<uint32_t>()));
-
- // These two are regression tests (void* only on 64-bit machines).
- REPORTER_ASSERT(r, is_aligned(record.alloc<uint64_t>()));
REPORTER_ASSERT(r, is_aligned(record.alloc<void*>()));
- // We're not testing beyond sizeof(void*), which is where the current implementation will break.
+ // It's not clear if we care that 8-byte values are aligned on 32-bit machines.
+ if (sizeof(void*) == 8) {
+ REPORTER_ASSERT(r, is_aligned(record.alloc<double>()));
+ REPORTER_ASSERT(r, is_aligned(record.alloc<uint64_t>()));
+ }
}