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 "components/exo/wayland/server.h" | 5 #include "components/exo/wayland/server.h" |
6 | 6 |
7 #include <grp.h> | 7 #include <grp.h> |
8 #include <linux/input.h> | 8 #include <linux/input.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 | 589 |
590 const struct dmabuf_supported_format { | 590 const struct dmabuf_supported_format { |
591 uint32_t dmabuf_format; | 591 uint32_t dmabuf_format; |
592 gfx::BufferFormat buffer_format; | 592 gfx::BufferFormat buffer_format; |
593 } dmabuf_supported_formats[] = { | 593 } dmabuf_supported_formats[] = { |
594 {DRM_FORMAT_RGB565, gfx::BufferFormat::BGR_565}, | 594 {DRM_FORMAT_RGB565, gfx::BufferFormat::BGR_565}, |
595 {DRM_FORMAT_XBGR8888, gfx::BufferFormat::RGBX_8888}, | 595 {DRM_FORMAT_XBGR8888, gfx::BufferFormat::RGBX_8888}, |
596 {DRM_FORMAT_ABGR8888, gfx::BufferFormat::RGBA_8888}, | 596 {DRM_FORMAT_ABGR8888, gfx::BufferFormat::RGBA_8888}, |
597 {DRM_FORMAT_XRGB8888, gfx::BufferFormat::BGRX_8888}, | 597 {DRM_FORMAT_XRGB8888, gfx::BufferFormat::BGRX_8888}, |
598 {DRM_FORMAT_ARGB8888, gfx::BufferFormat::BGRA_8888}, | 598 {DRM_FORMAT_ARGB8888, gfx::BufferFormat::BGRA_8888}, |
| 599 {DRM_FORMAT_NV12, gfx::BufferFormat::YUV_420_BIPLANAR}, |
599 {DRM_FORMAT_YVU420, gfx::BufferFormat::YVU_420}}; | 600 {DRM_FORMAT_YVU420, gfx::BufferFormat::YVU_420}}; |
600 | 601 |
601 struct LinuxBufferParams { | 602 struct LinuxBufferParams { |
602 struct Plane { | 603 struct Plane { |
603 base::ScopedFD fd; | 604 base::ScopedFD fd; |
604 uint32_t stride; | 605 uint32_t stride; |
605 uint32_t offset; | 606 uint32_t offset; |
606 }; | 607 }; |
607 | 608 |
608 explicit LinuxBufferParams(Display* display) : display(display) {} | 609 explicit LinuxBufferParams(Display* display) : display(display) {} |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 for (uint32_t i = 0; i < num_planes; ++i) { | 690 for (uint32_t i = 0; i < num_planes; ++i) { |
690 auto plane_it = linux_buffer_params->planes.find(i); | 691 auto plane_it = linux_buffer_params->planes.find(i); |
691 if (plane_it == linux_buffer_params->planes.end()) { | 692 if (plane_it == linux_buffer_params->planes.end()) { |
692 wl_resource_post_error(resource, | 693 wl_resource_post_error(resource, |
693 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE, | 694 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE, |
694 "missing a plane"); | 695 "missing a plane"); |
695 return; | 696 return; |
696 } | 697 } |
697 LinuxBufferParams::Plane& plane = plane_it->second; | 698 LinuxBufferParams::Plane& plane = plane_it->second; |
698 planes.emplace_back(plane.stride, plane.offset, 0, 0); | 699 planes.emplace_back(plane.stride, plane.offset, 0, 0); |
699 if (plane.fd.is_valid()) | 700 fds.push_back(std::move(plane.fd)); |
700 fds.push_back(std::move(plane.fd)); | |
701 } | 701 } |
702 | 702 |
703 std::unique_ptr<Buffer> buffer = | 703 std::unique_ptr<Buffer> buffer = |
704 linux_buffer_params->display->CreateLinuxDMABufBuffer( | 704 linux_buffer_params->display->CreateLinuxDMABufBuffer( |
705 gfx::Size(width, height), supported_format->buffer_format, planes, | 705 gfx::Size(width, height), supported_format->buffer_format, planes, |
706 std::move(fds)); | 706 std::move(fds)); |
707 if (!buffer) { | 707 if (!buffer) { |
708 zwp_linux_buffer_params_v1_send_failed(resource); | 708 zwp_linux_buffer_params_v1_send_failed(resource); |
709 return; | 709 return; |
710 } | 710 } |
(...skipping 2393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3104 DCHECK(event_loop); | 3104 DCHECK(event_loop); |
3105 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 3105 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
3106 } | 3106 } |
3107 | 3107 |
3108 void Server::Flush() { | 3108 void Server::Flush() { |
3109 wl_display_flush_clients(wl_display_.get()); | 3109 wl_display_flush_clients(wl_display_.get()); |
3110 } | 3110 } |
3111 | 3111 |
3112 } // namespace wayland | 3112 } // namespace wayland |
3113 } // namespace exo | 3113 } // namespace exo |
OLD | NEW |