diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-09 17:44:44 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-09 17:44:44 +0000 |
commit | 142e1fe7cf5dc82e5d4c107b06756302f0cbf96d (patch) | |
tree | 456e9e8eff8e3b3aef8e703c50587b3688c90917 /src | |
parent | fc8581b2d8c63439162c701623bce096088ce6e6 (diff) |
restore 4478 w/ fixed assert (no long need 8-byte alignment)
git-svn-id: http://skia.googlecode.com/svn/trunk@4480 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkPictureFlat.cpp | 21 | ||||
-rw-r--r-- | src/core/SkPictureFlat.h | 19 |
2 files changed, 8 insertions, 32 deletions
diff --git a/src/core/SkPictureFlat.cpp b/src/core/SkPictureFlat.cpp index ec04495db9..deb6412533 100644 --- a/src/core/SkPictureFlat.cpp +++ b/src/core/SkPictureFlat.cpp @@ -80,12 +80,6 @@ SkFlatData* SkFlatData::Create(SkChunkAlloc* heap, const void* obj, flattenProc(buffer, obj); uint32_t size = buffer.size(); - -#if !SK_PREFER_32BIT_CHECKSUM - uint32_t unpaddedSize = size; - size = SkAlign8(size); -#endif - // allocate enough memory to hold both SkFlatData and the serialized // contents SkFlatData* result = (SkFlatData*) heap->allocThrow(size + sizeof(SkFlatData)); @@ -94,18 +88,7 @@ SkFlatData* SkFlatData::Create(SkChunkAlloc* heap, const void* obj, // put the serialized contents into the data section of the new allocation buffer.flatten(result->data()); -#if SK_PREFER_32BIT_CHECKSUM - result->fChecksum = - SkComputeChecksum32(reinterpret_cast<uint32_t*>(result->data()), size); -#else - if (size != unpaddedSize) { - // Flat data is padded: put zeros in the last 32 bits. - SkASSERT(size - 4 == unpaddedSize); - *((uint32_t*)((char*)result->data() + unpaddedSize)) = 0; - } - result->fChecksum = - SkComputeChecksum64(reinterpret_cast<uint64_t*>(result->data()), size); -#endif + result->fChecksum = SkChecksum::Compute(result->data32(), size); return result; } @@ -122,5 +105,5 @@ void SkFlatData::unflatten(void* result, facePlayback->setupBuffer(buffer); } unflattenProc(buffer, result); - SkASSERT(fAllocSize == SkAlign8((int32_t)buffer.offset())); + SkASSERT(fAllocSize == (int32_t)buffer.offset()); } diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h index 5918261204..7888b2e563 100644 --- a/src/core/SkPictureFlat.h +++ b/src/core/SkPictureFlat.h @@ -156,16 +156,11 @@ public: static int Compare(const SkFlatData* a, const SkFlatData* b) { size_t bytesToCompare = sizeof(a->fChecksum) + a->fAllocSize; -#if SK_PREFER_32BIT_CHECKSUM - typedef uint32_t CompareType; SkASSERT(SkIsAlign4(bytesToCompare)); -#else - typedef uint64_t CompareType; - SkASSERT(SkIsAlign8(bytesToCompare)); -#endif - const CompareType* a_ptr = &(a->fChecksum); - const CompareType* b_ptr = &(b->fChecksum); - const CompareType* stop = a_ptr + bytesToCompare / sizeof(CompareType); + + const uint32_t* a_ptr = &(a->fChecksum); + const uint32_t* b_ptr = &(b->fChecksum); + const uint32_t* stop = a_ptr + bytesToCompare / sizeof(uint32_t); while(a_ptr < stop) { if (*a_ptr != *b_ptr) { return (*a_ptr < *b_ptr) ? -1 : 1; @@ -178,6 +173,8 @@ public: int index() const { return fIndex; } void* data() const { return (char*)this + sizeof(*this); } + // We guarantee that our data is 32bit aligned + uint32_t* data32() const { return (uint32_t*)this->data(); } #ifdef SK_DEBUG_SIZE size_t size() const { return sizeof(SkFlatData) + fAllocSize; } @@ -199,11 +196,7 @@ private: int fIndex; int32_t fAllocSize; // fChecksum must be defined last in order to be contiguous with data() -#if SK_PREFER_32BIT_CHECKSUM uint32_t fChecksum; -#else - uint64_t fChecksum; -#endif }; template <class T> |