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 "services/ui/demo/mus_demo.h" | 5 #include "services/ui/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" | |
9 #include "services/shell/public/cpp/connector.h" | 8 #include "services/shell/public/cpp/connector.h" |
10 #include "services/ui/common/gpu_service.h" | 9 #include "services/ui/common/gpu_service.h" |
| 10 #include "services/ui/public/cpp/bitmap_uploader.h" |
11 #include "services/ui/public/cpp/window.h" | 11 #include "services/ui/public/cpp/window.h" |
12 #include "services/ui/public/cpp/window_tree_client.h" | 12 #include "services/ui/public/cpp/window_tree_client.h" |
13 #include "third_party/skia/include/core/SkCanvas.h" | 13 #include "third_party/skia/include/core/SkCanvas.h" |
14 #include "third_party/skia/include/core/SkColor.h" | 14 #include "third_party/skia/include/core/SkColor.h" |
15 #include "third_party/skia/include/core/SkImageInfo.h" | 15 #include "third_party/skia/include/core/SkImageInfo.h" |
16 #include "third_party/skia/include/core/SkPaint.h" | 16 #include "third_party/skia/include/core/SkPaint.h" |
17 #include "third_party/skia/include/core/SkRect.h" | 17 #include "third_party/skia/include/core/SkRect.h" |
18 #include "ui/gfx/geometry/rect.h" | 18 #include "ui/gfx/geometry/rect.h" |
19 | 19 |
20 namespace ui { | 20 namespace ui { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 const std::set<Window*>& client_windows, | 110 const std::set<Window*>& client_windows, |
111 bool janky) { | 111 bool janky) { |
112 // Don't care | 112 // Don't care |
113 } | 113 } |
114 | 114 |
115 void MusDemo::OnWmNewDisplay(Window* window, const display::Display& display) { | 115 void MusDemo::OnWmNewDisplay(Window* window, const display::Display& display) { |
116 DCHECK(!window_); // Only support one display. | 116 DCHECK(!window_); // Only support one display. |
117 window_ = window; | 117 window_ = window; |
118 | 118 |
119 // Initialize bitmap uploader for sending frames to MUS. | 119 // Initialize bitmap uploader for sending frames to MUS. |
120 uploader_.reset(new bitmap_uploader::BitmapUploader(window_)); | 120 uploader_.reset(new ui::BitmapUploader(window_)); |
121 uploader_->Init(connector_); | 121 uploader_->Init(connector_); |
122 | 122 |
123 // Draw initial frame and start the timer to regularly draw frames. | 123 // Draw initial frame and start the timer to regularly draw frames. |
124 DrawFrame(); | 124 DrawFrame(); |
125 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kFrameDelay), | 125 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kFrameDelay), |
126 base::Bind(&MusDemo::DrawFrame, base::Unretained(this))); | 126 base::Bind(&MusDemo::DrawFrame, base::Unretained(this))); |
127 } | 127 } |
128 | 128 |
129 void MusDemo::OnWmPerformMoveLoop(Window* window, | 129 void MusDemo::OnWmPerformMoveLoop(Window* window, |
130 mojom::MoveLoopSource source, | 130 mojom::MoveLoopSource source, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 bitmap_.lockPixels(); | 171 bitmap_.lockPixels(); |
172 const unsigned char* addr = | 172 const unsigned char* addr = |
173 static_cast<const unsigned char*>(bitmap_.getPixels()); | 173 static_cast<const unsigned char*>(bitmap_.getPixels()); |
174 const int bytes = bounds.width() * bounds.height() * 4; | 174 const int bytes = bounds.width() * bounds.height() * 4; |
175 std::unique_ptr<std::vector<unsigned char>> data( | 175 std::unique_ptr<std::vector<unsigned char>> data( |
176 new std::vector<unsigned char>(addr, addr + bytes)); | 176 new std::vector<unsigned char>(addr, addr + bytes)); |
177 bitmap_.unlockPixels(); | 177 bitmap_.unlockPixels(); |
178 | 178 |
179 // Send frame to MUS via BitmapUploader. | 179 // Send frame to MUS via BitmapUploader. |
180 uploader_->SetBitmap(bounds.width(), bounds.height(), std::move(data), | 180 uploader_->SetBitmap(bounds.width(), bounds.height(), std::move(data), |
181 bitmap_uploader::BitmapUploader::BGRA); | 181 ui::BitmapUploader::BGRA); |
182 } | 182 } |
183 | 183 |
184 } // namespace demo | 184 } // namespace demo |
185 } // namespace ui | 185 } // namespace ui |
OLD | NEW |