| OLD | NEW |
| 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 <string> | 10 #include <string> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/callback.h" | 13 #include "base/callback.h" |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/scoped_ptr.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_tree_host.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 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 46 bool AcceptConnection(shell::Connection* connection) override; | 46 bool AcceptConnection(shell::Connection* connection) override; |
| 47 | 47 |
| 48 // WindowTreeDelegate: | 48 // WindowTreeDelegate: |
| 49 void OnEmbed(mus::Window* root) override; | 49 void OnEmbed(mus::Window* root) override; |
| 50 void OnUnembed(mus::Window* root) override; | 50 void OnUnembed(mus::Window* root) override; |
| 51 void OnConnectionLost(mus::WindowTreeConnection* connection) override; | 51 void OnConnectionLost(mus::WindowTreeConnection* connection) override; |
| 52 | 52 |
| 53 // WindowManagerDelegate: | 53 // WindowManagerDelegate: |
| 54 void SetWindowManagerClient(mus::WindowManagerClient* client) override; | 54 void SetWindowManagerClient(mus::WindowManagerClient* client) override; |
| 55 bool OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) override; | 55 bool OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) override; |
| 56 bool OnWmSetProperty(mus::Window* window, | 56 bool OnWmSetProperty( |
| 57 const std::string& name, | 57 mus::Window* window, |
| 58 scoped_ptr<std::vector<uint8_t>>* new_data) override; | 58 const std::string& name, |
| 59 std::unique_ptr<std::vector<uint8_t>>* new_data) override; |
| 59 mus::Window* OnWmCreateTopLevelWindow( | 60 mus::Window* OnWmCreateTopLevelWindow( |
| 60 std::map<std::string, std::vector<uint8_t>>* properties) override; | 61 std::map<std::string, std::vector<uint8_t>>* properties) override; |
| 61 void OnAccelerator(uint32_t id, const ui::Event& event) override; | 62 void OnAccelerator(uint32_t id, const ui::Event& event) override; |
| 62 | 63 |
| 63 // Allocate a bitmap the same size as the window to draw into. | 64 // Allocate a bitmap the same size as the window to draw into. |
| 64 void AllocBitmap(); | 65 void AllocBitmap(); |
| 65 | 66 |
| 66 // Draws one frame, incrementing the rotation angle. | 67 // Draws one frame, incrementing the rotation angle. |
| 67 void DrawFrame(); | 68 void DrawFrame(); |
| 68 | 69 |
| 69 shell::Connector* connector_ = nullptr; | 70 shell::Connector* connector_ = nullptr; |
| 70 | 71 |
| 71 mus::Window* window_ = nullptr; | 72 mus::Window* window_ = nullptr; |
| 72 mus::mojom::WindowTreeHostPtr window_tree_host_; | 73 mus::mojom::WindowTreeHostPtr window_tree_host_; |
| 73 | 74 |
| 74 // Used to send frames to mus. | 75 // Used to send frames to mus. |
| 75 scoped_ptr<bitmap_uploader::BitmapUploader> uploader_; | 76 std::unique_ptr<bitmap_uploader::BitmapUploader> uploader_; |
| 76 | 77 |
| 77 // Bitmap that is the same size as our client window area. | 78 // Bitmap that is the same size as our client window area. |
| 78 SkBitmap bitmap_; | 79 SkBitmap bitmap_; |
| 79 | 80 |
| 80 // Timer for calling DrawFrame(). | 81 // Timer for calling DrawFrame(). |
| 81 base::RepeatingTimer timer_; | 82 base::RepeatingTimer timer_; |
| 82 | 83 |
| 83 // Current rotation angle for drawing. | 84 // Current rotation angle for drawing. |
| 84 double angle_ = 0.0; | 85 double angle_ = 0.0; |
| 85 | 86 |
| 86 DISALLOW_COPY_AND_ASSIGN(MusDemo); | 87 DISALLOW_COPY_AND_ASSIGN(MusDemo); |
| 87 }; | 88 }; |
| 88 | 89 |
| 89 } // namespace mus_demo | 90 } // namespace mus_demo |
| 90 | 91 |
| 91 #endif // COMPONENTS_MUS_DEMO_MUS_DEMO_H_ | 92 #endif // COMPONENTS_MUS_DEMO_MUS_DEMO_H_ |
| OLD | NEW |