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

Side by Side Diff: mojo/examples/aura_demo/root_window_host_mojo.cc

Issue 120503003: run aura_demo as a mojo app (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "mojo/examples/aura_demo/root_window_host_mojo.h"
6
7 #include "mojo/examples/aura_demo/demo_context_factory.h"
8 #include "mojo/examples/compositor_app/gles2_client_impl.h"
9 #include "mojo/public/gles2/gles2.h"
10 #include "ui/aura/env.h"
11 #include "ui/aura/window.h"
12 #include "ui/aura/window_tree_host_delegate.h"
13 #include "ui/compositor/compositor.h"
14 #include "ui/gfx/geometry/insets.h"
15 #include "ui/gfx/geometry/rect.h"
16
17 namespace mojo {
18 namespace examples {
19
20 // static
21 ui::ContextFactory* RootWindowHostMojo::context_factory_ = NULL;
22
23 ////////////////////////////////////////////////////////////////////////////////
24 // RootWindowHostMojo, public:
25
26 RootWindowHostMojo::RootWindowHostMojo(
27 ScopedMessagePipeHandle viewport_handle,
28 const base::Callback<void()>& compositor_created_callback)
29 : native_viewport_(viewport_handle.Pass()),
30 compositor_created_callback_(compositor_created_callback) {
31 native_viewport_.SetPeer(this);
32 native_viewport_->Open();
33
34 ScopedMessagePipeHandle gles2_handle;
35 ScopedMessagePipeHandle gles2_client_handle;
36 CreateMessagePipe(&gles2_handle, &gles2_client_handle);
37
38 // The ContextFactory must exist before any Compositors are created.
39 if (!context_factory_) {
40 scoped_ptr<DemoContextFactory> cf(new DemoContextFactory(this));
41 if (cf->Initialize())
42 context_factory_ = cf.release();
43 ui::ContextFactory::SetInstance(context_factory_);
44 }
45 CHECK(context_factory_) << "No GL bindings.";
46
47 gles2_client_.reset(new GLES2ClientImpl(
48 gles2_handle.Pass(),
49 base::Bind(&RootWindowHostMojo::DidCreateContext,
50 base::Unretained(this))));
51 native_viewport_->CreateGLES2Context(gles2_client_handle.Pass());
52 }
53
54 RootWindowHostMojo::~RootWindowHostMojo() {}
55
56 ////////////////////////////////////////////////////////////////////////////////
57 // RootWindowHostMojo, aura::RootWindowHost implementation:
58
59 aura::RootWindow* RootWindowHostMojo::GetRootWindow() {
60 return delegate_->AsRootWindow();
61 }
62
63 gfx::AcceleratedWidget RootWindowHostMojo::GetAcceleratedWidget() {
64 NOTIMPLEMENTED();
65 return gfx::kNullAcceleratedWidget;
66 }
67
68 void RootWindowHostMojo::Show() {
69 NOTIMPLEMENTED();
70 }
71
72 void RootWindowHostMojo::Hide() {
73 NOTIMPLEMENTED();
74 }
75
76 void RootWindowHostMojo::ToggleFullScreen() {
77 NOTIMPLEMENTED();
78 }
79
80 gfx::Rect RootWindowHostMojo::GetBounds() const {
81 NOTIMPLEMENTED();
82 return gfx::Rect(500, 500);
83 }
84
85 void RootWindowHostMojo::SetBounds(const gfx::Rect& bounds) {
86 NOTIMPLEMENTED();
87 }
88
89 gfx::Insets RootWindowHostMojo::GetInsets() const {
90 NOTIMPLEMENTED();
91 return gfx::Insets();
92 }
93
94 void RootWindowHostMojo::SetInsets(const gfx::Insets& insets) {
95 NOTIMPLEMENTED();
96 }
97
98 gfx::Point RootWindowHostMojo::GetLocationOnNativeScreen() const {
99 return gfx::Point(0, 0);
100 }
101
102 void RootWindowHostMojo::SetCapture() {
103 NOTIMPLEMENTED();
104 }
105
106 void RootWindowHostMojo::ReleaseCapture() {
107 NOTIMPLEMENTED();
108 }
109
110 void RootWindowHostMojo::SetCursor(gfx::NativeCursor cursor) {
111 NOTIMPLEMENTED();
112 }
113
114 bool RootWindowHostMojo::QueryMouseLocation(gfx::Point* location_return) {
115 NOTIMPLEMENTED();
116 return false;
117 }
118
119 bool RootWindowHostMojo::ConfineCursorToRootWindow() {
120 NOTIMPLEMENTED();
121 return false;
122 }
123
124 void RootWindowHostMojo::UnConfineCursor() {
125 NOTIMPLEMENTED();
126 }
127
128 void RootWindowHostMojo::OnCursorVisibilityChanged(bool show) {
129 NOTIMPLEMENTED();
130 }
131
132 void RootWindowHostMojo::MoveCursorTo(const gfx::Point& location) {
133 NOTIMPLEMENTED();
134 }
135
136 void RootWindowHostMojo::PostNativeEvent(
137 const base::NativeEvent& native_event) {
138 NOTIMPLEMENTED();
139 }
140
141 void RootWindowHostMojo::OnDeviceScaleFactorChanged(float device_scale_factor) {
142 NOTIMPLEMENTED();
143 }
144
145 void RootWindowHostMojo::PrepareForShutdown() {
146 NOTIMPLEMENTED();
147 }
148
149 ////////////////////////////////////////////////////////////////////////////////
150 // RootWindowHostMojo, NativeViewportClientStub implementation:
151
152 void RootWindowHostMojo::OnCreated() {
153 }
154
155 void RootWindowHostMojo::OnDestroyed() {
156 base::MessageLoop::current()->Quit();
157 }
158
159 void RootWindowHostMojo::OnEvent(const Event& event) {
160 if (!event.location().is_null())
161 native_viewport_->AckEvent(event);
162
163 // TODO(beng): fwd to rootwindow.
164 };
165
166 ////////////////////////////////////////////////////////////////////////////////
167 // RootWindowHostMojo, private:
168
169 void RootWindowHostMojo::DidCreateContext(gfx::Size viewport_size) {
170 CreateCompositor(GetAcceleratedWidget());
171 compositor_created_callback_.Run();
172 NotifyHostResized(viewport_size);
173 }
174
175 } // namespace examples
176 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/examples/aura_demo/root_window_host_mojo.h ('k') | mojo/examples/compositor_app/gles2_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698