diff options
Diffstat (limited to 'src/core/SkPictureFlat.h')
-rw-r--r-- | src/core/SkPictureFlat.h | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h index 7888b2e563..5918261204 100644 --- a/src/core/SkPictureFlat.h +++ b/src/core/SkPictureFlat.h @@ -156,11 +156,16 @@ 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)); - - const uint32_t* a_ptr = &(a->fChecksum); - const uint32_t* b_ptr = &(b->fChecksum); - const uint32_t* stop = a_ptr + bytesToCompare / sizeof(uint32_t); +#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); while(a_ptr < stop) { if (*a_ptr != *b_ptr) { return (*a_ptr < *b_ptr) ? -1 : 1; @@ -173,8 +178,6 @@ 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; } @@ -196,7 +199,11 @@ 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> |