501
495
if (bFullScreenOn) {
502
496
xWindow->store_width = *screen_width;
503
497
xWindow->store_height = *screen_height;
504
xWindow->w_width = xWindow->display_width;
505
xWindow->w_height = xWindow->display_height;
499
xWindow->w_width = vout->max_screen_width;
500
xWindow->w_height = vout->max_screen_height;
507
502
XFreeGC (xWindow->display, xWindow->the_gc);
508
503
xWindow->the_gc = XCreateGC (xWindow->display, xWindow->full_wnd, 0, NULL);
510
505
XMoveResizeWindow (xWindow->display,
511
506
(Window) xWindow->full_wnd, 0, 0,
512
xWindow->display_width,
513
xWindow->display_height);
507
vout->max_screen_width,
508
vout->max_screen_height);
514
509
*screen_width = xWindow->w_width;
515
510
*screen_height = xWindow->w_height;
516
511
XUnmapWindow (xWindow->display, xWindow->wnd);
538
GF_Err X11_Clear (struct _video_out * vout, u32 color)
543
the_window = xWindow->fullscreen ? xWindow->full_wnd : xWindow->wnd;
544
switch (xWindow->videoaccesstype) {
545
case VIDEO_XI_STANDARD:
546
// TODO convert color to PIXEL
547
XSetWindowBackground (xWindow->display, the_window, color);
548
XClearWindow (xWindow->display, the_window);
557
GF_Err X11_LockSurface (struct _video_out * vout, u32 surface_id, GF_VideoSurface * vi)
536
GF_Err X11_LockBackBuffer(struct _video_out * vout, GF_VideoSurface * vi, u32 do_lock)
541
if (!vi) return GF_BAD_PARAM;
563
542
vi->width = xWindow->back_buffer->width;
564
543
vi->height = xWindow->back_buffer->height;
565
544
vi->pitch = xWindow->back_buffer->pitch;
566
545
vi->pixel_format = xWindow->pixel_format;
567
vi->os_handle = NULL;
568
546
vi->video_buffer = xWindow->back_buffer->buffer;
572
for (i = 0; i < gf_list_count(xWindow->surfaces); i++) {
573
X11WrapSurface *ptr = (X11WrapSurface *) gf_list_get(xWindow->surfaces, i);
574
if (ptr->id == surface_id) {
575
vi->width = ptr->width;
576
vi->height = ptr->height;
577
vi->pitch = ptr->pitch;
578
vi->pixel_format = ptr->pixel_format;
579
vi->os_handle = NULL;
580
vi->video_buffer = ptr->buffer;
587
GF_Err X11_UnlockSurface (struct _video_out * vout, u32 surface_id)
589
/*for now nothing to do (offscreen surfaces are not on video memory yet...)*/
594
* creates a offscreen video surface and setup surface id - pixel format
595
* MUST be respected except for YUV formats, where the hardware is free to
596
* choose the fastest format for blit
598
static GF_Err X11_CreateSurface (struct _video_out *vout, u32 width, u32 height, u32 pixel_format, u32 * surfaceID)
601
X11WrapSurface *surf;
605
GF_SAFEALLOC(surf, sizeof (X11WrapSurface));
607
switch (pixel_format) {
608
case GF_PIXEL_RGB_555:
611
case GF_PIXEL_RGB_565:
614
case GF_PIXEL_RGB_24:
617
case GF_PIXEL_RGB_32:
621
surf->pitch = width * surf->BPP;
622
size = height * surf->pitch;
623
surf->buffer = (unsigned char *) malloc (sizeof (unsigned char) * size);
624
surf->pixel_format = pixel_format;
625
surf->id = (u32) surf;
626
gf_list_add(xWindow->surfaces, surf);
627
*surfaceID = surf->id;
631
X11WrapSurface *X11_GetSurface (struct _video_out *vout, u32 surface_id)
634
X11WrapSurface *surf;
636
if (!surface_id) return NULL;
637
surf = (X11WrapSurface *)surface_id;
638
i = gf_list_find(xWindow->surfaces, surf);
639
if (i<0) return NULL;
643
GF_Err X11_DeleteSurface (struct _video_out * vout, u32 surface_id)
645
X11WrapSurface *surf;
647
if (!surface_id) return GF_BAD_PARAM;
648
surf = X11_GetSurface(vout, surface_id);
650
gf_list_del_item(xWindow->surfaces, surf);
651
if (surf->buffer) free(surf->buffer);
660
* checks if the surface is valid - this is used to discard surfaces when
661
* changing video mode (fullscreen)
664
X11_IsSurfaceValid (struct _video_out * vout, u32 surface_id)
666
return (X11_GetSurface(vout, surface_id) != NULL) ? 1 : 0;
670
* resize surface - the resulting surface can still be larger than what
674
X11_ResizeSurface (struct _video_out * vout, u32 surface_id,
675
u32 width, u32 height)
677
X11WrapSurface *wrap;
678
if (!surface_id) return X11_ResizeBackBuffer(vout, width, height);
680
wrap = X11_GetSurface(vout, surface_id);
681
if (!wrap || !wrap->BPP) return GF_BAD_PARAM;
682
if ((wrap->width>= width) && (wrap->height>=height)) return GF_OK;
684
wrap->pitch = wrap->BPP * width;
686
wrap->height = height;
687
wrap->buffer = malloc(sizeof(char) * wrap->pitch * wrap->height);
693
* blit surface src to surface dest - if a window is not specified, the
694
* full surface is used _ can be NULL
697
X11_Blit (struct _video_out * vout, u32 src_id, u32 dst_id,
698
GF_Window * src, GF_Window * dst)
702
if (dst_id) return GF_NOT_SUPPORTED;
704
X11WrapSurface *dest_surf = xWindow->back_buffer;
705
X11WrapSurface *src_surf = X11_GetSurface (vout, src_id);
707
pdst = dest_surf->buffer + dst->y * xWindow->back_buffer->pitch + dst->x * xWindow->bpp;
708
int dst_depth = xWindow->bpp*8;
709
int src_depth = src_surf->BPP*8;
710
int src_bpp = src_surf->BPP;
712
psrc = src_surf->buffer + src->y * src_surf->pitch + src->x * src_bpp;
713
StretchBits (pdst, dst_depth, dst->w, dst->h, dest_surf->pitch,
714
psrc, src_depth, src->w, src->h, src_surf->pitch,
720
* returns pixel format of the surface - if surfaceID is 0, the main video
721
* memory format is requested
724
X11_GetPixelFormat (struct _video_out * vout, u32 surfaceID,
731
*pixel_format = xWindow->pixel_format;
735
for (i = 0; i < gf_list_count (xWindow->surfaces); i++) {
736
X11WrapSurface *ptr = (X11WrapSurface *) gf_list_get (xWindow->surfaces, i);
737
if (ptr->id == surfaceID) {
738
*pixel_format = ptr->pixel_format;
547
vi->is_hardware_memory = (xWindow->videoaccesstype==VIDEO_XI_STANDARD) ? 0 : 1;
745
555
static XErrorHandler old_handler = NULL;
746
556
static int selectinput_err = 0;
874
685
xWindow->videoaccesstype = VIDEO_XI_STANDARD;
876
687
#ifdef GPAC_HAS_X11_SHM
877
int XShmMajor, XShmMinor;
879
if (XShmQueryVersion(xWindow->display, &XShmMajor, &XShmMinor, &XShmPixmaps)) {
880
/*this is disabled due to flip pb (we cannot reposition backbuffer)*/
881
if (0 && XShmPixmaps && (XShmPixmapFormat(xWindow->display) == ZPixmap)) {
882
xWindow->videoaccesstype = VIDEO_XI_SHMPIXMAP;
884
xWindow->videoaccesstype = VIDEO_XI_SHMSTD;
688
sOpt = gf_modules_get_option((GF_BaseInterface *)vout, "Video", "UseHardwareMemory");
689
if (sOpt && !strcmp(sOpt, "yes")) {
690
int XShmMajor, XShmMinor;
692
if (XShmQueryVersion(xWindow->display, &XShmMajor, &XShmMinor, &XShmPixmaps)) {
693
/*this is disabled due to flip pb (we cannot reposition backbuffer)*/
694
if (0 && XShmPixmaps && (XShmPixmapFormat(xWindow->display) == ZPixmap)) {
695
xWindow->videoaccesstype = VIDEO_XI_SHMPIXMAP;
697
xWindow->videoaccesstype = VIDEO_XI_SHMSTD;
698
//fprintf(stdout, "\nUsing X11 Hardware Blit\n");