Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chromeos / display / native_display_delegate_x11.h
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/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 NativeDisplayDelegateX11
26     : public OutputConfigurator::NativeDisplayDelegate {
27  public:
28   NativeDisplayDelegateX11();
29   virtual ~NativeDisplayDelegateX11();
30
31   // OutputConfigurator::Delegate overrides:
32   virtual void InitXRandRExtension(int* event_base) OVERRIDE;
33   virtual void UpdateXRandRConfiguration(const base::NativeEvent& event)
34       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 void AddOutputMode(RROutput output, RRMode mode) OVERRIDE;
42   virtual bool ConfigureCrtc(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 bool GetHDCPState(RROutput id, ui::HDCPState* state) OVERRIDE;
52   virtual bool SetHDCPState(RROutput id, ui::HDCPState state) OVERRIDE;
53
54  private:
55   // Initializes |mode_info| to contain details corresponding to |mode|. Returns
56   // true on success.
57   bool InitModeInfo(RRMode mode, OutputConfigurator::ModeInfo* mode_info);
58
59   // Helper method for GetOutputs() that returns an OutputSnapshot struct based
60   // on the passed-in information. Further initialization is required (e.g.
61   // |selected_mode|, |mirror_mode|, and |touch_device_id|).
62   OutputConfigurator::OutputSnapshot InitOutputSnapshot(RROutput id,
63                                                         XRROutputInfo* info,
64                                                         RRCrtc* last_used_crtc,
65                                                         int index);
66
67   // Destroys unused CRTCs and parks used CRTCs in a way which allows a
68   // framebuffer resize. This is faster than turning them off, resizing,
69   // then turning them back on.
70   void DestroyUnusedCrtcs(
71       const std::vector<OutputConfigurator::OutputSnapshot>& outputs);
72
73   // Returns whether |id| is configured to preserve aspect when scaling.
74   bool IsOutputAspectPreservingScaling(RROutput id);
75
76   Display* display_;
77   Window window_;
78
79   // Initialized when the server is grabbed and freed when it's ungrabbed.
80   XRRScreenResources* screen_;
81
82   DISALLOW_COPY_AND_ASSIGN(NativeDisplayDelegateX11);
83 };
84
85 }  // namespace chromeos
86
87 #endif  // CHROMEOS_DISPLAY_NATIVE_DISPLAY_DELEGATE_X11_H_