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

Side by Side Diff: ui/display/chromeos/x11/native_display_delegate_x11.cc

Issue 796263002: Remove synchronous GetDisplays() and Configure() from NativeDisplayDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@async-refactor5
Patch Set: Removed deprecated calls from TestNativeDisplayDelegate and update the ExternalControl test Created 6 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/display/chromeos/x11/native_display_delegate_x11.h" 5 #include "ui/display/chromeos/x11/native_display_delegate_x11.h"
6 6
7 #include <X11/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 #include <X11/extensions/dpms.h> 9 #include <X11/extensions/dpms.h>
10 #include <X11/extensions/Xrandr.h> 10 #include <X11/extensions/Xrandr.h>
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 void NativeDisplayDelegateX11::SetBackgroundColor(uint32_t color_argb) { 165 void NativeDisplayDelegateX11::SetBackgroundColor(uint32_t color_argb) {
166 background_color_argb_ = color_argb; 166 background_color_argb_ = color_argb;
167 } 167 }
168 168
169 void NativeDisplayDelegateX11::ForceDPMSOn() { 169 void NativeDisplayDelegateX11::ForceDPMSOn() {
170 CHECK(DPMSEnable(display_)); 170 CHECK(DPMSEnable(display_));
171 CHECK(DPMSForceLevel(display_, DPMSModeOn)); 171 CHECK(DPMSForceLevel(display_, DPMSModeOn));
172 } 172 }
173 173
174 std::vector<DisplaySnapshot*> NativeDisplayDelegateX11::GetDisplays() { 174 void NativeDisplayDelegateX11::GetDisplays(
175 const GetDisplaysCallback& callback) {
175 CHECK(screen_) << "Server not grabbed"; 176 CHECK(screen_) << "Server not grabbed";
176 177
177 cached_outputs_.clear(); 178 cached_outputs_.clear();
178 std::set<RRCrtc> last_used_crtcs; 179 std::set<RRCrtc> last_used_crtcs;
179 180
180 InitModes(); 181 InitModes();
181 for (int i = 0; i < screen_->noutput; ++i) { 182 for (int i = 0; i < screen_->noutput; ++i) {
182 RROutput output_id = screen_->outputs[i]; 183 RROutput output_id = screen_->outputs[i];
183 XRROutputInfo* output_info = XRRGetOutputInfo(display_, screen_, output_id); 184 XRROutputInfo* output_info = XRRGetOutputInfo(display_, screen_, output_id);
184 if (output_info->connection == RR_Connected) { 185 if (output_info->connection == RR_Connected) {
185 DisplaySnapshotX11* output = 186 DisplaySnapshotX11* output =
186 InitDisplaySnapshot(output_id, output_info, &last_used_crtcs, i); 187 InitDisplaySnapshot(output_id, output_info, &last_used_crtcs, i);
187 cached_outputs_.push_back(output); 188 cached_outputs_.push_back(output);
188 } 189 }
189 XRRFreeOutputInfo(output_info); 190 XRRFreeOutputInfo(output_info);
190 } 191 }
191 192
192 return cached_outputs_.get(); 193 callback.Run(cached_outputs_.get());
193 }
194
195 void NativeDisplayDelegateX11::GetDisplays(
196 const GetDisplaysCallback& callback) {
197 callback.Run(GetDisplays());
198 } 194 }
199 195
200 void NativeDisplayDelegateX11::AddMode(const DisplaySnapshot& output, 196 void NativeDisplayDelegateX11::AddMode(const DisplaySnapshot& output,
201 const DisplayMode* mode) { 197 const DisplayMode* mode) {
202 CHECK(screen_) << "Server not grabbed"; 198 CHECK(screen_) << "Server not grabbed";
203 CHECK(mode) << "Must add valid mode"; 199 CHECK(mode) << "Must add valid mode";
204 200
205 const DisplaySnapshotX11& x11_output = 201 const DisplaySnapshotX11& x11_output =
206 static_cast<const DisplaySnapshotX11&>(output); 202 static_cast<const DisplaySnapshotX11&>(output);
207 RRMode mode_id = static_cast<const DisplayModeX11*>(mode)->mode_id(); 203 RRMode mode_id = static_cast<const DisplayModeX11*>(mode)->mode_id();
208 204
209 VLOG(1) << "AddDisplayMode: output=" << x11_output.output() 205 VLOG(1) << "AddDisplayMode: output=" << x11_output.output()
210 << " mode=" << mode_id; 206 << " mode=" << mode_id;
211 XRRAddOutputMode(display_, x11_output.output(), mode_id); 207 XRRAddOutputMode(display_, x11_output.output(), mode_id);
212 } 208 }
213 209
214 bool NativeDisplayDelegateX11::Configure(const DisplaySnapshot& output, 210 void NativeDisplayDelegateX11::Configure(const DisplaySnapshot& output,
215 const DisplayMode* mode, 211 const DisplayMode* mode,
216 const gfx::Point& origin) { 212 const gfx::Point& origin,
213 const ConfigureCallback& callback) {
217 const DisplaySnapshotX11& x11_output = 214 const DisplaySnapshotX11& x11_output =
218 static_cast<const DisplaySnapshotX11&>(output); 215 static_cast<const DisplaySnapshotX11&>(output);
219 RRMode mode_id = None; 216 RRMode mode_id = None;
220 if (mode) 217 if (mode)
221 mode_id = static_cast<const DisplayModeX11*>(mode)->mode_id(); 218 mode_id = static_cast<const DisplayModeX11*>(mode)->mode_id();
222 219
223 return ConfigureCrtc( 220 callback.Run(ConfigureCrtc(x11_output.crtc(), mode_id, x11_output.output(),
224 x11_output.crtc(), mode_id, x11_output.output(), origin.x(), origin.y()); 221 origin.x(), origin.y()));
225 }
226
227 void NativeDisplayDelegateX11::Configure(const DisplaySnapshot& output,
228 const DisplayMode* mode,
229 const gfx::Point& origin,
230 const ConfigureCallback& callback) {
231 callback.Run(Configure(output, mode, origin));
232 } 222 }
233 223
234 bool NativeDisplayDelegateX11::ConfigureCrtc(RRCrtc crtc, 224 bool NativeDisplayDelegateX11::ConfigureCrtc(RRCrtc crtc,
235 RRMode mode, 225 RRMode mode,
236 RROutput output, 226 RROutput output,
237 int x, 227 int x,
238 int y) { 228 int y) {
239 CHECK(screen_) << "Server not grabbed"; 229 CHECK(screen_) << "Server not grabbed";
240 VLOG(1) << "ConfigureCrtc: crtc=" << crtc << " mode=" << mode 230 VLOG(1) << "ConfigureCrtc: crtc=" << crtc << " mode=" << mode
241 << " output=" << output << " x=" << x << " y=" << y; 231 << " output=" << output << " x=" << x << " y=" << y;
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 XSetForeground(display_, gc, color.pixel); 642 XSetForeground(display_, gc, color.pixel);
653 XSetFillStyle(display_, gc, FillSolid); 643 XSetFillStyle(display_, gc, FillSolid);
654 int width = DisplayWidth(display_, DefaultScreen(display_)); 644 int width = DisplayWidth(display_, DefaultScreen(display_));
655 int height = DisplayHeight(display_, DefaultScreen(display_)); 645 int height = DisplayHeight(display_, DefaultScreen(display_));
656 XFillRectangle(display_, window_, gc, 0, 0, width, height); 646 XFillRectangle(display_, window_, gc, 0, 0, width, height);
657 XFreeGC(display_, gc); 647 XFreeGC(display_, gc);
658 XFreeColors(display_, colormap, &color.pixel, 1, 0); 648 XFreeColors(display_, colormap, &color.pixel, 1, 0);
659 } 649 }
660 650
661 } // namespace ui 651 } // namespace ui
OLDNEW
« no previous file with comments | « ui/display/chromeos/x11/native_display_delegate_x11.h ('k') | ui/display/types/native_display_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698