aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkHalf.h
diff options
context:
space:
mode:
authorGravatar jvanverth <jvanverth@google.com>2014-11-26 13:15:59 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-26 13:15:59 -0800
commit936799204b34e7a2f20ac6c0868058799ceb851e (patch)
treec1dd34971c393de4bf7247aed276a91b123400fd /src/core/SkHalf.h
parent9881d63c57002ffbdf2adf623965ece280279989 (diff)
Add float-to-half (binary16) conversion functions.
Based on code by Fabian Giesen at https://fgiesen.wordpress.com/2012/03/28/half-to-float-done-quic/. These will be needed for creating binary16 textures from floating point data. BUG=skia:3103 Review URL: https://codereview.chromium.org/760753003
Diffstat (limited to 'src/core/SkHalf.h')
-rw-r--r--src/core/SkHalf.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/core/SkHalf.h b/src/core/SkHalf.h
new file mode 100644
index 0000000000..3fd07793e9
--- /dev/null
+++ b/src/core/SkHalf.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkHalf_DEFINED
+#define SkHalf_DEFINED
+
+#include "SkTypes.h"
+
+// 16-bit floating point value
+// format is 1 bit sign, 5 bits exponent, 10 bits mantissa
+// only used for storage
+typedef uint16_t SkHalf;
+
+// convert between half and single precision floating point
+float SkHalfToFloat(SkHalf h);
+SkHalf SkFloatToHalf(float f);
+
+#endif