| 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/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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 unsigned char* values = NULL; | 393 unsigned char* values = NULL; |
| 394 int actual_format = 0; | 394 int actual_format = 0; |
| 395 unsigned long nitems = 0; | 395 unsigned long nitems = 0; |
| 396 unsigned long bytes_after = 0; | 396 unsigned long bytes_after = 0; |
| 397 Atom actual_type = None; | 397 Atom actual_type = None; |
| 398 int success = 0; | 398 int success = 0; |
| 399 RROutput output_id = static_cast<const DisplaySnapshotX11&>(output).output(); | 399 RROutput output_id = static_cast<const DisplaySnapshotX11&>(output).output(); |
| 400 // TODO(kcwu): Use X11AtomCache to save round trip time of XInternAtom. | 400 // TODO(kcwu): Use X11AtomCache to save round trip time of XInternAtom. |
| 401 Atom prop = XInternAtom(display_, kContentProtectionAtomName, False); | 401 Atom prop = XInternAtom(display_, kContentProtectionAtomName, False); |
| 402 | 402 |
| 403 bool ok = true; | |
| 404 // TODO(kcwu): Move this to x11_util (similar method calls in this file and | 403 // TODO(kcwu): Move this to x11_util (similar method calls in this file and |
| 405 // output_util.cc) | 404 // output_util.cc) |
| 406 success = XRRGetOutputProperty(display_, | 405 success = XRRGetOutputProperty(display_, |
| 407 output_id, | 406 output_id, |
| 408 prop, | 407 prop, |
| 409 0, | 408 0, |
| 410 100, | 409 100, |
| 411 False, | 410 False, |
| 412 False, | 411 False, |
| 413 AnyPropertyType, | 412 AnyPropertyType, |
| 414 &actual_type, | 413 &actual_type, |
| 415 &actual_format, | 414 &actual_format, |
| 416 &nitems, | 415 &nitems, |
| 417 &bytes_after, | 416 &bytes_after, |
| 418 &values); | 417 &values); |
| 418 gfx::XScopedPtr<unsigned char> scoped_values(values); |
| 419 if (actual_type == None) { | 419 if (actual_type == None) { |
| 420 LOG(ERROR) << "Property '" << kContentProtectionAtomName | 420 LOG(ERROR) << "Property '" << kContentProtectionAtomName |
| 421 << "' does not exist"; | 421 << "' does not exist"; |
| 422 ok = false; | 422 return false; |
| 423 } else if (success == Success && actual_type == XA_ATOM && | 423 } |
| 424 actual_format == 32 && nitems == 1) { | 424 |
| 425 if (success == Success && actual_type == XA_ATOM && actual_format == 32 && |
| 426 nitems == 1) { |
| 425 Atom value = reinterpret_cast<Atom*>(values)[0]; | 427 Atom value = reinterpret_cast<Atom*>(values)[0]; |
| 426 if (value == XInternAtom(display_, kProtectionUndesiredAtomName, False)) { | 428 if (value == XInternAtom(display_, kProtectionUndesiredAtomName, False)) { |
| 427 *state = HDCP_STATE_UNDESIRED; | 429 *state = HDCP_STATE_UNDESIRED; |
| 428 } else if (value == | 430 } else if (value == |
| 429 XInternAtom(display_, kProtectionDesiredAtomName, False)) { | 431 XInternAtom(display_, kProtectionDesiredAtomName, False)) { |
| 430 *state = HDCP_STATE_DESIRED; | 432 *state = HDCP_STATE_DESIRED; |
| 431 } else if (value == | 433 } else if (value == |
| 432 XInternAtom(display_, kProtectionEnabledAtomName, False)) { | 434 XInternAtom(display_, kProtectionEnabledAtomName, False)) { |
| 433 *state = HDCP_STATE_ENABLED; | 435 *state = HDCP_STATE_ENABLED; |
| 434 } else { | 436 } else { |
| 435 LOG(ERROR) << "Unknown " << kContentProtectionAtomName | 437 LOG(ERROR) << "Unknown " << kContentProtectionAtomName |
| 436 << " value: " << value; | 438 << " value: " << value; |
| 437 ok = false; | 439 return false; |
| 438 } | 440 } |
| 439 } else { | 441 } else { |
| 440 LOG(ERROR) << "XRRGetOutputProperty failed"; | 442 LOG(ERROR) << "XRRGetOutputProperty failed"; |
| 441 ok = false; | 443 return false; |
| 442 } | 444 } |
| 443 if (values) | |
| 444 XFree(values); | |
| 445 | 445 |
| 446 VLOG(3) << "HDCP state: " << ok << "," << *state; | 446 VLOG(3) << "HDCP state: success," << *state; |
| 447 return ok; | 447 return true; |
| 448 } | 448 } |
| 449 | 449 |
| 450 bool NativeDisplayDelegateX11::SetHDCPState(const DisplaySnapshot& output, | 450 bool NativeDisplayDelegateX11::SetHDCPState(const DisplaySnapshot& output, |
| 451 HDCPState state) { | 451 HDCPState state) { |
| 452 Atom name = XInternAtom(display_, kContentProtectionAtomName, False); | 452 Atom name = XInternAtom(display_, kContentProtectionAtomName, False); |
| 453 Atom value = None; | 453 Atom value = None; |
| 454 switch (state) { | 454 switch (state) { |
| 455 case HDCP_STATE_UNDESIRED: | 455 case HDCP_STATE_UNDESIRED: |
| 456 value = XInternAtom(display_, kProtectionUndesiredAtomName, False); | 456 value = XInternAtom(display_, kProtectionUndesiredAtomName, False); |
| 457 break; | 457 break; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 output = None; | 530 output = None; |
| 531 mode_info = NULL; | 531 mode_info = NULL; |
| 532 } | 532 } |
| 533 } | 533 } |
| 534 | 534 |
| 535 ConfigureCrtc(x11_output->crtc(), mode, output, 0, 0); | 535 ConfigureCrtc(x11_output->crtc(), mode, output, 0, 0); |
| 536 } | 536 } |
| 537 } | 537 } |
| 538 | 538 |
| 539 bool NativeDisplayDelegateX11::IsOutputAspectPreservingScaling(RROutput id) { | 539 bool NativeDisplayDelegateX11::IsOutputAspectPreservingScaling(RROutput id) { |
| 540 bool ret = false; | |
| 541 | |
| 542 Atom scaling_prop = XInternAtom(display_, "scaling mode", False); | 540 Atom scaling_prop = XInternAtom(display_, "scaling mode", False); |
| 543 Atom full_aspect_atom = XInternAtom(display_, "Full aspect", False); | 541 Atom full_aspect_atom = XInternAtom(display_, "Full aspect", False); |
| 544 if (scaling_prop == None || full_aspect_atom == None) | 542 if (scaling_prop == None || full_aspect_atom == None) |
| 545 return false; | 543 return false; |
| 546 | 544 |
| 547 int nprop = 0; | 545 int nprop = 0; |
| 548 Atom* props = XRRListOutputProperties(display_, id, &nprop); | 546 gfx::XScopedPtr<Atom[]> props(XRRListOutputProperties(display_, id, &nprop)); |
| 549 for (int j = 0; j < nprop && !ret; j++) { | 547 for (int j = 0; j < nprop; j++) { |
| 550 Atom prop = props[j]; | 548 Atom prop = props[j]; |
| 551 if (scaling_prop == prop) { | 549 if (scaling_prop == prop) { |
| 552 unsigned char* values = NULL; | 550 unsigned char* values = NULL; |
| 553 int actual_format; | 551 int actual_format; |
| 554 unsigned long nitems; | 552 unsigned long nitems; |
| 555 unsigned long bytes_after; | 553 unsigned long bytes_after; |
| 556 Atom actual_type; | 554 Atom actual_type; |
| 557 int success; | 555 int success; |
| 558 | 556 |
| 559 success = XRRGetOutputProperty(display_, | 557 success = XRRGetOutputProperty(display_, |
| 560 id, | 558 id, |
| 561 prop, | 559 prop, |
| 562 0, | 560 0, |
| 563 100, | 561 100, |
| 564 False, | 562 False, |
| 565 False, | 563 False, |
| 566 AnyPropertyType, | 564 AnyPropertyType, |
| 567 &actual_type, | 565 &actual_type, |
| 568 &actual_format, | 566 &actual_format, |
| 569 &nitems, | 567 &nitems, |
| 570 &bytes_after, | 568 &bytes_after, |
| 571 &values); | 569 &values); |
| 570 gfx::XScopedPtr<unsigned char> scoped_value(values); |
| 572 if (success == Success && actual_type == XA_ATOM && actual_format == 32 && | 571 if (success == Success && actual_type == XA_ATOM && actual_format == 32 && |
| 573 nitems == 1) { | 572 nitems == 1) { |
| 574 Atom value = reinterpret_cast<Atom*>(values)[0]; | 573 Atom value = reinterpret_cast<Atom*>(values)[0]; |
| 575 if (full_aspect_atom == value) | 574 if (full_aspect_atom == value) |
| 576 ret = true; | 575 return true; |
| 577 } | 576 } |
| 578 if (values) | |
| 579 XFree(values); | |
| 580 } | 577 } |
| 581 } | 578 } |
| 582 if (props) | 579 return false; |
| 583 XFree(props); | |
| 584 | |
| 585 return ret; | |
| 586 } | 580 } |
| 587 | 581 |
| 588 | 582 |
| 589 std::vector<ColorCalibrationProfile> | 583 std::vector<ColorCalibrationProfile> |
| 590 NativeDisplayDelegateX11::GetAvailableColorCalibrationProfiles( | 584 NativeDisplayDelegateX11::GetAvailableColorCalibrationProfiles( |
| 591 const DisplaySnapshot& output) { | 585 const DisplaySnapshot& output) { |
| 592 // TODO(mukai|marcheu): Checks the system data and fills the result. | 586 // TODO(mukai|marcheu): Checks the system data and fills the result. |
| 593 // Note that the order would be Dynamic -> Standard -> Movie -> Reading. | 587 // Note that the order would be Dynamic -> Standard -> Movie -> Reading. |
| 594 return std::vector<ColorCalibrationProfile>(); | 588 return std::vector<ColorCalibrationProfile>(); |
| 595 } | 589 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 XSetForeground(display_, gc, color.pixel); | 634 XSetForeground(display_, gc, color.pixel); |
| 641 XSetFillStyle(display_, gc, FillSolid); | 635 XSetFillStyle(display_, gc, FillSolid); |
| 642 int width = DisplayWidth(display_, DefaultScreen(display_)); | 636 int width = DisplayWidth(display_, DefaultScreen(display_)); |
| 643 int height = DisplayHeight(display_, DefaultScreen(display_)); | 637 int height = DisplayHeight(display_, DefaultScreen(display_)); |
| 644 XFillRectangle(display_, window_, gc, 0, 0, width, height); | 638 XFillRectangle(display_, window_, gc, 0, 0, width, height); |
| 645 XFreeGC(display_, gc); | 639 XFreeGC(display_, gc); |
| 646 XFreeColors(display_, colormap, &color.pixel, 1, 0); | 640 XFreeColors(display_, colormap, &color.pixel, 1, 0); |
| 647 } | 641 } |
| 648 | 642 |
| 649 } // namespace ui | 643 } // namespace ui |
| OLD | NEW |