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

Side by Side Diff: chrome/browser/android/vr_shell/ui_elements.cc

Issue 2777633003: Avoid duplicate math when computing VR scene hierarchy. (Closed)
Patch Set: s/GetTransform()/mutable_transform()/ Created 3 years, 8 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/vr_shell/ui_elements.h" 5 #include "chrome/browser/android/vr_shell/ui_elements.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chrome/browser/android/vr_shell/animation.h" 10 #include "chrome/browser/android/vr_shell/animation.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 58
59 void Transform::Scale(float sx, float sy, float sz) { 59 void Transform::Scale(float sx, float sy, float sz) {
60 ScaleM(to_world, to_world, sx, sy, sz); 60 ScaleM(to_world, to_world, sx, sy, sz);
61 } 61 }
62 62
63 const gvr::Mat4f& WorldRectangle::TransformMatrix() const { 63 const gvr::Mat4f& WorldRectangle::TransformMatrix() const {
64 return transform_.to_world; 64 return transform_.to_world;
65 } 65 }
66 66
67 void WorldRectangle::SetTransform(const Transform& transform) {
68 transform_ = transform;
69 }
70
71 gvr::Vec3f WorldRectangle::GetCenter() const { 67 gvr::Vec3f WorldRectangle::GetCenter() const {
72 const gvr::Vec3f kOrigin = {0.0f, 0.0f, 0.0f}; 68 const gvr::Vec3f kOrigin = {0.0f, 0.0f, 0.0f};
73 return MatrixVectorMul(transform_.to_world, kOrigin); 69 return MatrixVectorMul(transform_.to_world, kOrigin);
74 } 70 }
75 71
76 gvr::Vec2f WorldRectangle::GetUnitRectangleCoordinates( 72 gvr::Vec2f WorldRectangle::GetUnitRectangleCoordinates(
77 const gvr::Vec3f& world_point) { 73 const gvr::Vec3f& world_point) {
78 const gvr::Mat4f& transform = transform_.to_world; 74 const gvr::Mat4f& transform = transform_.to_world;
79 gvr::Vec3f origin = MatrixVectorMul(transform, gvr::Vec3f({0, 0, 0})); 75 gvr::Vec3f origin = MatrixVectorMul(transform, gvr::Vec3f({0, 0, 0}));
80 gvr::Vec3f xAxis = MatrixVectorMul(transform, gvr::Vec3f({1, 0, 0})); 76 gvr::Vec3f xAxis = MatrixVectorMul(transform, gvr::Vec3f({1, 0, 0}));
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 204
209 bool ContentRectangle::IsVisible() const { 205 bool ContentRectangle::IsVisible() const {
210 return visible && computed_opacity > 0.0f; 206 return visible && computed_opacity > 0.0f;
211 } 207 }
212 208
213 bool ContentRectangle::IsHitTestable() const { 209 bool ContentRectangle::IsHitTestable() const {
214 return IsVisible() && hit_testable; 210 return IsVisible() && hit_testable;
215 } 211 }
216 212
217 } // namespace vr_shell 213 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/ui_elements.h ('k') | chrome/browser/android/vr_shell/ui_scene.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698