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

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

Issue 2924343002: Move ui::GetAtom to gfx::GetAtom (Closed)
Patch Set: fix CrOs build Created 3 years, 6 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 | « ui/base/x/x11_util.cc ('k') | ui/display/util/x11/edid_parser_x11.cc » ('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 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 <algorithm> 13 #include <algorithm>
14 #include <utility> 14 #include <utility>
15 15
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.h"
19 #include "ui/base/x/x11_util.h"
20 #include "ui/display/manager/chromeos/x11/display_mode_x11.h" 19 #include "ui/display/manager/chromeos/x11/display_mode_x11.h"
21 #include "ui/display/manager/chromeos/x11/display_snapshot_x11.h" 20 #include "ui/display/manager/chromeos/x11/display_snapshot_x11.h"
22 #include "ui/display/manager/chromeos/x11/display_util_x11.h" 21 #include "ui/display/manager/chromeos/x11/display_util_x11.h"
23 #include "ui/display/manager/chromeos/x11/native_display_event_dispatcher_x11.h" 22 #include "ui/display/manager/chromeos/x11/native_display_event_dispatcher_x11.h"
24 #include "ui/display/types/native_display_observer.h" 23 #include "ui/display/types/native_display_observer.h"
25 #include "ui/display/util/x11/edid_parser_x11.h" 24 #include "ui/display/util/x11/edid_parser_x11.h"
26 #include "ui/events/platform/platform_event_source.h" 25 #include "ui/events/platform/platform_event_source.h"
27 #include "ui/gfx/geometry/rect.h" 26 #include "ui/gfx/geometry/rect.h"
27 #include "ui/gfx/x/x11_atom_cache.h"
28 #include "ui/gfx/x/x11_error_tracker.h" 28 #include "ui/gfx/x/x11_error_tracker.h"
29 #include "ui/gfx/x/x11_types.h" 29 #include "ui/gfx/x/x11_types.h"
30 30
31 namespace display { 31 namespace display {
32 32
33 namespace { 33 namespace {
34 34
35 // DPI measurements. 35 // DPI measurements.
36 const float kMmInInch = 25.4; 36 const float kMmInInch = 25.4;
37 const float kDpi96 = 96.0; 37 const float kDpi96 = 96.0;
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 396
397 bool NativeDisplayDelegateX11::GetHDCPState(const DisplaySnapshot& output, 397 bool NativeDisplayDelegateX11::GetHDCPState(const DisplaySnapshot& output,
398 HDCPState* state) { 398 HDCPState* state) {
399 unsigned char* values = NULL; 399 unsigned char* values = NULL;
400 int actual_format = 0; 400 int actual_format = 0;
401 unsigned long nitems = 0; 401 unsigned long nitems = 0;
402 unsigned long bytes_after = 0; 402 unsigned long bytes_after = 0;
403 Atom actual_type = None; 403 Atom actual_type = None;
404 int success = 0; 404 int success = 0;
405 RROutput output_id = static_cast<const DisplaySnapshotX11&>(output).output(); 405 RROutput output_id = static_cast<const DisplaySnapshotX11&>(output).output();
406 Atom prop = ui::GetAtom(kContentProtectionAtomName); 406 Atom prop = gfx::GetAtom(kContentProtectionAtomName);
407 407
408 // TODO(kcwu): Move this to x11_util (similar method calls in this file and 408 // TODO(kcwu): Move this to x11_util (similar method calls in this file and
409 // output_util.cc) 409 // output_util.cc)
410 success = XRRGetOutputProperty(display_, 410 success = XRRGetOutputProperty(display_,
411 output_id, 411 output_id,
412 prop, 412 prop,
413 0, 413 0,
414 100, 414 100,
415 False, 415 False,
416 False, 416 False,
417 AnyPropertyType, 417 AnyPropertyType,
418 &actual_type, 418 &actual_type,
419 &actual_format, 419 &actual_format,
420 &nitems, 420 &nitems,
421 &bytes_after, 421 &bytes_after,
422 &values); 422 &values);
423 gfx::XScopedPtr<unsigned char> scoped_values(values); 423 gfx::XScopedPtr<unsigned char> scoped_values(values);
424 if (actual_type == None) { 424 if (actual_type == None) {
425 LOG(ERROR) << "Property '" << kContentProtectionAtomName 425 LOG(ERROR) << "Property '" << kContentProtectionAtomName
426 << "' does not exist"; 426 << "' does not exist";
427 return false; 427 return false;
428 } 428 }
429 429
430 if (success == Success && actual_type == XA_ATOM && actual_format == 32 && 430 if (success == Success && actual_type == XA_ATOM && actual_format == 32 &&
431 nitems == 1) { 431 nitems == 1) {
432 Atom value = reinterpret_cast<Atom*>(values)[0]; 432 Atom value = reinterpret_cast<Atom*>(values)[0];
433 if (value == ui::GetAtom(kProtectionUndesiredAtomName)) { 433 if (value == gfx::GetAtom(kProtectionUndesiredAtomName)) {
434 *state = HDCP_STATE_UNDESIRED; 434 *state = HDCP_STATE_UNDESIRED;
435 } else if (value == ui::GetAtom(kProtectionDesiredAtomName)) { 435 } else if (value == gfx::GetAtom(kProtectionDesiredAtomName)) {
436 *state = HDCP_STATE_DESIRED; 436 *state = HDCP_STATE_DESIRED;
437 } else if (value == ui::GetAtom(kProtectionEnabledAtomName)) { 437 } else if (value == gfx::GetAtom(kProtectionEnabledAtomName)) {
438 *state = HDCP_STATE_ENABLED; 438 *state = HDCP_STATE_ENABLED;
439 } else { 439 } else {
440 LOG(ERROR) << "Unknown " << kContentProtectionAtomName 440 LOG(ERROR) << "Unknown " << kContentProtectionAtomName
441 << " value: " << value; 441 << " value: " << value;
442 return false; 442 return false;
443 } 443 }
444 } else { 444 } else {
445 LOG(ERROR) << "XRRGetOutputProperty failed"; 445 LOG(ERROR) << "XRRGetOutputProperty failed";
446 return false; 446 return false;
447 } 447 }
448 448
449 VLOG(3) << "HDCP state: success," << *state; 449 VLOG(3) << "HDCP state: success," << *state;
450 return true; 450 return true;
451 } 451 }
452 452
453 void NativeDisplayDelegateX11::SetHDCPState( 453 void NativeDisplayDelegateX11::SetHDCPState(
454 const DisplaySnapshot& output, 454 const DisplaySnapshot& output,
455 HDCPState state, 455 HDCPState state,
456 const SetHDCPStateCallback& callback) { 456 const SetHDCPStateCallback& callback) {
457 callback.Run(SetHDCPState(output, state)); 457 callback.Run(SetHDCPState(output, state));
458 } 458 }
459 459
460 bool NativeDisplayDelegateX11::SetHDCPState(const DisplaySnapshot& output, 460 bool NativeDisplayDelegateX11::SetHDCPState(const DisplaySnapshot& output,
461 HDCPState state) { 461 HDCPState state) {
462 Atom name = ui::GetAtom(kContentProtectionAtomName); 462 Atom name = gfx::GetAtom(kContentProtectionAtomName);
463 Atom value = None; 463 Atom value = None;
464 switch (state) { 464 switch (state) {
465 case HDCP_STATE_UNDESIRED: 465 case HDCP_STATE_UNDESIRED:
466 value = ui::GetAtom(kProtectionUndesiredAtomName); 466 value = gfx::GetAtom(kProtectionUndesiredAtomName);
467 break; 467 break;
468 case HDCP_STATE_DESIRED: 468 case HDCP_STATE_DESIRED:
469 value = ui::GetAtom(kProtectionDesiredAtomName); 469 value = gfx::GetAtom(kProtectionDesiredAtomName);
470 break; 470 break;
471 default: 471 default:
472 NOTREACHED() << "Invalid HDCP state: " << state; 472 NOTREACHED() << "Invalid HDCP state: " << state;
473 return false; 473 return false;
474 } 474 }
475 gfx::X11ErrorTracker err_tracker; 475 gfx::X11ErrorTracker err_tracker;
476 unsigned char* data = reinterpret_cast<unsigned char*>(&value); 476 unsigned char* data = reinterpret_cast<unsigned char*>(&value);
477 RROutput output_id = static_cast<const DisplaySnapshotX11&>(output).output(); 477 RROutput output_id = static_cast<const DisplaySnapshotX11&>(output).output();
478 XRRChangeOutputProperty( 478 XRRChangeOutputProperty(
479 display_, output_id, name, XA_ATOM, 32, PropModeReplace, data, 1); 479 display_, output_id, name, XA_ATOM, 32, PropModeReplace, data, 1);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 output = None; 536 output = None;
537 mode_info = NULL; 537 mode_info = NULL;
538 } 538 }
539 } 539 }
540 540
541 ConfigureCrtc(x11_output->crtc(), mode, output, 0, 0); 541 ConfigureCrtc(x11_output->crtc(), mode, output, 0, 0);
542 } 542 }
543 } 543 }
544 544
545 bool NativeDisplayDelegateX11::IsOutputAspectPreservingScaling(RROutput id) { 545 bool NativeDisplayDelegateX11::IsOutputAspectPreservingScaling(RROutput id) {
546 Atom scaling_prop = ui::GetAtom("scaling mode"); 546 Atom scaling_prop = gfx::GetAtom("scaling mode");
547 Atom full_aspect_atom = ui::GetAtom("Full aspect"); 547 Atom full_aspect_atom = gfx::GetAtom("Full aspect");
548 if (scaling_prop == None || full_aspect_atom == None) 548 if (scaling_prop == None || full_aspect_atom == None)
549 return false; 549 return false;
550 550
551 int nprop = 0; 551 int nprop = 0;
552 gfx::XScopedPtr<Atom[]> props(XRRListOutputProperties(display_, id, &nprop)); 552 gfx::XScopedPtr<Atom[]> props(XRRListOutputProperties(display_, id, &nprop));
553 for (int j = 0; j < nprop; j++) { 553 for (int j = 0; j < nprop; j++) {
554 Atom prop = props[j]; 554 Atom prop = props[j];
555 if (scaling_prop == prop) { 555 if (scaling_prop == prop) {
556 unsigned char* values = NULL; 556 unsigned char* values = NULL;
557 int actual_format; 557 int actual_format;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 XSetForeground(display_, gc, color.pixel); 647 XSetForeground(display_, gc, color.pixel);
648 XSetFillStyle(display_, gc, FillSolid); 648 XSetFillStyle(display_, gc, FillSolid);
649 int width = DisplayWidth(display_, DefaultScreen(display_)); 649 int width = DisplayWidth(display_, DefaultScreen(display_));
650 int height = DisplayHeight(display_, DefaultScreen(display_)); 650 int height = DisplayHeight(display_, DefaultScreen(display_));
651 XFillRectangle(display_, window_, gc, 0, 0, width, height); 651 XFillRectangle(display_, window_, gc, 0, 0, width, height);
652 XFreeGC(display_, gc); 652 XFreeGC(display_, gc);
653 XFreeColors(display_, colormap, &color.pixel, 1, 0); 653 XFreeColors(display_, colormap, &color.pixel, 1, 0);
654 } 654 }
655 655
656 } // namespace display 656 } // namespace display
OLDNEW
« no previous file with comments | « ui/base/x/x11_util.cc ('k') | ui/display/util/x11/edid_parser_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698