diff options
author | Chia-I Wu <[email protected]> | 2011-06-25 15:48:24 +0900 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2011-06-25 16:23:21 +0900 |
commit | 7c4e9dcdceec1112c91206619fe8b0885be99a79 (patch) | |
tree | ceee00b84d4d07ee06f62a14678e1b508a4e4ff1 /src/gallium/state_trackers/egl/common/native_helper.c | |
parent | 73df31eedd0f33c8a9907855cb247c8f87964c48 (diff) |
st/egl: clean up eglCopyBuffers
Add copy_to_pixmap method to native_display and use it for
eglCopyBuffers.
Diffstat (limited to 'src/gallium/state_trackers/egl/common/native_helper.c')
-rw-r--r-- | src/gallium/state_trackers/egl/common/native_helper.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/gallium/state_trackers/egl/common/native_helper.c b/src/gallium/state_trackers/egl/common/native_helper.c index 25857308c5a..6f2097c61a6 100644 --- a/src/gallium/state_trackers/egl/common/native_helper.c +++ b/src/gallium/state_trackers/egl/common/native_helper.c @@ -368,6 +368,47 @@ resource_surface_wait(struct resource_surface *rsurf) while (resource_surface_throttle(rsurf)); } +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 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); + nsurf->present(nsurf, natt, FALSE, 0); + } + + if (dst) + pipe_resource_reference(&dst, NULL); + + nsurf->destroy(nsurf); + + return TRUE; +} + #include "state_tracker/drm_driver.h" struct pipe_resource * drm_display_import_native_buffer(struct native_display *ndpy, |