| 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 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 [format](const drm_supported_format& supported_format) { | 507 [format](const drm_supported_format& supported_format) { |
| 508 return supported_format.drm_format == format; | 508 return supported_format.drm_format == format; |
| 509 }); | 509 }); |
| 510 if (supported_format == | 510 if (supported_format == |
| 511 (drm_supported_formats + arraysize(drm_supported_formats))) { | 511 (drm_supported_formats + arraysize(drm_supported_formats))) { |
| 512 wl_resource_post_error(resource, WL_DRM_ERROR_INVALID_FORMAT, | 512 wl_resource_post_error(resource, WL_DRM_ERROR_INVALID_FORMAT, |
| 513 "invalid format 0x%x", format); | 513 "invalid format 0x%x", format); |
| 514 return; | 514 return; |
| 515 } | 515 } |
| 516 | 516 |
| 517 std::vector<int> strides{stride0, stride1, stride2}; | 517 std::vector<gfx::GbmBufferPlane> planes; |
| 518 std::vector<int> offsets{offset0, offset1, offset2}; | 518 planes.emplace_back(stride0, offset0, 0); |
| 519 planes.emplace_back(stride1, offset1, 0); |
| 520 planes.emplace_back(stride2, offset2, 0); |
| 519 std::vector<base::ScopedFD> fds; | 521 std::vector<base::ScopedFD> fds; |
| 520 | 522 |
| 521 int planes = | 523 int num_planes = |
| 522 gfx::NumberOfPlanesForBufferFormat(supported_format->buffer_format); | 524 gfx::NumberOfPlanesForBufferFormat(supported_format->buffer_format); |
| 523 strides.resize(planes); | 525 planes.resize(num_planes); |
| 524 offsets.resize(planes); | |
| 525 fds.push_back(base::ScopedFD(name)); | 526 fds.push_back(base::ScopedFD(name)); |
| 526 | 527 |
| 527 std::unique_ptr<Buffer> buffer = | 528 std::unique_ptr<Buffer> buffer = |
| 528 GetUserDataAs<Display>(resource)->CreateLinuxDMABufBuffer( | 529 GetUserDataAs<Display>(resource)->CreateLinuxDMABufBuffer( |
| 529 gfx::Size(width, height), supported_format->buffer_format, strides, | 530 gfx::Size(width, height), supported_format->buffer_format, planes, |
| 530 offsets, std::move(fds)); | 531 std::move(fds)); |
| 531 if (!buffer) { | 532 if (!buffer) { |
| 532 wl_resource_post_no_memory(resource); | 533 wl_resource_post_no_memory(resource); |
| 533 return; | 534 return; |
| 534 } | 535 } |
| 535 | 536 |
| 536 wl_resource* buffer_resource = | 537 wl_resource* buffer_resource = |
| 537 wl_resource_create(client, &wl_buffer_interface, 1, id); | 538 wl_resource_create(client, &wl_buffer_interface, 1, id); |
| 538 | 539 |
| 539 buffer->set_release_callback(base::Bind(&HandleBufferReleaseCallback, | 540 buffer->set_release_callback(base::Bind(&HandleBufferReleaseCallback, |
| 540 base::Unretained(buffer_resource))); | 541 base::Unretained(buffer_resource))); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 | 654 |
| 654 size_t num_planes = | 655 size_t num_planes = |
| 655 gfx::NumberOfPlanesForBufferFormat(supported_format->buffer_format); | 656 gfx::NumberOfPlanesForBufferFormat(supported_format->buffer_format); |
| 656 | 657 |
| 657 if (linux_buffer_params->planes.size() != num_planes) { | 658 if (linux_buffer_params->planes.size() != num_planes) { |
| 658 wl_resource_post_error(resource, ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX, | 659 wl_resource_post_error(resource, ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX, |
| 659 "plane idx out of bounds"); | 660 "plane idx out of bounds"); |
| 660 return; | 661 return; |
| 661 } | 662 } |
| 662 | 663 |
| 663 std::vector<int> strides; | 664 std::vector<gfx::GbmBufferPlane> planes; |
| 664 std::vector<int> offsets; | |
| 665 std::vector<base::ScopedFD> fds; | 665 std::vector<base::ScopedFD> fds; |
| 666 | 666 |
| 667 for (uint32_t i = 0; i < num_planes; ++i) { | 667 for (uint32_t i = 0; i < num_planes; ++i) { |
| 668 auto plane_it = linux_buffer_params->planes.find(i); | 668 auto plane_it = linux_buffer_params->planes.find(i); |
| 669 if (plane_it == linux_buffer_params->planes.end()) { | 669 if (plane_it == linux_buffer_params->planes.end()) { |
| 670 wl_resource_post_error(resource, | 670 wl_resource_post_error(resource, |
| 671 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE, | 671 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE, |
| 672 "missing a plane"); | 672 "missing a plane"); |
| 673 return; | 673 return; |
| 674 } | 674 } |
| 675 LinuxBufferParams::Plane& plane = plane_it->second; | 675 LinuxBufferParams::Plane& plane = plane_it->second; |
| 676 strides.push_back(plane.stride); | 676 planes.emplace_back(plane.stride, plane.offset, 0); |
| 677 offsets.push_back(plane.offset); | |
| 678 if (plane.fd.is_valid()) | 677 if (plane.fd.is_valid()) |
| 679 fds.push_back(std::move(plane.fd)); | 678 fds.push_back(std::move(plane.fd)); |
| 680 } | 679 } |
| 681 | 680 |
| 682 std::unique_ptr<Buffer> buffer = | 681 std::unique_ptr<Buffer> buffer = |
| 683 linux_buffer_params->display->CreateLinuxDMABufBuffer( | 682 linux_buffer_params->display->CreateLinuxDMABufBuffer( |
| 684 gfx::Size(width, height), supported_format->buffer_format, strides, | 683 gfx::Size(width, height), supported_format->buffer_format, planes, |
| 685 offsets, std::move(fds)); | 684 std::move(fds)); |
| 686 if (!buffer) { | 685 if (!buffer) { |
| 687 zwp_linux_buffer_params_v1_send_failed(resource); | 686 zwp_linux_buffer_params_v1_send_failed(resource); |
| 688 return; | 687 return; |
| 689 } | 688 } |
| 690 | 689 |
| 691 wl_resource* buffer_resource = | 690 wl_resource* buffer_resource = |
| 692 wl_resource_create(client, &wl_buffer_interface, 1, 0); | 691 wl_resource_create(client, &wl_buffer_interface, 1, 0); |
| 693 | 692 |
| 694 buffer->set_release_callback(base::Bind(&HandleBufferReleaseCallback, | 693 buffer->set_release_callback(base::Bind(&HandleBufferReleaseCallback, |
| 695 base::Unretained(buffer_resource))); | 694 base::Unretained(buffer_resource))); |
| (...skipping 1953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2649 DCHECK(event_loop); | 2648 DCHECK(event_loop); |
| 2650 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 2649 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
| 2651 } | 2650 } |
| 2652 | 2651 |
| 2653 void Server::Flush() { | 2652 void Server::Flush() { |
| 2654 wl_display_flush_clients(wl_display_.get()); | 2653 wl_display_flush_clients(wl_display_.get()); |
| 2655 } | 2654 } |
| 2656 | 2655 |
| 2657 } // namespace wayland | 2656 } // namespace wayland |
| 2658 } // namespace exo | 2657 } // namespace exo |
| OLD | NEW |