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

Side by Side Diff: ui/views/mus/surface_binding.cc

Issue 1406153004: components/mus/public/interfaces View => Window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Yet another rebase Created 5 years, 2 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 | « mojo/gles2/command_buffer_client_impl.cc ('k') | ui/views/mus/window_manager_connection.cc » ('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 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 <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 void Init(); 58 void Init();
59 59
60 static base::LazyInstance< 60 static base::LazyInstance<
61 base::ThreadLocalPointer<ConnectionToStateMap>>::Leaky window_states; 61 base::ThreadLocalPointer<ConnectionToStateMap>>::Leaky window_states;
62 62
63 mojo::Shell* shell_; 63 mojo::Shell* shell_;
64 mus::WindowTreeConnection* connection_; 64 mus::WindowTreeConnection* connection_;
65 65
66 // Set of state needed to create an OutputSurface. 66 // Set of state needed to create an OutputSurface.
67 mojo::GpuPtr gpu_; 67 mus::mojom::GpuPtr gpu_;
68 68
69 DISALLOW_COPY_AND_ASSIGN(PerConnectionState); 69 DISALLOW_COPY_AND_ASSIGN(PerConnectionState);
70 }; 70 };
71 71
72 // static 72 // static
73 base::LazyInstance<base::ThreadLocalPointer< 73 base::LazyInstance<base::ThreadLocalPointer<
74 SurfaceBinding::PerConnectionState::ConnectionToStateMap>>::Leaky 74 SurfaceBinding::PerConnectionState::ConnectionToStateMap>>::Leaky
75 SurfaceBinding::PerConnectionState::window_states; 75 SurfaceBinding::PerConnectionState::window_states;
76 76
77 // static 77 // static
78 SurfaceBinding::PerConnectionState* SurfaceBinding::PerConnectionState::Get( 78 SurfaceBinding::PerConnectionState* SurfaceBinding::PerConnectionState::Get(
79 mojo::Shell* shell, 79 mojo::Shell* shell,
80 mus::WindowTreeConnection* connection) { 80 mus::WindowTreeConnection* connection) {
81 ConnectionToStateMap* window_map = window_states.Pointer()->Get(); 81 ConnectionToStateMap* window_map = window_states.Pointer()->Get();
82 if (!window_map) { 82 if (!window_map) {
83 window_map = new ConnectionToStateMap; 83 window_map = new ConnectionToStateMap;
84 window_states.Pointer()->Set(window_map); 84 window_states.Pointer()->Set(window_map);
85 } 85 }
86 if (!(*window_map)[connection]) { 86 if (!(*window_map)[connection]) {
87 (*window_map)[connection] = new PerConnectionState(shell, connection); 87 (*window_map)[connection] = new PerConnectionState(shell, connection);
88 (*window_map)[connection]->Init(); 88 (*window_map)[connection]->Init();
89 } 89 }
90 return (*window_map)[connection]; 90 return (*window_map)[connection];
91 } 91 }
92 92
93 scoped_ptr<cc::OutputSurface> 93 scoped_ptr<cc::OutputSurface>
94 SurfaceBinding::PerConnectionState::CreateOutputSurface(mus::Window* window) { 94 SurfaceBinding::PerConnectionState::CreateOutputSurface(mus::Window* window) {
95 // TODO(sky): figure out lifetime here. Do I need to worry about the return 95 // TODO(sky): figure out lifetime here. Do I need to worry about the return
96 // value outliving this? 96 // value outliving this?
97 mojo::CommandBufferPtr cb; 97 mus::mojom::CommandBufferPtr cb;
98 gpu_->CreateOffscreenGLES2Context(GetProxy(&cb)); 98 gpu_->CreateOffscreenGLES2Context(GetProxy(&cb));
99 99
100 scoped_refptr<cc::ContextProvider> context_provider( 100 scoped_refptr<cc::ContextProvider> context_provider(
101 new mus::ContextProvider(cb.PassInterface().PassHandle())); 101 new mus::ContextProvider(cb.PassInterface().PassHandle()));
102 return make_scoped_ptr( 102 return make_scoped_ptr(
103 new mus::OutputSurface(context_provider, window->RequestSurface())); 103 new mus::OutputSurface(context_provider, window->RequestSurface()));
104 } 104 }
105 105
106 SurfaceBinding::PerConnectionState::PerConnectionState( 106 SurfaceBinding::PerConnectionState::PerConnectionState(
107 mojo::Shell* shell, 107 mojo::Shell* shell,
(...skipping 27 matching lines...) Expand all
135 : window_(window), 135 : window_(window),
136 state_(PerConnectionState::Get(shell, window->connection())) {} 136 state_(PerConnectionState::Get(shell, window->connection())) {}
137 137
138 SurfaceBinding::~SurfaceBinding() {} 138 SurfaceBinding::~SurfaceBinding() {}
139 139
140 scoped_ptr<cc::OutputSurface> SurfaceBinding::CreateOutputSurface() { 140 scoped_ptr<cc::OutputSurface> SurfaceBinding::CreateOutputSurface() {
141 return state_->CreateOutputSurface(window_); 141 return state_->CreateOutputSurface(window_);
142 } 142 }
143 143
144 } // namespace views 144 } // namespace views
OLDNEW
« no previous file with comments | « mojo/gles2/command_buffer_client_impl.cc ('k') | ui/views/mus/window_manager_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698