chromium/ui/gfx/geometry/rect_f.h

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_GFX_GEOMETRY_RECT_F_H_
#define UI_GFX_GEOMETRY_RECT_F_H_

#include <iosfwd>
#include <string>

#include "build/build_config.h"
#include "ui/gfx/geometry/insets_f.h"
#include "ui/gfx/geometry/outsets_f.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/size_f.h"
#include "ui/gfx/geometry/vector2d_f.h"

#if BUILDFLAG(IS_APPLE)
typedef struct CGRect CGRect;
#endif

namespace gfx {

// A floating version of gfx::Rect.
class GEOMETRY_EXPORT RectF {};

constexpr bool operator==(const RectF& lhs, const RectF& rhs) {}

constexpr bool operator!=(const RectF& lhs, const RectF& rhs) {}

inline RectF operator+(const RectF& lhs, const Vector2dF& rhs) {}

inline RectF operator-(const RectF& lhs, const Vector2dF& rhs) {}

inline RectF operator+(const Vector2dF& lhs, const RectF& rhs) {}

GEOMETRY_EXPORT RectF IntersectRects(const RectF& a, const RectF& b);
GEOMETRY_EXPORT RectF UnionRects(const RectF& a, const RectF& b);
GEOMETRY_EXPORT RectF UnionRectsEvenIfEmpty(const RectF& a, const RectF& b);
GEOMETRY_EXPORT RectF SubtractRects(const RectF& a, const RectF& b);

inline RectF ScaleRect(const RectF& r, float x_scale, float y_scale) {}

inline RectF ScaleRect(const RectF& r, const SizeF& size) {}

inline RectF ScaleRect(const RectF& r, const Size& size) {}

inline RectF ScaleRect(const RectF& r, float scale) {}

inline RectF TransposeRect(const RectF& r) {}

// Constructs a rectangle with |p1| and |p2| as opposite corners.
//
// This could also be thought of as "the smallest rect that contains both
// points", except that we consider points on the right/bottom edges of the
// rect to be outside the rect.  So technically one or both points will not be
// contained within the rect, because they will appear on one of these edges.
GEOMETRY_EXPORT RectF BoundingRect(const PointF& p1, const PointF& p2);

// Return a maximum rectangle in which any point is covered by either a or b.
GEOMETRY_EXPORT RectF MaximumCoveredRect(const RectF& a, const RectF& b);

// Returns the rect in |dest_rect| corresponding to |r] in |src_rect| when
// |src_rect| is mapped to |dest_rect|.
GEOMETRY_EXPORT RectF MapRect(const RectF& r,
                              const RectF& src_rect,
                              const RectF& dest_rect);

// This is declared here for use in gtest-based unit tests but is defined in
// the //ui/gfx:test_support target. Depend on that to use this in your unit
// test. This should not be used in production code - call ToString() instead.
void PrintTo(const RectF& rect, ::std::ostream* os);

}  // namespace gfx

#endif  // UI_GFX_GEOMETRY_RECT_F_H_