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

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

Issue 2046743002: exo: Add support for importing YVU_420 buffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@yv12-test
Patch Set: Created 4 years, 6 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.cc ('k') | no next file » | 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "components/exo/surface.h" 48 #include "components/exo/surface.h"
49 #include "components/exo/touch.h" 49 #include "components/exo/touch.h"
50 #include "components/exo/touch_delegate.h" 50 #include "components/exo/touch_delegate.h"
51 #include "ipc/unix_domain_socket_util.h" 51 #include "ipc/unix_domain_socket_util.h"
52 #include "third_party/skia/include/core/SkRegion.h" 52 #include "third_party/skia/include/core/SkRegion.h"
53 #include "ui/aura/window_property.h" 53 #include "ui/aura/window_property.h"
54 #include "ui/base/hit_test.h" 54 #include "ui/base/hit_test.h"
55 #include "ui/display/display_observer.h" 55 #include "ui/display/display_observer.h"
56 #include "ui/display/screen.h" 56 #include "ui/display/screen.h"
57 #include "ui/events/keycodes/dom/keycode_converter.h" 57 #include "ui/events/keycodes/dom/keycode_converter.h"
58 #include "ui/gfx/buffer_format_util.h"
59 #include "ui/gfx/buffer_types.h"
58 #include "ui/views/widget/widget.h" 60 #include "ui/views/widget/widget.h"
59 #include "ui/views/widget/widget_observer.h" 61 #include "ui/views/widget/widget_observer.h"
60 #include "ui/wm/public/activation_change_observer.h" 62 #include "ui/wm/public/activation_change_observer.h"
61 #include "ui/wm/public/activation_client.h" 63 #include "ui/wm/public/activation_client.h"
62 64
63 #if defined(USE_OZONE) 65 #if defined(USE_OZONE)
64 #include <drm_fourcc.h> 66 #include <drm_fourcc.h>
65 #include <linux-dmabuf-unstable-v1-server-protocol.h> 67 #include <linux-dmabuf-unstable-v1-server-protocol.h>
66 #include <wayland-drm-server-protocol.h> 68 #include <wayland-drm-server-protocol.h>
67 #endif 69 #endif
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 430
429 #if defined(USE_OZONE) 431 #if defined(USE_OZONE)
430 432
431 //////////////////////////////////////////////////////////////////////////////// 433 ////////////////////////////////////////////////////////////////////////////////
432 // wl_drm_interface: 434 // wl_drm_interface:
433 435
434 const struct drm_supported_format { 436 const struct drm_supported_format {
435 uint32_t drm_format; 437 uint32_t drm_format;
436 gfx::BufferFormat buffer_format; 438 gfx::BufferFormat buffer_format;
437 } drm_supported_formats[] = { 439 } drm_supported_formats[] = {
440 {WL_DRM_FORMAT_YUV420, gfx::BufferFormat::YUV_420},
438 {WL_DRM_FORMAT_RGB565, gfx::BufferFormat::BGR_565}, 441 {WL_DRM_FORMAT_RGB565, gfx::BufferFormat::BGR_565},
439 {WL_DRM_FORMAT_XBGR8888, gfx::BufferFormat::RGBX_8888}, 442 {WL_DRM_FORMAT_XBGR8888, gfx::BufferFormat::RGBX_8888},
440 {WL_DRM_FORMAT_ABGR8888, gfx::BufferFormat::RGBA_8888}, 443 {WL_DRM_FORMAT_ABGR8888, gfx::BufferFormat::RGBA_8888},
441 {WL_DRM_FORMAT_XRGB8888, gfx::BufferFormat::BGRX_8888}, 444 {WL_DRM_FORMAT_XRGB8888, gfx::BufferFormat::BGRX_8888},
442 {WL_DRM_FORMAT_ARGB8888, gfx::BufferFormat::BGRA_8888}}; 445 {WL_DRM_FORMAT_ARGB8888, gfx::BufferFormat::BGRA_8888}};
443 446
444 void drm_authenticate(wl_client* client, wl_resource* resource, uint32_t id) { 447 void drm_authenticate(wl_client* client, wl_resource* resource, uint32_t id) {
445 wl_drm_send_authenticated(resource); 448 wl_drm_send_authenticated(resource);
446 } 449 }
447 450
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 [format](const drm_supported_format& supported_format) { 496 [format](const drm_supported_format& supported_format) {
494 return supported_format.drm_format == format; 497 return supported_format.drm_format == format;
495 }); 498 });
496 if (supported_format == 499 if (supported_format ==
497 (drm_supported_formats + arraysize(drm_supported_formats))) { 500 (drm_supported_formats + arraysize(drm_supported_formats))) {
498 wl_resource_post_error(resource, WL_DRM_ERROR_INVALID_FORMAT, 501 wl_resource_post_error(resource, WL_DRM_ERROR_INVALID_FORMAT,
499 "invalid format 0x%x", format); 502 "invalid format 0x%x", format);
500 return; 503 return;
501 } 504 }
502 505
506 std::vector<int> strides{stride0, stride1, stride2};
507 std::vector<int> offsets{offset0, offset1, offset2};
508
509 int planes =
510 gfx::NumberOfPlanesForBufferFormat(supported_format->buffer_format);
511 strides.resize(planes);
512 offsets.resize(planes);
503 std::unique_ptr<Buffer> buffer = 513 std::unique_ptr<Buffer> buffer =
504 GetUserDataAs<Display>(resource)->CreateLinuxDMABufBuffer( 514 GetUserDataAs<Display>(resource)->CreateLinuxDMABufBuffer(
505 base::ScopedFD(name), gfx::Size(width, height), 515 base::ScopedFD(name), gfx::Size(width, height),
506 supported_format->buffer_format, stride0); 516 supported_format->buffer_format, strides, offsets);
507 if (!buffer) { 517 if (!buffer) {
508 wl_resource_post_no_memory(resource); 518 wl_resource_post_no_memory(resource);
509 return; 519 return;
510 } 520 }
511 521
512 wl_resource* buffer_resource = 522 wl_resource* buffer_resource =
513 wl_resource_create(client, &wl_buffer_interface, 1, id); 523 wl_resource_create(client, &wl_buffer_interface, 1, id);
514 524
515 buffer->set_release_callback(base::Bind(&HandleBufferReleaseCallback, 525 buffer->set_release_callback(base::Bind(&HandleBufferReleaseCallback,
516 base::Unretained(buffer_resource))); 526 base::Unretained(buffer_resource)));
(...skipping 20 matching lines...) Expand all
537 wl_drm_send_format(resource, supported_format.drm_format); 547 wl_drm_send_format(resource, supported_format.drm_format);
538 } 548 }
539 549
540 //////////////////////////////////////////////////////////////////////////////// 550 ////////////////////////////////////////////////////////////////////////////////
541 // linux_buffer_params_interface: 551 // linux_buffer_params_interface:
542 552
543 const struct dmabuf_supported_format { 553 const struct dmabuf_supported_format {
544 uint32_t dmabuf_format; 554 uint32_t dmabuf_format;
545 gfx::BufferFormat buffer_format; 555 gfx::BufferFormat buffer_format;
546 } dmabuf_supported_formats[] = { 556 } dmabuf_supported_formats[] = {
557 // TODO(dcastagna): Add support for YUV_420.
reveman 2016/06/06 21:24:08 Please add this format here as well. The interface
Daniele Castagna 2016/06/09 21:09:17 Done. Added also the support for multiple planes i
547 {DRM_FORMAT_RGB565, gfx::BufferFormat::BGR_565}, 558 {DRM_FORMAT_RGB565, gfx::BufferFormat::BGR_565},
548 {DRM_FORMAT_XBGR8888, gfx::BufferFormat::RGBX_8888}, 559 {DRM_FORMAT_XBGR8888, gfx::BufferFormat::RGBX_8888},
549 {DRM_FORMAT_ABGR8888, gfx::BufferFormat::RGBA_8888}, 560 {DRM_FORMAT_ABGR8888, gfx::BufferFormat::RGBA_8888},
550 {DRM_FORMAT_XRGB8888, gfx::BufferFormat::BGRX_8888}, 561 {DRM_FORMAT_XRGB8888, gfx::BufferFormat::BGRX_8888},
551 {DRM_FORMAT_ARGB8888, gfx::BufferFormat::BGRA_8888}}; 562 {DRM_FORMAT_ARGB8888, gfx::BufferFormat::BGRA_8888}};
552 563
553 struct LinuxBufferParams { 564 struct LinuxBufferParams {
554 explicit LinuxBufferParams(Display* display) 565 explicit LinuxBufferParams(Display* display)
555 : display(display), stride(0), offset(0) {} 566 : display(display), stride(0), offset(0) {}
556 567
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 if (linux_buffer_params->offset) { 640 if (linux_buffer_params->offset) {
630 wl_resource_post_error(resource, 641 wl_resource_post_error(resource,
631 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS, 642 ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS,
632 "offset not supported"); 643 "offset not supported");
633 return; 644 return;
634 } 645 }
635 646
636 std::unique_ptr<Buffer> buffer = 647 std::unique_ptr<Buffer> buffer =
637 linux_buffer_params->display->CreateLinuxDMABufBuffer( 648 linux_buffer_params->display->CreateLinuxDMABufBuffer(
638 std::move(linux_buffer_params->fd), gfx::Size(width, height), 649 std::move(linux_buffer_params->fd), gfx::Size(width, height),
639 supported_format->buffer_format, linux_buffer_params->stride); 650 supported_format->buffer_format, {linux_buffer_params->stride}, {0});
640 if (!buffer) { 651 if (!buffer) {
641 zwp_linux_buffer_params_v1_send_failed(resource); 652 zwp_linux_buffer_params_v1_send_failed(resource);
642 return; 653 return;
643 } 654 }
644 655
645 wl_resource* buffer_resource = 656 wl_resource* buffer_resource =
646 wl_resource_create(client, &wl_buffer_interface, 1, 0); 657 wl_resource_create(client, &wl_buffer_interface, 1, 0);
647 658
648 buffer->set_release_callback(base::Bind(&HandleBufferReleaseCallback, 659 buffer->set_release_callback(base::Bind(&HandleBufferReleaseCallback,
649 base::Unretained(buffer_resource))); 660 base::Unretained(buffer_resource)));
(...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 DCHECK(event_loop); 2511 DCHECK(event_loop);
2501 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); 2512 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds());
2502 } 2513 }
2503 2514
2504 void Server::Flush() { 2515 void Server::Flush() {
2505 wl_display_flush_clients(wl_display_.get()); 2516 wl_display_flush_clients(wl_display_.get());
2506 } 2517 }
2507 2518
2508 } // namespace wayland 2519 } // namespace wayland
2509 } // namespace exo 2520 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/display.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698