1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ 2 3 /* 4 * Copyright (C) 2014 Endless Mobile 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of the 9 * License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, but 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 19 * 02111-1307, USA. 20 * 21 * Written by: 22 * Jasper St. Pierre <jstpierre@mecheye.net> 23 */ 24 25 #ifndef META_WAYLAND_BUFFER_H 26 #define META_WAYLAND_BUFFER_H 27 28 #include <cairo.h> 29 #include <wayland-server.h> 30 31 #include "cogl/cogl.h" 32 #include "wayland/meta-wayland-types.h" 33 #include "wayland/meta-wayland-egl-stream.h" 34 #include "wayland/meta-wayland-dma-buf.h" 35 36 typedef enum _MetaWaylandBufferType 37 { 38 META_WAYLAND_BUFFER_TYPE_UNKNOWN, 39 META_WAYLAND_BUFFER_TYPE_SHM, 40 META_WAYLAND_BUFFER_TYPE_EGL_IMAGE, 41 #ifdef HAVE_WAYLAND_EGLSTREAM 42 META_WAYLAND_BUFFER_TYPE_EGL_STREAM, 43 #endif 44 META_WAYLAND_BUFFER_TYPE_DMA_BUF, 45 } MetaWaylandBufferType; 46 47 struct _MetaWaylandBuffer 48 { 49 GObject parent; 50 51 struct wl_resource *resource; 52 struct wl_listener destroy_listener; 53 54 gboolean is_y_inverted; 55 56 MetaWaylandBufferType type; 57 58 struct { 59 CoglTexture *texture; 60 } egl_image; 61 62 #ifdef HAVE_WAYLAND_EGLSTREAM 63 struct { 64 MetaWaylandEglStream *stream; 65 CoglTexture *texture; 66 } egl_stream; 67 #endif 68 69 struct { 70 MetaWaylandDmaBufBuffer *dma_buf; 71 CoglTexture *texture; 72 } dma_buf; 73 }; 74 75 #define META_TYPE_WAYLAND_BUFFER (meta_wayland_buffer_get_type ()) 76 G_DECLARE_FINAL_TYPE (MetaWaylandBuffer, meta_wayland_buffer, 77 META, WAYLAND_BUFFER, GObject); 78 79 MetaWaylandBuffer * meta_wayland_buffer_from_resource (struct wl_resource *resource); 80 struct wl_resource * meta_wayland_buffer_get_resource (MetaWaylandBuffer *buffer); 81 gboolean meta_wayland_buffer_is_realized (MetaWaylandBuffer *buffer); 82 gboolean meta_wayland_buffer_realize (MetaWaylandBuffer *buffer); 83 gboolean meta_wayland_buffer_attach (MetaWaylandBuffer *buffer, 84 CoglTexture **texture, 85 GError **error); 86 CoglSnippet * meta_wayland_buffer_create_snippet (MetaWaylandBuffer *buffer); 87 gboolean meta_wayland_buffer_is_y_inverted (MetaWaylandBuffer *buffer); 88 void meta_wayland_buffer_process_damage (MetaWaylandBuffer *buffer, 89 CoglTexture *texture, 90 cairo_region_t *region); 91 CoglScanout * meta_wayland_buffer_try_acquire_scanout (MetaWaylandBuffer *buffer, 92 CoglOnscreen *onscreen); 93 94 void meta_wayland_init_shm (MetaWaylandCompositor *compositor); 95 96 #endif /* META_WAYLAND_BUFFER_H */ 97