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
270 lines
9.2 KiB
C
270 lines
9.2 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 SkScalar_DEFINED
|
|
#define SkScalar_DEFINED
|
|
|
|
#include "SkFixed.h"
|
|
#include "SkFloatingPoint.h"
|
|
|
|
// TODO: move this sort of check into SkPostConfig.h
|
|
#define SK_SCALAR_IS_DOUBLE 0
|
|
#undef SK_SCALAR_IS_FLOAT
|
|
#define SK_SCALAR_IS_FLOAT 1
|
|
|
|
|
|
#if SK_SCALAR_IS_FLOAT
|
|
|
|
typedef float SkScalar;
|
|
|
|
#define SK_Scalar1 1.0f
|
|
#define SK_ScalarHalf 0.5f
|
|
#define SK_ScalarSqrt2 1.41421356f
|
|
#define SK_ScalarPI 3.14159265f
|
|
#define SK_ScalarTanPIOver8 0.414213562f
|
|
#define SK_ScalarRoot2Over2 0.707106781f
|
|
#define SK_ScalarMax 3.402823466e+38f
|
|
#define SK_ScalarInfinity SK_FloatInfinity
|
|
#define SK_ScalarNegativeInfinity SK_FloatNegativeInfinity
|
|
#define SK_ScalarNaN SK_FloatNaN
|
|
|
|
#define SkFixedToScalar(x) SkFixedToFloat(x)
|
|
#define SkScalarToFixed(x) SkFloatToFixed(x)
|
|
|
|
#define SkScalarFloorToScalar(x) sk_float_floor(x)
|
|
#define SkScalarCeilToScalar(x) sk_float_ceil(x)
|
|
#define SkScalarRoundToScalar(x) sk_float_floor((x) + 0.5f)
|
|
|
|
#define SkScalarFloorToInt(x) sk_float_floor2int(x)
|
|
#define SkScalarCeilToInt(x) sk_float_ceil2int(x)
|
|
#define SkScalarRoundToInt(x) sk_float_round2int(x)
|
|
|
|
#define SkScalarAbs(x) sk_float_abs(x)
|
|
#define SkScalarCopySign(x, y) sk_float_copysign(x, y)
|
|
#define SkScalarMod(x, y) sk_float_mod(x,y)
|
|
#define SkScalarFraction(x) sk_float_mod(x, 1.0f)
|
|
#define SkScalarSqrt(x) sk_float_sqrt(x)
|
|
#define SkScalarPow(b, e) sk_float_pow(b, e)
|
|
|
|
#define SkScalarSin(radians) (float)sk_float_sin(radians)
|
|
#define SkScalarCos(radians) (float)sk_float_cos(radians)
|
|
#define SkScalarTan(radians) (float)sk_float_tan(radians)
|
|
#define SkScalarASin(val) (float)sk_float_asin(val)
|
|
#define SkScalarACos(val) (float)sk_float_acos(val)
|
|
#define SkScalarATan2(y, x) (float)sk_float_atan2(y,x)
|
|
#define SkScalarExp(x) (float)sk_float_exp(x)
|
|
#define SkScalarLog(x) (float)sk_float_log(x)
|
|
#define SkScalarLog2(x) (float)sk_float_log2(x)
|
|
|
|
#else // SK_SCALAR_IS_DOUBLE
|
|
|
|
typedef double SkScalar;
|
|
|
|
#define SK_Scalar1 1.0
|
|
#define SK_ScalarHalf 0.5
|
|
#define SK_ScalarSqrt2 1.414213562373095
|
|
#define SK_ScalarPI 3.141592653589793
|
|
#define SK_ScalarTanPIOver8 0.4142135623731
|
|
#define SK_ScalarRoot2Over2 0.70710678118655
|
|
#define SK_ScalarMax 1.7976931348623157+308
|
|
#define SK_ScalarInfinity SK_DoubleInfinity
|
|
#define SK_ScalarNegativeInfinity SK_DoubleNegativeInfinity
|
|
#define SK_ScalarNaN SK_DoubleNaN
|
|
|
|
#define SkFixedToScalar(x) SkFixedToDouble(x)
|
|
#define SkScalarToFixed(x) SkDoubleToFixed(x)
|
|
|
|
#define SkScalarFloorToScalar(x) floor(x)
|
|
#define SkScalarCeilToScalar(x) ceil(x)
|
|
#define SkScalarRoundToScalar(x) floor((x) + 0.5)
|
|
|
|
#define SkScalarFloorToInt(x) (int)floor(x)
|
|
#define SkScalarCeilToInt(x) (int)ceil(x)
|
|
#define SkScalarRoundToInt(x) (int)floor((x) + 0.5)
|
|
|
|
#define SkScalarAbs(x) abs(x)
|
|
#define SkScalarCopySign(x, y) copysign(x, y)
|
|
#define SkScalarMod(x, y) fmod(x,y)
|
|
#define SkScalarFraction(x) fmod(x, 1.0)
|
|
#define SkScalarSqrt(x) sqrt(x)
|
|
#define SkScalarPow(b, e) pow(b, e)
|
|
|
|
#define SkScalarSin(radians) sin(radians)
|
|
#define SkScalarCos(radians) cos(radians)
|
|
#define SkScalarTan(radians) tan(radians)
|
|
#define SkScalarASin(val) asin(val)
|
|
#define SkScalarACos(val) acos(val)
|
|
#define SkScalarATan2(y, x) atan2(y,x)
|
|
#define SkScalarExp(x) exp(x)
|
|
#define SkScalarLog(x) log(x)
|
|
#define SkScalarLog2(x) log2(x)
|
|
|
|
#endif
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#define SkIntToScalar(x) static_cast<SkScalar>(x)
|
|
#define SkScalarTruncToInt(x) static_cast<int>(x)
|
|
|
|
#define SkScalarToFloat(x) static_cast<float>(x)
|
|
#define SkFloatToScalar(x) static_cast<SkScalar>(x)
|
|
#define SkScalarToDouble(x) static_cast<double>(x)
|
|
#define SkDoubleToScalar(x) static_cast<SkScalar>(x)
|
|
|
|
#define SK_ScalarMin (-SK_ScalarMax)
|
|
|
|
static inline bool SkScalarIsNaN(SkScalar x) { return x != x; }
|
|
|
|
/** Returns true if x is not NaN and not infinite
|
|
*/
|
|
static inline bool SkScalarIsFinite(SkScalar x) {
|
|
// We rely on the following behavior of infinities and nans
|
|
// 0 * finite --> 0
|
|
// 0 * infinity --> NaN
|
|
// 0 * NaN --> NaN
|
|
SkScalar prod = x * 0;
|
|
// At this point, prod will either be NaN or 0
|
|
return !SkScalarIsNaN(prod);
|
|
}
|
|
|
|
static inline bool SkScalarsAreFinite(SkScalar a, SkScalar b) {
|
|
SkScalar prod = 0;
|
|
prod *= a;
|
|
prod *= b;
|
|
// At this point, prod will either be NaN or 0
|
|
return !SkScalarIsNaN(prod);
|
|
}
|
|
|
|
static inline bool SkScalarsAreFinite(const SkScalar array[], int count) {
|
|
SkScalar prod = 0;
|
|
for (int i = 0; i < count; ++i) {
|
|
prod *= array[i];
|
|
}
|
|
// At this point, prod will either be NaN or 0
|
|
return !SkScalarIsNaN(prod);
|
|
}
|
|
|
|
/**
|
|
* Variant of SkScalarRoundToInt, that performs the rounding step (adding 0.5) explicitly using
|
|
* double, to avoid possibly losing the low bit(s) of the answer before calling floor().
|
|
*
|
|
* This routine will likely be slower than SkScalarRoundToInt(), and should only be used when the
|
|
* extra precision is known to be valuable.
|
|
*
|
|
* In particular, this catches the following case:
|
|
* SkScalar x = 0.49999997;
|
|
* int ix = SkScalarRoundToInt(x);
|
|
* SkASSERT(0 == ix); // <--- fails
|
|
* ix = SkDScalarRoundToInt(x);
|
|
* SkASSERT(0 == ix); // <--- succeeds
|
|
*/
|
|
static inline int SkDScalarRoundToInt(SkScalar x) {
|
|
double xx = x;
|
|
xx += 0.5;
|
|
return (int)floor(xx);
|
|
}
|
|
|
|
static inline SkScalar SkScalarClampMax(SkScalar x, SkScalar max) {
|
|
x = SkTMin(x, max);
|
|
x = SkTMax<SkScalar>(x, 0);
|
|
return x;
|
|
}
|
|
|
|
static inline SkScalar SkScalarPin(SkScalar x, SkScalar min, SkScalar max) {
|
|
return SkTPin(x, min, max);
|
|
}
|
|
|
|
SkScalar SkScalarSinCos(SkScalar radians, SkScalar* cosValue);
|
|
|
|
static inline SkScalar SkScalarSquare(SkScalar x) { return x * x; }
|
|
|
|
#define SkScalarMul(a, b) ((SkScalar)(a) * (b))
|
|
#define SkScalarMulAdd(a, b, c) ((SkScalar)(a) * (b) + (c))
|
|
#define SkScalarMulDiv(a, b, c) ((SkScalar)(a) * (b) / (c))
|
|
#define SkScalarInvert(x) (SK_Scalar1 / (x))
|
|
#define SkScalarFastInvert(x) (SK_Scalar1 / (x))
|
|
#define SkScalarAve(a, b) (((a) + (b)) * SK_ScalarHalf)
|
|
#define SkScalarHalf(a) ((a) * SK_ScalarHalf)
|
|
|
|
#define SkDegreesToRadians(degrees) ((degrees) * (SK_ScalarPI / 180))
|
|
#define SkRadiansToDegrees(radians) ((radians) * (180 / SK_ScalarPI))
|
|
|
|
static inline SkScalar SkMaxScalar(SkScalar a, SkScalar b) { return a > b ? a : b; }
|
|
static inline SkScalar SkMinScalar(SkScalar a, SkScalar b) { return a < b ? a : b; }
|
|
|
|
static inline bool SkScalarIsInt(SkScalar x) {
|
|
return x == (SkScalar)(int)x;
|
|
}
|
|
|
|
/**
|
|
* Returns -1 || 0 || 1 depending on the sign of value:
|
|
* -1 if x < 0
|
|
* 0 if x == 0
|
|
* 1 if x > 0
|
|
*/
|
|
static inline int SkScalarSignAsInt(SkScalar x) {
|
|
return x < 0 ? -1 : (x > 0);
|
|
}
|
|
|
|
// Scalar result version of above
|
|
static inline SkScalar SkScalarSignAsScalar(SkScalar x) {
|
|
return x < 0 ? -SK_Scalar1 : ((x > 0) ? SK_Scalar1 : 0);
|
|
}
|
|
|
|
#define SK_ScalarNearlyZero (SK_Scalar1 / (1 << 12))
|
|
|
|
static inline bool SkScalarNearlyZero(SkScalar x,
|
|
SkScalar tolerance = SK_ScalarNearlyZero) {
|
|
SkASSERT(tolerance >= 0);
|
|
return SkScalarAbs(x) <= tolerance;
|
|
}
|
|
|
|
static inline bool SkScalarNearlyEqual(SkScalar x, SkScalar y,
|
|
SkScalar tolerance = SK_ScalarNearlyZero) {
|
|
SkASSERT(tolerance >= 0);
|
|
return SkScalarAbs(x-y) <= tolerance;
|
|
}
|
|
|
|
/** Linearly interpolate between A and B, based on t.
|
|
If t is 0, return A
|
|
If t is 1, return B
|
|
else interpolate.
|
|
t must be [0..SK_Scalar1]
|
|
*/
|
|
static inline SkScalar SkScalarInterp(SkScalar A, SkScalar B, SkScalar t) {
|
|
SkASSERT(t >= 0 && t <= SK_Scalar1);
|
|
return A + (B - A) * t;
|
|
}
|
|
|
|
/** Interpolate along the function described by (keys[length], values[length])
|
|
for the passed searchKey. SearchKeys outside the range keys[0]-keys[Length]
|
|
clamp to the min or max value. This function was inspired by a desire
|
|
to change the multiplier for thickness in fakeBold; therefore it assumes
|
|
the number of pairs (length) will be small, and a linear search is used.
|
|
Repeated keys are allowed for discontinuous functions (so long as keys is
|
|
monotonically increasing), and if key is the value of a repeated scalar in
|
|
keys, the first one will be used. However, that may change if a binary
|
|
search is used.
|
|
*/
|
|
SkScalar SkScalarInterpFunc(SkScalar searchKey, const SkScalar keys[],
|
|
const SkScalar values[], int length);
|
|
|
|
/*
|
|
* Helper to compare an array of scalars.
|
|
*/
|
|
static inline bool SkScalarsEqual(const SkScalar a[], const SkScalar b[], int n) {
|
|
SkASSERT(n >= 0);
|
|
for (int i = 0; i < n; ++i) {
|
|
if (a[i] != b[i]) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
#endif
|