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

Side by Side Diff: mandoline/ui/aura/surface_binding.cc

Issue 1340983002: Mandoline UI Process: Update namespaces and file names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 3 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 | « mandoline/ui/aura/surface_binding.h ('k') | mandoline/ui/aura/surface_context_factory.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 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 "mandoline/ui/aura/surface_binding.h" 5 #include "mandoline/ui/aura/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 24 matching lines...) Expand all
35 35
36 // State needed per ViewManager. Provides the real implementation of 36 // State needed per ViewManager. Provides the real implementation of
37 // CreateOutputSurface. SurfaceBinding obtains a pointer to the 37 // CreateOutputSurface. SurfaceBinding obtains a pointer to the
38 // PerConnectionState appropriate for the ViewManager. PerConnectionState is 38 // PerConnectionState appropriate for the ViewManager. PerConnectionState is
39 // stored in a thread local map. When no more refereces to a PerConnectionState 39 // stored in a thread local map. When no more refereces to a PerConnectionState
40 // remain the PerConnectionState is deleted and the underlying map cleaned up. 40 // remain the PerConnectionState is deleted and the underlying map cleaned up.
41 class SurfaceBinding::PerConnectionState 41 class SurfaceBinding::PerConnectionState
42 : public base::RefCounted<PerConnectionState> { 42 : public base::RefCounted<PerConnectionState> {
43 public: 43 public:
44 static PerConnectionState* Get(mojo::Shell* shell, 44 static PerConnectionState* Get(mojo::Shell* shell,
45 mojo::ViewTreeConnection* connection); 45 mus::ViewTreeConnection* connection);
46 46
47 scoped_ptr<cc::OutputSurface> CreateOutputSurface(mojo::View* view); 47 scoped_ptr<cc::OutputSurface> CreateOutputSurface(mus::View* view);
48 48
49 private: 49 private:
50 typedef std::map<mojo::ViewTreeConnection*, 50 typedef std::map<mus::ViewTreeConnection*, PerConnectionState*>
51 PerConnectionState*> ConnectionToStateMap; 51 ConnectionToStateMap;
52 52
53 friend class base::RefCounted<PerConnectionState>; 53 friend class base::RefCounted<PerConnectionState>;
54 54
55 PerConnectionState(mojo::Shell* shell, mojo::ViewTreeConnection* connection); 55 PerConnectionState(mojo::Shell* shell, mus::ViewTreeConnection* connection);
56 ~PerConnectionState(); 56 ~PerConnectionState();
57 57
58 void Init(); 58 void Init();
59 59
60 static base::LazyInstance< 60 static base::LazyInstance<
61 base::ThreadLocalPointer<ConnectionToStateMap>>::Leaky view_states; 61 base::ThreadLocalPointer<ConnectionToStateMap>>::Leaky view_states;
62 62
63 mojo::Shell* shell_; 63 mojo::Shell* shell_;
64 mojo::ViewTreeConnection* connection_; 64 mus::ViewTreeConnection* 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 mojo::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::view_states; 75 SurfaceBinding::PerConnectionState::view_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 mojo::ViewTreeConnection* connection) { 80 mus::ViewTreeConnection* connection) {
81 ConnectionToStateMap* view_map = view_states.Pointer()->Get(); 81 ConnectionToStateMap* view_map = view_states.Pointer()->Get();
82 if (!view_map) { 82 if (!view_map) {
83 view_map = new ConnectionToStateMap; 83 view_map = new ConnectionToStateMap;
84 view_states.Pointer()->Set(view_map); 84 view_states.Pointer()->Set(view_map);
85 } 85 }
86 if (!(*view_map)[connection]) { 86 if (!(*view_map)[connection]) {
87 (*view_map)[connection] = new PerConnectionState(shell, connection); 87 (*view_map)[connection] = new PerConnectionState(shell, connection);
88 (*view_map)[connection]->Init(); 88 (*view_map)[connection]->Init();
89 } 89 }
90 return (*view_map)[connection]; 90 return (*view_map)[connection];
91 } 91 }
92 92
93 scoped_ptr<cc::OutputSurface> 93 scoped_ptr<cc::OutputSurface>
94 SurfaceBinding::PerConnectionState::CreateOutputSurface(mojo::View* view) { 94 SurfaceBinding::PerConnectionState::CreateOutputSurface(mus::View* view) {
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 mojo::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 mojo::ContextProviderMojo(cb.PassInterface().PassHandle())); 101 new mojo::ContextProviderMojo(cb.PassInterface().PassHandle()));
102 return make_scoped_ptr( 102 return make_scoped_ptr(
103 new mojo::OutputSurfaceMojo(context_provider, view->RequestSurface())); 103 new mojo::OutputSurfaceMojo(context_provider, view->RequestSurface()));
104 } 104 }
105 105
106 SurfaceBinding::PerConnectionState::PerConnectionState( 106 SurfaceBinding::PerConnectionState::PerConnectionState(
107 mojo::Shell* shell, 107 mojo::Shell* shell,
108 mojo::ViewTreeConnection* connection) 108 mus::ViewTreeConnection* connection)
109 : shell_(shell) { 109 : shell_(shell) {}
110 }
111 110
112 SurfaceBinding::PerConnectionState::~PerConnectionState() { 111 SurfaceBinding::PerConnectionState::~PerConnectionState() {
113 ConnectionToStateMap* view_map = view_states.Pointer()->Get(); 112 ConnectionToStateMap* view_map = view_states.Pointer()->Get();
114 DCHECK(view_map); 113 DCHECK(view_map);
115 DCHECK_EQ(this, (*view_map)[connection_]); 114 DCHECK_EQ(this, (*view_map)[connection_]);
116 view_map->erase(connection_); 115 view_map->erase(connection_);
117 if (view_map->empty()) { 116 if (view_map->empty()) {
118 delete view_map; 117 delete view_map;
119 view_states.Pointer()->Set(nullptr); 118 view_states.Pointer()->Set(nullptr);
120 } 119 }
121 } 120 }
122 121
123 void SurfaceBinding::PerConnectionState::Init() { 122 void SurfaceBinding::PerConnectionState::Init() {
124 mojo::ServiceProviderPtr service_provider; 123 mojo::ServiceProviderPtr service_provider;
125 mojo::URLRequestPtr request(mojo::URLRequest::New()); 124 mojo::URLRequestPtr request(mojo::URLRequest::New());
126 request->url = mojo::String::From("mojo:mus"); 125 request->url = mojo::String::From("mojo:mus");
127 shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), 126 shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider),
128 nullptr, nullptr, 127 nullptr, nullptr,
129 base::Bind(&OnGotContentHandlerID)); 128 base::Bind(&OnGotContentHandlerID));
130 ConnectToService(service_provider.get(), &gpu_); 129 ConnectToService(service_provider.get(), &gpu_);
131 } 130 }
132 131
133 // SurfaceBinding -------------------------------------------------------------- 132 // SurfaceBinding --------------------------------------------------------------
134 133
135 SurfaceBinding::SurfaceBinding(mojo::Shell* shell, mojo::View* view) 134 SurfaceBinding::SurfaceBinding(mojo::Shell* shell, mus::View* view)
136 : view_(view), 135 : view_(view), state_(PerConnectionState::Get(shell, view->connection())) {}
137 state_(PerConnectionState::Get(shell, view->connection())) {
138 }
139 136
140 SurfaceBinding::~SurfaceBinding() { 137 SurfaceBinding::~SurfaceBinding() {
141 } 138 }
142 139
143 scoped_ptr<cc::OutputSurface> SurfaceBinding::CreateOutputSurface() { 140 scoped_ptr<cc::OutputSurface> SurfaceBinding::CreateOutputSurface() {
144 return state_->CreateOutputSurface(view_); 141 return state_->CreateOutputSurface(view_);
145 } 142 }
146 143
147 } // namespace mandoline 144 } // namespace mandoline
OLDNEW
« no previous file with comments | « mandoline/ui/aura/surface_binding.h ('k') | mandoline/ui/aura/surface_context_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698