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

Side by Side Diff: tests/Sk4x4fTest.cpp

Issue 1825663002: Sk4x4f (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: port srcover_n_srgb_bw 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
« no previous file with comments | « src/core/SkXfermode4f.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
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "Sk4x4f.h"
9 #include "Test.h"
10
11 DEF_TEST(Sk4x4f, r) {
12 Sk4x4f f;
13
14 Sk4f x{ 0, 1, 2, 3},
15 y{ 4, 5, 6, 7},
16 z{ 8, 9,10,11},
17 w{12,13,14,15};
18 f = Sk4x4f::Transpose(x,y,z,w);
19 REPORTER_ASSERT(r, f.r[0] == 0 && f.r[1] == 4 && f.r[2] == 8 && f.r[3] == 1 2);
20 REPORTER_ASSERT(r, f.g[0] == 1 && f.g[1] == 5 && f.g[2] == 9 && f.g[3] == 1 3);
21 REPORTER_ASSERT(r, f.b[0] == 2 && f.b[1] == 6 && f.b[2] == 10 && f.b[3] == 1 4);
22 REPORTER_ASSERT(r, f.a[0] == 3 && f.a[1] == 7 && f.a[2] == 11 && f.a[3] == 1 5);
23
24 Sk4f s,t,u,v;
25 f.transpose(&s,&t,&u,&v);
26 REPORTER_ASSERT(r, (x == s).allTrue()
27 && (y == t).allTrue()
28 && (z == u).allTrue()
29 && (w == v).allTrue());
30
31
32 float fs[16] = {0,1,2,3, 4,5,6,7, 8,9,10,11, 12,13,14,15};
33 f = Sk4x4f::Transpose(fs);
34 REPORTER_ASSERT(r, f.r[0] == 0 && f.r[1] == 4 && f.r[2] == 8 && f.r[3] == 1 2);
35 REPORTER_ASSERT(r, f.g[0] == 1 && f.g[1] == 5 && f.g[2] == 9 && f.g[3] == 1 3);
36 REPORTER_ASSERT(r, f.b[0] == 2 && f.b[1] == 6 && f.b[2] == 10 && f.b[3] == 1 4);
37 REPORTER_ASSERT(r, f.a[0] == 3 && f.a[1] == 7 && f.a[2] == 11 && f.a[3] == 1 5);
38
39 float fs_back[16];
40 f.transpose(fs_back);
41 REPORTER_ASSERT(r, 0 == memcmp(fs, fs_back, sizeof(fs)));
42
43
44 uint8_t bs[16] = {0,1,2,3, 4,5,6,7, 8,9,10,11, 12,13,14,15};
45 f = Sk4x4f::Transpose(bs);
46 REPORTER_ASSERT(r, f.r[0] == 0 && f.r[1] == 4 && f.r[2] == 8 && f.r[3] == 1 2);
47 REPORTER_ASSERT(r, f.g[0] == 1 && f.g[1] == 5 && f.g[2] == 9 && f.g[3] == 1 3);
48 REPORTER_ASSERT(r, f.b[0] == 2 && f.b[1] == 6 && f.b[2] == 10 && f.b[3] == 1 4);
49 REPORTER_ASSERT(r, f.a[0] == 3 && f.a[1] == 7 && f.a[2] == 11 && f.a[3] == 1 5);
50
51 uint8_t bs_back[16];
52 f.transpose(bs_back);
53 REPORTER_ASSERT(r, 0 == memcmp(bs, bs_back, sizeof(bs)));
54 }
OLDNEW
« no previous file with comments | « src/core/SkXfermode4f.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698