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

Side by Side Diff: tests/Float16Test.cpp

Issue 2152583002: Remove bulk float <-> half routines. These are dead code. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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/SkOpts.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 2016 Google Inc. 2 * Copyright 2016 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 "Test.h" 8 #include "Test.h"
9 #include "SkAutoPixmapStorage.h" 9 #include "SkAutoPixmapStorage.h"
10 #include "SkColor.h" 10 #include "SkColor.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 SkPM4f origpm4 = c4.premul(); 49 SkPM4f origpm4 = c4.premul();
50 for (int y = 0; y < pm.height(); ++y) { 50 for (int y = 0; y < pm.height(); ++y) {
51 for (int x = 0; x < pm.width(); ++x) { 51 for (int x = 0; x < pm.width(); ++x) {
52 SkPM4f pm4 = SkPM4f::FromF16(pm.addrF16(x, y)); 52 SkPM4f pm4 = SkPM4f::FromF16(pm.addrF16(x, y));
53 REPORTER_ASSERT(reporter, eq_within_half_float(origpm4, pm4)); 53 REPORTER_ASSERT(reporter, eq_within_half_float(origpm4, pm4));
54 } 54 }
55 } 55 }
56 } 56 }
57 57
58 DEF_TEST(float_to_half, reporter) {
59 const float fs[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7 .0 };
60 const uint16_t hs[] = { 0x3c00, 0x4000, 0x4200, 0x4400, 0x4500, 0x4600, 0x47 00 };
61
62 uint16_t hscratch[7];
63 SkOpts::float_to_half(hscratch, fs, 7);
64 REPORTER_ASSERT(reporter, 0 == memcmp(hscratch, hs, sizeof(hs)));
65
66 float fscratch[7];
67 SkOpts::half_to_float(fscratch, hs, 7);
68 REPORTER_ASSERT(reporter, 0 == memcmp(fscratch, fs, sizeof(fs)));
69 }
70
71 static uint32_t u(float f) { 58 static uint32_t u(float f) {
72 uint32_t x; 59 uint32_t x;
73 memcpy(&x, &f, 4); 60 memcpy(&x, &f, 4);
74 return x; 61 return x;
75 } 62 }
76 63
77 DEF_TEST(HalfToFloat_01, r) { 64 DEF_TEST(HalfToFloat_01, r) {
78 for (uint16_t h = 0; h < 0x8000; h++) { 65 for (uint16_t h = 0; h < 0x8000; h++) {
79 float f = SkHalfToFloat(h); 66 float f = SkHalfToFloat(h);
80 if (f >= 0 && f <= 1) { 67 if (f >= 0 && f <= 1) {
(...skipping 26 matching lines...) Expand all
107 bool ok = (h1 == h2 || h1 == h2-1); 94 bool ok = (h1 == h2 || h1 == h2-1);
108 REPORTER_ASSERT(r, ok); 95 REPORTER_ASSERT(r, ok);
109 if (!ok) { 96 if (!ok) {
110 SkDebugf("%08x (%d) -> %04x (%d), want %04x (%d)\n", 97 SkDebugf("%08x (%d) -> %04x (%d), want %04x (%d)\n",
111 bits, bits>>23, h1, h1>>10, h2, h2>>10); 98 bits, bits>>23, h1, h1>>10, h2, h2>>10);
112 break; 99 break;
113 } 100 }
114 } 101 }
115 } 102 }
116 } 103 }
OLDNEW
« no previous file with comments | « src/core/SkOpts.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698