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_DISPLAY_SNAPSHOT_H_ 6 #define UI_DISPLAY_TYPES_DISPLAY_SNAPSHOT_H_ 7 8 #include <stdint.h> 9 10 #include <memory> 11 #include <string> 12 #include <vector> 13 14 #include "base/files/file_path.h" 15 #include "base/macros.h" 16 #include "ui/display/types/display_constants.h" 17 #include "ui/display/types/display_mode.h" 18 #include "ui/gfx/buffer_types.h" 19 #include "ui/gfx/color_space.h" 20 #include "ui/gfx/geometry/point.h" 21 #include "ui/gfx/geometry/size.h" 22 23 namespace display { 24 25 // This class represents the state of a display at one point in time. Platforms 26 // may extend this class in order to add platform specific configuration and 27 // identifiers required to configure this display. 28 class DISPLAY_TYPES_EXPORT DisplaySnapshot { 29 public: 30 using DisplayModeList = std::vector<std::unique_ptr<const DisplayMode>>; 31 32 DisplaySnapshot(int64_t display_id, 33 const gfx::Point& origin, 34 const gfx::Size& physical_size, 35 DisplayConnectionType type, 36 bool is_aspect_preserving_scaling, 37 bool has_overscan, 38 PrivacyScreenState privacy_screen_state, 39 bool has_color_correction_matrix, 40 bool color_correction_in_linear_space, 41 const gfx::ColorSpace& color_space, 42 uint32_t bits_per_channel, 43 std::string display_name, 44 const base::FilePath& sys_path, 45 DisplayModeList modes, 46 PanelOrientation panel_orientation, 47 const std::vector<uint8_t>& edid, 48 const DisplayMode* current_mode, 49 const DisplayMode* native_mode, 50 int64_t product_code, 51 int32_t year_of_manufacture, 52 const gfx::Size& maximum_cursor_size); 53 virtual ~DisplaySnapshot(); 54 display_id()55 int64_t display_id() const { return display_id_; } origin()56 const gfx::Point& origin() const { return origin_; } set_origin(const gfx::Point & origin)57 void set_origin(const gfx::Point& origin) { origin_ = origin; } physical_size()58 const gfx::Size& physical_size() const { return physical_size_; } type()59 DisplayConnectionType type() const { return type_; } is_aspect_preserving_scaling()60 bool is_aspect_preserving_scaling() const { 61 return is_aspect_preserving_scaling_; 62 } has_overscan()63 bool has_overscan() const { return has_overscan_; } privacy_screen_state()64 PrivacyScreenState privacy_screen_state() const { 65 return privacy_screen_state_; 66 } has_color_correction_matrix()67 bool has_color_correction_matrix() const { 68 return has_color_correction_matrix_; 69 } color_correction_in_linear_space()70 bool color_correction_in_linear_space() const { 71 return color_correction_in_linear_space_; 72 } color_space()73 const gfx::ColorSpace& color_space() const { return color_space_; } bits_per_channel()74 uint32_t bits_per_channel() const { return bits_per_channel_; } display_name()75 const std::string& display_name() const { return display_name_; } sys_path()76 const base::FilePath& sys_path() const { return sys_path_; } modes()77 const DisplayModeList& modes() const { return modes_; } panel_orientation()78 PanelOrientation panel_orientation() const { return panel_orientation_; } edid()79 const std::vector<uint8_t>& edid() const { return edid_; } current_mode()80 const DisplayMode* current_mode() const { return current_mode_; } set_current_mode(const DisplayMode * mode)81 void set_current_mode(const DisplayMode* mode) { current_mode_ = mode; } native_mode()82 const DisplayMode* native_mode() const { return native_mode_; } product_code()83 int64_t product_code() const { return product_code_; } year_of_manufacture()84 int32_t year_of_manufacture() const { return year_of_manufacture_; } maximum_cursor_size()85 const gfx::Size& maximum_cursor_size() const { return maximum_cursor_size_; } 86 add_mode(const DisplayMode * mode)87 void add_mode(const DisplayMode* mode) { modes_.push_back(mode->Clone()); } 88 89 // Clones display state. 90 std::unique_ptr<DisplaySnapshot> Clone(); 91 92 // Returns a textual representation of this display state. 93 std::string ToString() const; 94 95 // Used when no |product_code_| known. 96 static const int64_t kInvalidProductCode = -1; 97 98 // Returns the buffer format to be used for the primary plane buffer. 99 static gfx::BufferFormat PrimaryFormat(); 100 101 private: 102 // Display id for this output. 103 const int64_t display_id_; 104 105 // Display's origin on the framebuffer. 106 gfx::Point origin_; 107 108 const gfx::Size physical_size_; 109 110 const DisplayConnectionType type_; 111 112 const bool is_aspect_preserving_scaling_; 113 114 const bool has_overscan_; 115 116 const PrivacyScreenState privacy_screen_state_; 117 118 // Whether this display has advanced color correction available. 119 const bool has_color_correction_matrix_; 120 // Whether the color correction matrix will be applied in linear color space 121 // instead of gamma compressed one. 122 const bool color_correction_in_linear_space_; 123 124 const gfx::ColorSpace color_space_; 125 126 uint32_t bits_per_channel_; 127 128 const std::string display_name_; 129 130 const base::FilePath sys_path_; 131 132 DisplayModeList modes_; 133 134 // The orientation of the panel in respect to the natural device orientation. 135 PanelOrientation panel_orientation_; 136 137 // The display's EDID. It can be empty if nothing extracted such as in the 138 // case of a virtual display. 139 std::vector<uint8_t> edid_; 140 141 // Mode currently being used by the output. 142 const DisplayMode* current_mode_; 143 144 // "Best" mode supported by the output. 145 const DisplayMode* const native_mode_; 146 147 // Combination of manufacturer id and product id. 148 const int64_t product_code_; 149 150 const int32_t year_of_manufacture_; 151 152 // Maximum supported cursor size on this display. 153 const gfx::Size maximum_cursor_size_; 154 155 private: 156 DISALLOW_COPY_AND_ASSIGN(DisplaySnapshot); 157 }; 158 159 } // namespace display 160 161 #endif // UI_DISPLAY_TYPES_DISPLAY_SNAPSHOT_H_ 162