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

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

Issue 2966793002: NOT FOR REVIEW - convert to cc animation
Patch Set: switch to transform operations Created 3 years, 5 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 | « chrome/browser/android/vr_shell/ui_scene_unittest.cc ('k') | ui/gfx/animation/tween.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/vr_shell_gl.h" 5 #include "chrome/browser/android/vr_shell/vr_shell_gl.h"
6 6
7 #include <chrono> 7 #include <chrono>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 1292
1293 if (draw_reticle && (reticle_render_target_ == element)) { 1293 if (draw_reticle && (reticle_render_target_ == element)) {
1294 DrawReticle(view_proj_matrix); 1294 DrawReticle(view_proj_matrix);
1295 } 1295 }
1296 } 1296 }
1297 vr_shell_renderer_->Flush(); 1297 vr_shell_renderer_->Flush();
1298 } 1298 }
1299 1299
1300 void VrShellGl::DrawElement(const gfx::Transform& view_proj_matrix, 1300 void VrShellGl::DrawElement(const gfx::Transform& view_proj_matrix,
1301 const UiElement& element) { 1301 const UiElement& element) {
1302 gfx::Transform transform = view_proj_matrix * element.transform(); 1302 gfx::Transform transform =
1303 view_proj_matrix * element.screen_space_transform();
1303 1304
1304 switch (element.fill()) { 1305 switch (element.fill()) {
1305 case Fill::OPAQUE_GRADIENT: { 1306 case Fill::OPAQUE_GRADIENT: {
1306 vr_shell_renderer_->GetGradientQuadRenderer()->Draw( 1307 vr_shell_renderer_->GetGradientQuadRenderer()->Draw(
1307 transform, element.edge_color(), element.center_color(), 1308 transform, element.edge_color(), element.center_color(),
1308 element.computed_opacity()); 1309 element.computed_opacity());
1309 break; 1310 break;
1310 } 1311 }
1311 case Fill::GRID_GRADIENT: { 1312 case Fill::GRID_GRADIENT: {
1312 vr_shell_renderer_->GetGradientGridRenderer()->Draw( 1313 vr_shell_renderer_->GetGradientGridRenderer()->Draw(
(...skipping 27 matching lines...) Expand all
1340 // and secondarily based on their z-axis distance (more distant first). 1341 // and secondarily based on their z-axis distance (more distant first).
1341 // TODO(mthiesse, crbug.com/721356): This will not work well for elements not 1342 // TODO(mthiesse, crbug.com/721356): This will not work well for elements not
1342 // directly in front of the user, but works well enough for our initial 1343 // directly in front of the user, but works well enough for our initial
1343 // release, and provides a consistent ordering that we can easily design 1344 // release, and provides a consistent ordering that we can easily design
1344 // around. 1345 // around.
1345 std::sort(sorted_elements.begin(), sorted_elements.end(), 1346 std::sort(sorted_elements.begin(), sorted_elements.end(),
1346 [](const UiElement* first, const UiElement* second) { 1347 [](const UiElement* first, const UiElement* second) {
1347 if (first->draw_phase() != second->draw_phase()) { 1348 if (first->draw_phase() != second->draw_phase()) {
1348 return first->draw_phase() < second->draw_phase(); 1349 return first->draw_phase() < second->draw_phase();
1349 } else { 1350 } else {
1350 return first->transform().matrix().get(2, 3) < 1351 return first->screen_space_transform().matrix().get(2, 3) <
1351 second->transform().matrix().get(2, 3); 1352 second->screen_space_transform().matrix().get(2, 3);
1352 } 1353 }
1353 }); 1354 });
1354 1355
1355 return sorted_elements; 1356 return sorted_elements;
1356 } 1357 }
1357 1358
1358 void VrShellGl::DrawReticle(const gfx::Transform& render_matrix) { 1359 void VrShellGl::DrawReticle(const gfx::Transform& render_matrix) {
1359 // Scale the reticle to have a fixed FOV size at any distance. 1360 // Scale the reticle to have a fixed FOV size at any distance.
1360 const float eye_to_target = 1361 const float eye_to_target =
1361 std::sqrt(target_point_.SquaredDistanceTo(kOrigin)); 1362 std::sqrt(target_point_.SquaredDistanceTo(kOrigin));
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 // This assumes that the initial webvr_surface_size_ was set to the 1635 // This assumes that the initial webvr_surface_size_ was set to the
1635 // appropriate recommended render resolution as the default size during 1636 // appropriate recommended render resolution as the default size during
1636 // InitializeGl. Revisit if the initialization order changes. 1637 // InitializeGl. Revisit if the initialization order changes.
1637 device::mojom::VRDisplayInfoPtr info = 1638 device::mojom::VRDisplayInfoPtr info =
1638 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(), 1639 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(),
1639 webvr_surface_size_, device_id); 1640 webvr_surface_size_, device_id);
1640 browser_->RunVRDisplayInfoCallback(callback, &info); 1641 browser_->RunVRDisplayInfoCallback(callback, &info);
1641 } 1642 }
1642 1643
1643 } // namespace vr_shell 1644 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene_unittest.cc ('k') | ui/gfx/animation/tween.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698