Beispiel #1
0
static boolean
wayland_surface_validate(struct native_surface *nsurf, uint attachment_mask,
                         unsigned int *seq_num, struct pipe_resource **textures,
                         int *width, int *height)
{
   struct wayland_surface *surface = wayland_surface(nsurf);

   if (surface->type == WL_WINDOW_SURFACE)
      wayland_window_surface_handle_resize(surface);

   if (!resource_surface_add_resources(surface->rsurf, attachment_mask |
                                       surface->attachment_mask))
      return FALSE;

   if (textures)
      resource_surface_get_resources(surface->rsurf, textures, attachment_mask);

   if (seq_num)
      *seq_num = surface->sequence_number;

   resource_surface_get_size(surface->rsurf, (uint *) width, (uint *) height);

   if (surface->type == WL_PIXMAP_SURFACE)
      wayland_pixmap_surface_initialize(surface);

   return TRUE;
}
Beispiel #2
0
static void
wayland_surface_destroy(struct native_surface *nsurf)
{
   struct wayland_surface *surface = wayland_surface(nsurf);
   enum wayland_buffer_type buffer;

   for (buffer = 0; buffer < WL_BUFFER_COUNT; ++buffer) {
      if (surface->buffer[buffer])
         wl_buffer_destroy(surface->buffer[buffer]);
   }

   resource_surface_destroy(surface->rsurf);
   FREE(surface);
}
Beispiel #3
0
static boolean
wayland_surface_swap_buffers(struct native_surface *nsurf)
{
   struct wayland_surface *surface = wayland_surface(nsurf);
   struct wayland_display *display = surface->display;
   int ret = 0;

   while (surface->frame_callback && ret != -1)
      ret = wl_display_dispatch_queue(display->dpy, display->queue);
   if (ret == -1)
      return EGL_FALSE;

   surface->frame_callback = wl_surface_frame(surface->win->surface);
   wl_callback_add_listener(surface->frame_callback, &frame_listener, surface);
   wl_proxy_set_queue((struct wl_proxy *) surface->frame_callback,
                      display->queue);

   if (surface->type == WL_WINDOW_SURFACE) {
      resource_surface_swap_buffers(surface->rsurf,
                                    NATIVE_ATTACHMENT_FRONT_LEFT,
                                    NATIVE_ATTACHMENT_BACK_LEFT, FALSE);

      wayland_buffers_swap(surface->buffer, WL_BUFFER_FRONT, WL_BUFFER_BACK);

      if (surface->buffer[WL_BUFFER_FRONT] == NULL)
         surface->buffer[WL_BUFFER_FRONT] =
            display->create_buffer(display, surface,
                                   NATIVE_ATTACHMENT_FRONT_LEFT);

      wl_surface_attach(surface->win->surface, surface->buffer[WL_BUFFER_FRONT],
                        surface->dx, surface->dy);

      resource_surface_get_size(surface->rsurf,
                                (uint *) &surface->win->attached_width,
                                (uint *) &surface->win->attached_height);
      surface->dx = 0;
      surface->dy = 0;
   }

   surface->sequence_number++;
   wayland_event_handler->invalid_surface(&display->base,
                                          &surface->base,
                                          surface->sequence_number);

   return TRUE;
}
Beispiel #4
0
static boolean
wayland_surface_present(struct native_surface *nsurf,
                        const struct native_present_control *ctrl)
{
   struct wayland_surface *surface = wayland_surface(nsurf);
   uint width, height;
   boolean ret;

   if (ctrl->preserve || ctrl->swap_interval)
      return FALSE;

   /* force buffers to be re-created if they will be presented differently */
   if (surface->premultiplied_alpha != ctrl->premultiplied_alpha) {
      enum wayland_buffer_type buffer;

      for (buffer = 0; buffer < WL_BUFFER_COUNT; ++buffer) {
         if (surface->buffer[buffer]) {
            wl_buffer_destroy(surface->buffer[buffer]);
            surface->buffer[buffer] = NULL;
         }
      }

      surface->premultiplied_alpha = ctrl->premultiplied_alpha;
   }

   switch (ctrl->natt) {
   case NATIVE_ATTACHMENT_FRONT_LEFT:
      ret = TRUE;
      break;
   case NATIVE_ATTACHMENT_BACK_LEFT:
      ret = wayland_surface_swap_buffers(nsurf);
      break;
   default:
      ret = FALSE;
      break;
   }

   if (surface->type == WL_WINDOW_SURFACE) {
      resource_surface_get_size(surface->rsurf, &width, &height);
      wl_buffer_damage(surface->buffer[WL_BUFFER_FRONT], 0, 0, width, height);
      wl_surface_damage(surface->win->surface, 0, 0, width, height);
   }

   return ret;
}
Beispiel #5
0
static boolean
wayland_surface_swap_buffers(struct native_surface *nsurf)
{
   struct wayland_surface *surface = wayland_surface(nsurf);
   struct wayland_display *display = surface->display;
   struct wl_callback *callback;

   while (surface->block_swap_buffers)
      wl_display_iterate(display->dpy, WL_DISPLAY_READABLE);

   surface->block_swap_buffers = TRUE;

   callback = wl_surface_frame(surface->win->surface);
   wl_callback_add_listener(callback, &frame_listener, surface);

   if (surface->type == WL_WINDOW_SURFACE) {
      resource_surface_swap_buffers(surface->rsurf,
                                    NATIVE_ATTACHMENT_FRONT_LEFT,
                                    NATIVE_ATTACHMENT_BACK_LEFT, FALSE);

      wayland_buffers_swap(surface->buffer, WL_BUFFER_FRONT, WL_BUFFER_BACK);

      if (surface->buffer[WL_BUFFER_FRONT] == NULL)
         surface->buffer[WL_BUFFER_FRONT] =
            display->create_buffer(display, surface,
                                   NATIVE_ATTACHMENT_FRONT_LEFT);

      wl_surface_attach(surface->win->surface, surface->buffer[WL_BUFFER_FRONT],
                        surface->dx, surface->dy);

      resource_surface_get_size(surface->rsurf,
                                (uint *) &surface->win->attached_width,
                                (uint *) &surface->win->attached_height);
      surface->dx = 0;
      surface->dy = 0;
   }

   surface->sequence_number++;
   wayland_event_handler->invalid_surface(&display->base,
                                          &surface->base,
                                          surface->sequence_number);

   return TRUE;
}