/**
 * Schedule a copy swap from the back to the front buffer using the
 * native display's copy context.
 */
boolean
resource_surface_copy_swap(struct resource_surface *rsurf,
			   struct native_display *ndpy)
{
   struct pipe_resource *ftex;
   struct pipe_resource *btex;
   struct pipe_context *pipe;
   struct pipe_box src_box;
   boolean ret = FALSE;

   pipe = ndpy_get_copy_context(ndpy);
   if (!pipe)
      return FALSE;

   ftex = resource_surface_get_single_resource(rsurf,
					       NATIVE_ATTACHMENT_FRONT_LEFT);
   if (!ftex)
      goto out_no_ftex;
   btex = resource_surface_get_single_resource(rsurf,
					       NATIVE_ATTACHMENT_BACK_LEFT);
   if (!btex)
      goto out_no_btex;

   u_box_origin_2d(ftex->width0, ftex->height0, &src_box);
   pipe->resource_copy_region(pipe, ftex, 0, 0, 0, 0,
			      btex, 0, &src_box);
   ret = TRUE;

 out_no_btex:
   pipe_resource_reference(&btex, NULL);
 out_no_ftex:
   pipe_resource_reference(&ftex, NULL);

   return ret;
}
Beispiel #2
0
static boolean
dri2_surface_flush_frontbuffer(struct native_surface *nsurf)
{
    struct dri2_surface *dri2surf = dri2_surface(nsurf);
    struct dri2_display *dri2dpy = dri2surf->dri2dpy;
    struct native_display *ndpy = &dri2dpy->base;
    struct pipe_context *pipe = ndpy_get_copy_context(ndpy);

    /* flush buffer */
    pipe->flush_resource(pipe, dri2surf->textures[NATIVE_ATTACHMENT_FRONT_LEFT]);
    pipe->flush(pipe, NULL, 0);

    /* copy to real front buffer */
    if (dri2surf->have_fake)
        x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable,
                                  0, 0, dri2surf->width, dri2surf->height,
                                  DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft);

    /* force buffers to be updated in next validation call */
    if (!dri2_surface_receive_events(&dri2surf->base)) {
        dri2surf->server_stamp++;
        dri2dpy->event_handler->invalid_surface(&dri2dpy->base,
                                                &dri2surf->base, dri2surf->server_stamp);
    }

    return TRUE;
}
Beispiel #3
0
boolean
resource_surface_flush_resource(struct resource_surface *rsurf,
                                struct native_display *ndpy,
                                enum native_attachment which)
{
   struct pipe_context *pipe = ndpy_get_copy_context(ndpy);

   if (!pipe)
      return FALSE;

   pipe->flush_resource(pipe, rsurf->resources[which]);

   return TRUE;
}
static void
copy_resources(struct native_display *ndpy,
               struct pipe_resource *src,
               struct pipe_resource *dst)
{
   struct pipe_context *pipe;
   struct pipe_box box;

   pipe = ndpy_get_copy_context(ndpy);
   if (!pipe)
      return;

   u_box_origin_2d(src->width0, src->height0, &box);
   pipe->resource_copy_region(pipe, dst, 0, 0, 0, 0, src, 0, &box);
   pipe->flush(pipe, NULL);
}
Beispiel #5
0
static boolean
dri2_surface_swap_buffers(struct native_surface *nsurf, int num_rects,
                          const int *rects)
{
    struct dri2_surface *dri2surf = dri2_surface(nsurf);
    struct dri2_display *dri2dpy = dri2surf->dri2dpy;
    struct native_display *ndpy = &dri2dpy->base;
    struct pipe_context *pipe = ndpy_get_copy_context(ndpy);

    /* copy to front buffer */
    if (dri2surf->have_back) {
        pipe->flush_resource(pipe, dri2surf->textures[NATIVE_ATTACHMENT_BACK_LEFT]);
        pipe->flush(pipe, NULL, 0);

        if (num_rects > 0)
            x11_drawable_copy_buffers_region(dri2dpy->xscr, dri2surf->drawable,
                                             num_rects, rects,
                                             DRI2BufferBackLeft, DRI2BufferFrontLeft);
        else
            x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable,
                                      0, 0, dri2surf->width, dri2surf->height,
                                      DRI2BufferBackLeft, DRI2BufferFrontLeft);
    }

    /* and update fake front buffer */
    if (dri2surf->have_fake) {
        if (num_rects > 0)
            x11_drawable_copy_buffers_region(dri2dpy->xscr, dri2surf->drawable,
                                             num_rects, rects,
                                             DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft);
        else
            x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable,
                                      0, 0, dri2surf->width, dri2surf->height,
                                      DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft);
    }

    /* force buffers to be updated in next validation call */
    if (!dri2_surface_receive_events(&dri2surf->base)) {
        dri2surf->server_stamp++;
        dri2dpy->event_handler->invalid_surface(&dri2dpy->base,
                                                &dri2surf->base, dri2surf->server_stamp);
    }

    return TRUE;
}
boolean
native_display_copy_to_pixmap(struct native_display *ndpy,
                              EGLNativePixmapType pix,
                              struct pipe_resource *src)
{
   struct pipe_context *pipe;
   struct native_surface *nsurf;
   struct pipe_resource *dst;
   struct pipe_resource *tmp[NUM_NATIVE_ATTACHMENTS];
   const enum native_attachment natt = NATIVE_ATTACHMENT_FRONT_LEFT;

   pipe = ndpy_get_copy_context(ndpy);
   if (!pipe)
      return FALSE;

   nsurf = ndpy->create_pixmap_surface(ndpy, pix, NULL);
   if (!nsurf)
      return FALSE;

   /* get the texutre */
   tmp[natt] = NULL;
   nsurf->validate(nsurf, 1 << natt, NULL, tmp, NULL, NULL);
   dst = tmp[natt];

   if (dst && dst->format == src->format) {
      struct native_present_control ctrl;
      struct pipe_box src_box;

      u_box_origin_2d(src->width0, src->height0, &src_box);
      pipe->resource_copy_region(pipe, dst, 0, 0, 0, 0, src, 0, &src_box);
      pipe->flush(pipe, NULL, 0);

      memset(&ctrl, 0, sizeof(ctrl));
      ctrl.natt = natt;
      nsurf->present(nsurf, &ctrl);
   }

   if (dst)
      pipe_resource_reference(&dst, NULL);

   nsurf->destroy(nsurf);

   return TRUE;
}
boolean
resource_surface_flush(struct resource_surface *rsurf,
		       struct native_display *ndpy)
{
   struct pipe_fence_handle *fence = NULL;
   struct pipe_screen *screen = rsurf->screen;
   struct pipe_context *pipe= ndpy_get_copy_context(ndpy);

   if (!pipe)
      return FALSE;

   pipe->flush(pipe, &fence, 0);
   if (fence == NULL)
      return FALSE;

   swap_fences_push_back(rsurf, fence);
   screen->fence_reference(screen, &fence, NULL);

   return TRUE;
}