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

Unified Diff: include/core/SkFloatBits.h

Issue 1289483002: move some public headers into private (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkEndian.h ('k') | include/core/SkFloatingPoint.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkFloatBits.h
diff --git a/include/core/SkFloatBits.h b/include/core/SkFloatBits.h
deleted file mode 100644
index 3ddb9ef564cfaaf2dd07e9f04bd1ce02b4b39d35..0000000000000000000000000000000000000000
--- a/include/core/SkFloatBits.h
+++ /dev/null
@@ -1,132 +0,0 @@
-
-/*
- * Copyright 2008 The Android Open Source Project
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-#ifndef SkFloatBits_DEFINED
-#define SkFloatBits_DEFINED
-
-#include "SkTypes.h"
-
-/** Convert a sign-bit int (i.e. float interpreted as int) into a 2s compliement
- int. This also converts -0 (0x80000000) to 0. Doing this to a float allows
- it to be compared using normal C operators (<, <=, etc.)
-*/
-static inline int32_t SkSignBitTo2sCompliment(int32_t x) {
- if (x < 0) {
- x &= 0x7FFFFFFF;
- x = -x;
- }
- return x;
-}
-
-/** Convert a 2s compliment int to a sign-bit (i.e. int interpreted as float).
- This undoes the result of SkSignBitTo2sCompliment().
- */
-static inline int32_t Sk2sComplimentToSignBit(int32_t x) {
- int sign = x >> 31;
- // make x positive
- x = (x ^ sign) - sign;
- // set the sign bit as needed
- x |= sign << 31;
- return x;
-}
-
-/** Given the bit representation of a float, return its value cast to an int.
- If the value is out of range, or NaN, return return +/- SK_MaxS32
-*/
-int32_t SkFloatBits_toIntCast(int32_t floatBits);
-
-/** Given the bit representation of a float, return its floor as an int.
- If the value is out of range, or NaN, return return +/- SK_MaxS32
- */
-SK_API int32_t SkFloatBits_toIntFloor(int32_t floatBits);
-
-/** Given the bit representation of a float, return it rounded to an int.
- If the value is out of range, or NaN, return return +/- SK_MaxS32
- */
-SK_API int32_t SkFloatBits_toIntRound(int32_t floatBits);
-
-/** Given the bit representation of a float, return its ceiling as an int.
- If the value is out of range, or NaN, return return +/- SK_MaxS32
- */
-SK_API int32_t SkFloatBits_toIntCeil(int32_t floatBits);
-
-
-union SkFloatIntUnion {
- float fFloat;
- int32_t fSignBitInt;
-};
-
-// Helper to see a float as its bit pattern (w/o aliasing warnings)
-static inline int32_t SkFloat2Bits(float x) {
- SkFloatIntUnion data;
- data.fFloat = x;
- return data.fSignBitInt;
-}
-
-// Helper to see a bit pattern as a float (w/o aliasing warnings)
-static inline float SkBits2Float(int32_t floatAsBits) {
- SkFloatIntUnion data;
- data.fSignBitInt = floatAsBits;
- return data.fFloat;
-}
-
-/** Return the float as a 2s compliment int. Just to be used to compare floats
- to each other or against positive float-bit-constants (like 0). This does
- not return the int equivalent of the float, just something cheaper for
- compares-only.
- */
-static inline int32_t SkFloatAs2sCompliment(float x) {
- return SkSignBitTo2sCompliment(SkFloat2Bits(x));
-}
-
-/** Return the 2s compliment int as a float. This undos the result of
- SkFloatAs2sCompliment
- */
-static inline float Sk2sComplimentAsFloat(int32_t x) {
- return SkBits2Float(Sk2sComplimentToSignBit(x));
-}
-
-/** Return x cast to a float (i.e. (float)x)
-*/
-float SkIntToFloatCast(int x);
-
-/** Return the float cast to an int.
- If the value is out of range, or NaN, return +/- SK_MaxS32
-*/
-static inline int32_t SkFloatToIntCast(float x) {
- return SkFloatBits_toIntCast(SkFloat2Bits(x));
-}
-
-/** Return the floor of the float as an int.
- If the value is out of range, or NaN, return +/- SK_MaxS32
-*/
-static inline int32_t SkFloatToIntFloor(float x) {
- return SkFloatBits_toIntFloor(SkFloat2Bits(x));
-}
-
-/** Return the float rounded to an int.
- If the value is out of range, or NaN, return +/- SK_MaxS32
-*/
-static inline int32_t SkFloatToIntRound(float x) {
- return SkFloatBits_toIntRound(SkFloat2Bits(x));
-}
-
-/** Return the ceiling of the float as an int.
- If the value is out of range, or NaN, return +/- SK_MaxS32
-*/
-static inline int32_t SkFloatToIntCeil(float x) {
- return SkFloatBits_toIntCeil(SkFloat2Bits(x));
-}
-
-// Scalar wrappers for float-bit routines
-
-#define SkScalarAs2sCompliment(x) SkFloatAs2sCompliment(x)
-#define Sk2sComplimentAsScalar(x) Sk2sComplimentAsFloat(x)
-
-#endif
« no previous file with comments | « include/core/SkEndian.h ('k') | include/core/SkFloatingPoint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698