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

Side by Side Diff: components/mus/demo/mus_demo.h

Issue 2005143002: Fix mus_demo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 #ifndef COMPONENTS_MUS_DEMO_MUS_DEMO_H_ 5 #ifndef COMPONENTS_MUS_DEMO_MUS_DEMO_H_
6 #define COMPONENTS_MUS_DEMO_MUS_DEMO_H_ 6 #define COMPONENTS_MUS_DEMO_MUS_DEMO_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
16 #include "components/mus/public/cpp/window.h" 16 #include "components/mus/public/cpp/window.h"
17 #include "components/mus/public/cpp/window_manager_delegate.h" 17 #include "components/mus/public/cpp/window_manager_delegate.h"
18 #include "components/mus/public/cpp/window_tree_delegate.h" 18 #include "components/mus/public/cpp/window_tree_delegate.h"
19 #include "components/mus/public/interfaces/window_tree_host.mojom.h" 19 #include "components/mus/public/interfaces/window_manager_factory.mojom.h"
20 #include "mojo/public/cpp/bindings/binding_set.h" 20 #include "mojo/public/cpp/bindings/binding_set.h"
21 #include "services/shell/public/cpp/connector.h" 21 #include "services/shell/public/cpp/connector.h"
22 #include "services/shell/public/cpp/shell_client.h" 22 #include "services/shell/public/cpp/shell_client.h"
23 #include "third_party/skia/include/core/SkBitmap.h" 23 #include "third_party/skia/include/core/SkBitmap.h"
24 24
25 namespace bitmap_uploader { 25 namespace bitmap_uploader {
26 class BitmapUploader; 26 class BitmapUploader;
27 } 27 }
28 28
29 namespace mus_demo { 29 namespace mus_demo {
30 30
31 // A simple MUS Demo mojo app. This app connects to the mojo:mus, creates a new 31 // A simple MUS Demo mojo app. This app connects to the mojo:mus, creates a new
32 // window and draws a spinning square in the center of the window. Provides a 32 // window and draws a spinning square in the center of the window. Provides a
33 // simple way to demonstrate that the graphic stack works as intended. 33 // simple way to demonstrate that the graphic stack works as intended.
34 class MusDemo : public shell::ShellClient, 34 class MusDemo : public shell::ShellClient,
35 public mus::mojom::WindowManagerFactory,
35 public mus::WindowTreeDelegate, 36 public mus::WindowTreeDelegate,
36 public mus::WindowManagerDelegate { 37 public mus::WindowManagerDelegate {
37 public: 38 public:
38 MusDemo(); 39 MusDemo();
39 ~MusDemo() override; 40 ~MusDemo() override;
40 41
41 private: 42 private:
42 // shell::ShellClient: 43 // shell::ShellClient:
43 void Initialize(shell::Connector* connector, 44 void Initialize(shell::Connector* connector,
44 const shell::Identity& identity, 45 const shell::Identity& identity,
45 uint32_t id) override; 46 uint32_t id) override;
46 bool AcceptConnection(shell::Connection* connection) override; 47 bool AcceptConnection(shell::Connection* connection) override;
47 48
48 // WindowTreeDelegate: 49 // WindowTreeDelegate:
49 void OnEmbed(mus::Window* root) override; 50 void OnEmbed(mus::Window* root) override;
50 void OnUnembed(mus::Window* root) override; 51 void OnUnembed(mus::Window* root) override;
51 void OnConnectionLost(mus::WindowTreeConnection* connection) override; 52 void OnConnectionLost(mus::WindowTreeConnection* connection) override;
52 void OnEventObserved(const ui::Event& event, mus::Window* target) override; 53 void OnEventObserved(const ui::Event& event, mus::Window* target) override;
53 54
55 // mus::mojom::WindowManagerFactory:
56 void CreateWindowManager(
57 mus::mojom::DisplayPtr display,
58 mus::mojom::WindowTreeClientRequest request) override;
59
54 // WindowManagerDelegate: 60 // WindowManagerDelegate:
55 void SetWindowManagerClient(mus::WindowManagerClient* client) override; 61 void SetWindowManagerClient(mus::WindowManagerClient* client) override;
56 bool OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) override; 62 bool OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) override;
57 bool OnWmSetProperty( 63 bool OnWmSetProperty(
58 mus::Window* window, 64 mus::Window* window,
59 const std::string& name, 65 const std::string& name,
60 std::unique_ptr<std::vector<uint8_t>>* new_data) override; 66 std::unique_ptr<std::vector<uint8_t>>* new_data) override;
61 mus::Window* OnWmCreateTopLevelWindow( 67 mus::Window* OnWmCreateTopLevelWindow(
62 std::map<std::string, std::vector<uint8_t>>* properties) override; 68 std::map<std::string, std::vector<uint8_t>>* properties) override;
63 void OnAccelerator(uint32_t id, const ui::Event& event) override; 69 void OnAccelerator(uint32_t id, const ui::Event& event) override;
64 70
65 // Allocate a bitmap the same size as the window to draw into. 71 // Allocate a bitmap the same size as the window to draw into.
66 void AllocBitmap(); 72 void AllocBitmap();
67 73
68 // Draws one frame, incrementing the rotation angle. 74 // Draws one frame, incrementing the rotation angle.
69 void DrawFrame(); 75 void DrawFrame();
70 76
71 shell::Connector* connector_ = nullptr; 77 shell::Connector* connector_ = nullptr;
72 78
73 mus::Window* window_ = nullptr; 79 mus::Window* window_ = nullptr;
74 mus::mojom::WindowTreeHostPtr window_tree_host_; 80 // mus::mojom::WindowTreeHostPtr window_tree_host_;
kylechar 2016/05/24 14:38:42 Remove commented out code.
rjkroege 2016/05/24 18:05:15 Done.
81 std::unique_ptr<mus::WindowTreeConnection> window_tree_connection_;
82 mus::WindowManagerClient* window_manager_client_ = nullptr;
83 mojo::Binding<mus::mojom::WindowManagerFactory>
84 window_manager_factory_binding_;
75 85
76 // Used to send frames to mus. 86 // Used to send frames to mus.
77 std::unique_ptr<bitmap_uploader::BitmapUploader> uploader_; 87 std::unique_ptr<bitmap_uploader::BitmapUploader> uploader_;
78 88
79 // Bitmap that is the same size as our client window area. 89 // Bitmap that is the same size as our client window area.
80 SkBitmap bitmap_; 90 SkBitmap bitmap_;
81 91
82 // Timer for calling DrawFrame(). 92 // Timer for calling DrawFrame().
83 base::RepeatingTimer timer_; 93 base::RepeatingTimer timer_;
84 94
85 // Current rotation angle for drawing. 95 // Current rotation angle for drawing.
86 double angle_ = 0.0; 96 double angle_ = 0.0;
87 97
88 DISALLOW_COPY_AND_ASSIGN(MusDemo); 98 DISALLOW_COPY_AND_ASSIGN(MusDemo);
89 }; 99 };
90 100
91 } // namespace mus_demo 101 } // namespace mus_demo
92 102
93 #endif // COMPONENTS_MUS_DEMO_MUS_DEMO_H_ 103 #endif // COMPONENTS_MUS_DEMO_MUS_DEMO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698