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

Side by Side Diff: tests/SwizzlerTest.cpp

Issue 1564233002: test+bench new swizzle SkOpts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nah, that is dumb Created 4 years, 11 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
« no previous file with comments | « bench/SwizzleBench.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 "SkSwizzler.h" 8 #include "SkSwizzler.h"
9 #include "Test.h" 9 #include "Test.h"
10 #include "SkOpts.h"
10 11
11 // These are the values that we will look for to indicate that the fill was succ essful 12 // These are the values that we will look for to indicate that the fill was succ essful
12 static const uint8_t kFillIndex = 0x11; 13 static const uint8_t kFillIndex = 0x11;
13 static const uint8_t kFillGray = 0x22; 14 static const uint8_t kFillGray = 0x22;
14 static const uint16_t kFill565 = 0x3344; 15 static const uint16_t kFill565 = 0x3344;
15 static const uint32_t kFillColor = 0x55667788; 16 static const uint32_t kFillColor = 0x55667788;
16 17
17 static void check_fill(skiatest::Reporter* r, 18 static void check_fill(skiatest::Reporter* r,
18 const SkImageInfo& imageInfo, 19 const SkImageInfo& imageInfo,
19 uint32_t startRow, 20 uint32_t startRow,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 kFillGray); 118 kFillGray);
118 check_fill(r, color565Info, startRow, endRow, color5 65RowBytes, offset, 119 check_fill(r, color565Info, startRow, endRow, color5 65RowBytes, offset,
119 kFill565); 120 kFill565);
120 } 121 }
121 } 122 }
122 } 123 }
123 } 124 }
124 } 125 }
125 } 126 }
126 } 127 }
128
129 DEF_TEST(SwizzleOpts, r) {
130 uint32_t dst, src;
131
132 // forall c, c*255 == c, c*0 == 0
133 for (int c = 0; c <= 255; c++) {
134 src = (255<<24) | c;
135 SkOpts::premul_xxxa(&dst, &src, 1);
136 REPORTER_ASSERT(r, dst == src);
137 SkOpts::premul_swaprb_xxxa(&dst, &src, 1);
138 REPORTER_ASSERT(r, dst == (uint32_t)((255<<24) | (c<<16)));
139
140 src = (0<<24) | c;
141 SkOpts::premul_xxxa(&dst, &src, 1);
142 REPORTER_ASSERT(r, dst == 0);
143 SkOpts::premul_swaprb_xxxa(&dst, &src, 1);
144 REPORTER_ASSERT(r, dst == 0);
145 }
146
147 // check a totally arbitrary color
148 src = 0xFACEB004;
149 SkOpts::premul_xxxa(&dst, &src, 1);
150 REPORTER_ASSERT(r, dst == 0xFACAAD04);
151
152 // swap red and blue
153 SkOpts::swaprb_xxxa(&dst, &src, 1);
154 REPORTER_ASSERT(r, dst == 0xFA04B0CE);
155
156 // all together now
157 SkOpts::premul_swaprb_xxxa(&dst, &src, 1);
158 REPORTER_ASSERT(r, dst == 0xFA04ADCA);
159 }
OLDNEW
« no previous file with comments | « bench/SwizzleBench.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698