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

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

Issue 139053003: Chrome OS: avoid suspending on lid close when casting is active. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments and add unit test. Created 6 years, 11 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
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 #ifndef CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ 5 #ifndef CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_
6 #define CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ 6 #define CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/event_types.h" 13 #include "base/event_types.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "base/timer/timer.h" 17 #include "base/timer/timer.h"
18 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
18 #include "chromeos/chromeos_export.h" 19 #include "chromeos/chromeos_export.h"
19 #include "third_party/cros_system_api/dbus/service_constants.h" 20 #include "third_party/cros_system_api/dbus/service_constants.h"
20 21
21 // Forward declarations for Xlib and Xrandr. 22 // Forward declarations for Xlib and Xrandr.
22 // This is so unused X definitions don't pollute the namespace. 23 // This is so unused X definitions don't pollute the namespace.
23 typedef unsigned long XID; 24 typedef unsigned long XID;
24 typedef XID RROutput; 25 typedef XID RROutput;
25 typedef XID RRCrtc; 26 typedef XID RRCrtc;
26 typedef XID RRMode; 27 typedef XID RRMode;
27 28
(...skipping 30 matching lines...) Expand all
58 enum HDCPState { 59 enum HDCPState {
59 HDCP_STATE_UNDESIRED, 60 HDCP_STATE_UNDESIRED,
60 HDCP_STATE_DESIRED, 61 HDCP_STATE_DESIRED,
61 HDCP_STATE_ENABLED 62 HDCP_STATE_ENABLED
62 }; 63 };
63 64
64 // This class interacts directly with the underlying Xrandr API to manipulate 65 // This class interacts directly with the underlying Xrandr API to manipulate
65 // CTRCs and Outputs. 66 // CTRCs and Outputs.
66 class CHROMEOS_EXPORT OutputConfigurator 67 class CHROMEOS_EXPORT OutputConfigurator
67 : public base::MessageLoop::Dispatcher, 68 : public base::MessageLoop::Dispatcher,
68 public base::MessagePumpObserver { 69 public base::MessagePumpObserver,
70 public MediaCaptureDevicesDispatcher::Observer {
69 public: 71 public:
70 typedef uint64_t OutputProtectionClientId; 72 typedef uint64_t OutputProtectionClientId;
71 static const OutputProtectionClientId kInvalidClientId = 0; 73 static const OutputProtectionClientId kInvalidClientId = 0;
72 74
73 struct ModeInfo { 75 struct ModeInfo {
74 ModeInfo(); 76 ModeInfo();
75 ModeInfo(int width, int height, bool interlaced, float refresh_rate); 77 ModeInfo(int width, int height, bool interlaced, float refresh_rate);
76 78
77 int width; 79 int width;
78 int height; 80 int height;
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 // add/remove events. Note that Output add/remove events are sent in response 373 // add/remove events. Note that Output add/remove events are sent in response
372 // to our own reconfiguration operations so spurious events are common. 374 // to our own reconfiguration operations so spurious events are common.
373 // Spurious events will have no effect. 375 // Spurious events will have no effect.
374 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; 376 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE;
375 377
376 // Overridden from base::MessagePumpObserver: 378 // Overridden from base::MessagePumpObserver:
377 virtual base::EventStatus WillProcessEvent( 379 virtual base::EventStatus WillProcessEvent(
378 const base::NativeEvent& event) OVERRIDE; 380 const base::NativeEvent& event) OVERRIDE;
379 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE; 381 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE;
380 382
383 // Overridden from MediaCaptureDevicesDispatcher::Observer.
384 virtual void OnRequestUpdate(int render_process_id,
385 int render_view_id,
386 const content::MediaStreamDevice& device,
387 const content::MediaRequestState state) OVERRIDE;
388
381 void AddObserver(Observer* observer); 389 void AddObserver(Observer* observer);
382 void RemoveObserver(Observer* observer); 390 void RemoveObserver(Observer* observer);
383 391
384 // Sets all the displays into pre-suspend mode; usually this means 392 // Sets all the displays into pre-suspend mode; usually this means
385 // configure them for their resume state. This allows faster resume on 393 // configure them for their resume state. This allows faster resume on
386 // machines where display configuration is slow. 394 // machines where display configuration is slow.
387 void SuspendDisplays(); 395 void SuspendDisplays();
388 396
389 // Reprobes displays to handle changes made while the system was 397 // Reprobes displays to handle changes made while the system was
390 // suspended. 398 // suspended.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 int frame_buffer_height); 503 int frame_buffer_height);
496 504
497 // Returns the ratio between mirrored mode area and native mode area: 505 // Returns the ratio between mirrored mode area and native mode area:
498 // (mirror_mode_width * mirrow_mode_height) / (native_width * native_height) 506 // (mirror_mode_width * mirrow_mode_height) / (native_width * native_height)
499 float GetMirroredDisplayAreaRatio( 507 float GetMirroredDisplayAreaRatio(
500 const OutputConfigurator::OutputSnapshot& output); 508 const OutputConfigurator::OutputSnapshot& output);
501 509
502 // Applies output protections according to requests. 510 // Applies output protections according to requests.
503 bool ApplyProtections(const DisplayProtections& requests); 511 bool ApplyProtections(const DisplayProtections& requests);
504 512
513 // Sends the current projecting state to power manager.
514 void SendProjectingStateToPowerManager();
515
505 StateController* state_controller_; 516 StateController* state_controller_;
506 SoftwareMirroringController* mirroring_controller_; 517 SoftwareMirroringController* mirroring_controller_;
507 scoped_ptr<Delegate> delegate_; 518 scoped_ptr<Delegate> delegate_;
508 519
509 // Used to enable modes which rely on panel fitting. 520 // Used to enable modes which rely on panel fitting.
510 bool is_panel_fitting_enabled_; 521 bool is_panel_fitting_enabled_;
511 522
512 // Key of the map is the touch display's id, and the value of the map is the 523 // Key of the map is the touch display's id, and the value of the map is the
513 // touch display's area ratio in mirror mode defined as : 524 // touch display's area ratio in mirror mode defined as :
514 // mirror_mode_area / native_mode_area. 525 // mirror_mode_area / native_mode_area.
(...skipping 28 matching lines...) Expand all
543 // The timer to delay configuring outputs. See also the comments in 554 // The timer to delay configuring outputs. See also the comments in
544 // Dispatch(). 555 // Dispatch().
545 scoped_ptr<base::OneShotTimer<OutputConfigurator> > configure_timer_; 556 scoped_ptr<base::OneShotTimer<OutputConfigurator> > configure_timer_;
546 557
547 // Id for next output protection client. 558 // Id for next output protection client.
548 OutputProtectionClientId next_output_protection_client_id_; 559 OutputProtectionClientId next_output_protection_client_id_;
549 560
550 // Output protection requests of each client. 561 // Output protection requests of each client.
551 ProtectionRequests client_protection_requests_; 562 ProtectionRequests client_protection_requests_;
552 563
564 // Number of outstanding screen sharing sessions.
565 int screen_sharing_count_;
566
553 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); 567 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator);
554 }; 568 };
555 569
556 typedef std::vector<OutputConfigurator::OutputSnapshot> OutputSnapshotList; 570 typedef std::vector<OutputConfigurator::OutputSnapshot> OutputSnapshotList;
557 571
558 } // namespace chromeos 572 } // namespace chromeos
559 573
560 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ 574 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698