X11FrameBuffer Class Reference

This class serves as a frame buffer and event handler of a SDL RGB Surface widget for displaying video frames. More...

#include <X11FrameBuffer.hpp>

Inheritance diagram for X11FrameBuffer:

VideoFrameBuffer List of all members.

Public Member Functions

 X11FrameBuffer (Display *display, Window *xwin, int depth, bool gray, int width, int height)
 Constructor.
virtual ~X11FrameBuffer ()
 Destructor.
void setPixel (int x, int y, uint value)
 Set a pixel in the frame buffer.
void bitBlt (AU *au)
 does the fast bitblitting of the full (and unscaled) Frame
void postPaintEvent ()
 Post a custom event for this object to display the frame buffer on the SDL surface.

Protected Attributes

Display * display
Window * xwin
GC gc
XImage * image
char * pixmap
int width
int height
int row_size
uint * pixel32
unsigned short int * pixel16
int depth

Detailed Description

This class serves as a frame buffer and event handler of a SDL RGB Surface widget for displaying video frames.

Author:
Michael Kropfberger
Version:
Id
X11FrameBuffer.hpp,v 1.8 2005/04/19 12:51:55 mkropfbe Exp

Definition at line 72 of file X11FrameBuffer.hpp.


Constructor & Destructor Documentation

X11FrameBuffer::X11FrameBuffer Display *  display,
Window *  xwin,
int  depth,
bool  gray,
int  width,
int  height
 

Constructor.

Parameters:
display the X11 display handle
xwin the X11 window handle
depth the color depth of the frame buffer (8, 24, 32).
numColors the color table size of the frame buffer (if depth == 8).
gray if true and numColors > 0, set the color table entries to all gray values.
Definition at line 56 of file X11FrameBuffer.cpp.
00057 : VideoFrameBuffer(gray) 00058 { 00059 this->display = display; 00060 this->xwin = xwin; 00061 this->width = width; 00062 this->height = height; 00063 this->depth = depth; 00064 assert(depth % 8 == 0); 00065 00066 gc=XCreateGC(display, *xwin, 0, NULL); 00067 pixmap = (char*)calloc(width*height, sizeof(depth/8)); 00068 image = XCreateImage(display, CopyFromParent, 00069 depth, ZPixmap, 0, pixmap, 00070 width, height, 8 /*don't pad scanline*/, 0); //BitmapPad(display), 0); 00071 // row_size = width + (width % (BitmapPad(display)/8) != 0); 00072 row_size = width; 00073 00074 if (!image || !pixmap) { 00075 dprintf_err("Couldn't initialize blitbuffer at depth %i with dimension %ix%i\n",depth,width,height); 00076 ::exit(1); 00077 } 00078 dprintf_err("X11FrameBuffer: depth %i bit, row_size %i\n",depth, row_size); 00079 }


Member Function Documentation

void X11FrameBuffer::postPaintEvent  )  [virtual]
 

Post a custom event for this object to display the frame buffer on the SDL surface.

This is thread-safe and will cause the GUI thread to invoke customEvent(). We need to use custom events, as hidden widgets will not receive paint events.

Implements VideoFrameBuffer.

Definition at line 114 of file X11FrameBuffer.cpp.

00115 { 00116 XPutImage(display, *xwin, gc, image, 0,0,0,0, width, height); 00117 XSync(display, 0); 00118 XFlush(display); 00119 }

void X11FrameBuffer::setPixel int  x,
int  y,
uint  value
[inline, virtual]
 

Set a pixel in the frame buffer.

the frame buffer should be locked before setPixel() by calling the lock() method.

Reimplemented from VideoFrameBuffer.

Definition at line 94 of file X11FrameBuffer.cpp.

00094 { 00095 if (gray) 00096 value = value << 16 | value << 8 | value; 00097 00098 if (depth >=24) { 00099 pixel32 = (uint *)pixmap + y*row_size + x; 00100 *pixel32 = value; 00101 } else { 00102 pixel16 = (unsigned short int *)pixmap + y*row_size + x; 00103 *pixel16 = (unsigned short int) value; 00104 } 00105 }


The documentation for this class was generated from the following files: