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