dslinux/user/pixil/packages/dvdview/dvdview/libvideogfx/libvideogfx/x11 Makefile.am Makefile.in dispimg.cc dispimg.hh imgwin.cc imgwin.hh server.cc server.hh
amadeus
dslinux_amadeus at user.in-berlin.de
Tue Oct 3 13:25:45 CEST 2006
Update of /cvsroot/dslinux/dslinux/user/pixil/packages/dvdview/dvdview/libvideogfx/libvideogfx/x11
In directory antilope:/tmp/cvs-serv11916/packages/dvdview/dvdview/libvideogfx/libvideogfx/x11
Added Files:
Makefile.am Makefile.in dispimg.cc dispimg.hh imgwin.cc
imgwin.hh server.cc server.hh
Log Message:
adding pristine copy of pixil to HEAD so I can branch from it
--- NEW FILE: Makefile.in ---
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_alias = @build_alias@
build_triplet = @build@
host_alias = @host_alias@
host_triplet = @host@
target_alias = @target_alias@
target_triplet = @target@
AS = @AS@
CC = @CC@
CXX = @CXX@
DLLTOOL = @DLLTOOL@
LIBTOOL = @LIBTOOL@
LIBVIDEOGFX_BINARY_AGE = @LIBVIDEOGFX_BINARY_AGE@
LIBVIDEOGFX_INTERFACE_AGE = @LIBVIDEOGFX_INTERFACE_AGE@
LIBVIDEOGFX_MAJOR_VERSION = @LIBVIDEOGFX_MAJOR_VERSION@
LIBVIDEOGFX_MICRO_VERSION = @LIBVIDEOGFX_MICRO_VERSION@
LIBVIDEOGFX_MINOR_VERSION = @LIBVIDEOGFX_MINOR_VERSION@
LIBVIDEOGFX_VERSION = @LIBVIDEOGFX_VERSION@
LN_S = @LN_S@
LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@
LT_RELEASE = @LT_RELEASE@
LT_REVISION = @LT_REVISION@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
VERSION = @VERSION@
X_LDFLAGS = @X_LDFLAGS@
noinst_LTLIBRARIES = libvideogfx-x11.la
libvideogfx_x11_la_SOURCES = dispimg.cc dispimg.hh imgwin.cc imgwin.hh server.cc server.hh
INCLUDES = -I$(top_srcdir)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
DEFS = @DEFS@ -I. -I$(srcdir) -I../..
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
X_CFLAGS = @X_CFLAGS@
X_LIBS = @X_LIBS@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
libvideogfx_x11_la_LDFLAGS =
libvideogfx_x11_la_LIBADD =
libvideogfx_x11_la_OBJECTS = dispimg.lo imgwin.lo server.lo
CXXFLAGS = @CXXFLAGS@
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
DEP_FILES = .deps/dispimg.P .deps/imgwin.P .deps/server.P
SOURCES = $(libvideogfx_x11_la_SOURCES)
OBJECTS = $(libvideogfx_x11_la_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .cc .lo .o .s
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu libvideogfx/x11/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-noinstLTLIBRARIES:
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
distclean-noinstLTLIBRARIES:
maintainer-clean-noinstLTLIBRARIES:
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
.s.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.S.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
maintainer-clean-libtool:
libvideogfx-x11.la: $(libvideogfx_x11_la_OBJECTS) $(libvideogfx_x11_la_DEPENDENCIES)
$(CXXLINK) $(libvideogfx_x11_la_LDFLAGS) $(libvideogfx_x11_la_OBJECTS) $(libvideogfx_x11_la_LIBADD) $(LIBS)
.cc.o:
$(CXXCOMPILE) -c $<
.cc.lo:
$(LTCXXCOMPILE) -c $<
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = libvideogfx/x11
distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
cd $(top_srcdir) \
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu libvideogfx/x11/Makefile
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
-include $(DEP_FILES)
mostlyclean-depend:
clean-depend:
distclean-depend:
-rm -rf .deps
maintainer-clean-depend:
%.o: %.c
@echo '$(COMPILE) -c $<'; \
$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-cp .deps/$(*F).pp .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm .deps/$(*F).pp
%.lo: %.c
@echo '$(LTCOMPILE) -c $<'; \
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
< .deps/$(*F).pp > .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm -f .deps/$(*F).pp
%.o: %.cc
@echo '$(CXXCOMPILE) -c $<'; \
$(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-cp .deps/$(*F).pp .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm .deps/$(*F).pp
%.lo: %.cc
@echo '$(LTCXXCOMPILE) -c $<'; \
$(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
< .deps/$(*F).pp > .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm -f .deps/$(*F).pp
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am:
install-exec: install-exec-am
install-data-am:
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am:
uninstall: uninstall-am
all-am: Makefile $(LTLIBRARIES)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-noinstLTLIBRARIES mostlyclean-compile \
mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-noinstLTLIBRARIES clean-compile clean-libtool \
clean-tags clean-depend clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-noinstLTLIBRARIES distclean-compile \
distclean-libtool distclean-tags distclean-depend \
distclean-generic clean-am
-rm -f libtool
distclean: distclean-am
maintainer-clean-am: maintainer-clean-noinstLTLIBRARIES \
maintainer-clean-compile maintainer-clean-libtool \
maintainer-clean-tags maintainer-clean-depend \
maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-noinstLTLIBRARIES distclean-noinstLTLIBRARIES \
clean-noinstLTLIBRARIES maintainer-clean-noinstLTLIBRARIES \
mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile mostlyclean-libtool distclean-libtool \
clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir \
mostlyclean-depend distclean-depend clean-depend \
maintainer-clean-depend info-am info dvi-am dvi check check-am \
installcheck-am installcheck install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean
.PHONY: files
files:
@files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \
echo $$p; \
done
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
--- NEW FILE: imgwin.cc ---
/*
* imgwin.cc
*/
#include "config.h"
#include <time.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <errno.h>
#include <stdlib.h>
#include <iostream.h>
#include <iomanip.h>
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
#include <X11/Xutil.h>
#include "libvideogfx/init.hh"
#include "server.hh"
#include "imgwin.hh"
#include "libvideogfx/graphics/color/colorspace.hh"
struct X11SpecificData
{
Display* d_display;
Window d_win;
};
ImageWindow_X11::ImageWindow_X11()
: d_initialized(false),
d_xpos(-1),d_ypos(-1)
{
d_x11data = new X11SpecificData;
}
ImageWindow_X11::~ImageWindow_X11()
{
//printf("ImageWindow_X11::~ImageWindow_X11()\n");
Close();
if (d_x11data) { delete d_x11data; d_x11data=NULL; }
}
void ImageWindow_X11::Close()
{
if (!d_initialized)
return;
XUnmapWindow(d_x11data->d_display , d_x11data->d_win);
XFlush(d_x11data->d_display);
d_initialized=false;
}
Window ImageWindow_X11::AskWindow() { assert(d_initialized); return d_x11data->d_win; }
Display* ImageWindow_X11::AskDisplay() { return d_x11data->d_display; }
void ImageWindow_X11::Create(int w,int h,const char* title,const X11Server* server,Window parent)
{
assert(!d_initialized);
// Get X11 server.
if (server)
d_x11data->d_display = server->AskDisplay();
else
d_x11data->d_display = default_x11server.AskDisplay();
int screen = DefaultScreen(d_x11data->d_display);
Window rootwin = RootWindow(d_x11data->d_display,screen);
// Choose VisualInfo
XVisualInfo vinfo;
//bool use_cmap8=false;
if (XMatchVisualInfo(d_x11data->d_display, screen, 16, TrueColor, &vinfo))
{
}
else
if (XMatchVisualInfo(d_x11data->d_display, screen, 15, TrueColor, &vinfo))
{
}
else
if (XMatchVisualInfo(d_x11data->d_display, screen, 24, TrueColor, &vinfo))
{
}
else
if (XMatchVisualInfo(d_x11data->d_display, screen, 32, TrueColor, &vinfo))
{
}
else
if (XMatchVisualInfo(d_x11data->d_display, screen, 8, PseudoColor, &vinfo))
{
// use_cmap8=true;
}
#if 0
else
if (XMatchVisualInfo(d_x11data->d_display, screen, 8, GrayScale, &vinfo))
{
}
#endif
else
{
// TODO
cerr << "no matching visual found\n";
exit(10);
// throw Excpt_Base(ErrSev_Error,"I'm sorry, no matching visual info found.");
}
//cout << "VISUAL-ID used for window: 0x" << hex << vinfo.visualid << dec << endl;
// Create window
Colormap theCmap = XCreateColormap(d_x11data->d_display, rootwin, vinfo.visual, AllocNone);
XSetWindowAttributes attr;
attr.colormap = theCmap;
attr.background_pixel = 0;
attr.border_pixel = 1;
Window parent_window;
#if 1
if (parent)
parent_window = parent;
else
#endif
parent_window = RootWindow(d_x11data->d_display,screen);
//printf("WINID: %d %p\n",parent,parent);
d_x11data->d_win = XCreateWindow(d_x11data->d_display, parent_window,
d_xpos,d_ypos,w,h, 2, vinfo.depth, InputOutput, vinfo.visual,
CWBackPixel|CWBorderPixel|CWColormap,&attr);
#if 1
XSizeHints sizeh;
sizeh.flags = PSize; //|PMinSize|PMaxSize;
if (d_xpos>=0 && d_ypos>=0) sizeh.flags |= PPosition;
sizeh.width = w;
sizeh.height = h;
sizeh.min_width = w;
sizeh.min_height = h;
sizeh.max_width = w;
sizeh.max_height = h;
#endif
XSetStandardProperties(d_x11data->d_display,d_x11data->d_win,
title,
title,
None,
glob_argv,glob_argc,&sizeh);
XSelectInput(d_x11data->d_display, d_x11data->d_win, ExposureMask|KeyPressMask);
XMapWindow(d_x11data->d_display,d_x11data->d_win);
XFlush(d_x11data->d_display);
while (1)
{
XEvent xev;
XNextEvent(d_x11data->d_display,&xev);
if (xev.type == Expose)
break;
}
// Set Colormap
// TODO
d_initialized = true;
}
ImageWindow_Autorefresh_X11::ImageWindow_Autorefresh_X11()
: d_lastimg_was_RGB(false),
d_lastimg_was_YUV(false)
{
}
ImageWindow_Autorefresh_X11::~ImageWindow_Autorefresh_X11()
{
//printf("ImageWindow_Autorefresh_X11::~ImageWindow_Autorefresh_X11()\n");
}
void ImageWindow_Autorefresh_X11::Create(int w,int h,const char*title,const X11Server* server,Window win)
{
ImageWindow_X11::Create(w,h,title,server,win);
DisplayImage_X11::Create(w,h,AskWindow(),server);
}
void ImageWindow_Autorefresh_X11::Close()
{
ImageWindow_X11::Close();
}
void ImageWindow_Autorefresh_X11::Display_const(const Image_RGB<Pixel>& img)
{
if (!d_lastimg_was_RGB)
{
XImage& ximg = AskXImage();
RawImageSpec_RGB spec;
spec.bytes_per_line = ximg.bytes_per_line;
spec.bits_per_pixel = ximg.bits_per_pixel;
spec.little_endian = (ximg.byte_order==LSBFirst);
spec.SetRGBMasks(ximg.red_mask,ximg.green_mask,ximg.blue_mask);
SetOutputSpec(spec);
d_lastimg_was_RGB = true;
d_lastimg_was_YUV = false;
}
TransformRGB(img,(uint8*)(AskXImage().data));
PutImage();
}
void ImageWindow_Autorefresh_X11::Display_const(const Image_YUV<Pixel>& img)
{
if (!d_lastimg_was_YUV)
{
XImage& ximg = AskXImage();
RawImageSpec_RGB spec;
spec.bytes_per_line = ximg.bytes_per_line;
spec.bits_per_pixel = ximg.bits_per_pixel;
spec.little_endian = (ximg.byte_order==LSBFirst);
spec.SetRGBMasks(ximg.red_mask,ximg.green_mask,ximg.blue_mask);
SetOutputSpec(spec);
d_lastimg_was_RGB = false;
d_lastimg_was_YUV = true;
}
TransformYUV(img,(uint8*)(AskXImage().data));
PutImage();
}
void ImageWindow_Autorefresh_X11::Display(Image_YUV<Pixel>& img)
{
if (!d_lastimg_was_YUV)
{
XImage& ximg = AskXImage();
RawImageSpec_RGB spec;
spec.bytes_per_line = ximg.bytes_per_line;
spec.bits_per_pixel = ximg.bits_per_pixel;
spec.little_endian = (ximg.byte_order==LSBFirst);
spec.SetRGBMasks(ximg.red_mask,ximg.green_mask,ximg.blue_mask);
SetOutputSpec(spec);
d_lastimg_was_RGB = false;
d_lastimg_was_YUV = true;
}
TransformYUV(img,(uint8*)(AskXImage().data));
PutImage();
}
void ImageWindow_Autorefresh_X11::CheckForRedraw()
{
XEvent event;
while (XCheckWindowEvent(AskDisplay(),AskWindow(),ExposureMask,&event))
{
Redraw(event.xexpose);
}
}
void ImageWindow_Autorefresh_X11::RedrawForever()
{
XEvent event;
for (;;)
{
XWindowEvent(AskDisplay(),AskWindow(),ExposureMask,&event);
Redraw(event.xexpose);
}
}
char ImageWindow_Autorefresh_X11::CheckForKeypress()
{
XEvent event;
if (XCheckWindowEvent(AskDisplay(),AskWindow(),KeyPressMask,&event))
{
char buf;
if (XLookupString(&event.xkey,&buf,1,NULL,NULL) > 0)
return buf;
else
return 0;
}
else
return 0;
}
char ImageWindow_Autorefresh_X11::WaitForKeypress()
{
XEvent event;
for (;;)
{
XWindowEvent(AskDisplay(),AskWindow(),KeyPressMask|ExposureMask,&event);
if (event.type == Expose)
{
Redraw(event.xexpose);
}
else
{
char buf;
if (XLookupString(&event.xkey,&buf,1,NULL,NULL) > 0)
return buf;
else
return 0;
}
}
}
void ImageWindow_Autorefresh_X11::Redraw(XExposeEvent& ev)
{
PutImage(ev.x , ev.y,
ev.width , ev.height,
ev.x , ev.y);
}
/* All windows have to be on the same X-server.
*/
int MultiWindowRefresh(ImageWindow_Autorefresh_X11*const* windows,int nWindows)
{
XEvent ev;
bool refresh_occured=false;
while (!refresh_occured)
{
XMaskEvent(windows[0]->AskDisplay(),ExposureMask|KeyPressMask,&ev);
for (int i=0;i<nWindows;i++)
{
if (ev.xany.window == windows[i]->AskWindow())
{
if (ev.type == Expose)
{
windows[i]->Redraw(ev.xexpose);
refresh_occured=true;
}
else if (ev.type == KeyPress)
return i;
}
}
}
return -1;
}
--- NEW FILE: Makefile.am ---
## Makefile.am for libvideogfx/libvideogfx/x11
noinst_LTLIBRARIES = libvideogfx-x11.la
libvideogfx_x11_la_SOURCES = \
dispimg.cc \
dispimg.hh \
imgwin.cc \
imgwin.hh \
server.cc \
server.hh
INCLUDES = \
-I$(top_srcdir)
.PHONY: files
files:
@files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \
echo $$p; \
done
--- NEW FILE: server.hh ---
/*********************************************************************
libvideogfx/x11/server.hh
purpose:
notes:
to do:
author(s):
- Dirk Farin, farin at ti.uni-mannheim.de
modifications:
*********************************************************************/
#ifndef LIBVIDEOGFX_X11_SERVER_HH
#define LIBVIDEOGFX_X11_SERVER_HH
#include <X11/Xlib.h>
class X11Server
{
public:
virtual ~X11Server() { }
virtual Display* AskDisplay() const = 0;
};
extern const X11Server& default_x11server;
#endif
--- NEW FILE: dispimg.cc ---
/*
* dispimg.cc
*/
#include "config.h"
#include <time.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <errno.h>
#include <iostream.h>
#include <iomanip.h>
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
#include <X11/Xutil.h>
extern "C" {
#include <stdio.h>
extern int XShmGetEventBase(Display*); // TODO: where can this function declaration be found ?
}
#include "libvideogfx/types.hh"
#include "server.hh"
#include "dispimg.hh"
struct DisplayImage_Data
{
DisplayImage_Data()
: mayUseMITSHM(true),
d_initialized(false),
d_data(NULL)
{
}
~DisplayImage_Data()
{
if (d_initialized)
{
if (d_UseShmExt)
{
XShmDetach(d_display,&d_ShmSegInfo);
XDestroyImage(d_ximg);
shmdt(d_ShmSegInfo.shmaddr);
shmctl(d_ShmSegInfo.shmid,IPC_RMID,0);
}
else
{
d_ximg->data = NULL;
XDestroyImage(d_ximg);
if (d_data) delete[] d_data;
}
XFreeGC(d_display, d_gc);
}
}
// user parameters
bool mayUseMITSHM;
// internal parameters
bool d_initialized;
Display* d_display;
bool d_UseShmExt;
Window d_win;
GC d_gc;
XImage* d_ximg;
uint8* d_data;
XShmSegmentInfo d_ShmSegInfo;
bool d_WaitForCompletion;
int d_CompletionType;
int d_width,d_height;
};
static int shmmajor;
static bool shmfailed;
static int shmhandler(Display* display,XErrorEvent* err)
{
if (err->request_code == shmmajor &&
err->minor_code == X_ShmAttach)
shmfailed=true;
return 0;
}
DisplayImage_X11::DisplayImage_X11()
{
d_data = new DisplayImage_Data;
}
void DisplayImage_X11::UseMITSHM(bool flag=true) { d_data->mayUseMITSHM=flag; }
XImage& DisplayImage_X11::AskXImage() { assert(d_data->d_ximg); return *d_data->d_ximg; }
void DisplayImage_X11::Create(int w,int h,Window win,const X11Server* server)
{
if (d_data->d_initialized)
return;
d_data->d_width = w;
d_data->d_height = h;
int roundedwidth = (w+15); roundedwidth -= roundedwidth %16;
//int roundedheight = (h+15); roundedheight -= roundedheight%16;
// Connect to X11 server
if (server)
d_data->d_display = server->AskDisplay();
else
d_data->d_display = default_x11server.AskDisplay();
int screen = DefaultScreen(d_data->d_display);
d_data->d_win = win;
// Choose VisualInfo
XWindowAttributes winattr;
XGetWindowAttributes(d_data->d_display,win,&winattr);
VisualID visualid = XVisualIDFromVisual(winattr.visual);
XVisualInfo vinfo_template;
vinfo_template.visualid = visualid;
XVisualInfo* vinfo;
int nvinfos;
vinfo=XGetVisualInfo(d_data->d_display,VisualIDMask,&vinfo_template,&nvinfos);
assert(vinfo != NULL);
assert(nvinfos==1);
//cout << "VISUAL-ID used for image: 0x" << hex << visualid << dec << endl;
XGCValues gcvals;
d_data->d_gc = XCreateGC(d_data->d_display,win,0,&gcvals);
// Set Colormap
// TODO
// Create XImage structure
if (d_data->mayUseMITSHM && XShmQueryExtension(d_data->d_display))
{
int dummy;
int major_version,minor_version,pixmap_flag;
if (!XShmQueryVersion(d_data->d_display, &major_version, &minor_version,&pixmap_flag)
|| !XQueryExtension(d_data->d_display, "MIT-SHM", &dummy, &dummy, &dummy))
{
// ShowNote(ErrSev_Note,"X11 shared memory (MITSHM) extension not supported");
d_data->d_UseShmExt=false;
}
else
{
//char buffer[1000];
//sprintf(buffer,"X11 shared memory (MITSHM) extensions version %d.%d detected.",major_version, minor_version);
//ShowNote(ErrSev_Note,buffer);
d_data->d_UseShmExt = true;
}
}
else
{
/*
if (mayUseMITSHM)
ShowNote(ErrSev_Note,"X11 shared memory (MITSHM) extension not supported");
else
ShowNote(ErrSev_Note,"X11 shared memory (MITSHM) extension disabled");
*/
d_data->d_UseShmExt=false;
}
tryagain:
if (d_data->d_UseShmExt)
{
d_data->d_ximg = XShmCreateImage(d_data->d_display,winattr.visual,vinfo->depth,ZPixmap,(char*)0,
&d_data->d_ShmSegInfo,roundedwidth,h);
if (!d_data->d_ximg)
{
//TODO
assert(0);
//throw Excpt_Base(ErrSev_Error,"XShmCreateImage failed");
}
d_data->d_ShmSegInfo.shmid = shmget(IPC_PRIVATE,d_data->d_ximg->bytes_per_line*h, IPC_CREAT|0604);
if (d_data->d_ShmSegInfo.shmid==-1)
{ perror("shmget failed: "); assert(0); } // throw Excpt_Base(ErrSev_Error,"shmget failed"); }
d_data->d_ShmSegInfo.shmaddr = d_data->d_ximg->data = (char*)shmat(d_data->d_ShmSegInfo.shmid,0,0);
if (d_data->d_ShmSegInfo.shmaddr==((char *)-1))
{ perror("shmat failed: "); assert(0); } // throw Excpt_Base(ErrSev_Error,"shmat failed"); }
d_data->d_ShmSegInfo.readOnly = True;
int dummy;
XQueryExtension(d_data->d_display,"MIT-SHM",&shmmajor,&dummy,&dummy);
shmfailed=false;
XSetErrorHandler(shmhandler);
Status xshma;
xshma=XShmAttach(d_data->d_display,&d_data->d_ShmSegInfo);
XSync(d_data->d_display,False);
XSetErrorHandler(NULL);
shmctl(d_data->d_ShmSegInfo.shmid, IPC_RMID, 0);
if (!xshma)
{ assert(0); } // throw Excpt_Base(ErrSev_Error,"XShmAttach failed");
if (shmfailed)
{
cout << "MIT-SHM failed, falling back to network mode.\n";
XDestroyImage(d_data->d_ximg);
shmdt(d_data->d_ShmSegInfo.shmaddr);
shmctl(d_data->d_ShmSegInfo.shmid,IPC_RMID,0);
d_data->d_UseShmExt = false;
goto tryagain;
}
d_data->d_data = (uint8*)d_data->d_ximg->data;
d_data->d_CompletionType = XShmGetEventBase(d_data->d_display) + ShmCompletion;
}
else
{
d_data->d_ximg = XCreateImage(d_data->d_display,vinfo->visual,vinfo->depth,
ZPixmap,0,NULL,roundedwidth,h,32,0);
d_data->d_data = new uint8[d_data->d_ximg->bytes_per_line*h];
d_data->d_ximg->data = (char*)d_data->d_data;
}
d_data->d_WaitForCompletion=false;
XSync(d_data->d_display,False);
XFree(vinfo);
d_data->d_initialized = true;
}
DisplayImage_X11::~DisplayImage_X11()
{
delete d_data;
}
void DisplayImage_X11::PutImage(int srcx0,int srcy0,int w,int h, int dstx0,int dsty0)
{
if (w==0) w=d_data->d_width;
if (h==0) h=d_data->d_height;
if (d_data->d_WaitForCompletion)
while (1)
{
XEvent xev;
XNextEvent(d_data->d_display, &xev);
if (xev.type == d_data->d_CompletionType)
break;
}
if (d_data->d_UseShmExt)
{
XShmPutImage(d_data->d_display, d_data->d_win, d_data->d_gc, d_data->d_ximg, srcx0, srcy0, dstx0, dsty0, w,h, True);
XFlush(d_data->d_display);
d_data->d_WaitForCompletion=true;
}
else
{
XPutImage(d_data->d_display, d_data->d_win, d_data->d_gc, d_data->d_ximg, srcx0, srcy0, dstx0, dsty0, w,h);
XFlush(d_data->d_display);
}
}
--- NEW FILE: imgwin.hh ---
/*********************************************************************
libvideogfx/x11/imgwin.hh
purpose:
X11-wrapper classes that simplify window creation and
displaying true color images in them.
notes:
to do:
- There seems to be a problem with MultiWindowRefresh. Some
parts of the image sometimes don't get updated. At the moment
everything seems to work, though.
author(s):
- Dirk Farin, farin at ti.uni-mannheim.de
modifications:
31/Jul/2000 - Dirk Farin - new function: MultiWindowRefresh
03/Aug/1999 - Dirk Farin - new class: ImageWindow_Autorefresh_X11
29/Jul/1999 - Dirk Farin - first implementation
*********************************************************************/
#ifndef LIBVIDEOGFX_X11_IMGWIN_HH
#define LIBVIDEOGFX_X11_IMGWIN_HH
#include "dispimg.hh"
#include "libvideogfx/graphics/lowlevel/img2raw.hh"
/* Wrapper class for creating one X11 window with the highest color depth possible.
*/
class ImageWindow_X11
{
public:
ImageWindow_X11();
~ImageWindow_X11(); // Window will be closed in destructor.
void SetPosition(int x,int y) { d_xpos=x; d_ypos=y; }
void Create(int w,int h,const char* title,const X11Server* server=NULL,Window parent=0);
void Close();
Window AskWindow();
Display* AskDisplay();
private:
bool d_initialized;
struct X11SpecificData* d_x11data; // This hides X11 datatypes from global namespace.
int d_xpos,d_ypos;
};
/* Enhanced ImageWindow_X11-class that can accept an image and that watches
X11 events to automatically redraw itself.
To get fully automatic redrawing you have to create a new thread that
calls RedrawForever() which will never return.
*/
class ImageWindow_Autorefresh_X11 : public ImageWindow_X11, // the window itself
private DisplayImage_X11, // the image to be displayed
private Image2Raw // the transformation for image representation convertion
{
public:
ImageWindow_Autorefresh_X11();
~ImageWindow_Autorefresh_X11();
void Create(int w,int h,const char* title,const X11Server* server=NULL,Window parent=0);
void Close();
void Display_const(const Image_YUV<Pixel>&);
void Display_const(const Image_RGB<Pixel>&);
void Display ( Image_YUV<Pixel>&); // Input image contents may be destroyed
void Display ( Image_RGB<Pixel>& i) { Display_const(i); }
// --- user interaction ---
char CheckForKeypress();
char WaitForKeypress(); // Image will be refreshed while waiting for the keypress.
void CheckForRedraw();
void RedrawForever();
private:
bool d_lastimg_was_RGB;
bool d_lastimg_was_YUV;
void Redraw(XExposeEvent& ev);
friend int MultiWindowRefresh(ImageWindow_Autorefresh_X11*const*,int nWindows);
};
/* MultiWindowRefresh also checks for keypresses. The window index of the window,
in which the keypress has occured, is returned. Otherwise -1 is returned.
*/
int MultiWindowRefresh(ImageWindow_Autorefresh_X11*const*,int nWindows);
#endif
--- NEW FILE: server.cc ---
/*
* server.cc
*/
#include "config.h"
#include "server.hh"
class X11Server_Default : public X11Server
{
public:
X11Server_Default()
{
display = XOpenDisplay(NULL);
}
~X11Server_Default()
{
/* NOTE: eigentlich sollte der server schon wieder zugemacht werden,
aber wenn globale Windows erstellt werden kann es passieren, dass
der Server vor den Windows zugemacht wird, was dann schiefgeht. */
// XCloseDisplay(display);
}
Display* AskDisplay() const { return display; }
private:
Display* display;
};
static X11Server_Default default_x11server_OBJECT;
const X11Server& default_x11server = default_x11server_OBJECT;
--- NEW FILE: dispimg.hh ---
/*********************************************************************
libvideogfx/x11/dispimg.hh
purpose:
Wrapper class around X11 XImage. Whenever possible the MIT-SHM
extension is used for storing the images.
notes:
- Create() is not multi-threading save as X11-errors are caught
to do:
- Check that different endian schemes on client and server are working.
- Try to redefine interface so that hardward YUV2RGB convertion is possible.
- Support for other display depths.
author(s):
- Dirk Farin, farin at ti.uni-mannheim.de
modifications:
21/Jan/2000 - Dirk Farin - X11 specific data is now hidden to circumvent
global namespace pollution by definitions in
X11-header files.
20/Oct/1999 - Dirk Farin - Bugfix. mayUseMITSHM was uninitialized
29/Jul/1999 - Dirk Farin - Integration into ULib, changes in user interface.
07/Jul/1999 - Dirk Farin - robust handling of MIT-SHM failures
25/Jan/1999 - Dirk Farin - support 8bit displays
14/Jan/1999 - Dirk Farin - Bugfix: 24 and 32bit display code now working
07/Jan/1999 - Dirk Farin - support for 24 and 32bit deep displays
03/Jan/1999 - Dirk Farin - support for X11 shared memory extension
30/Dec/1998 - Dirk Farin - first implementation (16 bit deep displays only, 5:6:5 format)
*********************************************************************/
#ifndef LIBVIDEOGFX_X11_DISPIMG_HH
#define LIBVIDEOGFX_X11_DISPIMG_HH
#include "libvideogfx/x11/server.hh"
class DisplayImage_X11
{
public:
DisplayImage_X11();
~DisplayImage_X11();
void UseMITSHM(bool flag=true);
void Create(int w,int h,Window win,const X11Server* server=NULL);
XImage& AskXImage();
void PutImage(int srcx0=0,int srcy0=0,int w=0,int h=0, int dstx0=0,int dsty0=0);
private:
struct DisplayImage_Data* d_data;
};
#endif
More information about the dslinux-commit
mailing list