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 #include "components/mus/demo/mus_demo.h" | 5 #include "components/mus/demo/mus_demo.h" |
6 | 6 |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "components/bitmap_uploader/bitmap_uploader.h" | 8 #include "components/bitmap_uploader/bitmap_uploader.h" |
9 #include "components/mus/public/cpp/window_tree_connection.h" | 9 #include "components/mus/public/cpp/window_tree_client.h" |
10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
11 #include "third_party/skia/include/core/SkColor.h" | 11 #include "third_party/skia/include/core/SkColor.h" |
12 #include "third_party/skia/include/core/SkImageInfo.h" | 12 #include "third_party/skia/include/core/SkImageInfo.h" |
13 #include "third_party/skia/include/core/SkPaint.h" | 13 #include "third_party/skia/include/core/SkPaint.h" |
14 #include "third_party/skia/include/core/SkRect.h" | 14 #include "third_party/skia/include/core/SkRect.h" |
15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
16 | 16 |
17 namespace mus_demo { | 17 namespace mus_demo { |
18 | 18 |
19 namespace { | 19 namespace { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 uploader_->Init(connector_); | 80 uploader_->Init(connector_); |
81 | 81 |
82 // Draw initial frame and start the timer to regularly draw frames. | 82 // Draw initial frame and start the timer to regularly draw frames. |
83 DrawFrame(); | 83 DrawFrame(); |
84 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kFrameDelay), | 84 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kFrameDelay), |
85 base::Bind(&MusDemo::DrawFrame, base::Unretained(this))); | 85 base::Bind(&MusDemo::DrawFrame, base::Unretained(this))); |
86 } | 86 } |
87 | 87 |
88 void MusDemo::OnUnembed(mus::Window* root) {} | 88 void MusDemo::OnUnembed(mus::Window* root) {} |
89 | 89 |
90 void MusDemo::OnConnectionLost(mus::WindowTreeConnection* connection) { | 90 void MusDemo::OnWindowTreeClientDestroyed(mus::WindowTreeClient* client) { |
91 timer_.Stop(); | 91 timer_.Stop(); |
92 } | 92 } |
93 | 93 |
94 void MusDemo::OnEventObserved(const ui::Event& event, mus::Window* target) {} | 94 void MusDemo::OnEventObserved(const ui::Event& event, mus::Window* target) {} |
95 | 95 |
96 // mus::mojom::WindowManagerFactory: | 96 // mus::mojom::WindowManagerFactory: |
97 void MusDemo::CreateWindowManager(mus::mojom::DisplayPtr display, | 97 void MusDemo::CreateWindowManager(mus::mojom::DisplayPtr display, |
98 mus::mojom::WindowTreeClientRequest request) { | 98 mus::mojom::WindowTreeClientRequest request) { |
99 mus::WindowTreeConnection::CreateForWindowManager( | 99 new mus::WindowTreeClient(this, this, std::move(request)); |
100 this, std::move(request), | |
101 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED, this); | |
102 } | 100 } |
103 | 101 |
104 // mus::WindowManagerDelegate: | 102 // mus::WindowManagerDelegate: |
105 void MusDemo::SetWindowManagerClient(mus::WindowManagerClient* client) { | 103 void MusDemo::SetWindowManagerClient(mus::WindowManagerClient* client) { |
106 window_manager_client_ = client; | 104 window_manager_client_ = client; |
107 } | 105 } |
108 | 106 |
109 bool MusDemo::OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) { | 107 bool MusDemo::OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) { |
110 return true; | 108 return true; |
111 } | 109 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 std::unique_ptr<std::vector<unsigned char>> data( | 169 std::unique_ptr<std::vector<unsigned char>> data( |
172 new std::vector<unsigned char>(addr, addr + bytes)); | 170 new std::vector<unsigned char>(addr, addr + bytes)); |
173 bitmap_.unlockPixels(); | 171 bitmap_.unlockPixels(); |
174 | 172 |
175 // Send frame to MUS via BitmapUploader. | 173 // Send frame to MUS via BitmapUploader. |
176 uploader_->SetBitmap(bounds.width(), bounds.height(), std::move(data), | 174 uploader_->SetBitmap(bounds.width(), bounds.height(), std::move(data), |
177 bitmap_uploader::BitmapUploader::BGRA); | 175 bitmap_uploader::BitmapUploader::BGRA); |
178 } | 176 } |
179 | 177 |
180 } // namespace mus_demo | 178 } // namespace mus_demo |
OLD | NEW |