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

Side by Side Diff: chromeos/display/output_configurator.cc

Issue 12079002: Minimize black screen during the boot with multi displays (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chromeos/display/output_configurator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chromeos/display/output_configurator.h" 5 #include "chromeos/display/output_configurator.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include <X11/Xatom.h> 9 #include <X11/Xatom.h>
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 : is_running_on_chrome_os_(base::chromeos::IsRunningOnChromeOS()), 532 : is_running_on_chrome_os_(base::chromeos::IsRunningOnChromeOS()),
533 is_panel_fitting_enabled_(false), 533 is_panel_fitting_enabled_(false),
534 connected_output_count_(0), 534 connected_output_count_(0),
535 xrandr_event_base_(0), 535 xrandr_event_base_(0),
536 output_state_(STATE_INVALID), 536 output_state_(STATE_INVALID),
537 mirror_mode_will_preserve_aspect_(false), 537 mirror_mode_will_preserve_aspect_(false),
538 mirror_mode_preserved_aspect_(false), 538 mirror_mode_preserved_aspect_(false),
539 last_enter_state_time_() { 539 last_enter_state_time_() {
540 } 540 }
541 541
542 void OutputConfigurator::Init(bool is_panel_fitting_enabled) { 542 OutputConfigurator::~OutputConfigurator() {
543 RecordPreviousStateUMA();
544 }
545
546 void OutputConfigurator::Init(bool is_panel_fitting_enabled,
547 uint32 background_color_argb) {
543 TRACE_EVENT0("chromeos", "OutputConfigurator::Init"); 548 TRACE_EVENT0("chromeos", "OutputConfigurator::Init");
544 if (!is_running_on_chrome_os_) 549 if (!is_running_on_chrome_os_)
545 return; 550 return;
546
547 is_panel_fitting_enabled_ = is_panel_fitting_enabled; 551 is_panel_fitting_enabled_ = is_panel_fitting_enabled;
548 552
549 // Cache the initial output state. 553 // Cache the initial output state.
550 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); 554 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay();
551 CHECK(display != NULL); 555 CHECK(display != NULL);
552 XGrabServer(display); 556 XGrabServer(display);
553 Window window = DefaultRootWindow(display); 557 Window window = DefaultRootWindow(display);
554 XRRScreenResources* screen = GetScreenResourcesAndRecordUMA(display, window); 558 XRRScreenResources* screen = GetScreenResourcesAndRecordUMA(display, window);
555 CHECK(screen != NULL); 559 CHECK(screen != NULL);
556 560
557 // Detect our initial state. 561 // Detect our initial state.
558 std::vector<OutputSnapshot> outputs = GetDualOutputs(display, screen); 562 std::vector<OutputSnapshot> outputs = GetDualOutputs(display, screen);
559 connected_output_count_ = outputs.size(); 563 connected_output_count_ = outputs.size();
564 if (outputs.size() > 1 && background_color_argb) {
565 // Configuring CRTCs/Framebuffer clears the boot screen image.
566 // Set the same background color while configuring the
567 // display to minimize the duration of black screen at boot
568 // time. The background is filled with black later in
569 // ash::DisplayManager.
570 // crbug.com/171050.
571 XSetWindowAttributes swa = {0};
572 XColor color;
573 Colormap colormap = DefaultColormap(display, 0);
574 // XColor uses 16 bits per color.
575 color.red = (background_color_argb & 0x00FF0000) >> 8;
576 color.green = (background_color_argb & 0x0000FF00);
577 color.blue = (background_color_argb & 0x000000FF) << 8;
578 color.flags = DoRed | DoGreen | DoBlue;
579 XAllocColor(display, colormap, &color);
580 swa.background_pixel = color.pixel;
581 XChangeWindowAttributes(display, window, CWBackPixel, &swa);
582 XFreeColors(display, colormap, &color.pixel, 1, 0);
583 }
584
560 output_state_ = InferCurrentState(display, screen, outputs); 585 output_state_ = InferCurrentState(display, screen, outputs);
561 // Ensure that we are in a supported state with all connected displays powered 586 // Ensure that we are in a supported state with all connected displays powered
562 // on. 587 // on.
563 OutputState starting_state = GetNextState(display, 588 OutputState starting_state = GetNextState(display,
564 screen, 589 screen,
565 STATE_INVALID, 590 STATE_INVALID,
566 outputs); 591 outputs);
567 if (output_state_ != starting_state && 592 if (output_state_ != starting_state &&
568 EnterState(display, 593 EnterState(display,
569 screen, 594 screen,
(...skipping 14 matching lines...) Expand all
584 CHECK(DPMSForceLevel(display, DPMSModeOn)); 609 CHECK(DPMSForceLevel(display, DPMSModeOn));
585 610
586 // Relinquish X resources. 611 // Relinquish X resources.
587 XRRFreeScreenResources(screen); 612 XRRFreeScreenResources(screen);
588 XUngrabServer(display); 613 XUngrabServer(display);
589 614
590 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 615 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
591 SetIsProjecting(is_projecting); 616 SetIsProjecting(is_projecting);
592 } 617 }
593 618
594 OutputConfigurator::~OutputConfigurator() {
595 RecordPreviousStateUMA();
596 }
597
598 bool OutputConfigurator::CycleDisplayMode() { 619 bool OutputConfigurator::CycleDisplayMode() {
599 TRACE_EVENT0("chromeos", "OutputConfigurator::CycleDisplayMode"); 620 TRACE_EVENT0("chromeos", "OutputConfigurator::CycleDisplayMode");
600 VLOG(1) << "CycleDisplayMode"; 621 VLOG(1) << "CycleDisplayMode";
601 if (!is_running_on_chrome_os_) 622 if (!is_running_on_chrome_os_)
602 return false; 623 return false;
603 624
604 bool did_change = false; 625 bool did_change = false;
605 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); 626 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay();
606 CHECK(display != NULL); 627 CHECK(display != NULL);
607 XGrabServer(display); 628 XGrabServer(display);
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 // static 1339 // static
1319 RRMode OutputConfigurator::GetOutputNativeMode( 1340 RRMode OutputConfigurator::GetOutputNativeMode(
1320 const XRROutputInfo* output_info) { 1341 const XRROutputInfo* output_info) {
1321 if (output_info->nmode <= 0) 1342 if (output_info->nmode <= 0)
1322 return None; 1343 return None;
1323 1344
1324 return output_info->modes[0]; 1345 return output_info->modes[0];
1325 } 1346 }
1326 1347
1327 } // namespace chromeos 1348 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/display/output_configurator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698