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/drm/gpu/drm_window.h" | 5 #include "ui/ozone/platform/drm/gpu/drm_window.h" |
| 6 | 6 |
| 7 #include <drm_fourcc.h> | 7 #include <drm_fourcc.h> |
| 8 | 8 |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| 11 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
| 12 #include "third_party/skia/include/core/SkDevice.h" | 12 #include "third_party/skia/include/core/SkDevice.h" |
| 13 #include "third_party/skia/include/core/SkSurface.h" | 13 #include "third_party/skia/include/core/SkSurface.h" |
| 14 #include "ui/gfx/geometry/size_conversions.h" | |
| 14 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h" | 15 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h" |
| 15 #include "ui/ozone/platform/drm/common/drm_util.h" | 16 #include "ui/ozone/platform/drm/common/drm_util.h" |
| 16 #include "ui/ozone/platform/drm/gpu/crtc_controller.h" | 17 #include "ui/ozone/platform/drm/gpu/crtc_controller.h" |
| 17 #include "ui/ozone/platform/drm/gpu/drm_buffer.h" | 18 #include "ui/ozone/platform/drm/gpu/drm_buffer.h" |
| 18 #include "ui/ozone/platform/drm/gpu/drm_device.h" | 19 #include "ui/ozone/platform/drm/gpu/drm_device.h" |
| 19 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" | 20 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" |
| 20 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h" | 21 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h" |
| 21 #include "ui/ozone/platform/drm/gpu/screen_manager.h" | 22 #include "ui/ozone/platform/drm/gpu/screen_manager.h" |
| 22 | 23 |
| 23 namespace ui { | 24 namespace ui { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 // Nothing much we can do here. | 149 // Nothing much we can do here. |
| 149 return params; | 150 return params; |
| 150 } | 151 } |
| 151 | 152 |
| 152 OverlayPlaneList compatible_test_list; | 153 OverlayPlaneList compatible_test_list; |
| 153 scoped_refptr<DrmDevice> drm = controller_->GetAllocationDrmDevice(); | 154 scoped_refptr<DrmDevice> drm = controller_->GetAllocationDrmDevice(); |
| 154 for (const auto& overlay : overlays) { | 155 for (const auto& overlay : overlays) { |
| 155 OverlayCheck_Params overlay_params(overlay); | 156 OverlayCheck_Params overlay_params(overlay); |
| 156 gfx::Size size = | 157 gfx::Size size = |
| 157 (overlay.plane_z_order == 0) ? bounds().size() : overlay.buffer_size; | 158 (overlay.plane_z_order == 0) ? bounds().size() : overlay.buffer_size; |
| 159 | |
| 160 // TODO(kalyank): We assume that it's always a Video buffer in case | |
| 161 // plane_z_order > 1. This needs to be revisited when we add Overlay support | |
| 162 // for other layers. | |
| 163 OverlayBufferConfiguration buffer_config = GetOverlayBufferConfiguration( | |
| 164 overlay.display_rect, overlay.crop_rect, size, overlay.plane_z_order, | |
|
dnicoara
2015/11/09 20:53:23
I think that the way |size| is being used in GetOv
kalyank
2015/11/09 21:44:05
Everytime, display bounds of window changes we wil
dnicoara
2015/11/09 22:26:42
Yes, line 157 is making me scratch my head. It sou
kalyank
2015/11/09 23:03:40
You are right. I think this is a bug in Compositor
| |
| 165 overlay.plane_z_order > 1); | |
| 166 | |
| 167 size = buffer_config.buffer_size; | |
| 168 gfx::BufferFormat buffer_format = buffer_config.buffer_format; | |
| 169 | |
| 158 scoped_refptr<ScanoutBuffer> buffer; | 170 scoped_refptr<ScanoutBuffer> buffer; |
| 159 // Check if we can re-use existing buffers. | 171 // Check if we can re-use existing buffers. |
| 160 for (const auto& plane : last_submitted_planes_) { | 172 for (const auto& plane : last_submitted_planes_) { |
| 161 uint32_t format = GetFourCCFormatFromBufferFormat(overlay.format); | 173 uint32_t format = GetFourCCFormatFromBufferFormat(buffer_format); |
|
dnicoara
2015/11/09 20:53:23
This is no longer looking at the requested format.
| |
| 162 // We always use a storage type of XRGB, even if the pixel format | |
| 163 // is ARGB. | |
| 164 if (format == DRM_FORMAT_ARGB8888) | |
| 165 format = DRM_FORMAT_XRGB8888; | |
| 166 | |
| 167 if (plane.buffer->GetFramebufferPixelFormat() == format && | 174 if (plane.buffer->GetFramebufferPixelFormat() == format && |
| 168 plane.z_order == overlay.plane_z_order && | 175 plane.z_order == overlay.plane_z_order && |
| 169 plane.display_bounds == overlay.display_rect && | 176 plane.display_bounds == overlay.display_rect && |
| 170 plane.buffer->GetSize() == size) { | 177 plane.buffer->GetSize() == size) { |
| 171 buffer = plane.buffer; | 178 buffer = plane.buffer; |
| 172 break; | 179 break; |
| 173 } | 180 } |
| 174 } | 181 } |
| 175 | 182 |
| 176 if (!buffer) | 183 if (!buffer) |
| 177 buffer = buffer_generator->Create(drm, overlay.format, size); | 184 buffer = buffer_generator->Create(drm, buffer_format, size); |
| 178 | 185 |
| 179 if (!buffer) | 186 if (!buffer) |
| 180 continue; | 187 continue; |
| 181 | 188 |
| 182 OverlayPlane plane(buffer, overlay.plane_z_order, overlay.transform, | 189 OverlayPlane plane_config(buffer, overlay.plane_z_order, overlay.transform, |
| 183 overlay.display_rect, overlay.crop_rect); | 190 overlay.display_rect, overlay.crop_rect); |
| 184 | 191 |
| 185 // Buffer for Primary plane should always be present for compatibility test. | 192 // Buffer for Primary plane should always be present for compatibility test. |
| 186 if (!compatible_test_list.size() && overlay.plane_z_order != 0) { | 193 if (!compatible_test_list.size() && overlay.plane_z_order != 0) { |
| 187 compatible_test_list.push_back( | 194 compatible_test_list.push_back( |
| 188 *OverlayPlane::GetPrimaryPlane(last_submitted_planes_)); | 195 *OverlayPlane::GetPrimaryPlane(last_submitted_planes_)); |
| 189 } | 196 } |
| 190 | 197 |
| 191 compatible_test_list.push_back(plane); | 198 compatible_test_list.push_back(plane_config); |
| 192 | 199 |
| 193 if (controller_->TestPageFlip(compatible_test_list)) { | 200 if (controller_->TestPageFlip(compatible_test_list)) { |
| 194 overlay_params.plane_ids = | 201 overlay_params.plane_ids = |
| 195 controller_->GetCompatibleHardwarePlaneIds(plane); | 202 controller_->GetCompatibleHardwarePlaneIds(plane_config); |
| 196 params.push_back(overlay_params); | 203 params.push_back(overlay_params); |
| 197 } | 204 } |
| 198 | 205 |
| 199 if (compatible_test_list.size() > 1) | 206 if (compatible_test_list.size() > 1) |
| 200 compatible_test_list.pop_back(); | 207 compatible_test_list.pop_back(); |
| 201 } | 208 } |
| 202 | 209 |
| 203 return params; | 210 return params; |
| 204 } | 211 } |
| 205 | 212 |
| 213 OverlayBufferConfiguration DrmWindow::GetOverlayBufferConfiguration( | |
| 214 const gfx::Rect& display_bounds, | |
| 215 const gfx::RectF& crop_rect, | |
| 216 const gfx::Size& buffer_size, | |
| 217 uint32_t z_order, | |
| 218 bool video_content) { | |
| 219 gfx::Size required_size = buffer_size; | |
| 220 if (crop_rect.width() && crop_rect.height()) { | |
|
dnicoara
2015/11/09 20:53:23
nit: !crop_rect.IsEmpty()
kalyank
2015/11/19 16:10:41
Done.
| |
| 221 required_size = gfx::ToCeiledSize( | |
| 222 gfx::SizeF(display_bounds.width() / crop_rect.width(), | |
| 223 display_bounds.height() / crop_rect.height())); | |
| 224 } | |
| 225 | |
| 226 bool needs_scaling = false; | |
| 227 if (buffer_size != required_size) | |
| 228 needs_scaling = true; | |
| 229 | |
| 230 gfx::BufferFormat format = gfx::BufferFormat::BGRX_8888; | |
| 231 if (video_content && display_bounds != bounds_) { | |
|
dnicoara
2015/11/09 20:53:23
Why do you need to check for different bounds? Wha
kalyank
2015/11/09 21:44:05
This was to check if we are displaying the content
dnicoara
2015/11/09 22:26:42
Sorry, I think I'm confused. If it isn't fullscree
kalyank
2015/11/09 23:03:40
Sure.
kalyank
2015/11/19 16:10:41
Done.
| |
| 232 if (controller_->IsFormatSupported(DRM_FORMAT_UYVY, z_order)) | |
| 233 format = gfx::BufferFormat::UYVY_422; | |
| 234 } | |
| 235 | |
| 236 return OverlayBufferConfiguration(format, required_size, needs_scaling); | |
| 237 } | |
| 238 | |
| 206 const OverlayPlane* DrmWindow::GetLastModesetBuffer() { | 239 const OverlayPlane* DrmWindow::GetLastModesetBuffer() { |
| 207 return OverlayPlane::GetPrimaryPlane(last_submitted_planes_); | 240 return OverlayPlane::GetPrimaryPlane(last_submitted_planes_); |
| 208 } | 241 } |
| 209 | 242 |
| 210 void DrmWindow::GetVSyncParameters( | 243 void DrmWindow::GetVSyncParameters( |
| 211 const gfx::VSyncProvider::UpdateVSyncCallback& callback) const { | 244 const gfx::VSyncProvider::UpdateVSyncCallback& callback) const { |
| 212 if (!controller_) | 245 if (!controller_) |
| 213 return; | 246 return; |
| 214 | 247 |
| 215 // If we're in mirror mode the 2 CRTCs should have similar modes with the same | 248 // If we're in mirror mode the 2 CRTCs should have similar modes with the same |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 if (!cursor_buffers_[i]->Initialize( | 330 if (!cursor_buffers_[i]->Initialize( |
| 298 info, false /* should_register_framebuffer */)) { | 331 info, false /* should_register_framebuffer */)) { |
| 299 LOG(FATAL) << "Failed to initialize cursor buffer"; | 332 LOG(FATAL) << "Failed to initialize cursor buffer"; |
| 300 return; | 333 return; |
| 301 } | 334 } |
| 302 } | 335 } |
| 303 } | 336 } |
| 304 } | 337 } |
| 305 | 338 |
| 306 } // namespace ui | 339 } // namespace ui |
| OLD | NEW |