Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 986 } | 986 } |
| 987 } | 987 } |
| 988 } | 988 } |
| 989 | 989 |
| 990 void VrShellGl::DrawElements(const vr::Mat4f& view_proj_matrix, | 990 void VrShellGl::DrawElements(const vr::Mat4f& view_proj_matrix, |
| 991 const std::vector<const UiElement*>& elements) { | 991 const std::vector<const UiElement*>& elements) { |
| 992 for (const auto* rect : elements) { | 992 for (const auto* rect : elements) { |
| 993 vr::Mat4f transform; | 993 vr::Mat4f transform; |
| 994 vr::MatrixMul(view_proj_matrix, rect->TransformMatrix(), &transform); | 994 vr::MatrixMul(view_proj_matrix, rect->TransformMatrix(), &transform); |
| 995 | 995 |
| 996 if (rect->Render(vr_shell_renderer_.get())) { | |
| 997 continue; | |
| 998 } | |
| 996 switch (rect->fill) { | 999 switch (rect->fill) { |
| 997 case Fill::SKIA: { | |
| 998 break; | |
| 999 } | |
| 1000 case Fill::OPAQUE_GRADIENT: { | 1000 case Fill::OPAQUE_GRADIENT: { |
| 1001 vr_shell_renderer_->GetTexturedQuadRenderer()->Flush(); | |
| 1002 vr_shell_renderer_->GetGradientQuadRenderer()->Draw( | 1001 vr_shell_renderer_->GetGradientQuadRenderer()->Draw( |
| 1003 transform, rect->edge_color, rect->center_color, | 1002 transform, rect->edge_color, rect->center_color, |
| 1004 rect->computed_opacity); | 1003 rect->computed_opacity); |
| 1004 vr_shell_renderer_->GetTexturedQuadRenderer()->Flush(); | |
|
cjgrant
2017/04/19 16:24:52
This may not be great, but I think this Flush opti
| |
| 1005 break; | 1005 break; |
| 1006 } | 1006 } |
| 1007 case Fill::GRID_GRADIENT: { | 1007 case Fill::GRID_GRADIENT: { |
| 1008 vr_shell_renderer_->GetTexturedQuadRenderer()->Flush(); | |
| 1009 vr_shell_renderer_->GetGradientGridRenderer()->Draw( | 1008 vr_shell_renderer_->GetGradientGridRenderer()->Draw( |
| 1010 transform, rect->edge_color, rect->center_color, | 1009 transform, rect->edge_color, rect->center_color, |
| 1011 rect->gridline_count, rect->computed_opacity); | 1010 rect->gridline_count, rect->computed_opacity); |
| 1011 vr_shell_renderer_->GetTexturedQuadRenderer()->Flush(); | |
| 1012 break; | 1012 break; |
| 1013 } | 1013 } |
| 1014 case Fill::CONTENT: { | 1014 case Fill::CONTENT: { |
| 1015 gfx::RectF copy_rect(0, 0, 1, 1); | 1015 gfx::RectF copy_rect(0, 0, 1, 1); |
| 1016 vr_shell_renderer_->GetTexturedQuadRenderer()->AddQuad( | 1016 vr_shell_renderer_->GetTexturedQuadRenderer()->AddQuad( |
| 1017 content_texture_id_, transform, copy_rect, rect->computed_opacity); | 1017 content_texture_id_, transform, copy_rect, rect->computed_opacity); |
| 1018 vr_shell_renderer_->GetTexturedQuadRenderer()->Flush(); | |
| 1018 break; | 1019 break; |
| 1019 } | 1020 } |
| 1020 default: | 1021 default: |
| 1021 break; | 1022 break; |
| 1022 } | 1023 } |
| 1023 } | 1024 } |
| 1024 | |
| 1025 vr_shell_renderer_->GetTexturedQuadRenderer()->Flush(); | |
| 1026 } | 1025 } |
| 1027 | 1026 |
| 1028 std::vector<const UiElement*> VrShellGl::GetElementsInDrawOrder( | 1027 std::vector<const UiElement*> VrShellGl::GetElementsInDrawOrder( |
| 1029 const vr::Mat4f& view_matrix, | 1028 const vr::Mat4f& view_matrix, |
| 1030 const std::vector<const UiElement*>& elements) { | 1029 const std::vector<const UiElement*>& elements) { |
| 1031 typedef std::pair<float, const UiElement*> DistanceElementPair; | 1030 typedef std::pair<float, const UiElement*> DistanceElementPair; |
| 1032 std::vector<DistanceElementPair> zOrderedElementPairs; | 1031 std::vector<DistanceElementPair> zOrderedElementPairs; |
| 1033 zOrderedElementPairs.reserve(elements.size()); | 1032 zOrderedElementPairs.reserve(elements.size()); |
| 1034 | 1033 |
| 1035 for (const auto* element : elements) { | 1034 for (const auto* element : elements) { |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1325 // InitializeGl. Revisit if the initialization order changes. | 1324 // InitializeGl. Revisit if the initialization order changes. |
| 1326 device::mojom::VRDisplayInfoPtr info = | 1325 device::mojom::VRDisplayInfoPtr info = |
| 1327 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(), | 1326 device::GvrDelegate::CreateVRDisplayInfo(gvr_api_.get(), |
| 1328 webvr_surface_size_, device_id); | 1327 webvr_surface_size_, device_id); |
| 1329 main_thread_task_runner_->PostTask( | 1328 main_thread_task_runner_->PostTask( |
| 1330 FROM_HERE, | 1329 FROM_HERE, |
| 1331 base::Bind(&RunVRDisplayInfoCallback, callback, base::Passed(&info))); | 1330 base::Bind(&RunVRDisplayInfoCallback, callback, base::Passed(&info))); |
| 1332 } | 1331 } |
| 1333 | 1332 |
| 1334 } // namespace vr_shell | 1333 } // namespace vr_shell |
| OLD | NEW |