Index: cc/base/math_util.cc |
diff --git a/cc/base/math_util.cc b/cc/base/math_util.cc |
index e3cb81f70cca5c92b9b881b744c97a34d3daada2..d28c195971f6cd14eb753b6d9eddd51d1dd082fb 100644 |
--- a/cc/base/math_util.cc |
+++ b/cc/base/math_util.cc |
@@ -7,6 +7,9 @@ |
#include <algorithm> |
#include <cmath> |
#include <limits> |
+#ifdef __SSE__ |
+#include <xmmintrin.h> |
+#endif |
#include "base/trace_event/trace_event_argument.h" |
#include "base/values.h" |
@@ -918,4 +921,18 @@ gfx::Vector3dF MathUtil::GetYAxis(const gfx::Transform& transform) { |
transform.matrix().getFloat(2, 1)); |
} |
+ScopedSubnormalFloatDisabler::ScopedSubnormalFloatDisabler() { |
+#ifdef __SSE__ |
+ // Turn on "subnormals are zero" and "flush to zero" CSR flags. |
+ orig_state_ = _mm_getcsr(); |
+ _mm_setcsr(orig_state_ | 0x8040); |
+#endif |
+} |
+ |
+ScopedSubnormalFloatDisabler::~ScopedSubnormalFloatDisabler() { |
+#ifdef __SSE__ |
+ _mm_setcsr(orig_state_); |
+#endif |
+} |
+ |
} // namespace cc |