Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: services/ui/demo/mus_demo.cc

Issue 2179023004: Make Service own ServiceContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/ui/demo/mus_demo.h ('k') | services/ui/service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "services/shell/public/cpp/connector.h" 8 #include "services/shell/public/cpp/connector.h"
9 #include "services/ui/common/gpu_service.h" 9 #include "services/ui/common/gpu_service.h"
10 #include "services/ui/public/cpp/bitmap_uploader.h" 10 #include "services/ui/public/cpp/bitmap_uploader.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 58
59 } // namespace 59 } // namespace
60 60
61 MusDemo::MusDemo() {} 61 MusDemo::MusDemo() {}
62 62
63 MusDemo::~MusDemo() { 63 MusDemo::~MusDemo() {
64 delete window_tree_client_; 64 delete window_tree_client_;
65 } 65 }
66 66
67 void MusDemo::OnStart(shell::Connector* connector, 67 void MusDemo::OnStart(const shell::Identity& identity) {
68 const shell::Identity& identity, 68 GpuService::Initialize(connector());
69 uint32_t id) {
70 connector_ = connector;
71 GpuService::Initialize(connector_);
72 window_tree_client_ = new WindowTreeClient(this, this, nullptr); 69 window_tree_client_ = new WindowTreeClient(this, this, nullptr);
73 window_tree_client_->ConnectAsWindowManager(connector); 70 window_tree_client_->ConnectAsWindowManager(connector());
74 } 71 }
75 72
76 bool MusDemo::OnConnect(shell::Connection* connection) { 73 bool MusDemo::OnConnect(shell::Connection* connection) {
77 return true; 74 return true;
78 } 75 }
79 76
80 void MusDemo::OnEmbed(Window* window) { 77 void MusDemo::OnEmbed(Window* window) {
81 // Not called for the WindowManager. 78 // Not called for the WindowManager.
82 NOTREACHED(); 79 NOTREACHED();
83 } 80 }
(...skipping 27 matching lines...) Expand all
111 bool janky) { 108 bool janky) {
112 // Don't care 109 // Don't care
113 } 110 }
114 111
115 void MusDemo::OnWmNewDisplay(Window* window, const display::Display& display) { 112 void MusDemo::OnWmNewDisplay(Window* window, const display::Display& display) {
116 DCHECK(!window_); // Only support one display. 113 DCHECK(!window_); // Only support one display.
117 window_ = window; 114 window_ = window;
118 115
119 // Initialize bitmap uploader for sending frames to MUS. 116 // Initialize bitmap uploader for sending frames to MUS.
120 uploader_.reset(new ui::BitmapUploader(window_)); 117 uploader_.reset(new ui::BitmapUploader(window_));
121 uploader_->Init(connector_); 118 uploader_->Init(connector());
122 119
123 // Draw initial frame and start the timer to regularly draw frames. 120 // Draw initial frame and start the timer to regularly draw frames.
124 DrawFrame(); 121 DrawFrame();
125 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kFrameDelay), 122 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kFrameDelay),
126 base::Bind(&MusDemo::DrawFrame, base::Unretained(this))); 123 base::Bind(&MusDemo::DrawFrame, base::Unretained(this)));
127 } 124 }
128 125
129 void MusDemo::OnWmPerformMoveLoop(Window* window, 126 void MusDemo::OnWmPerformMoveLoop(Window* window,
130 mojom::MoveLoopSource source, 127 mojom::MoveLoopSource source,
131 const gfx::Point& cursor_location, 128 const gfx::Point& cursor_location,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 new std::vector<unsigned char>(addr, addr + bytes)); 173 new std::vector<unsigned char>(addr, addr + bytes));
177 bitmap_.unlockPixels(); 174 bitmap_.unlockPixels();
178 175
179 // Send frame to MUS via BitmapUploader. 176 // Send frame to MUS via BitmapUploader.
180 uploader_->SetBitmap(bounds.width(), bounds.height(), std::move(data), 177 uploader_->SetBitmap(bounds.width(), bounds.height(), std::move(data),
181 ui::BitmapUploader::BGRA); 178 ui::BitmapUploader::BGRA);
182 } 179 }
183 180
184 } // namespace demo 181 } // namespace demo
185 } // namespace ui 182 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/demo/mus_demo.h ('k') | services/ui/service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698