| OLD | NEW | 
|---|
|  | (Empty) | 
| 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 |  | 
| 3 // found in the LICENSE file. |  | 
| 4 |  | 
| 5 #ifndef CHROMEOS_DISPLAY_NATIVE_DISPLAY_DELEGATE_X11_H_ |  | 
| 6 #define CHROMEOS_DISPLAY_NATIVE_DISPLAY_DELEGATE_X11_H_ |  | 
| 7 |  | 
| 8 #include <vector> |  | 
| 9 |  | 
| 10 #include "base/basictypes.h" |  | 
| 11 #include "base/compiler_specific.h" |  | 
| 12 #include "chromeos/display/native_display_delegate.h" |  | 
| 13 |  | 
| 14 typedef XID Window; |  | 
| 15 |  | 
| 16 struct _XDisplay; |  | 
| 17 typedef struct _XDisplay Display; |  | 
| 18 struct _XRROutputInfo; |  | 
| 19 typedef _XRROutputInfo XRROutputInfo; |  | 
| 20 struct _XRRScreenResources; |  | 
| 21 typedef _XRRScreenResources XRRScreenResources; |  | 
| 22 |  | 
| 23 namespace chromeos { |  | 
| 24 |  | 
| 25 class NativeDisplayEventDispatcherX11; |  | 
| 26 |  | 
| 27 class NativeDisplayDelegateX11 : public NativeDisplayDelegate { |  | 
| 28  public: |  | 
| 29   // Helper class that allows NativeDisplayEventDispatcherX11 and |  | 
| 30   // NativeDisplayDelegateX11::MessagePumpObserverX11 to interact with this |  | 
| 31   // class or with mocks in tests. |  | 
| 32   class HelperDelegate { |  | 
| 33    public: |  | 
| 34     virtual ~HelperDelegate() {} |  | 
| 35 |  | 
| 36     // Tells XRandR to update its configuration in response to |event|, an |  | 
| 37     // RRScreenChangeNotify event. |  | 
| 38     virtual void UpdateXRandRConfiguration(const base::NativeEvent& event) = 0; |  | 
| 39 |  | 
| 40     // Returns the list of current outputs. This is used to discard duplicate |  | 
| 41     // events. |  | 
| 42     virtual const std::vector<OutputConfigurator::OutputSnapshot>& |  | 
| 43         GetCachedOutputs() const = 0; |  | 
| 44 |  | 
| 45     // Notify |observers_| that a change in configuration has occurred. |  | 
| 46     virtual void NotifyDisplayObservers() = 0; |  | 
| 47   }; |  | 
| 48 |  | 
| 49   NativeDisplayDelegateX11(); |  | 
| 50   virtual ~NativeDisplayDelegateX11(); |  | 
| 51 |  | 
| 52   // OutputConfigurator::Delegate overrides: |  | 
| 53   virtual void Initialize() OVERRIDE; |  | 
| 54   virtual void GrabServer() OVERRIDE; |  | 
| 55   virtual void UngrabServer() OVERRIDE; |  | 
| 56   virtual void SyncWithServer() OVERRIDE; |  | 
| 57   virtual void SetBackgroundColor(uint32 color_argb) OVERRIDE; |  | 
| 58   virtual void ForceDPMSOn() OVERRIDE; |  | 
| 59   virtual std::vector<OutputConfigurator::OutputSnapshot> GetOutputs() OVERRIDE; |  | 
| 60   virtual void AddMode(const OutputConfigurator::OutputSnapshot& output, |  | 
| 61                        RRMode mode) OVERRIDE; |  | 
| 62   virtual bool Configure(const OutputConfigurator::OutputSnapshot& output, |  | 
| 63                          RRMode mode, |  | 
| 64                          int x, |  | 
| 65                          int y) OVERRIDE; |  | 
| 66   virtual void CreateFrameBuffer( |  | 
| 67       int width, |  | 
| 68       int height, |  | 
| 69       const std::vector<OutputConfigurator::OutputSnapshot>& outputs) OVERRIDE; |  | 
| 70   virtual bool GetHDCPState(const OutputConfigurator::OutputSnapshot& output, |  | 
| 71                             ui::HDCPState* state) OVERRIDE; |  | 
| 72   virtual bool SetHDCPState(const OutputConfigurator::OutputSnapshot& output, |  | 
| 73                             ui::HDCPState state) OVERRIDE; |  | 
| 74 |  | 
| 75   virtual void AddObserver(NativeDisplayObserver* observer) OVERRIDE; |  | 
| 76   virtual void RemoveObserver(NativeDisplayObserver* observer) OVERRIDE; |  | 
| 77 |  | 
| 78  private: |  | 
| 79   class HelperDelegateX11; |  | 
| 80   class MessagePumpObserverX11; |  | 
| 81 |  | 
| 82   // Initializes |mode_info| to contain details corresponding to |mode|. Returns |  | 
| 83   // true on success. |  | 
| 84   bool InitModeInfo(RRMode mode, OutputConfigurator::ModeInfo* mode_info); |  | 
| 85 |  | 
| 86   // Helper method for GetOutputs() that returns an OutputSnapshot struct based |  | 
| 87   // on the passed-in information. Further initialization is required (e.g. |  | 
| 88   // |selected_mode|, |mirror_mode|, and |touch_device_id|). |  | 
| 89   OutputConfigurator::OutputSnapshot InitOutputSnapshot(RROutput id, |  | 
| 90                                                         XRROutputInfo* info, |  | 
| 91                                                         RRCrtc* last_used_crtc, |  | 
| 92                                                         int index); |  | 
| 93 |  | 
| 94   // Destroys unused CRTCs and parks used CRTCs in a way which allows a |  | 
| 95   // framebuffer resize. This is faster than turning them off, resizing, |  | 
| 96   // then turning them back on. |  | 
| 97   void DestroyUnusedCrtcs( |  | 
| 98       const std::vector<OutputConfigurator::OutputSnapshot>& outputs); |  | 
| 99 |  | 
| 100   bool ConfigureCrtc(RRCrtc crtc, RRMode mode, RROutput output, int x, int y); |  | 
| 101 |  | 
| 102   // Returns whether |id| is configured to preserve aspect when scaling. |  | 
| 103   bool IsOutputAspectPreservingScaling(RROutput id); |  | 
| 104 |  | 
| 105   Display* display_; |  | 
| 106   Window window_; |  | 
| 107 |  | 
| 108   // Initialized when the server is grabbed and freed when it's ungrabbed. |  | 
| 109   XRRScreenResources* screen_; |  | 
| 110 |  | 
| 111   // Every time GetOutputs() is called we cache the updated list of outputs in |  | 
| 112   // |cached_outputs_| so that we can check for duplicate events rather than |  | 
| 113   // propagate them. |  | 
| 114   std::vector<OutputConfigurator::OutputSnapshot> cached_outputs_; |  | 
| 115 |  | 
| 116   scoped_ptr<HelperDelegate> helper_delegate_; |  | 
| 117 |  | 
| 118   // Processes X11 display events associated with the root window and notifies |  | 
| 119   // |observers_| when a display change has occurred. |  | 
| 120   scoped_ptr<NativeDisplayEventDispatcherX11> message_pump_dispatcher_; |  | 
| 121 |  | 
| 122   // Processes X11 display events that have no X11 window associated with it. |  | 
| 123   scoped_ptr<MessagePumpObserverX11> message_pump_observer_; |  | 
| 124 |  | 
| 125   // List of observers waiting for display configuration change events. |  | 
| 126   ObserverList<NativeDisplayObserver> observers_; |  | 
| 127 |  | 
| 128   DISALLOW_COPY_AND_ASSIGN(NativeDisplayDelegateX11); |  | 
| 129 }; |  | 
| 130 |  | 
| 131 }  // namespace chromeos |  | 
| 132 |  | 
| 133 #endif  // CHROMEOS_DISPLAY_NATIVE_DISPLAY_DELEGATE_X11_H_ |  | 
| OLD | NEW | 
|---|