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
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_DISPLAY_REAL_OUTPUT_CONFIGURATOR_DELEGATE_H_
6 #define CHROMEOS_DISPLAY_REAL_OUTPUT_CONFIGURATOR_DELEGATE_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "chromeos/display/output_configurator.h"
17 typedef struct _XDisplay Display
;
18 struct _XRROutputInfo
;
19 typedef _XRROutputInfo XRROutputInfo
;
20 struct _XRRScreenResources
;
21 typedef _XRRScreenResources XRRScreenResources
;
25 class RealOutputConfiguratorDelegate
: public OutputConfigurator::Delegate
{
27 RealOutputConfiguratorDelegate();
28 virtual ~RealOutputConfiguratorDelegate();
30 // OutputConfigurator::Delegate overrides:
31 virtual void SetPanelFittingEnabled(bool enabled
) OVERRIDE
;
32 virtual void InitXRandRExtension(int* event_base
) OVERRIDE
;
33 virtual void UpdateXRandRConfiguration(
34 const base::NativeEvent
& event
) OVERRIDE
;
35 virtual void GrabServer() OVERRIDE
;
36 virtual void UngrabServer() OVERRIDE
;
37 virtual void SyncWithServer() OVERRIDE
;
38 virtual void SetBackgroundColor(uint32 color_argb
) OVERRIDE
;
39 virtual void ForceDPMSOn() OVERRIDE
;
40 virtual std::vector
<OutputConfigurator::OutputSnapshot
> GetOutputs() OVERRIDE
;
41 virtual bool GetModeDetails(
45 bool* interlaced
) OVERRIDE
;
46 virtual void ConfigureCrtc(OutputConfigurator::CrtcConfig
* config
) OVERRIDE
;
47 virtual void CreateFrameBuffer(
50 const std::vector
<OutputConfigurator::CrtcConfig
>& configs
) OVERRIDE
;
51 virtual void ConfigureCTM(
53 const OutputConfigurator::CoordinateTransformation
& ctm
) OVERRIDE
;
54 virtual void SendProjectingStateToPowerManager(bool projecting
) OVERRIDE
;
57 // Destroys unused CRTCs and parks used CRTCs in a way which allows a
58 // framebuffer resize. This is faster than turning them off, resizing,
59 // then turning them back on.
60 void DestroyUnusedCrtcs(
61 const std::vector
<OutputConfigurator::CrtcConfig
>& configs
);
63 // Returns whether |id| is configured to preserve aspect when scaling.
64 bool IsOutputAspectPreservingScaling(RROutput id
);
66 // Looks for a mode on internal and external outputs having same
67 // resolution. |internal_info| and |external_info| are used to search
68 // for the modes. |internal_output_id| is used to create a new mode, if
69 // applicable. |try_creating|=true will enable creating panel-fitting
70 // mode on the |internal_info| output instead of only searching for a
71 // matching mode. Note: it may lead to a crash, if |internal_info| is
72 // not capable of panel fitting. |preserve_aspect|=true will limit the
73 // search / creation only to the modes having the native aspect ratio of
74 // |external_info|. |internal_mirror_mode| and |external_mirror_mode|
75 // are the out-parameters for the modes on the two outputs which will
76 // have the same resolution. Returns false if no mode appropriate for
77 // mirroring has been found/created.
78 bool FindOrCreateMirrorMode(XRROutputInfo
* internal_info
,
79 XRROutputInfo
* external_info
,
80 RROutput internal_output_id
,
83 RRMode
* internal_mirror_mode
,
84 RRMode
* external_mirror_mode
);
86 // Searches for touchscreens among input devices,
87 // and tries to match them up to screens in |outputs|.
88 // |outputs| is an array of detected screens.
89 // If a touchscreen with same resolution as an output's native mode
90 // is detected, its id will be stored in this output.
92 std::vector
<OutputConfigurator::OutputSnapshot
>* outputs
);
97 // Initialized when the server is grabbed and freed when it's ungrabbed.
98 XRRScreenResources
* screen_
;
100 // Used to enable modes which rely on panel fitting.
101 bool is_panel_fitting_enabled_
;
103 DISALLOW_COPY_AND_ASSIGN(RealOutputConfiguratorDelegate
);
106 } // namespace chromeos
108 #endif // CHROMEOS_DISPLAY_REAL_OUTPUT_CONFIGURATOR_DELEGATE_H_