Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / chromeos / display / real_output_configurator_delegate.h
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.
4
5 #ifndef CHROMEOS_DISPLAY_REAL_OUTPUT_CONFIGURATOR_DELEGATE_H_
6 #define CHROMEOS_DISPLAY_REAL_OUTPUT_CONFIGURATOR_DELEGATE_H_
7
8 #include <vector>
9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "chromeos/display/output_configurator.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 RealOutputConfiguratorDelegate : public OutputConfigurator::Delegate {
26  public:
27   RealOutputConfiguratorDelegate();
28   virtual ~RealOutputConfiguratorDelegate();
29
30   // OutputConfigurator::Delegate overrides:
31   virtual void InitXRandRExtension(int* event_base) OVERRIDE;
32   virtual void UpdateXRandRConfiguration(
33       const base::NativeEvent& event) OVERRIDE;
34   virtual void GrabServer() OVERRIDE;
35   virtual void UngrabServer() OVERRIDE;
36   virtual void SyncWithServer() OVERRIDE;
37   virtual void SetBackgroundColor(uint32 color_argb) OVERRIDE;
38   virtual void ForceDPMSOn() OVERRIDE;
39   virtual std::vector<OutputConfigurator::OutputSnapshot> GetOutputs() OVERRIDE;
40   virtual void AddOutputMode(RROutput output, RRMode mode) OVERRIDE;
41   virtual bool ConfigureCrtc(
42       RRCrtc crtc,
43       RRMode mode,
44       RROutput output,
45       int x,
46       int y) OVERRIDE;
47   virtual void CreateFrameBuffer(
48       int width,
49       int height,
50       const std::vector<OutputConfigurator::OutputSnapshot>& outputs) OVERRIDE;
51   virtual void ConfigureCTM(
52       int touch_device_id,
53       const OutputConfigurator::CoordinateTransformation& ctm) OVERRIDE;
54   virtual void SendProjectingStateToPowerManager(bool projecting) OVERRIDE;
55   virtual bool GetHDCPState(RROutput id, HDCPState* state) OVERRIDE;
56   virtual bool SetHDCPState(RROutput id, HDCPState state) OVERRIDE;
57
58  private:
59   // Initializes |mode_info| to contain details corresponding to |mode|. Returns
60   // true on success.
61   bool InitModeInfo(RRMode mode, OutputConfigurator::ModeInfo* mode_info);
62
63   // Helper method for GetOutputs() that returns an OutputSnapshot struct based
64   // on the passed-in information. Further initialization is required (e.g.
65   // |selected_mode|, |mirror_mode|, and |touch_device_id|).
66   OutputConfigurator::OutputSnapshot InitOutputSnapshot(
67       RROutput id,
68       XRROutputInfo* info,
69       RRCrtc* last_used_crtc,
70       int index);
71
72   // Destroys unused CRTCs and parks used CRTCs in a way which allows a
73   // framebuffer resize. This is faster than turning them off, resizing,
74   // then turning them back on.
75   void DestroyUnusedCrtcs(
76       const std::vector<OutputConfigurator::OutputSnapshot>& outputs);
77
78   // Returns whether |id| is configured to preserve aspect when scaling.
79   bool IsOutputAspectPreservingScaling(RROutput id);
80
81   // Searches for touchscreens among input devices,
82   // and tries to match them up to screens in |outputs|.
83   // |outputs| is an array of detected screens.
84   // If a touchscreen with same resolution as an output's native mode
85   // is detected, its id will be stored in this output.
86   void GetTouchscreens(
87       std::vector<OutputConfigurator::OutputSnapshot>* outputs);
88
89   Display* display_;
90   Window window_;
91
92   // Initialized when the server is grabbed and freed when it's ungrabbed.
93   XRRScreenResources* screen_;
94
95   DISALLOW_COPY_AND_ASSIGN(RealOutputConfiguratorDelegate);
96 };
97
98 }  // namespace chromeos
99
100 #endif  // CHROMEOS_DISPLAY_REAL_OUTPUT_CONFIGURATOR_DELEGATE_H_