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

Side by Side Diff: services/ui/demo/mus_demo.cc

Issue 2693923004: Mus Demo: Extract code specific to internal mode into a separate class (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "services/ui/demo/mus_demo.h" 5 #include "services/ui/demo/mus_demo.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "services/service_manager/public/cpp/connector.h" 9 #include "services/service_manager/public/cpp/connector.h"
10 #include "services/service_manager/public/cpp/service_context.h"
11 #include "services/ui/public/cpp/gpu/gpu.h" 10 #include "services/ui/public/cpp/gpu/gpu.h"
12 #include "third_party/skia/include/core/SkBitmap.h" 11 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "third_party/skia/include/core/SkCanvas.h" 12 #include "third_party/skia/include/core/SkCanvas.h"
14 #include "third_party/skia/include/core/SkColor.h" 13 #include "third_party/skia/include/core/SkColor.h"
15 #include "third_party/skia/include/core/SkImageInfo.h" 14 #include "third_party/skia/include/core/SkImageInfo.h"
16 #include "third_party/skia/include/core/SkPaint.h" 15 #include "third_party/skia/include/core/SkPaint.h"
17 #include "third_party/skia/include/core/SkRect.h" 16 #include "third_party/skia/include/core/SkRect.h"
18 #include "ui/aura/client/default_capture_client.h" 17 #include "ui/aura/client/default_capture_client.h"
19 #include "ui/aura/env.h" 18 #include "ui/aura/env.h"
20 #include "ui/aura/mus/property_converter.h" 19 #include "ui/aura/mus/property_converter.h"
21 #include "ui/aura/mus/window_tree_client.h" 20 #include "ui/aura/mus/window_tree_client.h"
22 #include "ui/aura/mus/window_tree_host_mus.h" 21 #include "ui/aura/mus/window_tree_host_mus.h"
23 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
24 #include "ui/aura_extra/image_window_delegate.h" 23 #include "ui/aura_extra/image_window_delegate.h"
25 #include "ui/gfx/geometry/rect.h" 24 #include "ui/gfx/geometry/rect.h"
26 #include "ui/gfx/image/image.h" 25 #include "ui/gfx/image/image.h"
27 #include "ui/wm/core/wm_state.h" 26 #include "ui/wm/core/wm_state.h"
28 27
29 namespace ui { 28 namespace ui {
30 namespace demo { 29 namespace demo {
31 30
32 namespace { 31 namespace {
33 32
34 // Milliseconds between frames. 33 // Milliseconds between frames.
35 const int64_t kFrameDelay = 33; 34 const int64_t kFrameDelay = 33;
36 35
37 // Size of square in pixels to draw.
38 const int kSquareSize = 300;
39
40 const SkColor kBgColor = SK_ColorRED; 36 const SkColor kBgColor = SK_ColorRED;
41 const SkColor kFgColor = SK_ColorYELLOW; 37 const SkColor kFgColor = SK_ColorYELLOW;
42 38
43 void DrawSquare(const gfx::Rect& bounds, 39 void DrawSquare(const gfx::Rect& bounds,
44 double angle, 40 double angle,
45 SkCanvas* canvas, 41 SkCanvas* canvas,
46 int size) { 42 int size) {
47 // Create SkRect to draw centered inside the bounds. 43 // Create SkRect to draw centered inside the bounds.
48 gfx::Point top_left = bounds.CenterPoint(); 44 gfx::Point top_left = bounds.CenterPoint();
49 top_left.Offset(-size / 2, -size / 2); 45 top_left.Offset(-size / 2, -size / 2);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 138
143 void MusDemo::OnStart() { 139 void MusDemo::OnStart() {
144 screen_ = base::MakeUnique<display::ScreenBase>(); 140 screen_ = base::MakeUnique<display::ScreenBase>();
145 display::Screen::SetScreenInstance(screen_.get()); 141 display::Screen::SetScreenInstance(screen_.get());
146 142
147 env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS); 143 env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS);
148 capture_client_ = base::MakeUnique<aura::client::DefaultCaptureClient>(); 144 capture_client_ = base::MakeUnique<aura::client::DefaultCaptureClient>();
149 property_converter_ = base::MakeUnique<aura::PropertyConverter>(); 145 property_converter_ = base::MakeUnique<aura::PropertyConverter>();
150 wm_state_ = base::MakeUnique<::wm::WMState>(); 146 wm_state_ = base::MakeUnique<::wm::WMState>();
151 147
152 window_tree_client_ = base::MakeUnique<aura::WindowTreeClient>( 148 OnStartImpl();
153 context()->connector(), this, this);
154 window_tree_client_->ConnectAsWindowManager();
155 149
156 env_->SetWindowTreeClient(window_tree_client_.get()); 150 env_->SetWindowTreeClient(window_tree_client_.get());
157 } 151 }
158 152
159 bool MusDemo::OnConnect(const service_manager::ServiceInfo& remote_info, 153 bool MusDemo::OnConnect(const service_manager::ServiceInfo& remote_info,
160 service_manager::InterfaceRegistry* registry) { 154 service_manager::InterfaceRegistry* registry) {
161 return true; 155 return true;
162 } 156 }
163 157
164 void MusDemo::OnEmbed( 158 void MusDemo::OnEmbed(
165 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { 159 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) {
166 // Not called for the WindowManager.
167 NOTREACHED(); 160 NOTREACHED();
168 } 161 }
169 162
170 void MusDemo::OnUnembed(aura::Window* root) { 163 void MusDemo::OnUnembed(aura::Window* root) {
171 NOTREACHED(); 164 NOTREACHED();
172 } 165 }
173 166
174 void MusDemo::OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) { 167 void MusDemo::OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) {
175 // Not called for the WindowManager.
176 NOTREACHED(); 168 NOTREACHED();
177 } 169 }
178 170
179 void MusDemo::OnLostConnection(aura::WindowTreeClient* client) { 171 void MusDemo::OnLostConnection(aura::WindowTreeClient* client) {
180 window_tree_client_.reset(); 172 window_tree_client_.reset();
181 window_tree_data_.reset(); 173 window_tree_data_.reset();
182 } 174 }
183 175
184 void MusDemo::OnPointerEventObserved(const PointerEvent& event, 176 void MusDemo::OnPointerEventObserved(const PointerEvent& event,
185 aura::Window* target) {} 177 aura::Window* target) {}
186 178
187 aura::PropertyConverter* MusDemo::GetPropertyConverter() { 179 aura::PropertyConverter* MusDemo::GetPropertyConverter() {
188 return property_converter_.get(); 180 return property_converter_.get();
189 } 181 }
190 182
191 void MusDemo::SetWindowManagerClient(aura::WindowManagerClient* client) {}
192
193 bool MusDemo::OnWmSetBounds(aura::Window* window, gfx::Rect* bounds) {
194 return true;
195 }
196
197 bool MusDemo::OnWmSetProperty(aura::Window* window,
198 const std::string& name,
199 std::unique_ptr<std::vector<uint8_t>>* new_data) {
200 return true;
201 }
202
203 void MusDemo::OnWmSetCanFocus(aura::Window* window, bool can_focus) {}
204
205 aura::Window* MusDemo::OnWmCreateTopLevelWindow(
206 mojom::WindowType window_type,
207 std::map<std::string, std::vector<uint8_t>>* properties) {
208 NOTREACHED();
209 return nullptr;
210 }
211
212 void MusDemo::OnWmClientJankinessChanged(
213 const std::set<aura::Window*>& client_windows,
214 bool janky) {
215 // Don't care
216 }
217
218 void MusDemo::OnWmWillCreateDisplay(const display::Display& display) {
219 screen_->display_list().AddDisplay(display,
220 display::DisplayList::Type::PRIMARY);
221 }
222
223 void MusDemo::OnWmNewDisplay(
224 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host,
225 const display::Display& display) {
226 DCHECK(!window_tree_data_); // Only support one display.
227 window_tree_data_ = base::MakeUnique<WindowTreeData>(
228 std::move(window_tree_host), kSquareSize);
229 }
230
231 void MusDemo::OnWmDisplayRemoved(aura::WindowTreeHostMus* window_tree_host) {
232 window_tree_data_.reset();
233 }
234
235 void MusDemo::OnWmDisplayModified(const display::Display& display) {}
236
237 mojom::EventResult MusDemo::OnAccelerator(uint32_t id, const Event& event) {
238 return mojom::EventResult::UNHANDLED;
239 }
240
241 void MusDemo::OnWmPerformMoveLoop(aura::Window* window,
242 mojom::MoveLoopSource source,
243 const gfx::Point& cursor_location,
244 const base::Callback<void(bool)>& on_done) {
245 // Don't care
246 }
247
248 void MusDemo::OnWmCancelMoveLoop(aura::Window* window) {}
249
250 void MusDemo::OnWmSetClientArea(
251 aura::Window* window,
252 const gfx::Insets& insets,
253 const std::vector<gfx::Rect>& additional_client_areas) {}
254
255 bool MusDemo::IsWindowActive(aura::Window* window) { return false; }
256
257 void MusDemo::OnWmDeactivateWindow(aura::Window* window) {}
258
259 } // namespace demo 183 } // namespace demo
260 } // namespace aura 184 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698