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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 [format](const drm_supported_format& supported_format) { | 514 [format](const drm_supported_format& supported_format) { |
515 return supported_format.drm_format == format; | 515 return supported_format.drm_format == format; |
516 }); | 516 }); |
517 if (supported_format == | 517 if (supported_format == |
518 (drm_supported_formats + arraysize(drm_supported_formats))) { | 518 (drm_supported_formats + arraysize(drm_supported_formats))) { |
519 wl_resource_post_error(resource, WL_DRM_ERROR_INVALID_FORMAT, | 519 wl_resource_post_error(resource, WL_DRM_ERROR_INVALID_FORMAT, |
520 "invalid format 0x%x", format); | 520 "invalid format 0x%x", format); |
521 return; | 521 return; |
522 } | 522 } |
523 | 523 |
524 std::vector<gfx::NativePixmapPlane> planes; | 524 std::vector<int> strides{stride0, stride1, stride2}; |
525 planes.emplace_back(stride0, offset0, 0); | 525 std::vector<int> offsets{offset0, offset1, offset2}; |
526 planes.emplace_back(stride1, offset1, 0); | |
527 planes.emplace_back(stride2, offset2, 0); | |
528 std::vector<base::ScopedFD> fds; | 526 std::vector<base::ScopedFD> fds; |
529 | 527 |
530 size_t num_planes = | 528 int planes = |
531 gfx::NumberOfPlanesForBufferFormat(supported_format->buffer_format); | 529 gfx::NumberOfPlanesForBufferFormat(supported_format->buffer_format); |
532 planes.resize(num_planes); | 530 strides.resize(planes); |
| 531 offsets.resize(planes); |
533 fds.push_back(base::ScopedFD(name)); | 532 fds.push_back(base::ScopedFD(name)); |
534 | 533 |
535 std::unique_ptr<Buffer> buffer = | 534 std::unique_ptr<Buffer> buffer = |
536 GetUserDataAs<Display>(resource)->CreateLinuxDMABufBuffer( | 535 GetUserDataAs<Display>(resource)->CreateLinuxDMABufBuffer( |
537 gfx::Size(width, height), supported_format->buffer_format, planes, | 536 gfx::Size(width, height), supported_format->buffer_format, strides, |
538 std::move(fds)); | 537 offsets, std::move(fds)); |
539 if (!buffer) { | 538 if (!buffer) { |
540 wl_resource_post_no_memory(resource); | 539 wl_resource_post_no_memory(resource); |
541 return; | 540 return; |
542 } | 541 } |
543 | 542 |
544 wl_resource* buffer_resource = | 543 wl_resource* buffer_resource = |
545 wl_resource_create(client, &wl_buffer_interface, 1, id); | 544 wl_resource_create(client, &wl_buffer_interface, 1, id); |
546 | 545 |
547 buffer->set_release_callback(base::Bind(&HandleBufferReleaseCallback, | 546 buffer->set_release_callback(base::Bind(&HandleBufferReleaseCallback, |
548 base::Unretained(buffer_resource))); | 547 base::Unretained(buffer_resource))); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 | 660 |
662 size_t num_planes = | 661 size_t num_planes = |
663 gfx::NumberOfPlanesForBufferFormat(supported_format->buffer_format); | 662 gfx::NumberOfPlanesForBufferFormat(supported_format->buffer_format); |
664 | 663 |
665 if (linux_buffer_params->planes.size() != num_planes) { | 664 if (linux_buffer_params->planes.size() != num_planes) { |
666 wl_resource_post_error(resource, ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX, | 665 wl_resource_post_error(resource, ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX, |
667 "plane idx out of bounds"); | 666 "plane idx out of bounds"); |
668 return; | 667 return; |
669 } | 668 } |
670 | 669 |
671 std::vector<gfx::NativePixmapPlane> planes; | 670 std::vector<int> strides; |
| 671 std::vector<int> offsets; |
672 std::vector<base::ScopedFD> fds; | 672 std::vector<base::ScopedFD> fds; |
673 | 673 |
674 for (uint32_t i = 0; i < num_planes; ++i) { | 674 for (uint32_t i = 0; i < num_planes; ++i) { |
675 auto plane_it = linux_buffer_params->planes.find(i); | 675 auto plane_it = linux_buffer_params->planes.find(i); |
676 if (plane_it == linux_buffer_params->planes.end()) { | 676 if (plane_it == linux_buffer_params->planes.end()) { |
677 wl_resource_post_error(resource, | 677 wl_resource_post_error(resource, |
678 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE, | 678 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE, |
679 "missing a plane"); | 679 "missing a plane"); |
680 return; | 680 return; |
681 } | 681 } |
682 LinuxBufferParams::Plane& plane = plane_it->second; | 682 LinuxBufferParams::Plane& plane = plane_it->second; |
683 planes.emplace_back(plane.stride, plane.offset, 0); | 683 strides.push_back(plane.stride); |
| 684 offsets.push_back(plane.offset); |
684 if (plane.fd.is_valid()) | 685 if (plane.fd.is_valid()) |
685 fds.push_back(std::move(plane.fd)); | 686 fds.push_back(std::move(plane.fd)); |
686 } | 687 } |
687 | 688 |
688 std::unique_ptr<Buffer> buffer = | 689 std::unique_ptr<Buffer> buffer = |
689 linux_buffer_params->display->CreateLinuxDMABufBuffer( | 690 linux_buffer_params->display->CreateLinuxDMABufBuffer( |
690 gfx::Size(width, height), supported_format->buffer_format, planes, | 691 gfx::Size(width, height), supported_format->buffer_format, strides, |
691 std::move(fds)); | 692 offsets, std::move(fds)); |
692 if (!buffer) { | 693 if (!buffer) { |
693 zwp_linux_buffer_params_v1_send_failed(resource); | 694 zwp_linux_buffer_params_v1_send_failed(resource); |
694 return; | 695 return; |
695 } | 696 } |
696 | 697 |
697 wl_resource* buffer_resource = | 698 wl_resource* buffer_resource = |
698 wl_resource_create(client, &wl_buffer_interface, 1, 0); | 699 wl_resource_create(client, &wl_buffer_interface, 1, 0); |
699 | 700 |
700 buffer->set_release_callback(base::Bind(&HandleBufferReleaseCallback, | 701 buffer->set_release_callback(base::Bind(&HandleBufferReleaseCallback, |
701 base::Unretained(buffer_resource))); | 702 base::Unretained(buffer_resource))); |
(...skipping 2133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2835 DCHECK(event_loop); | 2836 DCHECK(event_loop); |
2836 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 2837 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
2837 } | 2838 } |
2838 | 2839 |
2839 void Server::Flush() { | 2840 void Server::Flush() { |
2840 wl_display_flush_clients(wl_display_.get()); | 2841 wl_display_flush_clients(wl_display_.get()); |
2841 } | 2842 } |
2842 | 2843 |
2843 } // namespace wayland | 2844 } // namespace wayland |
2844 } // namespace exo | 2845 } // namespace exo |
OLD | NEW |