Chromium Code Reviews| 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> |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 (*window_map)[connection] = new PerConnectionState(connector, connection); | 91 (*window_map)[connection] = new PerConnectionState(connector, connection); |
| 92 (*window_map)[connection]->Init(); | 92 (*window_map)[connection]->Init(); |
| 93 } | 93 } |
| 94 return (*window_map)[connection]; | 94 return (*window_map)[connection]; |
| 95 } | 95 } |
| 96 | 96 |
| 97 std::unique_ptr<cc::OutputSurface> | 97 std::unique_ptr<cc::OutputSurface> |
| 98 SurfaceBinding::PerConnectionState::CreateOutputSurface( | 98 SurfaceBinding::PerConnectionState::CreateOutputSurface( |
| 99 mus::Window* window, | 99 mus::Window* window, |
| 100 mus::mojom::SurfaceType surface_type) { | 100 mus::mojom::SurfaceType surface_type) { |
| 101 if (gpu_.encountered_error()) | |
| 102 return nullptr; | |
| 101 // TODO(sky): figure out lifetime here. Do I need to worry about the return | 103 // TODO(sky): figure out lifetime here. Do I need to worry about the return |
| 102 // value outliving this? | 104 // value outliving this? |
| 103 mus::mojom::CommandBufferPtr cb; | 105 mus::mojom::CommandBufferPtr cb; |
| 104 gpu_->CreateOffscreenGLES2Context(GetProxy(&cb)); | 106 gpu_->CreateOffscreenGLES2Context(GetProxy(&cb)); |
| 105 | 107 |
| 106 scoped_refptr<cc::ContextProvider> context_provider( | 108 scoped_refptr<cc::ContextProvider> context_provider( |
| 107 new mus::ContextProvider(cb.PassInterface().PassHandle())); | 109 new mus::ContextProvider(cb.PassInterface().PassHandle())); |
| 108 return base::WrapUnique(new mus::OutputSurface( | 110 return base::WrapUnique(new mus::OutputSurface( |
| 109 context_provider, window->RequestSurface(surface_type))); | 111 context_provider, window->RequestSurface(surface_type))); |
| 110 } | 112 } |
| 111 | 113 |
| 112 SurfaceBinding::PerConnectionState::PerConnectionState( | 114 SurfaceBinding::PerConnectionState::PerConnectionState( |
| 113 shell::Connector* connector, | 115 shell::Connector* connector, |
| 114 mus::WindowTreeConnection* connection) | 116 mus::WindowTreeConnection* connection) |
| 115 : connector_(connector), connection_(connection) {} | 117 : connector_(connector), connection_(connection) {} |
| 116 | 118 |
| 117 SurfaceBinding::PerConnectionState::~PerConnectionState() { | 119 SurfaceBinding::PerConnectionState::~PerConnectionState() { |
| 118 ConnectionToStateMap* window_map = window_states.Pointer()->Get(); | 120 ConnectionToStateMap* window_map = window_states.Pointer()->Get(); |
| 119 DCHECK(window_map); | 121 DCHECK(window_map); |
| 120 DCHECK_EQ(this, (*window_map)[connection_]); | 122 DCHECK_EQ(this, (*window_map)[connection_]); |
| 121 window_map->erase(connection_); | 123 window_map->erase(connection_); |
| 122 if (window_map->empty()) { | 124 if (window_map->empty()) { |
| 123 delete window_map; | 125 delete window_map; |
| 124 window_states.Pointer()->Set(nullptr); | 126 window_states.Pointer()->Set(nullptr); |
| 125 } | 127 } |
| 126 } | 128 } |
| 127 | 129 |
| 128 void SurfaceBinding::PerConnectionState::Init() { | 130 void SurfaceBinding::PerConnectionState::Init() { |
| 129 connector_->ConnectToInterface("mojo:mus", &gpu_); | 131 connector_->ConnectToInterface("mojo:mus", &gpu_); |
| 132 gpu_.set_connection_error_handler([]{}); | |
|
sadrul
2016/05/18 20:00:19
rockot@: This seems to be necessary for the change
sky
2016/05/18 20:10:32
This seems like a bug in the bindings code.
Ken Rockot(use gerrit already)
2016/05/18 20:11:08
Because we lazily set up the internal proxy in Int
sadrul
2016/05/19 20:14:17
OK. Sounds like this is not entirely unexpected, t
sky
2016/05/19 20:59:42
Yes, go for it.
| |
| 130 } | 133 } |
| 131 | 134 |
| 132 // SurfaceBinding -------------------------------------------------------------- | 135 // SurfaceBinding -------------------------------------------------------------- |
| 133 | 136 |
| 134 SurfaceBinding::SurfaceBinding(shell::Connector* connector, | 137 SurfaceBinding::SurfaceBinding(shell::Connector* connector, |
| 135 mus::Window* window, | 138 mus::Window* window, |
| 136 mus::mojom::SurfaceType surface_type) | 139 mus::mojom::SurfaceType surface_type) |
| 137 : window_(window), | 140 : window_(window), |
| 138 surface_type_(surface_type), | 141 surface_type_(surface_type), |
| 139 state_(PerConnectionState::Get(connector, window->connection())) {} | 142 state_(PerConnectionState::Get(connector, window->connection())) {} |
| 140 | 143 |
| 141 SurfaceBinding::~SurfaceBinding() {} | 144 SurfaceBinding::~SurfaceBinding() {} |
| 142 | 145 |
| 143 std::unique_ptr<cc::OutputSurface> SurfaceBinding::CreateOutputSurface() { | 146 std::unique_ptr<cc::OutputSurface> SurfaceBinding::CreateOutputSurface() { |
| 144 return state_->CreateOutputSurface(window_, surface_type_); | 147 return state_->CreateOutputSurface(window_, surface_type_); |
| 145 } | 148 } |
| 146 | 149 |
| 147 } // namespace views | 150 } // namespace views |
| OLD | NEW |