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

Unified Diff: services/gfx/compositor/graph/transform_pair.cc

Issue 1781993002: Mozart: Compute hits using 4x4 matrix. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-10
Patch Set: Created 4 years, 9 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 | « services/gfx/compositor/graph/transform_pair.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/gfx/compositor/graph/transform_pair.cc
diff --git a/services/gfx/compositor/graph/transform_pair.cc b/services/gfx/compositor/graph/transform_pair.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b7c523a31cf5a6e78f2641b440303bc38b775c7a
--- /dev/null
+++ b/services/gfx/compositor/graph/transform_pair.cc
@@ -0,0 +1,35 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "services/gfx/compositor/graph/transform_pair.h"
+
+namespace compositor {
+
+TransformPair::TransformPair(const SkMatrix44& forward)
+ : forward_(forward),
+ cached_inverse_(SkMatrix44::kUninitialized_Constructor) {}
+
+TransformPair::~TransformPair() {}
+
+const SkMatrix44& TransformPair::GetInverse() const {
+ if (!cached_inverse_valid_) {
+ if (!forward_.invert(&cached_inverse_)) {
+ // Matrix is singular!
+ // Return [0,0,0,0][0,0,0,0][0,0,0,0][0,0,0,1] (all zeroes except
+ // last component). This causes all points to be mapped to the origin
+ // when transformed.
+ cached_inverse_.setScale(0.f, 0.f, 0.f);
+ }
+ cached_inverse_valid_ = true;
+ }
+ return cached_inverse_;
+}
+
+const SkPoint TransformPair::InverseMapPoint(const SkPoint& point) const {
+ SkScalar vec[4] = {point.x(), point.y(), 0.f, 1.f};
+ GetInverse().mapScalars(vec);
+ return SkPoint::Make(vec[0], vec[1]);
+}
+
+} // namespace compositor
« no previous file with comments | « services/gfx/compositor/graph/transform_pair.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698