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

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

Issue 2018823002: Eliminate WindowTreeConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@connection
Patch Set: . Created 4 years, 6 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 | « no previous file | components/mus/demo/mus_demo.cc » ('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 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_client_delegate.h"
19 #include "components/mus/public/interfaces/window_manager_factory.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::mojom::WindowManagerFactory,
36 public mus::WindowTreeDelegate, 36 public mus::WindowTreeClientDelegate,
37 public mus::WindowManagerDelegate { 37 public mus::WindowManagerDelegate {
38 public: 38 public:
39 MusDemo(); 39 MusDemo();
40 ~MusDemo() override; 40 ~MusDemo() override;
41 41
42 private: 42 private:
43 // shell::ShellClient: 43 // shell::ShellClient:
44 void Initialize(shell::Connector* connector, 44 void Initialize(shell::Connector* connector,
45 const shell::Identity& identity, 45 const shell::Identity& identity,
46 uint32_t id) override; 46 uint32_t id) override;
47 bool AcceptConnection(shell::Connection* connection) override; 47 bool AcceptConnection(shell::Connection* connection) override;
48 48
49 // WindowTreeDelegate: 49 // WindowTreeClientDelegate:
50 void OnEmbed(mus::Window* root) override; 50 void OnEmbed(mus::Window* root) override;
51 void OnUnembed(mus::Window* root) override; 51 void OnUnembed(mus::Window* root) override;
52 void OnConnectionLost(mus::WindowTreeConnection* connection) override; 52 void OnWindowTreeClientDestroyed(mus::WindowTreeClient* client) override;
53 void OnEventObserved(const ui::Event& event, mus::Window* target) override; 53 void OnEventObserved(const ui::Event& event, mus::Window* target) override;
54 54
55 // mus::mojom::WindowManagerFactory: 55 // mus::mojom::WindowManagerFactory:
56 void CreateWindowManager( 56 void CreateWindowManager(
57 mus::mojom::DisplayPtr display, 57 mus::mojom::DisplayPtr display,
58 mus::mojom::WindowTreeClientRequest request) override; 58 mus::mojom::WindowTreeClientRequest request) override;
59 59
60 // WindowManagerDelegate: 60 // WindowManagerDelegate:
61 void SetWindowManagerClient(mus::WindowManagerClient* client) override; 61 void SetWindowManagerClient(mus::WindowManagerClient* client) override;
62 bool OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) override; 62 bool OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) override;
63 bool OnWmSetProperty( 63 bool OnWmSetProperty(
64 mus::Window* window, 64 mus::Window* window,
65 const std::string& name, 65 const std::string& name,
66 std::unique_ptr<std::vector<uint8_t>>* new_data) override; 66 std::unique_ptr<std::vector<uint8_t>>* new_data) override;
67 mus::Window* OnWmCreateTopLevelWindow( 67 mus::Window* OnWmCreateTopLevelWindow(
68 std::map<std::string, std::vector<uint8_t>>* properties) override; 68 std::map<std::string, std::vector<uint8_t>>* properties) override;
69 void OnWmClientJankinessChanged(const std::set<mus::Window*>& client_windows, 69 void OnWmClientJankinessChanged(const std::set<mus::Window*>& client_windows,
70 bool janky) override; 70 bool janky) override;
71 void OnAccelerator(uint32_t id, const ui::Event& event) override; 71 void OnAccelerator(uint32_t id, const ui::Event& event) override;
72 72
73 // Allocate a bitmap the same size as the window to draw into. 73 // Allocate a bitmap the same size as the window to draw into.
74 void AllocBitmap(); 74 void AllocBitmap();
75 75
76 // Draws one frame, incrementing the rotation angle. 76 // Draws one frame, incrementing the rotation angle.
77 void DrawFrame(); 77 void DrawFrame();
78 78
79 shell::Connector* connector_ = nullptr; 79 shell::Connector* connector_ = nullptr;
80 80
81 mus::Window* window_ = nullptr; 81 mus::Window* window_ = nullptr;
82 std::unique_ptr<mus::WindowTreeConnection> window_tree_connection_;
83 mus::WindowManagerClient* window_manager_client_ = nullptr; 82 mus::WindowManagerClient* window_manager_client_ = nullptr;
84 mojo::Binding<mus::mojom::WindowManagerFactory> 83 mojo::Binding<mus::mojom::WindowManagerFactory>
85 window_manager_factory_binding_; 84 window_manager_factory_binding_;
86 85
87 // Used to send frames to mus. 86 // Used to send frames to mus.
88 std::unique_ptr<bitmap_uploader::BitmapUploader> uploader_; 87 std::unique_ptr<bitmap_uploader::BitmapUploader> uploader_;
89 88
90 // Bitmap that is the same size as our client window area. 89 // Bitmap that is the same size as our client window area.
91 SkBitmap bitmap_; 90 SkBitmap bitmap_;
92 91
93 // Timer for calling DrawFrame(). 92 // Timer for calling DrawFrame().
94 base::RepeatingTimer timer_; 93 base::RepeatingTimer timer_;
95 94
96 // Current rotation angle for drawing. 95 // Current rotation angle for drawing.
97 double angle_ = 0.0; 96 double angle_ = 0.0;
98 97
99 DISALLOW_COPY_AND_ASSIGN(MusDemo); 98 DISALLOW_COPY_AND_ASSIGN(MusDemo);
100 }; 99 };
101 100
102 } // namespace mus_demo 101 } // namespace mus_demo
103 102
104 #endif // COMPONENTS_MUS_DEMO_MUS_DEMO_H_ 103 #endif // COMPONENTS_MUS_DEMO_MUS_DEMO_H_
OLDNEW
« no previous file with comments | « no previous file | components/mus/demo/mus_demo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698