| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/views/mus/surface_binding.h" | 5 #include "ui/views/mus/surface_binding.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/threading/thread_local.h" | 16 #include "base/threading/thread_local.h" |
| 17 #include "cc/output/compositor_frame.h" | 17 #include "cc/output/compositor_frame.h" |
| 18 #include "cc/output/output_surface.h" | 18 #include "cc/output/output_surface.h" |
| 19 #include "cc/output/output_surface_client.h" | 19 #include "cc/output/output_surface_client.h" |
| 20 #include "cc/output/software_output_device.h" | 20 #include "cc/output/software_output_device.h" |
| 21 #include "cc/resources/shared_bitmap_manager.h" | 21 #include "cc/resources/shared_bitmap_manager.h" |
| 22 #include "components/mus/public/cpp/context_provider.h" | 22 #include "components/mus/public/cpp/context_provider.h" |
| 23 #include "components/mus/public/cpp/gpu_service.h" |
| 23 #include "components/mus/public/cpp/output_surface.h" | 24 #include "components/mus/public/cpp/output_surface.h" |
| 24 #include "components/mus/public/cpp/window.h" | 25 #include "components/mus/public/cpp/window.h" |
| 25 #include "components/mus/public/cpp/window_tree_connection.h" | 26 #include "components/mus/public/cpp/window_tree_connection.h" |
| 26 #include "components/mus/public/interfaces/gpu.mojom.h" | 27 #include "components/mus/public/interfaces/gpu.mojom.h" |
| 27 #include "mojo/converters/geometry/geometry_type_converters.h" | 28 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 28 #include "mojo/converters/surfaces/surfaces_type_converters.h" | 29 #include "mojo/converters/surfaces/surfaces_type_converters.h" |
| 29 #include "mojo/public/cpp/bindings/binding.h" | 30 #include "mojo/public/cpp/bindings/binding.h" |
| 30 #include "services/shell/public/cpp/connector.h" | 31 #include "services/shell/public/cpp/connector.h" |
| 31 #include "ui/views/mus/window_tree_host_mus.h" | 32 #include "ui/views/mus/window_tree_host_mus.h" |
| 32 | 33 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 94 } |
| 94 return (*window_map)[connection]; | 95 return (*window_map)[connection]; |
| 95 } | 96 } |
| 96 | 97 |
| 97 std::unique_ptr<cc::OutputSurface> | 98 std::unique_ptr<cc::OutputSurface> |
| 98 SurfaceBinding::PerConnectionState::CreateOutputSurface( | 99 SurfaceBinding::PerConnectionState::CreateOutputSurface( |
| 99 mus::Window* window, | 100 mus::Window* window, |
| 100 mus::mojom::SurfaceType surface_type) { | 101 mus::mojom::SurfaceType surface_type) { |
| 101 if (gpu_.encountered_error()) | 102 if (gpu_.encountered_error()) |
| 102 return nullptr; | 103 return nullptr; |
| 103 // TODO(sky): figure out lifetime here. Do I need to worry about the return | 104 mojo::ScopedMessagePipeHandle scoped_handle; |
| 104 // value outliving this? | 105 if (!mus::GpuService::UseChromeGpuCommandBuffer()) { |
| 105 mus::mojom::CommandBufferPtr cb; | 106 // TODO(sky): figure out lifetime here. Do I need to worry about the return |
| 106 gpu_->CreateOffscreenGLES2Context(GetProxy(&cb)); | 107 // value outliving this? |
| 107 | 108 mus::mojom::CommandBufferPtr cb; |
| 109 gpu_->CreateOffscreenGLES2Context(GetProxy(&cb)); |
| 110 scoped_handle = cb.PassInterface().PassHandle(); |
| 111 } else { |
| 112 mus::GpuService::Initialize(connector_); |
| 113 } |
| 108 scoped_refptr<cc::ContextProvider> context_provider( | 114 scoped_refptr<cc::ContextProvider> context_provider( |
| 109 new mus::ContextProvider(cb.PassInterface().PassHandle())); | 115 new mus::ContextProvider(std::move(scoped_handle))); |
| 110 return base::WrapUnique(new mus::OutputSurface( | 116 return base::WrapUnique(new mus::OutputSurface( |
| 111 context_provider, window->RequestSurface(surface_type))); | 117 context_provider, window->RequestSurface(surface_type))); |
| 112 } | 118 } |
| 113 | 119 |
| 114 SurfaceBinding::PerConnectionState::PerConnectionState( | 120 SurfaceBinding::PerConnectionState::PerConnectionState( |
| 115 shell::Connector* connector, | 121 shell::Connector* connector, |
| 116 mus::WindowTreeConnection* connection) | 122 mus::WindowTreeConnection* connection) |
| 117 : connector_(connector), connection_(connection) {} | 123 : connector_(connector), connection_(connection) {} |
| 118 | 124 |
| 119 SurfaceBinding::PerConnectionState::~PerConnectionState() { | 125 SurfaceBinding::PerConnectionState::~PerConnectionState() { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 146 surface_type_(surface_type), | 152 surface_type_(surface_type), |
| 147 state_(PerConnectionState::Get(connector, window->connection())) {} | 153 state_(PerConnectionState::Get(connector, window->connection())) {} |
| 148 | 154 |
| 149 SurfaceBinding::~SurfaceBinding() {} | 155 SurfaceBinding::~SurfaceBinding() {} |
| 150 | 156 |
| 151 std::unique_ptr<cc::OutputSurface> SurfaceBinding::CreateOutputSurface() { | 157 std::unique_ptr<cc::OutputSurface> SurfaceBinding::CreateOutputSurface() { |
| 152 return state_->CreateOutputSurface(window_, surface_type_); | 158 return state_->CreateOutputSurface(window_, surface_type_); |
| 153 } | 159 } |
| 154 | 160 |
| 155 } // namespace views | 161 } // namespace views |
| OLD | NEW |