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

Unified Diff: ui/gfx/transform.cc

Issue 26116004: Add gfx::Transform::TransformBox and TransformBoxReverse (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 | « ui/gfx/transform.h ('k') | ui/gfx/transform_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/transform.cc
diff --git a/ui/gfx/transform.cc b/ui/gfx/transform.cc
index ac62006163091ea589e6d01e35859fd64507109d..59e6a607a8de11558cbec9ac06fd6f1b47c067ab 100644
--- a/ui/gfx/transform.cc
+++ b/ui/gfx/transform.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/strings/stringprintf.h"
+#include "ui/gfx/box_f.h"
#include "ui/gfx/point.h"
#include "ui/gfx/point3_f.h"
#include "ui/gfx/rect.h"
@@ -428,6 +429,33 @@ bool Transform::TransformRectReverse(RectF* rect) const {
return true;
}
+void Transform::TransformBox(BoxF* box) const {
+ BoxF bounds;
+ bool first_point = true;
+ for (int corner = 0; corner < 8; ++corner) {
+ gfx::Point3F point = box->origin();
+ point += gfx::Vector3dF(corner & 1 ? box->width() : 0.f,
+ corner & 2 ? box->height() : 0.f,
+ corner & 4 ? box->depth() : 0.f);
+ TransformPoint(&point);
+ if (first_point) {
+ bounds.set_origin(point);
+ first_point = false;
+ } else {
+ bounds.ExpandTo(point);
+ }
+ }
+ *box = bounds;
+}
+
+bool Transform::TransformBoxReverse(BoxF* box) const {
+ gfx::Transform inverse = *this;
+ if (!GetInverse(&inverse))
+ return false;
+ inverse.TransformBox(box);
+ return true;
+}
+
bool Transform::Blend(const Transform& from, double progress) {
DecomposedTransform to_decomp;
DecomposedTransform from_decomp;
« no previous file with comments | « ui/gfx/transform.h ('k') | ui/gfx/transform_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698