| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_REAL_OUTPUT_CONFIGURATOR_DELEGATE_H_ | 5 #ifndef CHROMEOS_DISPLAY_REAL_OUTPUT_CONFIGURATOR_DELEGATE_H_ |
| 6 #define CHROMEOS_DISPLAY_REAL_OUTPUT_CONFIGURATOR_DELEGATE_H_ | 6 #define CHROMEOS_DISPLAY_REAL_OUTPUT_CONFIGURATOR_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 typedef _XRRScreenResources XRRScreenResources; | 21 typedef _XRRScreenResources XRRScreenResources; |
| 22 | 22 |
| 23 namespace chromeos { | 23 namespace chromeos { |
| 24 | 24 |
| 25 class RealOutputConfiguratorDelegate : public OutputConfigurator::Delegate { | 25 class RealOutputConfiguratorDelegate : public OutputConfigurator::Delegate { |
| 26 public: | 26 public: |
| 27 RealOutputConfiguratorDelegate(); | 27 RealOutputConfiguratorDelegate(); |
| 28 virtual ~RealOutputConfiguratorDelegate(); | 28 virtual ~RealOutputConfiguratorDelegate(); |
| 29 | 29 |
| 30 // OutputConfigurator::Delegate overrides: | 30 // OutputConfigurator::Delegate overrides: |
| 31 virtual void SetPanelFittingEnabled(bool enabled) OVERRIDE; | |
| 32 virtual void InitXRandRExtension(int* event_base) OVERRIDE; | 31 virtual void InitXRandRExtension(int* event_base) OVERRIDE; |
| 33 virtual void UpdateXRandRConfiguration( | 32 virtual void UpdateXRandRConfiguration( |
| 34 const base::NativeEvent& event) OVERRIDE; | 33 const base::NativeEvent& event) OVERRIDE; |
| 35 virtual void GrabServer() OVERRIDE; | 34 virtual void GrabServer() OVERRIDE; |
| 36 virtual void UngrabServer() OVERRIDE; | 35 virtual void UngrabServer() OVERRIDE; |
| 37 virtual void SyncWithServer() OVERRIDE; | 36 virtual void SyncWithServer() OVERRIDE; |
| 38 virtual void SetBackgroundColor(uint32 color_argb) OVERRIDE; | 37 virtual void SetBackgroundColor(uint32 color_argb) OVERRIDE; |
| 39 virtual void ForceDPMSOn() OVERRIDE; | 38 virtual void ForceDPMSOn() OVERRIDE; |
| 40 virtual std::vector<OutputConfigurator::OutputSnapshot> GetOutputs( | 39 virtual std::vector<OutputConfigurator::OutputSnapshot> GetOutputs() OVERRIDE; |
| 41 const OutputConfigurator::StateController* state_controller) OVERRIDE; | 40 virtual void AddOutputMode(RROutput output, RRMode mode) OVERRIDE; |
| 42 virtual bool ConfigureCrtc( | 41 virtual bool ConfigureCrtc( |
| 43 RRCrtc crtc, | 42 RRCrtc crtc, |
| 44 RRMode mode, | 43 RRMode mode, |
| 45 RROutput output, | 44 RROutput output, |
| 46 int x, | 45 int x, |
| 47 int y) OVERRIDE; | 46 int y) OVERRIDE; |
| 48 virtual void CreateFrameBuffer( | 47 virtual void CreateFrameBuffer( |
| 49 int width, | 48 int width, |
| 50 int height, | 49 int height, |
| 51 const std::vector<OutputConfigurator::OutputSnapshot>& outputs) OVERRIDE; | 50 const std::vector<OutputConfigurator::OutputSnapshot>& outputs) OVERRIDE; |
| 52 virtual void ConfigureCTM( | 51 virtual void ConfigureCTM( |
| 53 int touch_device_id, | 52 int touch_device_id, |
| 54 const OutputConfigurator::CoordinateTransformation& ctm) OVERRIDE; | 53 const OutputConfigurator::CoordinateTransformation& ctm) OVERRIDE; |
| 55 virtual void SendProjectingStateToPowerManager(bool projecting) OVERRIDE; | 54 virtual void SendProjectingStateToPowerManager(bool projecting) OVERRIDE; |
| 56 | 55 |
| 57 private: | 56 private: |
| 58 // Gets details corresponding to |mode|. Parameters may be NULL. Returns | 57 // Initializes |mode_info| to contain details corresponding to |mode|. Returns |
| 59 // true on success. | 58 // true on success. |
| 60 bool GetModeDetails(RRMode mode, int* width, int* height, bool* interlaced); | 59 bool InitModeInfo(RRMode mode, OutputConfigurator::ModeInfo* mode_info); |
| 61 | 60 |
| 62 // Helper method for GetOutputs() that returns an OutputSnapshot struct based | 61 // Helper method for GetOutputs() that returns an OutputSnapshot struct based |
| 63 // on the passed-in information. Further initialization is required (e.g. | 62 // on the passed-in information. Further initialization is required (e.g. |
| 64 // |selected_mode|, |mirror_mode|, and |touch_device_id|). | 63 // |selected_mode|, |mirror_mode|, and |touch_device_id|). |
| 65 OutputConfigurator::OutputSnapshot InitOutputSnapshot( | 64 OutputConfigurator::OutputSnapshot InitOutputSnapshot( |
| 66 RROutput id, | 65 RROutput id, |
| 67 XRROutputInfo* info, | 66 XRROutputInfo* info, |
| 68 RRCrtc* last_used_crtc, | 67 RRCrtc* last_used_crtc, |
| 69 int index); | 68 int index); |
| 70 | 69 |
| 71 // Destroys unused CRTCs and parks used CRTCs in a way which allows a | 70 // Destroys unused CRTCs and parks used CRTCs in a way which allows a |
| 72 // framebuffer resize. This is faster than turning them off, resizing, | 71 // framebuffer resize. This is faster than turning them off, resizing, |
| 73 // then turning them back on. | 72 // then turning them back on. |
| 74 void DestroyUnusedCrtcs( | 73 void DestroyUnusedCrtcs( |
| 75 const std::vector<OutputConfigurator::OutputSnapshot>& outputs); | 74 const std::vector<OutputConfigurator::OutputSnapshot>& outputs); |
| 76 | 75 |
| 77 // Returns whether |id| is configured to preserve aspect when scaling. | 76 // Returns whether |id| is configured to preserve aspect when scaling. |
| 78 bool IsOutputAspectPreservingScaling(RROutput id); | 77 bool IsOutputAspectPreservingScaling(RROutput id); |
| 79 | 78 |
| 80 // Looks for a mode on internal and external outputs having same | |
| 81 // resolution. |internal_info| and |external_info| are used to search | |
| 82 // for the modes. |internal_output_id| is used to create a new mode, if | |
| 83 // applicable. |try_creating|=true will enable creating panel-fitting | |
| 84 // mode on the |internal_info| output instead of only searching for a | |
| 85 // matching mode. Note: it may lead to a crash, if |internal_info| is | |
| 86 // not capable of panel fitting. |preserve_aspect|=true will limit the | |
| 87 // search / creation only to the modes having the native aspect ratio of | |
| 88 // |external_info|. |internal_mirror_mode| and |external_mirror_mode| | |
| 89 // are the out-parameters for the modes on the two outputs which will | |
| 90 // have the same resolution. Returns false if no mode appropriate for | |
| 91 // mirroring has been found/created. | |
| 92 bool FindOrCreateMirrorMode(XRROutputInfo* internal_info, | |
| 93 XRROutputInfo* external_info, | |
| 94 RROutput internal_output_id, | |
| 95 bool try_creating, | |
| 96 bool preserve_aspect, | |
| 97 RRMode* internal_mirror_mode, | |
| 98 RRMode* external_mirror_mode); | |
| 99 | |
| 100 // Searches for touchscreens among input devices, | 79 // Searches for touchscreens among input devices, |
| 101 // and tries to match them up to screens in |outputs|. | 80 // and tries to match them up to screens in |outputs|. |
| 102 // |outputs| is an array of detected screens. | 81 // |outputs| is an array of detected screens. |
| 103 // If a touchscreen with same resolution as an output's native mode | 82 // If a touchscreen with same resolution as an output's native mode |
| 104 // is detected, its id will be stored in this output. | 83 // is detected, its id will be stored in this output. |
| 105 void GetTouchscreens( | 84 void GetTouchscreens( |
| 106 std::vector<OutputConfigurator::OutputSnapshot>* outputs); | 85 std::vector<OutputConfigurator::OutputSnapshot>* outputs); |
| 107 | 86 |
| 108 Display* display_; | 87 Display* display_; |
| 109 Window window_; | 88 Window window_; |
| 110 | 89 |
| 111 // Initialized when the server is grabbed and freed when it's ungrabbed. | 90 // Initialized when the server is grabbed and freed when it's ungrabbed. |
| 112 XRRScreenResources* screen_; | 91 XRRScreenResources* screen_; |
| 113 | 92 |
| 114 // Used to enable modes which rely on panel fitting. | |
| 115 bool is_panel_fitting_enabled_; | |
| 116 | |
| 117 DISALLOW_COPY_AND_ASSIGN(RealOutputConfiguratorDelegate); | 93 DISALLOW_COPY_AND_ASSIGN(RealOutputConfiguratorDelegate); |
| 118 }; | 94 }; |
| 119 | 95 |
| 120 } // namespace chromeos | 96 } // namespace chromeos |
| 121 | 97 |
| 122 #endif // CHROMEOS_DISPLAY_REAL_OUTPUT_CONFIGURATOR_DELEGATE_H_ | 98 #endif // CHROMEOS_DISPLAY_REAL_OUTPUT_CONFIGURATOR_DELEGATE_H_ |
| OLD | NEW |