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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « services/gfx/compositor/graph/transform_pair.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "services/gfx/compositor/graph/transform_pair.h"
6
7 namespace compositor {
8
9 TransformPair::TransformPair(const SkMatrix44& forward)
10 : forward_(forward),
11 cached_inverse_(SkMatrix44::kUninitialized_Constructor) {}
12
13 TransformPair::~TransformPair() {}
14
15 const SkMatrix44& TransformPair::GetInverse() const {
16 if (!cached_inverse_valid_) {
17 if (!forward_.invert(&cached_inverse_)) {
18 // Matrix is singular!
19 // Return [0,0,0,0][0,0,0,0][0,0,0,0][0,0,0,1] (all zeroes except
20 // last component). This causes all points to be mapped to the origin
21 // when transformed.
22 cached_inverse_.setScale(0.f, 0.f, 0.f);
23 }
24 cached_inverse_valid_ = true;
25 }
26 return cached_inverse_;
27 }
28
29 const SkPoint TransformPair::InverseMapPoint(const SkPoint& point) const {
30 SkScalar vec[4] = {point.x(), point.y(), 0.f, 1.f};
31 GetInverse().mapScalars(vec);
32 return SkPoint::Make(vec[0], vec[1]);
33 }
34
35 } // namespace compositor
OLDNEW
« 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