cc1229c9d5
This reverts commit 33e00db73d
.
BUG=skia:
TBR=
NOTREECHECKS=True
FAILED: /b/build/goma/gomacc ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/components/user_manager/user_manager_test_support.fake_user_manager.o.d -DV8_DEPRECATION_WARNINGS -DCLD_VERSION=2 -D_FILE_OFFSET_BITS=64 -DCHROMIUM_BUILD -DCR_CLANG_REVISION=242792-1 -DCOMPONENT_BUILD -DUI_COMPOSITOR_IMAGE_TRANSPORT -DUSE_AURA=1 -DUSE_ASH=1 -DUSE_PANGO=1 -DUSE_CAIRO=1 -DUSE_DEFAULT_RENDER_THEME=1 -DUSE_LIBJPEG_TURBO=1 -DUSE_X11=1 -DIMAGE_LOADER_EXTENSION=1 -DENABLE_WEBRTC=1 -DENABLE_MEDIA_ROUTER=1 -DUSE_PROPRIETARY_CODECS -DENABLE_PEPPER_CDMS -DENABLE_CONFIGURATION_POLICY -DENABLE_NOTIFICATIONS -DENABLE_HIDPI=1 -DENABLE_TOPCHROME_MD=1 -DUSE_UDEV -DDONT_EMBED_BUILD_METADATA -DDCHECK_ALWAYS_ON=1 -DFIELDTRIAL_TESTING_ENABLED -DENABLE_TASK_MANAGER=1 -DENABLE_EXTENSIONS=1 -DENABLE_PLUGINS=1 -DENABLE_SESSION_SERVICE=1 -DENABLE_THEMES=1 -DENABLE_AUTOFILL_DIALOG=1 -DENABLE_BACKGROUND=1 -DENABLE_GOOGLE_NOW=1 -DENABLE_PRINTING=1 -DENABLE_PRINT_PREVIEW=1 -DENABLE_SPELLCHECK=1 -DENABLE_CAPTIVE_PORTAL_DETECTION=1 -DENABLE_APP_LIST=1 -DENABLE_SUPERVISED_USERS=1 -DENABLE_MDNS=1 -DENABLE_SERVICE_DISCOVERY=1 -DV8_USE_EXTERNAL_STARTUP_DATA -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DSAFE_BROWSING_SERVICE -DGTEST_HAS_POSIX_RE=0 -DGTEST_LANG_CXX11=0 -DUNIT_TEST -DGTEST_HAS_RTTI=0 -DUSE_LIBPCI=1 -DUSE_OPENSSL=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DOS_CHROMEOS=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DWTF_USE_DYNAMIC_ANNOTATIONS=1 -D_DEBUG -D_GLIBCXX_DEBUG=1 -Igen -I../.. -I../../skia/config -I../../testing/gmock/include -I../../testing/gtest/include -Werror -pthread -fno-strict-aliasing -Wall -Wno-unused-parameter -Wno-missing-field-initializers -fvisibility=hidden -pipe -fPIC -Wno-reserved-user-defined-literal -Xclang -load -Xclang /b/build/slave/linux_chromeos/build/src/third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.so -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang check-templates -fcolor-diagnostics -B/b/build/slave/linux_chromeos/build/src/third_party/binutils/Linux_x64/Release/bin -Wheader-hygiene -Wno-char-subscripts -Wno-unneeded-internal-declaration -Wno-covered-switch-default -Wstring-conversion -Wno-c++11-narrowing -Wno-deprecated-register -Wno-inconsistent-missing-override -Wno-shift-negative-value -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -m64 -march=x86-64 -O0 -g -funwind-tables -gsplit-dwarf -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -g0 -fno-exceptions -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden -Wsign-compare -std=gnu++11 -c ../../components/user_manager/fake_user_manager.cc -o obj/components/user_manager/user_manager_test_support.fake_user_manager.o
In file included from ../../components/user_manager/fake_user_manager.cc:5:
In file included from ../../components/user_manager/fake_user_manager.h:12:
In file included from ../../components/user_manager/user.h:14:
In file included from ../../components/user_manager/user_image/user_image.h:12:
In file included from ../../ui/gfx/image/image_skia.h:15:
In file included from ../../ui/gfx/image/image_skia_rep.h:8:
In file included from ../../third_party/skia/include/core/SkBitmap.h:11:
In file included from ../../third_party/skia/include/core/SkColor.h:11:
In file included from ../../third_party/skia/include/core/SkScalar.h:12:
../../third_party/skia/include/core/../private/SkFloatingPoint.h:13:10: fatal error: 'SkTypes.h' file not found
#include "SkTypes.h"
ninja -w dupbuild=err -C /b/build/slave/linux_chromeos/build/src/out/Debug accessibility_unittests accessibility_unittests_run app_list_unittests app_list_unittests_run app_shell_unittests app_shell_unittests_run ash_unittests ash_unittests_run aura_builder aura_unittests aura_unittests_run base_unittests base_unittests_run browser_tests browser_tests_run cacheinvalidation_unittests cacheinvalidation_unittests_run chromeos_unittests chromeos_unittests_run components_unittests components_unittests_run compositor_unittests compositor_unittests_run content_browsertests content_browsertests_run content_unittests content_unittests_run crypto_unittests crypto_unittests_run dbus_unittests device_unittests device_unittests_run display_unittests display_unittests_run events_unittests events_unittests_run extensions_browsertests extensions_browsertests_run extensions_unittests extensions_unittests_run gcm_unit_tests gcm_unit_tests_run gfx_unittests gfx_unittests_run google_apis_unittests google_apis_unittests_run gpu_unittests gpu_unittests_run interactive_ui_tests interactive_ui_tests_run ipc_tests ipc_tests_run jingle_unittests jingle_unittests_run media_unittests media_unittests_run message_center_unittests message_center_unittests_run midi_unittests midi_unittests_run nacl_helper_nonsfi_unittests nacl_loader_unittests nacl_loader_unittests_run net_unittests net_unittests_run ppapi_unittests printing_unittests printing_unittests_run remoting_unittests remoting_unittests_run sandbox_linux_unittests sandbox_linux_unittests_run skia_unittests skia_unittests_run sql_unittests sql_unittests_run sync_unit_tests sync_unit_tests_run ui_base_unittests ui_base_unittests_run ui_chromeos_unittests ui_touch_selection_unittests ui_touch_selection_unittests_run unit_tests unit_tests_run url_unittests url_unittests_run views_unittests wm_unittests wm_unittests_run -j50
ninja: Entering directory `/b/build/slave/linux_chromeos/build/src/out/Debug'
Review URL: https://codereview.chromium.org/1288863002
171 lines
6.0 KiB
C++
171 lines
6.0 KiB
C++
|
|
/*
|
|
* Copyright 2006 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 SkFloatingPoint_DEFINED
|
|
#define SkFloatingPoint_DEFINED
|
|
|
|
#include "SkTypes.h"
|
|
|
|
#include <math.h>
|
|
#include <float.h>
|
|
|
|
// For _POSIX_VERSION
|
|
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
#include "SkFloatBits.h"
|
|
|
|
// C++98 cmath std::pow seems to be the earliest portable way to get float pow.
|
|
// However, on Linux including cmath undefines isfinite.
|
|
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14608
|
|
static inline float sk_float_pow(float base, float exp) {
|
|
return powf(base, exp);
|
|
}
|
|
|
|
static inline float sk_float_copysign(float x, float y) {
|
|
// c++11 contains a 'float copysign(float, float)' function in <cmath>.
|
|
// clang-cl reports __cplusplus for clang, not the __cplusplus vc++ version _MSC_VER would report.
|
|
#if (defined(_MSC_VER) && defined(__clang__))
|
|
# define SK_BUILD_WITH_CLANG_CL 1
|
|
#else
|
|
# define SK_BUILD_WITH_CLANG_CL 0
|
|
#endif
|
|
#if (!SK_BUILD_WITH_CLANG_CL && __cplusplus >= 201103L) || (_MSC_VER >= 1800)
|
|
return copysignf(x, y);
|
|
|
|
// Posix has demanded 'float copysignf(float, float)' (from C99) since Issue 6.
|
|
#elif defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L
|
|
return copysignf(x, y);
|
|
|
|
// Visual studio prior to 13 only has 'double _copysign(double, double)'.
|
|
#elif defined(_MSC_VER)
|
|
return (float)_copysign(x, y);
|
|
|
|
// Otherwise convert to bits and extract sign.
|
|
#else
|
|
int32_t xbits = SkFloat2Bits(x);
|
|
int32_t ybits = SkFloat2Bits(y);
|
|
return SkBits2Float((xbits & 0x7FFFFFFF) | (ybits & 0x80000000));
|
|
#endif
|
|
}
|
|
|
|
#define sk_float_sqrt(x) sqrtf(x)
|
|
#define sk_float_sin(x) sinf(x)
|
|
#define sk_float_cos(x) cosf(x)
|
|
#define sk_float_tan(x) tanf(x)
|
|
#define sk_float_floor(x) floorf(x)
|
|
#define sk_float_ceil(x) ceilf(x)
|
|
#ifdef SK_BUILD_FOR_MAC
|
|
# define sk_float_acos(x) static_cast<float>(acos(x))
|
|
# define sk_float_asin(x) static_cast<float>(asin(x))
|
|
#else
|
|
# define sk_float_acos(x) acosf(x)
|
|
# define sk_float_asin(x) asinf(x)
|
|
#endif
|
|
#define sk_float_atan2(y,x) atan2f(y,x)
|
|
#define sk_float_abs(x) fabsf(x)
|
|
#define sk_float_mod(x,y) fmodf(x,y)
|
|
#define sk_float_exp(x) expf(x)
|
|
#define sk_float_log(x) logf(x)
|
|
|
|
#define sk_float_round(x) sk_float_floor((x) + 0.5f)
|
|
|
|
// can't find log2f on android, but maybe that just a tool bug?
|
|
#ifdef SK_BUILD_FOR_ANDROID
|
|
static inline float sk_float_log2(float x) {
|
|
const double inv_ln_2 = 1.44269504088896;
|
|
return (float)(log(x) * inv_ln_2);
|
|
}
|
|
#else
|
|
#define sk_float_log2(x) log2f(x)
|
|
#endif
|
|
|
|
#ifdef SK_BUILD_FOR_WIN
|
|
#define sk_float_isfinite(x) _finite(x)
|
|
#define sk_float_isnan(x) _isnan(x)
|
|
static inline int sk_float_isinf(float x) {
|
|
int32_t bits = SkFloat2Bits(x);
|
|
return (bits << 1) == (0xFF << 24);
|
|
}
|
|
#else
|
|
#define sk_float_isfinite(x) isfinite(x)
|
|
#define sk_float_isnan(x) isnan(x)
|
|
#define sk_float_isinf(x) isinf(x)
|
|
#endif
|
|
|
|
#define sk_double_isnan(a) sk_float_isnan(a)
|
|
|
|
#ifdef SK_USE_FLOATBITS
|
|
#define sk_float_floor2int(x) SkFloatToIntFloor(x)
|
|
#define sk_float_round2int(x) SkFloatToIntRound(x)
|
|
#define sk_float_ceil2int(x) SkFloatToIntCeil(x)
|
|
#else
|
|
#define sk_float_floor2int(x) (int)sk_float_floor(x)
|
|
#define sk_float_round2int(x) (int)sk_float_floor((x) + 0.5f)
|
|
#define sk_float_ceil2int(x) (int)sk_float_ceil(x)
|
|
#endif
|
|
|
|
#define sk_double_floor(x) floor(x)
|
|
#define sk_double_round(x) floor((x) + 0.5)
|
|
#define sk_double_ceil(x) ceil(x)
|
|
#define sk_double_floor2int(x) (int)floor(x)
|
|
#define sk_double_round2int(x) (int)floor((x) + 0.5f)
|
|
#define sk_double_ceil2int(x) (int)ceil(x)
|
|
|
|
extern const uint32_t gIEEENotANumber;
|
|
extern const uint32_t gIEEEInfinity;
|
|
extern const uint32_t gIEEENegativeInfinity;
|
|
|
|
#define SK_FloatNaN (*SkTCast<const float*>(&gIEEENotANumber))
|
|
#define SK_FloatInfinity (*SkTCast<const float*>(&gIEEEInfinity))
|
|
#define SK_FloatNegativeInfinity (*SkTCast<const float*>(&gIEEENegativeInfinity))
|
|
|
|
// We forward declare this to break an #include cycle.
|
|
// (SkScalar -> SkFloatingPoint -> SkOpts.h -> SkXfermode -> SkColor -> SkScalar)
|
|
namespace SkOpts { extern float (*rsqrt)(float); }
|
|
|
|
// Fast, approximate inverse square root.
|
|
// Compare to name-brand "1.0f / sk_float_sqrt(x)". Should be around 10x faster on SSE, 2x on NEON.
|
|
static inline float sk_float_rsqrt(const float x) {
|
|
// We want all this inlined, so we'll inline SIMD and just take the hit when we don't know we've got
|
|
// it at compile time. This is going to be too fast to productively hide behind a function pointer.
|
|
//
|
|
// We do one step of Newton's method to refine the estimates in the NEON and null paths. No
|
|
// refinement is faster, but very innacurate. Two steps is more accurate, but slower than 1/sqrt.
|
|
//
|
|
// Optimized constants in the null path courtesy of http://rrrola.wz.cz/inv_sqrt.html
|
|
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE1
|
|
return _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(x)));
|
|
#elif defined(SK_ARM_HAS_NEON)
|
|
// Get initial estimate.
|
|
const float32x2_t xx = vdup_n_f32(x); // Clever readers will note we're doing everything 2x.
|
|
float32x2_t estimate = vrsqrte_f32(xx);
|
|
|
|
// One step of Newton's method to refine.
|
|
const float32x2_t estimate_sq = vmul_f32(estimate, estimate);
|
|
estimate = vmul_f32(estimate, vrsqrts_f32(xx, estimate_sq));
|
|
return vget_lane_f32(estimate, 0); // 1 will work fine too; the answer's in both places.
|
|
#else
|
|
// Perhaps runtime-detected NEON, or a portable fallback.
|
|
return SkOpts::rsqrt(x);
|
|
#endif
|
|
}
|
|
|
|
// This is the number of significant digits we can print in a string such that when we read that
|
|
// string back we get the floating point number we expect. The minimum value C requires is 6, but
|
|
// most compilers support 9
|
|
#ifdef FLT_DECIMAL_DIG
|
|
#define SK_FLT_DECIMAL_DIG FLT_DECIMAL_DIG
|
|
#else
|
|
#define SK_FLT_DECIMAL_DIG 9
|
|
#endif
|
|
|
|
#endif
|