| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/ozone/platform/dri/display_snapshot_dri.h" | 5 #include "ui/ozone/platform/dri/display_snapshot_dri.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <xf86drmMode.h> | 9 #include <xf86drmMode.h> |
| 10 | 10 |
| 11 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "ui/display/util/edid_parser.h" | 14 #include "ui/display/util/edid_parser.h" |
| 15 #include "ui/ozone/platform/dri/display_mode_dri.h" | 15 #include "ui/ozone/platform/dri/display_mode_dri.h" |
| 16 #include "ui/ozone/platform/dri/dri_util.h" | 16 #include "ui/ozone/platform/dri/dri_util.h" |
| 17 #include "ui/ozone/platform/dri/dri_wrapper.h" | 17 #include "ui/ozone/platform/dri/drm_device.h" |
| 18 | 18 |
| 19 #if !defined(DRM_MODE_CONNECTOR_DSI) | 19 #if !defined(DRM_MODE_CONNECTOR_DSI) |
| 20 #define DRM_MODE_CONNECTOR_DSI 16 | 20 #define DRM_MODE_CONNECTOR_DSI 16 |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 namespace ui { | 23 namespace ui { |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 DisplayConnectionType GetDisplayType(drmModeConnector* connector) { | 27 DisplayConnectionType GetDisplayType(drmModeConnector* connector) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 39 case DRM_MODE_CONNECTOR_DisplayPort: | 39 case DRM_MODE_CONNECTOR_DisplayPort: |
| 40 return DISPLAY_CONNECTION_TYPE_DISPLAYPORT; | 40 return DISPLAY_CONNECTION_TYPE_DISPLAYPORT; |
| 41 case DRM_MODE_CONNECTOR_HDMIA: | 41 case DRM_MODE_CONNECTOR_HDMIA: |
| 42 case DRM_MODE_CONNECTOR_HDMIB: | 42 case DRM_MODE_CONNECTOR_HDMIB: |
| 43 return DISPLAY_CONNECTION_TYPE_HDMI; | 43 return DISPLAY_CONNECTION_TYPE_HDMI; |
| 44 default: | 44 default: |
| 45 return DISPLAY_CONNECTION_TYPE_UNKNOWN; | 45 return DISPLAY_CONNECTION_TYPE_UNKNOWN; |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 | 48 |
| 49 bool IsAspectPreserving(DriWrapper* drm, drmModeConnector* connector) { | 49 bool IsAspectPreserving(DrmDevice* drm, drmModeConnector* connector) { |
| 50 ScopedDrmPropertyPtr property(drm->GetProperty(connector, "scaling mode")); | 50 ScopedDrmPropertyPtr property(drm->GetProperty(connector, "scaling mode")); |
| 51 if (!property) | 51 if (!property) |
| 52 return false; | 52 return false; |
| 53 | 53 |
| 54 for (int props_i = 0; props_i < connector->count_props; ++props_i) { | 54 for (int props_i = 0; props_i < connector->count_props; ++props_i) { |
| 55 if (connector->props[props_i] != property->prop_id) | 55 if (connector->props[props_i] != property->prop_id) |
| 56 continue; | 56 continue; |
| 57 | 57 |
| 58 for (int enums_i = 0; enums_i < property->count_enums; ++enums_i) { | 58 for (int enums_i = 0; enums_i < property->count_enums; ++enums_i) { |
| 59 if (property->enums[enums_i].value == connector->prop_values[props_i] && | 59 if (property->enums[enums_i].value == connector->prop_values[props_i] && |
| 60 strcmp(property->enums[enums_i].name, "Full aspect") == 0) | 60 strcmp(property->enums[enums_i].name, "Full aspect") == 0) |
| 61 return true; | 61 return true; |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 return false; | 65 return false; |
| 66 } | 66 } |
| 67 | 67 |
| 68 } // namespace | 68 } // namespace |
| 69 | 69 |
| 70 DisplaySnapshotDri::DisplaySnapshotDri(const scoped_refptr<DriWrapper>& drm, | 70 DisplaySnapshotDri::DisplaySnapshotDri(const scoped_refptr<DrmDevice>& drm, |
| 71 drmModeConnector* connector, | 71 drmModeConnector* connector, |
| 72 drmModeCrtc* crtc, | 72 drmModeCrtc* crtc, |
| 73 uint32_t index) | 73 uint32_t index) |
| 74 : DisplaySnapshot(index, | 74 : DisplaySnapshot(index, |
| 75 gfx::Point(crtc->x, crtc->y), | 75 gfx::Point(crtc->x, crtc->y), |
| 76 gfx::Size(connector->mmWidth, connector->mmHeight), | 76 gfx::Size(connector->mmWidth, connector->mmHeight), |
| 77 GetDisplayType(connector), | 77 GetDisplayType(connector), |
| 78 IsAspectPreserving(drm.get(), connector), | 78 IsAspectPreserving(drm.get(), connector), |
| 79 false, | 79 false, |
| 80 std::string(), | 80 std::string(), |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 std::string DisplaySnapshotDri::ToString() const { | 129 std::string DisplaySnapshotDri::ToString() const { |
| 130 return base::StringPrintf( | 130 return base::StringPrintf( |
| 131 "[type=%d, connector=%" PRIu32 ", crtc=%" PRIu32 | 131 "[type=%d, connector=%" PRIu32 ", crtc=%" PRIu32 |
| 132 ", origin=%s, mode=%s, dim=%s]", | 132 ", origin=%s, mode=%s, dim=%s]", |
| 133 type_, connector_, crtc_, origin_.ToString().c_str(), | 133 type_, connector_, crtc_, origin_.ToString().c_str(), |
| 134 current_mode_ ? current_mode_->ToString().c_str() : "NULL", | 134 current_mode_ ? current_mode_->ToString().c_str() : "NULL", |
| 135 physical_size_.ToString().c_str()); | 135 physical_size_.ToString().c_str()); |
| 136 } | 136 } |
| 137 | 137 |
| 138 } // namespace ui | 138 } // namespace ui |
| OLD | NEW |