diff options
author | marha <marha@users.sourceforge.net> | 2015-02-22 21:39:56 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2015-02-22 21:39:56 +0100 |
commit | 462f18c7b25fe3e467f837647d07ab0a78aa8d2b (patch) | |
tree | fc8013c0a1bac05a1945846c1697e973f4c35013 /xorg-server/glamor | |
parent | 36f711ee12b6dd5184198abed3aa551efb585587 (diff) | |
download | vcxsrv-462f18c7b25fe3e467f837647d07ab0a78aa8d2b.tar.gz vcxsrv-462f18c7b25fe3e467f837647d07ab0a78aa8d2b.tar.bz2 vcxsrv-462f18c7b25fe3e467f837647d07ab0a78aa8d2b.zip |
Merged origin/release (checked in because wanted to merge new stuff)
Diffstat (limited to 'xorg-server/glamor')
-rw-r--r-- | xorg-server/glamor/glamor.c | 57 | ||||
-rw-r--r-- | xorg-server/glamor/glamor.h | 4 | ||||
-rw-r--r-- | xorg-server/glamor/glamor_egl.c | 89 | ||||
-rw-r--r-- | xorg-server/glamor/glamor_egl_stubs.c | 2 | ||||
-rw-r--r-- | xorg-server/glamor/glamor_fbo.c | 4 | ||||
-rw-r--r-- | xorg-server/glamor/glamor_priv.h | 3 | ||||
-rw-r--r-- | xorg-server/glamor/glamor_xv.c | 26 |
7 files changed, 86 insertions, 99 deletions
diff --git a/xorg-server/glamor/glamor.c b/xorg-server/glamor/glamor.c index d228e35ad..017266a85 100644 --- a/xorg-server/glamor/glamor.c +++ b/xorg-server/glamor/glamor.c @@ -123,8 +123,6 @@ glamor_set_screen_pixmap(PixmapPtr screen_pixmap, PixmapPtr *back_pixmap) pixmap_priv->base.fbo->width = screen_pixmap->drawable.width; pixmap_priv->base.fbo->height = screen_pixmap->drawable.height; - - glamor_priv->back_pixmap = back_pixmap; } uint32_t @@ -222,23 +220,20 @@ void glamor_destroy_textured_pixmap(PixmapPtr pixmap) { if (pixmap->refcnt == 1) { - glamor_pixmap_private *pixmap_priv; - - pixmap_priv = glamor_get_pixmap_private(pixmap); - if (pixmap_priv != NULL) - glamor_pixmap_destroy_fbo(pixmap_priv); + glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); + if (pixmap_priv != NULL) { +#if GLAMOR_HAS_GBM + glamor_egl_destroy_pixmap_image(pixmap); +#endif + glamor_set_pixmap_private(pixmap, NULL); + } } } Bool glamor_destroy_pixmap(PixmapPtr pixmap) { - glamor_screen_private - *glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen); - if (glamor_priv->dri3_enabled) - glamor_egl_destroy_textured_pixmap(pixmap); - else - glamor_destroy_textured_pixmap(pixmap); + glamor_destroy_textured_pixmap(pixmap); return fbDestroyPixmap(pixmap); } @@ -254,20 +249,20 @@ glamor_block_handler(ScreenPtr screen) } static void -_glamor_block_handler(void *data, OSTimePtr timeout, void *last_select_mask) +_glamor_block_handler(ScreenPtr screen, void *timeout, void *readmask) { - glamor_screen_private *glamor_priv = data; + glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); + + screen->BlockHandler = glamor_priv->saved_procs.block_handler; + screen->BlockHandler(screen, timeout, readmask); + glamor_priv->saved_procs.block_handler = screen->BlockHandler; + screen->BlockHandler = _glamor_block_handler; glamor_make_current(glamor_priv); glFlush(); } static void -_glamor_wakeup_handler(void *data, int result, void *last_select_mask) -{ -} - -static void glamor_set_debug_level(int *debug_level) { char *debug_level_string; @@ -428,6 +423,9 @@ glamor_init(ScreenPtr screen, unsigned int flags) glamor_set_debug_level(&glamor_debug_level); + glamor_priv->saved_procs.close_screen = screen->CloseScreen; + screen->CloseScreen = glamor_close_screen; + /* If we are using egl screen, call egl screen init to * register correct close screen function. */ if (flags & GLAMOR_USE_EGL_SCREEN) { @@ -437,9 +435,6 @@ glamor_init(ScreenPtr screen, unsigned int flags) goto fail; } - glamor_priv->saved_procs.close_screen = screen->CloseScreen; - screen->CloseScreen = glamor_close_screen; - glamor_priv->saved_procs.create_screen_resources = screen->CreateScreenResources; screen->CreateScreenResources = glamor_create_screen_resources; @@ -448,11 +443,9 @@ glamor_init(ScreenPtr screen, unsigned int flags) goto fail; if (flags & GLAMOR_USE_SCREEN) { - if (!RegisterBlockAndWakeupHandlers(_glamor_block_handler, - _glamor_wakeup_handler, - glamor_priv)) { - goto fail; - } + + glamor_priv->saved_procs.block_handler = screen->BlockHandler; + screen->BlockHandler = _glamor_block_handler; glamor_priv->saved_procs.create_gc = screen->CreateGC; screen->CreateGC = glamor_create_gc; @@ -558,7 +551,6 @@ _X_EXPORT void glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv) { glamor_pixmap_private *old_priv; - glamor_pixmap_fbo *fbo; old_priv = dixGetPrivate(&pixmap->devPrivates, &glamor_pixmap_private_key); @@ -568,8 +560,8 @@ glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv) else { if (old_priv == NULL) return; - fbo = glamor_pixmap_detach_fbo(old_priv); - glamor_purge_fbo(fbo); + + glamor_pixmap_destroy_fbo(old_priv); free(old_priv); } @@ -603,6 +595,7 @@ glamor_close_screen(ScreenPtr screen) glamor_priv->saved_procs.change_window_attributes; screen->CopyWindow = glamor_priv->saved_procs.copy_window; screen->BitmapToRegion = glamor_priv->saved_procs.bitmap_to_region; + screen->BlockHandler = glamor_priv->saved_procs.block_handler; } #ifdef RENDER if (ps && (flags & GLAMOR_USE_PICTURE_SCREEN)) { @@ -619,8 +612,6 @@ glamor_close_screen(ScreenPtr screen) #endif screen_pixmap = screen->GetScreenPixmap(screen); glamor_set_pixmap_private(screen_pixmap, NULL); - if (glamor_priv->back_pixmap && *glamor_priv->back_pixmap) - glamor_set_pixmap_private(*glamor_priv->back_pixmap, NULL); glamor_release_screen_priv(screen); diff --git a/xorg-server/glamor/glamor.h b/xorg-server/glamor/glamor.h index 405dbe8ed..206158c02 100644 --- a/xorg-server/glamor/glamor.h +++ b/xorg-server/glamor/glamor.h @@ -170,6 +170,10 @@ extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr, unsigned int, Bool, CARD16 *, CARD32 *); +extern void glamor_egl_destroy_pixmap_image(PixmapPtr pixmap); + +extern _X_EXPORT void *glamor_egl_get_gbm_device(ScreenPtr screen); + /* @glamor_supports_pixmap_import_export: Returns whether * glamor_fd_from_pixmap(), glamor_name_from_pixmap(), and * glamor_pixmap_from_fd() are supported. diff --git a/xorg-server/glamor/glamor_egl.c b/xorg-server/glamor/glamor_egl.c index 182e2e8c9..113450c8d 100644 --- a/xorg-server/glamor/glamor_egl.c +++ b/xorg-server/glamor/glamor_egl.c @@ -69,8 +69,6 @@ struct glamor_egl_screen_private { CreateScreenResourcesProcPtr CreateScreenResources; CloseScreenProcPtr CloseScreen; int fd; - EGLImageKHR front_image; - PixmapPtr *back_pixmap; int cpp; #ifdef GLAMOR_HAS_GBM struct gbm_device *gbm; @@ -176,6 +174,18 @@ glamor_create_texture_from_image(ScreenPtr screen, return TRUE; } +void * +glamor_egl_get_gbm_device(ScreenPtr screen) +{ +#ifdef GLAMOR_HAS_GBM + struct glamor_egl_screen_private *glamor_egl = + glamor_egl_get_screen_private(xf86ScreenToScrn(screen)); + return glamor_egl->gbm; +#else + return NULL; +#endif +} + unsigned int glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h) { @@ -220,13 +230,9 @@ Bool glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride) { ScrnInfoPtr scrn = xf86ScreenToScrn(screen); - struct glamor_pixmap_private *pixmap_priv; - struct glamor_egl_screen_private *glamor_egl; PixmapPtr screen_pixmap; - glamor_egl = glamor_egl_get_screen_private(scrn); screen_pixmap = screen->GetScreenPixmap(screen); - pixmap_priv = glamor_get_pixmap_private(screen_pixmap); if (!glamor_egl_create_textured_pixmap(screen_pixmap, handle, stride)) { xf86DrvMsg(scrn->scrnIndex, X_ERROR, @@ -234,8 +240,7 @@ glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride) return FALSE; } - glamor_egl->front_image = pixmap_priv->base.image; - glamor_set_screen_pixmap(screen_pixmap, glamor_egl->back_pixmap); + glamor_set_screen_pixmap(screen_pixmap, NULL); return TRUE; } @@ -244,15 +249,7 @@ glamor_egl_create_textured_screen_ext(ScreenPtr screen, int handle, int stride, PixmapPtr *back_pixmap) { - ScrnInfoPtr scrn = xf86ScreenToScrn(screen); - struct glamor_egl_screen_private *glamor_egl; - - glamor_egl = glamor_egl_get_screen_private(scrn); - - glamor_egl->back_pixmap = back_pixmap; - if (!glamor_egl_create_textured_screen(screen, handle, stride)) - return FALSE; - return TRUE; + return glamor_egl_create_textured_screen(screen, handle, stride); } static Bool @@ -268,6 +265,24 @@ glamor_egl_check_has_gem(int fd) return FALSE; } +static void +glamor_egl_set_pixmap_image(PixmapPtr pixmap, EGLImageKHR image) +{ + struct glamor_pixmap_private *pixmap_priv = + glamor_get_pixmap_private(pixmap); + EGLImageKHR old; + + old = pixmap_priv->base.image; + if (old) { + ScreenPtr screen = pixmap->drawable.pScreen; + ScrnInfoPtr scrn = xf86ScreenToScrn(screen); + struct glamor_egl_screen_private *glamor_egl = glamor_egl_get_screen_private(scrn); + + eglDestroyImageKHR(glamor_egl->display, old); + } + pixmap_priv->base.image = image; +} + Bool glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride) { @@ -275,8 +290,6 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride) ScrnInfoPtr scrn = xf86ScreenToScrn(screen); struct glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); - struct glamor_pixmap_private *pixmap_priv = - glamor_get_pixmap_private(pixmap); struct glamor_egl_screen_private *glamor_egl; EGLImageKHR image; GLuint texture; @@ -311,7 +324,7 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride) glamor_create_texture_from_image(screen, image, &texture); glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM); glamor_set_pixmap_texture(pixmap, texture); - pixmap_priv->base.image = image; + glamor_egl_set_pixmap_image(pixmap, image); ret = TRUE; done: @@ -325,8 +338,6 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo) ScrnInfoPtr scrn = xf86ScreenToScrn(screen); struct glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); - struct glamor_pixmap_private *pixmap_priv = - glamor_get_pixmap_private(pixmap); struct glamor_egl_screen_private *glamor_egl; EGLImageKHR image; GLuint texture; @@ -346,7 +357,7 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo) glamor_create_texture_from_image(screen, image, &texture); glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM); glamor_set_pixmap_texture(pixmap, texture); - pixmap_priv->base.image = image; + glamor_egl_set_pixmap_image(pixmap, image); ret = TRUE; done: @@ -419,8 +430,8 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen, if (image == EGL_NO_IMAGE_KHR) goto failure; - pixmap_priv->base.image = image; glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM); + glamor_egl_set_pixmap_image(pixmap, image); } bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_EGL_IMAGE, image, 0); @@ -519,16 +530,17 @@ glamor_pixmap_from_fd(ScreenPtr screen, #endif } -static void -_glamor_egl_destroy_pixmap_image(PixmapPtr pixmap) +void +glamor_egl_destroy_pixmap_image(PixmapPtr pixmap) { - ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen); - struct glamor_egl_screen_private *glamor_egl = - glamor_egl_get_screen_private(scrn); struct glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); - if (pixmap_priv->base.image) { + if (pixmap_priv && pixmap_priv->base.image) { + ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen); + struct glamor_egl_screen_private *glamor_egl = + glamor_egl_get_screen_private(scrn); + /* Before destroy an image which was attached to * a texture. we must call glFlush to make sure the * operation on that texture has been done.*/ @@ -541,9 +553,6 @@ _glamor_egl_destroy_pixmap_image(PixmapPtr pixmap) _X_EXPORT void glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back) { - ScrnInfoPtr scrn = xf86ScreenToScrn(front->drawable.pScreen); - struct glamor_egl_screen_private *glamor_egl = - glamor_egl_get_screen_private(scrn); EGLImageKHR temp; struct glamor_pixmap_private *front_priv = glamor_get_pixmap_private(front); @@ -558,15 +567,12 @@ glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back) glamor_set_pixmap_type(front, GLAMOR_TEXTURE_DRM); glamor_set_pixmap_type(back, GLAMOR_TEXTURE_DRM); - glamor_egl->front_image = front_priv->base.image; } void glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap) { - if (pixmap->refcnt == 1) - _glamor_egl_destroy_pixmap_image(pixmap); glamor_destroy_textured_pixmap(pixmap); } @@ -583,17 +589,8 @@ glamor_egl_close_screen(ScreenPtr screen) screen_pixmap = screen->GetScreenPixmap(screen); pixmap_priv = glamor_get_pixmap_private(screen_pixmap); - eglDestroyImageKHR(glamor_egl->display, glamor_egl->front_image); + eglDestroyImageKHR(glamor_egl->display, pixmap_priv->base.image); pixmap_priv->base.image = NULL; - glamor_egl->front_image = NULL; - - if (glamor_egl->back_pixmap && *glamor_egl->back_pixmap) { - pixmap_priv = glamor_get_pixmap_private(*glamor_egl->back_pixmap); - if (pixmap_priv->base.image) { - eglDestroyImageKHR(glamor_egl->display, pixmap_priv->base.image); - pixmap_priv->base.image = NULL; - } - } screen->CloseScreen = glamor_egl->saved_close_screen; diff --git a/xorg-server/glamor/glamor_egl_stubs.c b/xorg-server/glamor/glamor_egl_stubs.c index 028d1cc05..a93f62dcb 100644 --- a/xorg-server/glamor/glamor_egl_stubs.c +++ b/xorg-server/glamor/glamor_egl_stubs.c @@ -36,7 +36,7 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx) } void -glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap) +glamor_egl_destroy_pixmap_image(PixmapPtr pixmap) { } diff --git a/xorg-server/glamor/glamor_fbo.c b/xorg-server/glamor/glamor_fbo.c index 42738268c..8d73e4765 100644 --- a/xorg-server/glamor/glamor_fbo.c +++ b/xorg-server/glamor/glamor_fbo.c @@ -126,7 +126,7 @@ glamor_pixmap_fbo_cache_get(glamor_screen_private *glamor_priv, #endif } -void +static void glamor_purge_fbo(glamor_pixmap_fbo *fbo) { glamor_make_current(fbo->glamor_priv); @@ -540,8 +540,6 @@ glamor_pixmap_destroy_fbo(glamor_pixmap_private *priv) if (fbo) glamor_destroy_fbo(fbo); } - - free(priv); } Bool diff --git a/xorg-server/glamor/glamor_priv.h b/xorg-server/glamor/glamor_priv.h index 885f12a6d..ed6e2d192 100644 --- a/xorg-server/glamor/glamor_priv.h +++ b/xorg-server/glamor/glamor_priv.h @@ -215,6 +215,7 @@ struct glamor_saved_procs { #if XSYNC SyncScreenFuncsRec sync_screen_funcs; #endif + ScreenBlockHandlerProcPtr block_handler; }; #define CACHE_FORMAT_COUNT 3 @@ -306,7 +307,6 @@ typedef struct glamor_screen_private { int linear_max_nstops; int radial_max_nstops; - PixmapPtr *back_pixmap; int screen_fbo; struct glamor_saved_procs saved_procs; char delayed_fallback_string[GLAMOR_DELAYED_STRING_MAX + 1]; @@ -654,7 +654,6 @@ glamor_pixmap_fbo *glamor_create_fbo(glamor_screen_private *glamor_priv, int w, int h, GLenum format, int flag); void glamor_destroy_fbo(glamor_pixmap_fbo *fbo); void glamor_pixmap_destroy_fbo(glamor_pixmap_private *priv); -void glamor_purge_fbo(glamor_pixmap_fbo *fbo); void glamor_init_pixmap_fbo(ScreenPtr screen); void glamor_fini_pixmap_fbo(ScreenPtr screen); diff --git a/xorg-server/glamor/glamor_xv.c b/xorg-server/glamor/glamor_xv.c index 26bdef66b..83e24adb2 100644 --- a/xorg-server/glamor/glamor_xv.c +++ b/xorg-server/glamor/glamor_xv.c @@ -208,15 +208,14 @@ glamor_xv_query_image_attributes(int id, switch (id) { case FOURCC_YV12: case FOURCC_I420: - *h = *h; - *w = *w; - size = *w; + *h = ALIGN(*h, 2); + size = ALIGN(*w, 4); if (pitches) pitches[0] = size; size *= *h; if (offsets) offsets[1] = size; - tmp = *w >> 1; + tmp = ALIGN(*w >> 1, 4); if (pitches) pitches[1] = pitches[2] = tmp; tmp *= (*h >> 1); @@ -413,9 +412,6 @@ glamor_xv_put_image(glamor_port_private *port_priv, s2offset = s3offset = srcPitch2 = 0; - srcPitch = width; - srcPitch2 = width >> 1; - if (!port_priv->src_pix[0] || (width != port_priv->src_pix_w || height != port_priv->src_pix_h)) { int i; @@ -439,11 +435,13 @@ glamor_xv_put_image(glamor_port_private *port_priv, } top = (src_y) & ~1; - nlines = (src_y + height) - top; + nlines = (src_y + src_h) - top; switch (id) { case FOURCC_YV12: case FOURCC_I420: + srcPitch = ALIGN(width, 4); + srcPitch2 = ALIGN(width >> 1, 4); s2offset = srcPitch * height; s3offset = s2offset + (srcPitch2 * ((height + 1) >> 1)); s2offset += ((top >> 1) * srcPitch2); @@ -454,18 +452,18 @@ glamor_xv_put_image(glamor_port_private *port_priv, s3offset = tmp; } glamor_upload_sub_pixmap_to_texture(port_priv->src_pix[0], - 0, 0, srcPitch, nlines, - port_priv->src_pix[0]->devKind, + 0, 0, width, nlines, + srcPitch, buf + (top * srcPitch), 0); glamor_upload_sub_pixmap_to_texture(port_priv->src_pix[1], - 0, 0, srcPitch2, (nlines + 1) >> 1, - port_priv->src_pix[1]->devKind, + 0, 0, width >> 1, (nlines + 1) >> 1, + srcPitch2, buf + s2offset, 0); glamor_upload_sub_pixmap_to_texture(port_priv->src_pix[2], - 0, 0, srcPitch2, (nlines + 1) >> 1, - port_priv->src_pix[2]->devKind, + 0, 0, width >> 1, (nlines + 1) >> 1, + srcPitch2, buf + s3offset, 0); break; default: |