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

Side by Side Diff: tests/SwizzlerTest.cpp

Issue 1822363002: Publicly expose one accelerated swizzle. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add test, fix bugs from review Created 4 years, 9 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 unified diff | Download patch
« src/core/SkSwizzle.cpp ('K') | « src/core/SkSwizzle.cpp ('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 /* 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
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 }
OLDNEW
« src/core/SkSwizzle.cpp ('K') | « src/core/SkSwizzle.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698