Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkSwizzle.h" | |
| 8 #include "SkSwizzler.h" | 9 #include "SkSwizzler.h" |
| 9 #include "Test.h" | 10 #include "Test.h" |
| 10 #include "SkOpts.h" | 11 #include "SkOpts.h" |
| 11 | 12 |
| 12 // These are the values that we will look for to indicate that the fill was succ essful | 13 // These are the values that we will look for to indicate that the fill was succ essful |
| 13 static const uint8_t kFillIndex = 0x11; | 14 static const uint8_t kFillIndex = 0x11; |
| 14 static const uint8_t kFillGray = 0x22; | 15 static const uint8_t kFillGray = 0x22; |
| 15 static const uint16_t kFill565 = 0x3344; | 16 static const uint16_t kFill565 = 0x3344; |
| 16 static const uint32_t kFillColor = 0x55667788; | 17 static const uint32_t kFillColor = 0x55667788; |
| 17 | 18 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 REPORTER_ASSERT(r, dst == 0xFACAAD04); | 151 REPORTER_ASSERT(r, dst == 0xFACAAD04); |
| 151 | 152 |
| 152 // swap red and blue | 153 // swap red and blue |
| 153 SkOpts::RGBA_to_BGRA(&dst, &src, 1); | 154 SkOpts::RGBA_to_BGRA(&dst, &src, 1); |
| 154 REPORTER_ASSERT(r, dst == 0xFA04B0CE); | 155 REPORTER_ASSERT(r, dst == 0xFA04B0CE); |
| 155 | 156 |
| 156 // all together now | 157 // all together now |
| 157 SkOpts::RGBA_to_bgrA(&dst, &src, 1); | 158 SkOpts::RGBA_to_bgrA(&dst, &src, 1); |
| 158 REPORTER_ASSERT(r, dst == 0xFA04ADCA); | 159 REPORTER_ASSERT(r, dst == 0xFA04ADCA); |
| 159 } | 160 } |
| 161 | |
| 162 DEF_TEST(PublicSwizzleOpts, r) { | |
| 163 uint32_t dst, src; | |
| 164 | |
| 165 // forall c, c*255 == c, c*0 == 0 | |
| 166 for (int c = 0; c <= 255; c++) { | |
|
mtklein
2016/03/23 17:35:13
We making these public too?
tomhudson
2016/03/23 17:38:48
My bad.
Done.
| |
| 167 src = (255<<24) | c; | |
| 168 SkOpts::RGBA_to_rgbA(&dst, &src, 1); | |
| 169 REPORTER_ASSERT(r, dst == src); | |
| 170 SkOpts::RGBA_to_bgrA(&dst, &src, 1); | |
| 171 REPORTER_ASSERT(r, dst == (uint32_t)((255<<24) | (c<<16))); | |
| 172 | |
| 173 src = (0<<24) | c; | |
| 174 SkOpts::RGBA_to_rgbA(&dst, &src, 1); | |
| 175 REPORTER_ASSERT(r, dst == 0); | |
| 176 SkOpts::RGBA_to_bgrA(&dst, &src, 1); | |
| 177 REPORTER_ASSERT(r, dst == 0); | |
| 178 } | |
| 179 | |
| 180 // check a totally arbitrary color | |
| 181 src = 0xFACEB004; | |
| 182 SkSwapRB(&dst, &src, 1); | |
| 183 REPORTER_ASSERT(r, dst == 0xFA04B0CE); | |
| 184 } | |
| OLD | NEW |