| 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 <memory> | |
| 10 #include <string> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/callback.h" | |
| 14 #include "base/macros.h" | |
| 15 #include "base/timer/timer.h" | |
| 16 #include "components/mus/public/cpp/window_manager_delegate.h" | |
| 17 #include "components/mus/public/cpp/window_tree_client_delegate.h" | |
| 18 #include "services/shell/public/cpp/shell_client.h" | |
| 19 #include "third_party/skia/include/core/SkBitmap.h" | |
| 20 | |
| 21 namespace bitmap_uploader { | |
| 22 class BitmapUploader; | |
| 23 } | |
| 24 | |
| 25 namespace mus_demo { | |
| 26 | |
| 27 // A simple MUS Demo mojo app. This app connects to the mojo:mus, creates a new | |
| 28 // window and draws a spinning square in the center of the window. Provides a | |
| 29 // simple way to demonstrate that the graphic stack works as intended. | |
| 30 class MusDemo : public shell::ShellClient, | |
| 31 public mus::WindowTreeClientDelegate, | |
| 32 public mus::WindowManagerDelegate { | |
| 33 public: | |
| 34 MusDemo(); | |
| 35 ~MusDemo() override; | |
| 36 | |
| 37 private: | |
| 38 // shell::ShellClient: | |
| 39 void Initialize(shell::Connector* connector, | |
| 40 const shell::Identity& identity, | |
| 41 uint32_t id) override; | |
| 42 bool AcceptConnection(shell::Connection* connection) override; | |
| 43 | |
| 44 // WindowTreeClientDelegate: | |
| 45 void OnEmbed(mus::Window* root) override; | |
| 46 void OnDidDestroyClient(mus::WindowTreeClient* client) override; | |
| 47 void OnEventObserved(const ui::Event& event, mus::Window* target) override; | |
| 48 | |
| 49 // WindowManagerDelegate: | |
| 50 void SetWindowManagerClient(mus::WindowManagerClient* client) override; | |
| 51 bool OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) override; | |
| 52 bool OnWmSetProperty( | |
| 53 mus::Window* window, | |
| 54 const std::string& name, | |
| 55 std::unique_ptr<std::vector<uint8_t>>* new_data) override; | |
| 56 mus::Window* OnWmCreateTopLevelWindow( | |
| 57 std::map<std::string, std::vector<uint8_t>>* properties) override; | |
| 58 void OnWmClientJankinessChanged(const std::set<mus::Window*>& client_windows, | |
| 59 bool janky) override; | |
| 60 void OnWmNewDisplay(mus::Window* window, | |
| 61 const display::Display& display) override; | |
| 62 void OnAccelerator(uint32_t id, const ui::Event& event) override; | |
| 63 | |
| 64 // Allocate a bitmap the same size as the window to draw into. | |
| 65 void AllocBitmap(); | |
| 66 | |
| 67 // Draws one frame, incrementing the rotation angle. | |
| 68 void DrawFrame(); | |
| 69 | |
| 70 shell::Connector* connector_ = nullptr; | |
| 71 | |
| 72 mus::Window* window_ = nullptr; | |
| 73 mus::WindowTreeClient* window_tree_client_ = nullptr; | |
| 74 | |
| 75 // Used to send frames to mus. | |
| 76 std::unique_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_demo | |
| 91 | |
| 92 #endif // COMPONENTS_MUS_DEMO_MUS_DEMO_H_ | |
| OLD | NEW |