| 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/dri_wrapper.h" | 5 #include "ui/ozone/platform/dri/dri_wrapper.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <unistd.h> | 8 #include <unistd.h> |
| 9 #include <xf86drm.h> | 9 #include <xf86drm.h> |
| 10 #include <xf86drmMode.h> | 10 #include <xf86drmMode.h> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 | 13 |
| 14 namespace ui { | 14 namespace ui { |
| 15 namespace { |
| 16 uint32_t ToFixedPoint(double v) { |
| 17 // This returns a number in a 16-bit.16-bit fixed point. |
| 18 return v * 65536.0; |
| 19 } |
| 20 } // namespace |
| 15 | 21 |
| 16 DriWrapper::DriWrapper(const char* device_path) { | 22 DriWrapper::DriWrapper(const char* device_path) { |
| 17 fd_ = open(device_path, O_RDWR | O_CLOEXEC); | 23 fd_ = open(device_path, O_RDWR | O_CLOEXEC); |
| 18 } | 24 } |
| 19 | 25 |
| 20 DriWrapper::~DriWrapper() { | 26 DriWrapper::~DriWrapper() { |
| 21 if (fd_ >= 0) | 27 if (fd_ >= 0) |
| 22 close(fd_); | 28 close(fd_); |
| 23 } | 29 } |
| 24 | 30 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 uint32_t framebuffer, | 85 uint32_t framebuffer, |
| 80 void* data) { | 86 void* data) { |
| 81 CHECK(fd_ >= 0); | 87 CHECK(fd_ >= 0); |
| 82 return !drmModePageFlip(fd_, | 88 return !drmModePageFlip(fd_, |
| 83 crtc_id, | 89 crtc_id, |
| 84 framebuffer, | 90 framebuffer, |
| 85 DRM_MODE_PAGE_FLIP_EVENT, | 91 DRM_MODE_PAGE_FLIP_EVENT, |
| 86 data); | 92 data); |
| 87 } | 93 } |
| 88 | 94 |
| 95 bool DriWrapper::PageFlipOverlay(uint32_t crtc_id, |
| 96 uint32_t framebuffer, |
| 97 const gfx::Rect& location, |
| 98 const gfx::RectF& source, |
| 99 int overlay_plane) { |
| 100 CHECK(fd_ >= 0); |
| 101 return !drmModeSetPlane(fd_, |
| 102 overlay_plane, |
| 103 crtc_id, |
| 104 framebuffer, |
| 105 0, |
| 106 location.x(), |
| 107 location.y(), |
| 108 location.width(), |
| 109 location.height(), |
| 110 ToFixedPoint(source.x()), |
| 111 ToFixedPoint(source.y()), |
| 112 ToFixedPoint(source.width()), |
| 113 ToFixedPoint(source.height())); |
| 114 } |
| 115 |
| 89 ScopedDrmFramebufferPtr DriWrapper::GetFramebuffer(uint32_t framebuffer) { | 116 ScopedDrmFramebufferPtr DriWrapper::GetFramebuffer(uint32_t framebuffer) { |
| 90 CHECK(fd_ >= 0); | 117 CHECK(fd_ >= 0); |
| 91 return ScopedDrmFramebufferPtr(drmModeGetFB(fd_, framebuffer)); | 118 return ScopedDrmFramebufferPtr(drmModeGetFB(fd_, framebuffer)); |
| 92 } | 119 } |
| 93 | 120 |
| 94 ScopedDrmPropertyPtr DriWrapper::GetProperty(drmModeConnector* connector, | 121 ScopedDrmPropertyPtr DriWrapper::GetProperty(drmModeConnector* connector, |
| 95 const char* name) { | 122 const char* name) { |
| 96 for (int i = 0; i < connector->count_props; ++i) { | 123 for (int i = 0; i < connector->count_props; ++i) { |
| 97 ScopedDrmPropertyPtr property(drmModeGetProperty(fd_, connector->props[i])); | 124 ScopedDrmPropertyPtr property(drmModeGetProperty(fd_, connector->props[i])); |
| 98 if (!property) | 125 if (!property) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 CHECK(fd_ >= 0); | 168 CHECK(fd_ >= 0); |
| 142 return !drmModeMoveCursor(fd_, crtc_id, x, y); | 169 return !drmModeMoveCursor(fd_, crtc_id, x, y); |
| 143 } | 170 } |
| 144 | 171 |
| 145 void DriWrapper::HandleEvent(drmEventContext& event) { | 172 void DriWrapper::HandleEvent(drmEventContext& event) { |
| 146 CHECK(fd_ >= 0); | 173 CHECK(fd_ >= 0); |
| 147 drmHandleEvent(fd_, &event); | 174 drmHandleEvent(fd_, &event); |
| 148 } | 175 } |
| 149 | 176 |
| 150 } // namespace ui | 177 } // namespace ui |
| OLD | NEW |