| 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 SERVICES_UI_DEMO_MUS_DEMO_H_ | 5 #ifndef SERVICES_UI_DEMO_MUS_DEMO_H_ |
| 6 #define SERVICES_UI_DEMO_MUS_DEMO_H_ | 6 #define SERVICES_UI_DEMO_MUS_DEMO_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
| 17 #include "services/service_manager/public/cpp/service.h" | 17 #include "services/service_manager/public/cpp/service.h" |
| 18 #include "services/ui/public/cpp/window_manager_delegate.h" | 18 #include "services/ui/public/cpp/window_manager_delegate.h" |
| 19 #include "services/ui/public/cpp/window_tree_client_delegate.h" | 19 #include "services/ui/public/cpp/window_tree_client_delegate.h" |
| 20 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
| 21 #include "ui/display/screen_base.h" |
| 21 | 22 |
| 22 namespace ui { | 23 namespace ui { |
| 23 class BitmapUploader; | 24 class BitmapUploader; |
| 24 class GpuService; | 25 class GpuService; |
| 25 | 26 |
| 26 namespace demo { | 27 namespace demo { |
| 27 | 28 |
| 28 // A simple MUS Demo service. This service connects to the service:ui, creates a | 29 // A simple MUS Demo service. This service connects to the service:ui, creates a |
| 29 // new window and draws a spinning square in the center of the window. Provides | 30 // new window and draws a spinning square in the center of the window. Provides |
| 30 // a simple way to demonstrate that the graphic stack works as intended. | 31 // a simple way to demonstrate that the graphic stack works as intended. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // Allocate a bitmap the same size as the window to draw into. | 72 // Allocate a bitmap the same size as the window to draw into. |
| 72 void AllocBitmap(); | 73 void AllocBitmap(); |
| 73 | 74 |
| 74 // Draws one frame, incrementing the rotation angle. | 75 // Draws one frame, incrementing the rotation angle. |
| 75 void DrawFrame(); | 76 void DrawFrame(); |
| 76 | 77 |
| 77 Window* window_ = nullptr; | 78 Window* window_ = nullptr; |
| 78 std::unique_ptr<WindowTreeClient> window_tree_client_; | 79 std::unique_ptr<WindowTreeClient> window_tree_client_; |
| 79 std::unique_ptr<GpuService> gpu_service_; | 80 std::unique_ptr<GpuService> gpu_service_; |
| 80 | 81 |
| 82 // Dummy screen required to be the screen instance. |
| 83 std::unique_ptr<display::ScreenBase> screen_; |
| 84 |
| 81 // Used to send frames to mus. | 85 // Used to send frames to mus. |
| 82 std::unique_ptr<BitmapUploader> uploader_; | 86 std::unique_ptr<BitmapUploader> uploader_; |
| 83 | 87 |
| 84 // Bitmap that is the same size as our client window area. | 88 // Bitmap that is the same size as our client window area. |
| 85 SkBitmap bitmap_; | 89 SkBitmap bitmap_; |
| 86 | 90 |
| 87 // Timer for calling DrawFrame(). | 91 // Timer for calling DrawFrame(). |
| 88 base::RepeatingTimer timer_; | 92 base::RepeatingTimer timer_; |
| 89 | 93 |
| 90 // Current rotation angle for drawing. | 94 // Current rotation angle for drawing. |
| 91 double angle_ = 0.0; | 95 double angle_ = 0.0; |
| 92 | 96 |
| 93 // Last time a frame was drawn. | 97 // Last time a frame was drawn. |
| 94 base::TimeTicks last_draw_frame_time_; | 98 base::TimeTicks last_draw_frame_time_; |
| 95 | 99 |
| 96 DISALLOW_COPY_AND_ASSIGN(MusDemo); | 100 DISALLOW_COPY_AND_ASSIGN(MusDemo); |
| 97 }; | 101 }; |
| 98 | 102 |
| 99 } // namespace demo | 103 } // namespace demo |
| 100 } // namespace ui | 104 } // namespace ui |
| 101 | 105 |
| 102 #endif // SERVICES_UI_DEMO_MUS_DEMO_H_ | 106 #endif // SERVICES_UI_DEMO_MUS_DEMO_H_ |
| OLD | NEW |