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

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

Issue 1351013002: Revert of Mandoline UI Process: Update namespaces and file names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 mus::ViewTreeConnection* connection); 45 mojo::ViewTreeConnection* connection);
46 46
47 scoped_ptr<cc::OutputSurface> CreateOutputSurface(mus::View* view); 47 scoped_ptr<cc::OutputSurface> CreateOutputSurface(mojo::View* view);
48 48
49 private: 49 private:
50 typedef std::map<mus::ViewTreeConnection*, PerConnectionState*> 50 typedef std::map<mojo::ViewTreeConnection*,
51 ConnectionToStateMap; 51 PerConnectionState*> ConnectionToStateMap;
52 52
53 friend class base::RefCounted<PerConnectionState>; 53 friend class base::RefCounted<PerConnectionState>;
54 54
55 PerConnectionState(mojo::Shell* shell, mus::ViewTreeConnection* connection); 55 PerConnectionState(mojo::Shell* shell, mojo::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 mus::ViewTreeConnection* connection_; 64 mojo::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 mus::ViewTreeConnection* connection) { 80 mojo::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(mus::View* view) { 94 SurfaceBinding::PerConnectionState::CreateOutputSurface(mojo::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 mus::ViewTreeConnection* connection) 108 mojo::ViewTreeConnection* connection)
109 : shell_(shell) {} 109 : shell_(shell) {
110 }
110 111
111 SurfaceBinding::PerConnectionState::~PerConnectionState() { 112 SurfaceBinding::PerConnectionState::~PerConnectionState() {
112 ConnectionToStateMap* view_map = view_states.Pointer()->Get(); 113 ConnectionToStateMap* view_map = view_states.Pointer()->Get();
113 DCHECK(view_map); 114 DCHECK(view_map);
114 DCHECK_EQ(this, (*view_map)[connection_]); 115 DCHECK_EQ(this, (*view_map)[connection_]);
115 view_map->erase(connection_); 116 view_map->erase(connection_);
116 if (view_map->empty()) { 117 if (view_map->empty()) {
117 delete view_map; 118 delete view_map;
118 view_states.Pointer()->Set(nullptr); 119 view_states.Pointer()->Set(nullptr);
119 } 120 }
120 } 121 }
121 122
122 void SurfaceBinding::PerConnectionState::Init() { 123 void SurfaceBinding::PerConnectionState::Init() {
123 mojo::ServiceProviderPtr service_provider; 124 mojo::ServiceProviderPtr service_provider;
124 mojo::URLRequestPtr request(mojo::URLRequest::New()); 125 mojo::URLRequestPtr request(mojo::URLRequest::New());
125 request->url = mojo::String::From("mojo:mus"); 126 request->url = mojo::String::From("mojo:mus");
126 shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), 127 shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider),
127 nullptr, nullptr, 128 nullptr, nullptr,
128 base::Bind(&OnGotContentHandlerID)); 129 base::Bind(&OnGotContentHandlerID));
129 ConnectToService(service_provider.get(), &gpu_); 130 ConnectToService(service_provider.get(), &gpu_);
130 } 131 }
131 132
132 // SurfaceBinding -------------------------------------------------------------- 133 // SurfaceBinding --------------------------------------------------------------
133 134
134 SurfaceBinding::SurfaceBinding(mojo::Shell* shell, mus::View* view) 135 SurfaceBinding::SurfaceBinding(mojo::Shell* shell, mojo::View* view)
135 : view_(view), state_(PerConnectionState::Get(shell, view->connection())) {} 136 : view_(view),
137 state_(PerConnectionState::Get(shell, view->connection())) {
138 }
136 139
137 SurfaceBinding::~SurfaceBinding() { 140 SurfaceBinding::~SurfaceBinding() {
138 } 141 }
139 142
140 scoped_ptr<cc::OutputSurface> SurfaceBinding::CreateOutputSurface() { 143 scoped_ptr<cc::OutputSurface> SurfaceBinding::CreateOutputSurface() {
141 return state_->CreateOutputSurface(view_); 144 return state_->CreateOutputSurface(view_);
142 } 145 }
143 146
144 } // namespace mandoline 147 } // 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