diff options
author | 2012-07-09 17:05:51 +0000 | |
---|---|---|
committer | 2012-07-09 17:05:51 +0000 | |
commit | f8affe5adff8e82ca6a3e5b98b0d772e204edc51 (patch) | |
tree | e8443f9752b20c7b90caf0a7056757be25cbc056 /src | |
parent | de1cf48790d235aba46852abdd932602cf2a6aaa (diff) |
switch callers to SkChecksum::Compute (no 32/64 preference)
Review URL: https://codereview.appspot.com/6377043
git-svn-id: http://skia.googlecode.com/svn/trunk@4478 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkPictureFlat.cpp | 19 | ||||
-rw-r--r-- | src/core/SkPictureFlat.h | 19 |
2 files changed, 7 insertions, 31 deletions
diff --git a/src/core/SkPictureFlat.cpp b/src/core/SkPictureFlat.cpp index ec04495db9..2f8d1e198c 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; } 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> |