Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Unified Diff: ui/gfx/quad_f.h

Issue 15298013: ui: Inline QuadF::BoundingBox() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/gfx/quad_f.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/quad_f.h
diff --git a/ui/gfx/quad_f.h b/ui/gfx/quad_f.h
index faf214941beb3fb915bccb68fee53f682079e6eb..4173dbe0f2fb1996edd0ea0c052f8502e6ca63e1 100644
--- a/ui/gfx/quad_f.h
+++ b/ui/gfx/quad_f.h
@@ -5,6 +5,7 @@
#ifndef UI_GFX_QUAD_F_H_
#define UI_GFX_QUAD_F_H_
+#include <cmath>
#include <string>
#include "ui/base/ui_export.h"
@@ -56,7 +57,13 @@ class UI_EXPORT QuadF {
// Returns a rectangle that bounds the four points of the quad. The points of
// the quad may lie on the right/bottom edge of the resulting rectangle,
// rather than being strictly inside it.
- RectF BoundingBox() const;
+ RectF BoundingBox() const {
+ float rl = std::min(std::min(p1_.x(), p2_.x()), std::min(p3_.x(), p4_.x()));
+ float rr = std::max(std::max(p1_.x(), p2_.x()), std::max(p3_.x(), p4_.x()));
+ float rt = std::min(std::min(p1_.y(), p2_.y()), std::min(p3_.y(), p4_.y()));
+ float rb = std::max(std::max(p1_.y(), p2_.y()), std::max(p3_.y(), p4_.y()));
+ return RectF(rl, rt, rr - rl, rb - rt);
+ }
// Add a vector to the quad, offseting each point in the quad by the vector.
void operator+=(const Vector2dF& rhs);
« no previous file with comments | « no previous file | ui/gfx/quad_f.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698