Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: components/exo/wayland/server.cc

Issue 2039813002: Add format modifier IDs for EGL_EXT_image_dma_buf_import extension (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add format modifier IDs for EGL_EXT_image_dma_buf_import extension Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/exo/display_unittest.cc ('k') | gpu/ipc/client/gpu_channel_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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<int> strides{stride0, stride1, stride2}; 524 std::vector<gfx::NativePixmapPlane> planes;
525 std::vector<int> offsets{offset0, offset1, offset2}; 525 planes.emplace_back(stride0, offset0, 0);
526 planes.emplace_back(stride1, offset1, 0);
527 planes.emplace_back(stride2, offset2, 0);
526 std::vector<base::ScopedFD> fds; 528 std::vector<base::ScopedFD> fds;
527 529
528 int planes = 530 size_t num_planes =
529 gfx::NumberOfPlanesForBufferFormat(supported_format->buffer_format); 531 gfx::NumberOfPlanesForBufferFormat(supported_format->buffer_format);
530 strides.resize(planes); 532 planes.resize(num_planes);
531 offsets.resize(planes);
532 fds.push_back(base::ScopedFD(name)); 533 fds.push_back(base::ScopedFD(name));
533 534
534 std::unique_ptr<Buffer> buffer = 535 std::unique_ptr<Buffer> buffer =
535 GetUserDataAs<Display>(resource)->CreateLinuxDMABufBuffer( 536 GetUserDataAs<Display>(resource)->CreateLinuxDMABufBuffer(
536 gfx::Size(width, height), supported_format->buffer_format, strides, 537 gfx::Size(width, height), supported_format->buffer_format, planes,
537 offsets, std::move(fds)); 538 std::move(fds));
538 if (!buffer) { 539 if (!buffer) {
539 wl_resource_post_no_memory(resource); 540 wl_resource_post_no_memory(resource);
540 return; 541 return;
541 } 542 }
542 543
543 wl_resource* buffer_resource = 544 wl_resource* buffer_resource =
544 wl_resource_create(client, &wl_buffer_interface, 1, id); 545 wl_resource_create(client, &wl_buffer_interface, 1, id);
545 546
546 buffer->set_release_callback(base::Bind(&HandleBufferReleaseCallback, 547 buffer->set_release_callback(base::Bind(&HandleBufferReleaseCallback,
547 base::Unretained(buffer_resource))); 548 base::Unretained(buffer_resource)));
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 661
661 size_t num_planes = 662 size_t num_planes =
662 gfx::NumberOfPlanesForBufferFormat(supported_format->buffer_format); 663 gfx::NumberOfPlanesForBufferFormat(supported_format->buffer_format);
663 664
664 if (linux_buffer_params->planes.size() != num_planes) { 665 if (linux_buffer_params->planes.size() != num_planes) {
665 wl_resource_post_error(resource, ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX, 666 wl_resource_post_error(resource, ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX,
666 "plane idx out of bounds"); 667 "plane idx out of bounds");
667 return; 668 return;
668 } 669 }
669 670
670 std::vector<int> strides; 671 std::vector<gfx::NativePixmapPlane> planes;
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 strides.push_back(plane.stride); 683 planes.emplace_back(plane.stride, plane.offset, 0);
684 offsets.push_back(plane.offset);
685 if (plane.fd.is_valid()) 684 if (plane.fd.is_valid())
686 fds.push_back(std::move(plane.fd)); 685 fds.push_back(std::move(plane.fd));
687 } 686 }
688 687
689 std::unique_ptr<Buffer> buffer = 688 std::unique_ptr<Buffer> buffer =
690 linux_buffer_params->display->CreateLinuxDMABufBuffer( 689 linux_buffer_params->display->CreateLinuxDMABufBuffer(
691 gfx::Size(width, height), supported_format->buffer_format, strides, 690 gfx::Size(width, height), supported_format->buffer_format, planes,
692 offsets, std::move(fds)); 691 std::move(fds));
693 if (!buffer) { 692 if (!buffer) {
694 zwp_linux_buffer_params_v1_send_failed(resource); 693 zwp_linux_buffer_params_v1_send_failed(resource);
695 return; 694 return;
696 } 695 }
697 696
698 wl_resource* buffer_resource = 697 wl_resource* buffer_resource =
699 wl_resource_create(client, &wl_buffer_interface, 1, 0); 698 wl_resource_create(client, &wl_buffer_interface, 1, 0);
700 699
701 buffer->set_release_callback(base::Bind(&HandleBufferReleaseCallback, 700 buffer->set_release_callback(base::Bind(&HandleBufferReleaseCallback,
702 base::Unretained(buffer_resource))); 701 base::Unretained(buffer_resource)));
(...skipping 2167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2870 DCHECK(event_loop); 2869 DCHECK(event_loop);
2871 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); 2870 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds());
2872 } 2871 }
2873 2872
2874 void Server::Flush() { 2873 void Server::Flush() {
2875 wl_display_flush_clients(wl_display_.get()); 2874 wl_display_flush_clients(wl_display_.get());
2876 } 2875 }
2877 2876
2878 } // namespace wayland 2877 } // namespace wayland
2879 } // namespace exo 2878 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/display_unittest.cc ('k') | gpu/ipc/client/gpu_channel_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698