Chromium Code Reviews| 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 int ToFixedPoint(double v) { | |
|
dnicoara
2014/07/07 19:17:54
Return an uint32_t please.
achaulk
2014/07/07 20:18:04
Done.
| |
| 17 return v * 65536.0; | |
|
dnicoara
2014/07/07 19:17:54
Could you please add a comment (maybe to this func
achaulk
2014/07/07 20:18:04
Sure
| |
| 18 } | |
| 19 } // namespace | |
| 15 | 20 |
| 16 DriWrapper::DriWrapper(const char* device_path) { | 21 DriWrapper::DriWrapper(const char* device_path) { |
| 17 fd_ = open(device_path, O_RDWR | O_CLOEXEC); | 22 fd_ = open(device_path, O_RDWR | O_CLOEXEC); |
| 18 } | 23 } |
| 19 | 24 |
| 20 DriWrapper::~DriWrapper() { | 25 DriWrapper::~DriWrapper() { |
| 21 if (fd_ >= 0) | 26 if (fd_ >= 0) |
| 22 close(fd_); | 27 close(fd_); |
| 23 } | 28 } |
| 24 | 29 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 uint32_t framebuffer, | 84 uint32_t framebuffer, |
| 80 void* data) { | 85 void* data) { |
| 81 CHECK(fd_ >= 0); | 86 CHECK(fd_ >= 0); |
| 82 return !drmModePageFlip(fd_, | 87 return !drmModePageFlip(fd_, |
| 83 crtc_id, | 88 crtc_id, |
| 84 framebuffer, | 89 framebuffer, |
| 85 DRM_MODE_PAGE_FLIP_EVENT, | 90 DRM_MODE_PAGE_FLIP_EVENT, |
| 86 data); | 91 data); |
| 87 } | 92 } |
| 88 | 93 |
| 94 bool DriWrapper::PageFlipOverlay(uint32_t crtc_id, | |
| 95 uint32_t framebuffer, | |
| 96 const gfx::Rect& location, | |
| 97 const gfx::RectF& source, | |
| 98 int overlay_plane) { | |
| 99 CHECK(fd_ >= 0); | |
| 100 return !drmModeSetPlane(fd_, | |
| 101 overlay_plane, | |
| 102 crtc_id, | |
| 103 framebuffer, | |
| 104 0, | |
| 105 location.x(), | |
| 106 location.y(), | |
| 107 location.width(), | |
| 108 location.height(), | |
| 109 ToFixedPoint(source.x()), | |
| 110 ToFixedPoint(source.y()), | |
| 111 ToFixedPoint(source.width()), | |
| 112 ToFixedPoint(source.height())); | |
| 113 } | |
| 114 | |
| 89 ScopedDrmFramebufferPtr DriWrapper::GetFramebuffer(uint32_t framebuffer) { | 115 ScopedDrmFramebufferPtr DriWrapper::GetFramebuffer(uint32_t framebuffer) { |
| 90 CHECK(fd_ >= 0); | 116 CHECK(fd_ >= 0); |
| 91 return ScopedDrmFramebufferPtr(drmModeGetFB(fd_, framebuffer)); | 117 return ScopedDrmFramebufferPtr(drmModeGetFB(fd_, framebuffer)); |
| 92 } | 118 } |
| 93 | 119 |
| 94 ScopedDrmPropertyPtr DriWrapper::GetProperty(drmModeConnector* connector, | 120 ScopedDrmPropertyPtr DriWrapper::GetProperty(drmModeConnector* connector, |
| 95 const char* name) { | 121 const char* name) { |
| 96 for (int i = 0; i < connector->count_props; ++i) { | 122 for (int i = 0; i < connector->count_props; ++i) { |
| 97 ScopedDrmPropertyPtr property(drmModeGetProperty(fd_, connector->props[i])); | 123 ScopedDrmPropertyPtr property(drmModeGetProperty(fd_, connector->props[i])); |
| 98 if (!property) | 124 if (!property) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 CHECK(fd_ >= 0); | 167 CHECK(fd_ >= 0); |
| 142 return !drmModeMoveCursor(fd_, crtc_id, x, y); | 168 return !drmModeMoveCursor(fd_, crtc_id, x, y); |
| 143 } | 169 } |
| 144 | 170 |
| 145 void DriWrapper::HandleEvent(drmEventContext& event) { | 171 void DriWrapper::HandleEvent(drmEventContext& event) { |
| 146 CHECK(fd_ >= 0); | 172 CHECK(fd_ >= 0); |
| 147 drmHandleEvent(fd_, &event); | 173 drmHandleEvent(fd_, &event); |
| 148 } | 174 } |
| 149 | 175 |
| 150 } // namespace ui | 176 } // namespace ui |
| OLD | NEW |