/* * Copyright 2006 The Android Open Source Project * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file.
*/
Macros and helper functions for handling 16 and 32 bit values in big and little endian formats.
*/
#ifdefined(SK_CPU_LENDIAN) && defined(SK_CPU_BENDIAN) #error"can't have both LENDIAN and BENDIAN defined" #endif
#if !defined(SK_CPU_LENDIAN) && !defined(SK_CPU_BENDIAN) #error"need either LENDIAN or BENDIAN defined" #endif
/** Swap the two bytes in the low 16bits of the parameters. e.g. 0x1234 -> 0x3412
*/ staticinline uint16_t SkEndianSwap16(uint16_t value) { returnstatic_cast<uint16_t>((value >> 8) | ((value & 0xFF) << 8));
}
/** Vector version of SkEndianSwap16(), which swaps the low two bytes of each value in the array.
*/ staticinlinevoid SkEndianSwap16s(uint16_t array[], int count) {
SkASSERT(count == 0 || array != nullptr);
/** Vector version of SkEndianSwap32(), which swaps the bytes of each value in the array.
*/ staticinlinevoid SkEndianSwap32s(uint32_t array[], int count) {
SkASSERT(count == 0 || array != nullptr);
/** Vector version of SkEndianSwap64(), which swaps the bytes of each value in the array.
*/ staticinlinevoid SkEndianSwap64s(uint64_t array[], int count) {
SkASSERT(count == 0 || array != nullptr);
// Static casts are used here for otherwise no-op macros to make sure they return the same type as // SkEndianSwap* functions. #ifdef SK_CPU_LENDIAN #define SkEndian_SwapBE16(n) SkEndianSwap16(n) #define SkEndian_SwapBE32(n) SkEndianSwap32(n) #define SkEndian_SwapBE64(n) SkEndianSwap64(n) #define SkEndian_SwapLE16(n) static_cast<uint16_t>(n) #define SkEndian_SwapLE32(n) static_cast<uint32_t>(n) #define SkEndian_SwapLE64(n) static_cast<uint64_t>(n)
// When a bytestream is embedded in a 32-bit word, how far we need to // shift the word to extract each byte from the low 8 bits by anding with 0xff. #ifdef SK_CPU_LENDIAN #define SkEndian_Byte0Shift 0 #define SkEndian_Byte1Shift 8 #define SkEndian_Byte2Shift 16 #define SkEndian_Byte3Shift 24 #else// SK_CPU_BENDIAN #define SkEndian_Byte0Shift 24 #define SkEndian_Byte1Shift 16 #define SkEndian_Byte2Shift 8 #define SkEndian_Byte3Shift 0 #endif
#ifdefined(SK_UINT8_BITFIELD_LENDIAN) && defined(SK_UINT8_BITFIELD_BENDIAN) #error"can't have both bitfield LENDIAN and BENDIAN defined" #endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.