| OLD | NEW |
| 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/manager/chromeos/x11/native_display_delegate_x11.h" | 5 #include "ui/display/manager/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/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
| 11 #include <X11/extensions/Xrandr.h> | 11 #include <X11/extensions/Xrandr.h> |
| 12 | 12 |
| 13 #include <utility> | 13 #include <utility> |
| 14 | 14 |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 18 #include "ui/display/manager/chromeos/x11/display_mode_x11.h" | 18 #include "ui/display/manager/chromeos/x11/display_mode_x11.h" |
| 19 #include "ui/display/manager/chromeos/x11/display_snapshot_x11.h" | 19 #include "ui/display/manager/chromeos/x11/display_snapshot_x11.h" |
| 20 #include "ui/display/manager/chromeos/x11/display_util_x11.h" | 20 #include "ui/display/manager/chromeos/x11/display_util_x11.h" |
| 21 #include "ui/display/manager/chromeos/x11/native_display_event_dispatcher_x11.h" | 21 #include "ui/display/manager/chromeos/x11/native_display_event_dispatcher_x11.h" |
| 22 #include "ui/display/types/native_display_observer.h" | 22 #include "ui/display/types/native_display_observer.h" |
| 23 #include "ui/display/util/x11/edid_parser_x11.h" | 23 #include "ui/display/util/x11/edid_parser_x11.h" |
| 24 #include "ui/events/platform/platform_event_source.h" | 24 #include "ui/events/platform/platform_event_source.h" |
| 25 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
| 26 #include "ui/gfx/x/x11_error_tracker.h" | 26 #include "ui/gfx/x/x11_error_tracker.h" |
| 27 #include "ui/gfx/x/x11_types.h" | 27 #include "ui/gfx/x/x11_types.h" |
| 28 | 28 |
| 29 namespace ui { | 29 namespace display { |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 // DPI measurements. | 33 // DPI measurements. |
| 34 const float kMmInInch = 25.4; | 34 const float kMmInInch = 25.4; |
| 35 const float kDpi96 = 96.0; | 35 const float kDpi96 = 96.0; |
| 36 const float kPixelsToMmScale = kMmInInch / kDpi96; | 36 const float kPixelsToMmScale = kMmInInch / kDpi96; |
| 37 | 37 |
| 38 const char kContentProtectionAtomName[] = "Content Protection"; | 38 const char kContentProtectionAtomName[] = "Content Protection"; |
| 39 const char kProtectionUndesiredAtomName[] = "Undesired"; | 39 const char kProtectionUndesiredAtomName[] = "Undesired"; |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 } | 275 } |
| 276 | 276 |
| 277 void NativeDisplayDelegateX11::AddObserver(NativeDisplayObserver* observer) { | 277 void NativeDisplayDelegateX11::AddObserver(NativeDisplayObserver* observer) { |
| 278 observers_.AddObserver(observer); | 278 observers_.AddObserver(observer); |
| 279 } | 279 } |
| 280 | 280 |
| 281 void NativeDisplayDelegateX11::RemoveObserver(NativeDisplayObserver* observer) { | 281 void NativeDisplayDelegateX11::RemoveObserver(NativeDisplayObserver* observer) { |
| 282 observers_.RemoveObserver(observer); | 282 observers_.RemoveObserver(observer); |
| 283 } | 283 } |
| 284 | 284 |
| 285 display::FakeDisplayController* | 285 FakeDisplayController* NativeDisplayDelegateX11::GetFakeDisplayController() { |
| 286 NativeDisplayDelegateX11::GetFakeDisplayController() { | |
| 287 return nullptr; | 286 return nullptr; |
| 288 } | 287 } |
| 289 | 288 |
| 290 void NativeDisplayDelegateX11::InitModes() { | 289 void NativeDisplayDelegateX11::InitModes() { |
| 291 CHECK(screen_) << "Server not grabbed"; | 290 CHECK(screen_) << "Server not grabbed"; |
| 292 | 291 |
| 293 modes_.clear(); | 292 modes_.clear(); |
| 294 | 293 |
| 295 for (int i = 0; i < screen_->nmode; ++i) { | 294 for (int i = 0; i < screen_->nmode; ++i) { |
| 296 const XRRModeInfo& info = screen_->modes[i]; | 295 const XRRModeInfo& info = screen_->modes[i]; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 307 info.modeFlags & RR_Interlace, refresh_rate, info.id))); | 306 info.modeFlags & RR_Interlace, refresh_rate, info.id))); |
| 308 } | 307 } |
| 309 } | 308 } |
| 310 | 309 |
| 311 DisplaySnapshotX11* NativeDisplayDelegateX11::InitDisplaySnapshot( | 310 DisplaySnapshotX11* NativeDisplayDelegateX11::InitDisplaySnapshot( |
| 312 RROutput output, | 311 RROutput output, |
| 313 XRROutputInfo* info, | 312 XRROutputInfo* info, |
| 314 std::set<RRCrtc>* last_used_crtcs, | 313 std::set<RRCrtc>* last_used_crtcs, |
| 315 int index) { | 314 int index) { |
| 316 int64_t display_id = 0; | 315 int64_t display_id = 0; |
| 317 display::EDIDParserX11 edid_parser(output); | 316 EDIDParserX11 edid_parser(output); |
| 318 if (!edid_parser.GetDisplayId(static_cast<uint8_t>(index), &display_id)) | 317 if (!edid_parser.GetDisplayId(static_cast<uint8_t>(index), &display_id)) |
| 319 display_id = index; | 318 display_id = index; |
| 320 | 319 |
| 321 bool has_overscan = false; | 320 bool has_overscan = false; |
| 322 edid_parser.GetOutputOverscanFlag(&has_overscan); | 321 edid_parser.GetOutputOverscanFlag(&has_overscan); |
| 323 | 322 |
| 324 DisplayConnectionType type = GetDisplayConnectionTypeFromName(info->name); | 323 DisplayConnectionType type = GetDisplayConnectionTypeFromName(info->name); |
| 325 if (type == DISPLAY_CONNECTION_TYPE_UNKNOWN) | 324 if (type == DISPLAY_CONNECTION_TYPE_UNKNOWN) |
| 326 LOG(ERROR) << "Unknown link type: " << info->name; | 325 LOG(ERROR) << "Unknown link type: " << info->name; |
| 327 | 326 |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 | 620 |
| 622 XRRCrtcGamma* NativeDisplayDelegateX11::CreateGammaRampForProfile( | 621 XRRCrtcGamma* NativeDisplayDelegateX11::CreateGammaRampForProfile( |
| 623 const DisplaySnapshotX11& x11_output, | 622 const DisplaySnapshotX11& x11_output, |
| 624 ColorCalibrationProfile new_profile) { | 623 ColorCalibrationProfile new_profile) { |
| 625 // TODO(mukai|marcheu): Creates the appropriate gamma ramp data from the | 624 // TODO(mukai|marcheu): Creates the appropriate gamma ramp data from the |
| 626 // profile enum. It would be served by the vendor. | 625 // profile enum. It would be served by the vendor. |
| 627 return NULL; | 626 return NULL; |
| 628 } | 627 } |
| 629 | 628 |
| 630 bool NativeDisplayDelegateX11::SetColorCorrection( | 629 bool NativeDisplayDelegateX11::SetColorCorrection( |
| 631 const ui::DisplaySnapshot& output, | 630 const DisplaySnapshot& output, |
| 632 const std::vector<GammaRampRGBEntry>& degamma_lut, | 631 const std::vector<GammaRampRGBEntry>& degamma_lut, |
| 633 const std::vector<GammaRampRGBEntry>& gamma_lut, | 632 const std::vector<GammaRampRGBEntry>& gamma_lut, |
| 634 const std::vector<float>& correction_matrix) { | 633 const std::vector<float>& correction_matrix) { |
| 635 NOTIMPLEMENTED(); | 634 NOTIMPLEMENTED(); |
| 636 return false; | 635 return false; |
| 637 } | 636 } |
| 638 | 637 |
| 639 void NativeDisplayDelegateX11::DrawBackground() { | 638 void NativeDisplayDelegateX11::DrawBackground() { |
| 640 if (!background_color_argb_) | 639 if (!background_color_argb_) |
| 641 return; | 640 return; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 654 GC gc = XCreateGC(display_, window_, 0, 0); | 653 GC gc = XCreateGC(display_, window_, 0, 0); |
| 655 XSetForeground(display_, gc, color.pixel); | 654 XSetForeground(display_, gc, color.pixel); |
| 656 XSetFillStyle(display_, gc, FillSolid); | 655 XSetFillStyle(display_, gc, FillSolid); |
| 657 int width = DisplayWidth(display_, DefaultScreen(display_)); | 656 int width = DisplayWidth(display_, DefaultScreen(display_)); |
| 658 int height = DisplayHeight(display_, DefaultScreen(display_)); | 657 int height = DisplayHeight(display_, DefaultScreen(display_)); |
| 659 XFillRectangle(display_, window_, gc, 0, 0, width, height); | 658 XFillRectangle(display_, window_, gc, 0, 0, width, height); |
| 660 XFreeGC(display_, gc); | 659 XFreeGC(display_, gc); |
| 661 XFreeColors(display_, colormap, &color.pixel, 1, 0); | 660 XFreeColors(display_, colormap, &color.pixel, 1, 0); |
| 662 } | 661 } |
| 663 | 662 |
| 664 } // namespace ui | 663 } // namespace display |
| OLD | NEW |