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

Side by Side Diff: tests/ColorPrivTest.cpp

Issue 98343006: Fix 32/64 bit warnings on g++-4.2. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/core/SkColorPriv.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "Test.h" 1 #include "Test.h"
2 #include "TestClassDef.h" 2 #include "TestClassDef.h"
3 3
4 #include "SkColorPriv.h" 4 #include "SkColorPriv.h"
5 5
6 #define ASSERT(expr) REPORTER_ASSERT(r, expr) 6 #define ASSERT(expr) REPORTER_ASSERT(r, expr)
7 7
8 DEF_TEST(Splay, r) { 8 DEF_TEST(Splay, r) {
9 const SkPMColor color = 0xA1B2C3D4; 9 const SkPMColor color = 0xA1B2C3D4;
10 10
11 uint32_t ag, rb; 11 uint32_t ag, rb;
12 SkSplay(color, &ag, &rb); 12 SkSplay(color, &ag, &rb);
13 ASSERT(ag == 0x00A100C3); 13 ASSERT(ag == 0x00A100C3);
14 ASSERT(rb == 0x00B200D4); 14 ASSERT(rb == 0x00B200D4);
15 ASSERT(SkUnsplay(ag << 8, rb << 8) == color); 15 ASSERT(SkUnsplay(ag << 8, rb << 8) == color);
16 16
17 const uint64_t agrb = SkSplay(color); 17 const uint64_t agrb = SkSplay(color);
18 ASSERT(agrb == 0x00A100C300B200D4); 18 ASSERT(agrb == 0x00A100C300B200D4ULL);
19 ASSERT(SkUnsplay(agrb<<8) == color); 19 ASSERT(SkUnsplay(agrb<<8) == color);
20 } 20 }
21 21
22 DEF_TEST(FourByteInterp, r) { 22 DEF_TEST(FourByteInterp, r) {
23 const SkPMColor src = 0xAB998877, dst = 0x66334455; 23 const SkPMColor src = 0xAB998877, dst = 0x66334455;
24 for (unsigned scale = 0; scale <= 256; scale++) { 24 for (unsigned scale = 0; scale <= 256; scale++) {
25 ASSERT(SkFourByteInterp256(src, dst, scale) == SkFastFourByteInterp256(s rc, dst, scale)); 25 ASSERT(SkFourByteInterp256(src, dst, scale) == SkFastFourByteInterp256(s rc, dst, scale));
26 } 26 }
27 27
28 for (unsigned scale = 0; scale < 256; scale++) { 28 for (unsigned scale = 0; scale < 256; scale++) {
29 // SkFourByteInterp and SkFastFourByteInterp convert from [0, 255] to [0 , 256] differently. 29 // SkFourByteInterp and SkFastFourByteInterp convert from [0, 255] to [0 , 256] differently.
30 // In particular, slow may end up a little too high (weirdly, fast is mo re accurate). 30 // In particular, slow may end up a little too high (weirdly, fast is mo re accurate).
31 const SkPMColor slow = SkFourByteInterp(src, dst, scale); 31 const SkPMColor slow = SkFourByteInterp(src, dst, scale);
32 const SkPMColor fast = SkFastFourByteInterp(src, dst, scale); 32 const SkPMColor fast = SkFastFourByteInterp(src, dst, scale);
33 33
34 const int deltaA = SkGetPackedA32(slow) - SkGetPackedA32(fast); 34 const int deltaA = SkGetPackedA32(slow) - SkGetPackedA32(fast);
35 const int deltaR = SkGetPackedR32(slow) - SkGetPackedR32(fast); 35 const int deltaR = SkGetPackedR32(slow) - SkGetPackedR32(fast);
36 const int deltaG = SkGetPackedG32(slow) - SkGetPackedG32(fast); 36 const int deltaG = SkGetPackedG32(slow) - SkGetPackedG32(fast);
37 const int deltaB = SkGetPackedB32(slow) - SkGetPackedB32(fast); 37 const int deltaB = SkGetPackedB32(slow) - SkGetPackedB32(fast);
38 38
39 ASSERT(deltaA == 0 || deltaA == 1); 39 ASSERT(deltaA == 0 || deltaA == 1);
40 ASSERT(deltaR == 0 || deltaR == 1); 40 ASSERT(deltaR == 0 || deltaR == 1);
41 ASSERT(deltaG == 0 || deltaG == 1); 41 ASSERT(deltaG == 0 || deltaG == 1);
42 ASSERT(deltaB == 0 || deltaB == 1); 42 ASSERT(deltaB == 0 || deltaB == 1);
43 } 43 }
44 } 44 }
OLDNEW
« no previous file with comments | « include/core/SkColorPriv.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698