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 UI_DISPLAY_TYPES_NATIVE_DISPLAY_DELEGATE_H_
6 #define UI_DISPLAY_TYPES_NATIVE_DISPLAY_DELEGATE_H_
7 
8 #include <stdint.h>
9 
10 #include <vector>
11 
12 #include "base/callback.h"
13 #include "ui/display/types/display_constants.h"
14 #include "ui/display/types/display_types_export.h"
15 #include "ui/display/types/fake_display_controller.h"
16 
17 namespace gfx {
18 class Point;
19 }
20 
21 namespace display {
22 class DisplayMode;
23 class DisplaySnapshot;
24 class NativeDisplayObserver;
25 
26 struct GammaRampRGBEntry;
27 
28 using GetDisplaysCallback =
29     base::OnceCallback<void(const std::vector<DisplaySnapshot*>&)>;
30 using ConfigureCallback = base::OnceCallback<void(bool)>;
31 using GetHDCPStateCallback = base::OnceCallback<void(bool, HDCPState)>;
32 using SetHDCPStateCallback = base::OnceCallback<void(bool)>;
33 using DisplayControlCallback = base::OnceCallback<void(bool)>;
34 
35 // Interface for classes that perform display configuration actions on behalf
36 // of DisplayConfigurator.
37 // Implementations may perform calls asynchronously. In the case of functions
38 // taking callbacks, the callbacks may be called asynchronously when the results
39 // are available. The implementations must provide a strong guarantee that the
40 // callbacks are always called.
41 class DISPLAY_TYPES_EXPORT NativeDisplayDelegate {
42  public:
43   virtual ~NativeDisplayDelegate();
44 
45   virtual void Initialize() = 0;
46 
47   // Take control of the display from any other controlling process.
48   virtual void TakeDisplayControl(DisplayControlCallback callback) = 0;
49 
50   // Let others control the display.
51   virtual void RelinquishDisplayControl(DisplayControlCallback callback) = 0;
52 
53   // Queries for a list of fresh displays and returns them via |callback|.
54   // Note the query operation may be expensive and take over 60 milliseconds.
55   virtual void GetDisplays(GetDisplaysCallback callback) = 0;
56 
57   // Configures the display represented by |output| to use |mode| and positions
58   // the display to |origin| in the framebuffer. |mode| can be NULL, which
59   // represents disabling the display. The callback will return the status of
60   // the operation.
61   virtual void Configure(const DisplaySnapshot& output,
62                          const DisplayMode* mode,
63                          const gfx::Point& origin,
64                          ConfigureCallback callback) = 0;
65 
66   // Gets HDCP state of output.
67   virtual void GetHDCPState(const DisplaySnapshot& output,
68                             GetHDCPStateCallback callback) = 0;
69 
70   // Sets HDCP state of output.
71   virtual void SetHDCPState(const DisplaySnapshot& output,
72                             HDCPState state,
73                             SetHDCPStateCallback callback) = 0;
74 
75   // Sets the given 3x3 |color_matrix| on the display with |display_id|.
76   // This doesn't affect gamma or degamma. It returns true the color matrix was
77   // sent to the GPU process successfully.
78   virtual bool SetColorMatrix(int64_t display_id,
79                               const std::vector<float>& color_matrix) = 0;
80 
81   // Sets the given |gamma_lut| and |degamma_lut| on the display with
82   // |display_id|. Returns true if the given tables were sent to the GPU process
83   // successfully.
84   virtual bool SetGammaCorrection(
85       int64_t display_id,
86       const std::vector<GammaRampRGBEntry>& degamma_lut,
87       const std::vector<GammaRampRGBEntry>& gamma_lut) = 0;
88 
89   // Sets the privacy screen state on the display with |display_id|.
90   virtual void SetPrivacyScreen(int64_t display_id, bool enabled) = 0;
91 
92   virtual void AddObserver(NativeDisplayObserver* observer) = 0;
93 
94   virtual void RemoveObserver(NativeDisplayObserver* observer) = 0;
95 
96   // Returns a fake display controller that can modify the fake display state.
97   // Will return null if not needed, most likely because the delegate is
98   // intended for use on device and doesn't need to fake the display state.
99   virtual FakeDisplayController* GetFakeDisplayController() = 0;
100 };
101 
102 }  // namespace display
103 
104 #endif  // UI_DISPLAY_TYPES_NATIVE_DISPLAY_DELEGATE_H_
105