OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/drm/gpu/drm_thread.h" | 5 #include "ui/ozone/platform/drm/gpu/drm_thread.h" |
6 | 6 |
7 #include <gbm.h> | 7 #include <gbm.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 break; | 117 break; |
118 case gfx::BufferUsage::SCANOUT: | 118 case gfx::BufferUsage::SCANOUT: |
119 flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING; | 119 flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING; |
120 break; | 120 break; |
121 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: | 121 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: |
122 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: | 122 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: |
123 flags = GBM_BO_USE_LINEAR; | 123 flags = GBM_BO_USE_LINEAR; |
124 break; | 124 break; |
125 } | 125 } |
126 | 126 |
127 *buffer = GbmBuffer::CreateBuffer( | 127 DrmWindow* window = screen_manager_->GetWindow(widget); |
128 gbm, ui::GetFourCCFormatFromBufferFormat(format), size, flags); | 128 std::vector<uint64_t> modifiers; |
| 129 |
| 130 uint32_t fourcc_format = ui::GetFourCCFormatFromBufferFormat(format); |
| 131 |
| 132 // TODO(hoegsberg): We shouldn't really get here without a window, |
| 133 // but it happens during init. Need to figure out why. |
| 134 if (window && window->GetController()) |
| 135 modifiers = window->GetController()->GetFormatModifiers(fourcc_format); |
| 136 |
| 137 if (modifiers.size() > 0 && !(flags & GBM_BO_USE_LINEAR)) |
| 138 *buffer = GbmBuffer::CreateBufferWithModifiers(gbm, fourcc_format, size, |
| 139 flags, modifiers); |
| 140 else |
| 141 *buffer = GbmBuffer::CreateBuffer(gbm, fourcc_format, size, flags); |
129 } | 142 } |
130 | 143 |
131 void DrmThread::CreateBufferFromFds( | 144 void DrmThread::CreateBufferFromFds( |
132 gfx::AcceleratedWidget widget, | 145 gfx::AcceleratedWidget widget, |
133 const gfx::Size& size, | 146 const gfx::Size& size, |
134 gfx::BufferFormat format, | 147 gfx::BufferFormat format, |
135 std::vector<base::ScopedFD>&& fds, | 148 std::vector<base::ScopedFD>&& fds, |
136 const std::vector<gfx::NativePixmapPlane>& planes, | 149 const std::vector<gfx::NativePixmapPlane>& planes, |
137 scoped_refptr<GbmBuffer>* buffer) { | 150 scoped_refptr<GbmBuffer>* buffer) { |
138 scoped_refptr<GbmDevice> gbm = | 151 scoped_refptr<GbmDevice> gbm = |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 correction_matrix); | 286 correction_matrix); |
274 } | 287 } |
275 | 288 |
276 // DrmThread requires a BindingSet instead of a simple Binding because it will | 289 // DrmThread requires a BindingSet instead of a simple Binding because it will |
277 // be used from multiple threads in multiple processes. | 290 // be used from multiple threads in multiple processes. |
278 void DrmThread::AddBinding(ozone::mojom::DeviceCursorRequest request) { | 291 void DrmThread::AddBinding(ozone::mojom::DeviceCursorRequest request) { |
279 bindings_.AddBinding(this, std::move(request)); | 292 bindings_.AddBinding(this, std::move(request)); |
280 } | 293 } |
281 | 294 |
282 } // namespace ui | 295 } // namespace ui |
OLD | NEW |