#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "cc/base/math_util.h"
#include <algorithm>
#include <cmath>
#include <limits>
#if defined(ARCH_CPU_X86_FAMILY)
#include <xmmintrin.h>
#endif
#include "base/numerics/angle_conversions.h"
#include "base/trace_event/traced_value.h"
#include "base/values.h"
#include "ui/gfx/geometry/linear_gradient.h"
#include "ui/gfx/geometry/quad_f.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/rrect_f.h"
#include "ui/gfx/geometry/transform.h"
#include "ui/gfx/geometry/vector2d_conversions.h"
#include "ui/gfx/geometry/vector2d_f.h"
#include "ui/gfx/geometry/vector3d_f.h"
namespace cc {
static HomogeneousCoordinate ProjectHomogeneousPoint(
const gfx::Transform& transform,
const gfx::PointF& p) { … }
static HomogeneousCoordinate ProjectHomogeneousPoint(
const gfx::Transform& transform,
const gfx::PointF& p,
bool* clipped) { … }
static HomogeneousCoordinate MapHomogeneousPoint(
const gfx::Transform& transform,
const gfx::PointF& p) { … }
namespace {
const float kStationaryPointEpsilon = …;
}
static void homogeneousLimitAtZero(SkScalar a1,
SkScalar w1,
SkScalar a2,
SkScalar w2,
float t,
float* limit) { … }
static gfx::PointF ComputeClippedCartesianPoint2dForEdge(
const HomogeneousCoordinate& h1,
const HomogeneousCoordinate& h2) { … }
static void homogeneousLimitNearZero(SkScalar a1,
SkScalar w1,
SkScalar a2,
SkScalar w2,
float t,
float* limit) { … }
static gfx::Point3F ComputeClippedCartesianPoint3dForEdge(
const HomogeneousCoordinate& h1,
const HomogeneousCoordinate& h2) { … }
static inline void ExpandBoundsToIncludePoint(float* xmin,
float* xmax,
float* ymin,
float* ymax,
const gfx::PointF& p) { … }
static inline bool IsNearlyTheSame(float f, float g) { … }
static inline bool IsNearlyTheSame(const gfx::PointF& lhs,
const gfx::PointF& rhs) { … }
static inline bool IsNearlyTheSame(const gfx::Point3F& lhs,
const gfx::Point3F& rhs) { … }
static inline void AddVertexToClippedQuad3d(const gfx::Point3F& new_vertex,
gfx::Point3F clipped_quad[6],
int* num_vertices_in_clipped_quad,
bool* need_to_clamp) { … }
gfx::Rect MathUtil::MapEnclosingClippedRect(const gfx::Transform& transform,
const gfx::Rect& src_rect) { … }
gfx::Rect MathUtil::MapEnclosingClippedRectIgnoringError(
const gfx::Transform& transform,
const gfx::Rect& src_rect,
float ignore_error) { … }
gfx::RectF MathUtil::MapClippedRect(const gfx::Transform& transform,
const gfx::RectF& src_rect) { … }
gfx::Rect MathUtil::ProjectEnclosingClippedRect(const gfx::Transform& transform,
const gfx::Rect& src_rect) { … }
gfx::RectF MathUtil::ProjectClippedRect(const gfx::Transform& transform,
const gfx::RectF& src_rect) { … }
gfx::QuadF MathUtil::InverseMapQuadToLocalSpace(
const gfx::Transform& device_transform,
const gfx::QuadF& device_quad) { … }
gfx::Rect MathUtil::MapEnclosedRectWith2dAxisAlignedTransform(
const gfx::Transform& transform,
const gfx::Rect& rect) { … }
bool MathUtil::MapClippedQuad3d(const gfx::Transform& transform,
const gfx::QuadF& src_quad,
gfx::Point3F clipped_quad[6],
int* num_vertices_in_clipped_quad) { … }
gfx::RectF MathUtil::ComputeEnclosingRectOfVertices(
const gfx::PointF vertices[],
int num_vertices) { … }
gfx::RectF MathUtil::ComputeEnclosingClippedRect(
const HomogeneousCoordinate& h1,
const HomogeneousCoordinate& h2,
const HomogeneousCoordinate& h3,
const HomogeneousCoordinate& h4) { … }
gfx::QuadF MathUtil::MapQuad(const gfx::Transform& transform,
const gfx::QuadF& q,
bool* clipped) { … }
gfx::PointF MathUtil::MapPoint(const gfx::Transform& transform,
const gfx::PointF& p,
bool* clipped) { … }
gfx::PointF MathUtil::ProjectPoint(const gfx::Transform& transform,
const gfx::PointF& p,
bool* clipped) { … }
gfx::Point3F MathUtil::ProjectPoint3D(const gfx::Transform& transform,
const gfx::PointF& p,
bool* clipped) { … }
gfx::RectF MathUtil::ScaleRectProportional(const gfx::RectF& input_outer_rect,
const gfx::RectF& scale_outer_rect,
const gfx::RectF& scale_inner_rect) { … }
float MathUtil::SmallestAngleBetweenVectors(const gfx::Vector2dF& v1,
const gfx::Vector2dF& v2) { … }
gfx::Vector2dF MathUtil::ProjectVector(const gfx::Vector2dF& source,
const gfx::Vector2dF& destination) { … }
bool MathUtil::FromValue(const base::Value* raw_value, gfx::Rect* out_rect) { … }
void MathUtil::AddToTracedValue(const char* name,
const gfx::Size& s,
base::trace_event::TracedValue* res) { … }
void MathUtil::AddToTracedValue(const char* name,
const gfx::SizeF& s,
base::trace_event::TracedValue* res) { … }
void MathUtil::AddToTracedValue(const char* name,
const gfx::Rect& r,
base::trace_event::TracedValue* res) { … }
void MathUtil::AddToTracedValue(const char* name,
const gfx::Point& pt,
base::trace_event::TracedValue* res) { … }
void MathUtil::AddToTracedValue(const char* name,
const gfx::PointF& pt,
base::trace_event::TracedValue* res) { … }
void MathUtil::AddToTracedValue(const char* name,
const gfx::Point3F& pt,
base::trace_event::TracedValue* res) { … }
void MathUtil::AddToTracedValue(const char* name,
const gfx::Vector2d& v,
base::trace_event::TracedValue* res) { … }
void MathUtil::AddToTracedValue(const char* name,
const gfx::Vector2dF& v,
base::trace_event::TracedValue* res) { … }
void MathUtil::AddToTracedValue(const char* name,
const gfx::QuadF& q,
base::trace_event::TracedValue* res) { … }
void MathUtil::AddToTracedValue(const char* name,
const gfx::RectF& rect,
base::trace_event::TracedValue* res) { … }
void MathUtil::AddToTracedValue(const char* name,
const gfx::Transform& transform,
base::trace_event::TracedValue* res) { … }
void MathUtil::AddToTracedValue(const char* name,
const gfx::BoxF& box,
base::trace_event::TracedValue* res) { … }
void MathUtil::AddToTracedValue(const char* name,
const gfx::RRectF& rect,
base::trace_event::TracedValue* res) { … }
void MathUtil::AddCornerRadiiToTracedValue(
const char* name,
const gfx::RRectF& rect,
base::trace_event::TracedValue* res) { … }
void MathUtil::AddToTracedValue(const char* name,
const gfx::LinearGradient& gradient,
base::trace_event::TracedValue* res) { … }
double MathUtil::AsDoubleSafely(double value) { … }
float MathUtil::AsFloatSafely(float value) { … }
gfx::Vector3dF MathUtil::GetXAxis(const gfx::Transform& transform) { … }
gfx::Vector3dF MathUtil::GetYAxis(const gfx::Transform& transform) { … }
ScopedSubnormalFloatDisabler::ScopedSubnormalFloatDisabler() { … }
ScopedSubnormalFloatDisabler::~ScopedSubnormalFloatDisabler() { … }
bool MathUtil::IsFloatNearlyTheSame(float left, float right) { … }
bool MathUtil::IsNearlyTheSameForTesting(const gfx::PointF& left,
const gfx::PointF& right) { … }
bool MathUtil::IsNearlyTheSameForTesting(const gfx::Point3F& left,
const gfx::Point3F& right) { … }
bool MathUtil::SkM44HasPerspective(const SkM44& m) { … }
bool MathUtil::SkM44Is2D(const SkM44& m) { … }
bool MathUtil::SkM44Preserves2DAxisAlignment(const SkM44& m) { … }
}