Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_MUS_DEMO_MUS_DEMO_H_ | |
| 6 #define COMPONENTS_MUS_DEMO_MUS_DEMO_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/callback.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/timer/timer.h" | |
| 16 #include "components/mus/public/cpp/window.h" | |
| 17 #include "components/mus/public/cpp/window_manager_delegate.h" | |
| 18 #include "components/mus/public/cpp/window_tree_delegate.h" | |
| 19 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | |
| 20 #include "mojo/public/cpp/bindings/binding_set.h" | |
| 21 #include "mojo/shell/public/cpp/connector.h" | |
| 22 #include "mojo/shell/public/cpp/shell_client.h" | |
| 23 #include "third_party/skia/include/core/SkBitmap.h" | |
| 24 | |
| 25 namespace bitmap_uploader { | |
| 26 class BitmapUploader; | |
| 27 } | |
| 28 | |
| 29 namespace mus { | |
|
rjkroege
2016/03/29 18:53:23
I think it would be better to be in a different na
kylechar
2016/03/29 20:43:39
Done.
| |
| 30 | |
| 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 | |
| 33 // simple way to demonstrate the graphic stack works as intended. | |
|
rjkroege
2016/03/29 18:53:22
to demonstrate that the
kylechar
2016/03/29 20:43:39
Done.
| |
| 34 class MusDemo : public mojo::ShellClient, | |
| 35 public WindowTreeDelegate, | |
| 36 public WindowManagerDelegate { | |
| 37 public: | |
| 38 MusDemo(); | |
| 39 ~MusDemo() override; | |
| 40 | |
| 41 private: | |
| 42 // mojo::ShellClient: | |
| 43 void Initialize(mojo::Connector* connector, | |
| 44 const mojo::Identity& identity, | |
| 45 uint32_t id) override; | |
| 46 bool AcceptConnection(mojo::Connection* connection) override; | |
| 47 | |
| 48 // WindowTreeDelegate: | |
| 49 void OnEmbed(Window* root) override; | |
| 50 void OnUnembed(Window* root) override; | |
| 51 void OnConnectionLost(WindowTreeConnection* connection) override; | |
| 52 | |
| 53 // WindowManagerDelegate: | |
| 54 void SetWindowManagerClient(WindowManagerClient* client) override; | |
| 55 bool OnWmSetBounds(Window* window, gfx::Rect* bounds) override; | |
| 56 bool OnWmSetProperty(Window* window, | |
| 57 const std::string& name, | |
| 58 scoped_ptr<std::vector<uint8_t>>* new_data) override; | |
| 59 Window* OnWmCreateTopLevelWindow( | |
| 60 std::map<std::string, std::vector<uint8_t>>* properties) override; | |
| 61 void OnAccelerator(uint32_t id, const ui::Event& event) override; | |
| 62 | |
| 63 // Allocate a bitmap the same size as the window t draw into. | |
|
rjkroege
2016/03/29 18:53:23
t -> to
kylechar
2016/03/29 20:43:39
Done.
| |
| 64 void AllocBitmap(); | |
| 65 | |
| 66 // Draws one frame, incrementing the rotation angle. | |
| 67 void DrawFrame(); | |
| 68 | |
| 69 mojo::Connector* connector_ = nullptr; | |
|
rjkroege
2016/03/29 18:53:23
These are owned elsewhere? if so, adding // NOT OW
kylechar
2016/03/29 20:43:39
I believe they're owned elsewhere (based on other
rjkroege
2016/03/29 20:56:54
My understanding is that the mojo owns infrastruct
| |
| 70 | |
| 71 mojom::WindowTreeHostPtr host_ = nullptr; | |
| 72 | |
| 73 Window* window_ = nullptr; | |
| 74 | |
| 75 // Used to send frames to mus. | |
| 76 scoped_ptr<bitmap_uploader::BitmapUploader> uploader_; | |
| 77 | |
| 78 // Bitmap that is the same size as our client window area. | |
| 79 SkBitmap bitmap_; | |
| 80 | |
| 81 // Timer for calling DrawFrame(). | |
| 82 base::RepeatingTimer timer_; | |
| 83 | |
| 84 // Current rotation angle for drawing. | |
| 85 double angle_ = 0.0; | |
| 86 | |
| 87 DISALLOW_COPY_AND_ASSIGN(MusDemo); | |
| 88 }; | |
| 89 | |
| 90 } // namespace mus | |
| 91 #endif // COMPONENTS_MUS_DEMO_MUS_DEMO_H_ | |
| OLD | NEW |