Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Unified Diff: include/core/SkEndian.h

Issue 247753003: fix size_t/int warnings (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | include/core/SkReader32.h » ('j') | include/core/SkReader32.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkEndian.h
diff --git a/include/core/SkEndian.h b/include/core/SkEndian.h
index 6eba297548ee0a88d63b2e11e7c0fca4f95d1786..ad0e2a0ca0147cdf4367875baf6e433022bbc83e 100644
--- a/include/core/SkEndian.h
+++ b/include/core/SkEndian.h
@@ -29,7 +29,7 @@
/** Swap the two bytes in the low 16bits of the parameters.
e.g. 0x1234 -> 0x3412
*/
-static inline uint16_t SkEndianSwap16(U16CPU value) {
+static inline uint16_t SkEndianSwap16(size_t value) {
mtklein 2014/04/23 13:36:18 If you feel like being a little fancier, I think
reed1 2014/04/23 14:04:22 don't want to take any non-integral values (e.g. p
SkASSERT(value == (uint16_t)value);
return static_cast<uint16_t>((value >> 8) | (value << 8));
}
@@ -52,11 +52,12 @@ static inline void SkEndianSwap16s(uint16_t array[], int count) {
/** Reverse all 4 bytes in a 32bit value.
e.g. 0x12345678 -> 0x78563412
*/
-static inline uint32_t SkEndianSwap32(uint32_t value) {
- return ((value & 0xFF) << 24) |
- ((value & 0xFF00) << 8) |
- ((value & 0xFF0000) >> 8) |
- (value >> 24);
+static inline uint32_t SkEndianSwap32(size_t value) {
mtklein 2014/04/23 13:36:18 This guy seems like he really wants to be u32 -> u
reed1 2014/04/23 14:04:22 well, so does swap16, but the caller may give us l
+ uint32_t v = SkToU32(value);
+ return ((v & 0xFF) << 24) |
+ ((v & 0xFF00) << 8) |
+ ((v & 0xFF0000) >> 8) |
+ (v >> 24);
}
template<uint32_t N> struct SkTEndianSwap32 {
static const uint32_t value = ((N & 0xFF) << 24) |
« no previous file with comments | « no previous file | include/core/SkReader32.h » ('j') | include/core/SkReader32.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698