Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

bcbitmap.h

Go to the documentation of this file.
00001 #ifndef BCBITMAP_H
00002 #define BCBITMAP_H
00003 
00004 #include <X11/Xlib.h>
00005 #include <sys/ipc.h>
00006 #include <sys/shm.h>
00007 #include <X11/extensions/XShm.h>
00008 #include <X11/extensions/Xvlib.h>
00009 
00010 #include "bcwindowbase.inc"
00011 #include "colors.h"
00012 #include "sizes.h"
00013 #include "vframe.inc"
00014 
00015 //#define BITMAP_RING 1
00016 #define BITMAP_RING 4
00017 
00018 class BC_Bitmap
00019 {
00020 public:
00021         BC_Bitmap(BC_WindowBase *parent_window, unsigned char *png_data);
00022         BC_Bitmap(BC_WindowBase *parent_window, VFrame *frame);
00023 
00024 // Shared memory is a problem in X because it's asynchronous and there's
00025 // no easy way to join with the blitting process.
00026         BC_Bitmap(BC_WindowBase *parent_window, 
00027                 int w, 
00028                 int h, 
00029                 int color_model, 
00030                 int use_shm = 1);
00031         virtual ~BC_Bitmap();
00032 
00033 // transfer VFrame
00034         int read_frame(VFrame *frame,
00035                 int in_x, int in_y, int in_w, int in_h,
00036                 int out_x, int out_y, int out_w, int out_h);
00037 // x1, y1, x2, y2 dimensions of output area
00038         int read_frame(VFrame *frame, 
00039                 int x1, int y1, int x2, int y2);
00040 // Reset bitmap to match the new parameters
00041         int match_params(int w, 
00042                 int h, 
00043                 int color_model, 
00044                 int use_shm);
00045 // Test if bitmap already matches parameters
00046         int params_match(int w, int h, int color_model, int use_shm);
00047 
00048 // When showing the same frame twice need to rewind
00049         void rewind_ring();
00050 // If dont_wait is true, the XSync comes before the flash.
00051 // For YUV bitmaps, the image is scaled to fill dest_x ... w * dest_y ... h
00052         int write_drawable(Drawable &pixmap, 
00053                         GC &gc,
00054                         int source_x, 
00055                         int source_y, 
00056                         int source_w,
00057                         int source_h,
00058                         int dest_x, 
00059                         int dest_y, 
00060                         int dest_w, 
00061                         int dest_h, 
00062                         int dont_wait);
00063         int write_drawable(Drawable &pixmap, 
00064                         GC &gc,
00065                         int dest_x, 
00066                         int dest_y, 
00067                         int source_x, 
00068                         int source_y, 
00069                         int dest_w, 
00070                         int dest_h, 
00071                         int dont_wait);
00072 // the bitmap must be wholly contained in the source during a GetImage
00073         int read_drawable(Drawable &pixmap, int source_x, int source_y);
00074 
00075         int rotate_90(int side);
00076         int get_w();
00077         int get_h();
00078         void transparency_bitswap();
00079 // Data pointers for current ring buffer
00080         unsigned char* get_data();
00081         unsigned char* get_y_plane();
00082         unsigned char* get_u_plane();
00083         unsigned char* get_v_plane();
00084 // Get the frame buffer itself
00085         int get_color_model();
00086         int hardware_scaling();
00087         unsigned char** get_row_pointers();
00088         int get_bytes_per_line();
00089         long get_shm_id();
00090         long get_shm_size();
00091 // Offset of current ringbuffer in shared memory
00092         long get_shm_offset();
00093 // Returns plane offset + ringbuffer offset
00094         long get_y_shm_offset();
00095         long get_u_shm_offset();
00096         long get_v_shm_offset();
00097 // Returns just the plane offset
00098         long get_y_offset();
00099         long get_u_offset();
00100         long get_v_offset();
00101         
00102 // Rewing ringbuffer to the previous frame
00103         void rewind_ringbuffer();
00104         int set_bg_color(int color);
00105         int invert();
00106 
00107 private:
00108         int initialize(BC_WindowBase *parent_window, int w, int h, int color_model, int use_shm);
00109         int allocate_data();
00110         int delete_data();
00111         int get_default_depth();
00112         char byte_bitswap(char src);
00113 
00114         int ring_buffers, current_ringbuffer;
00115         int w, h;
00116 // Color model from colormodels.h
00117         int color_model;
00118 // Background color for using pngs
00119         int bg_color;
00120 // Override top_level for small bitmaps
00121         int use_shm;
00122         BC_WindowBase *top_level;
00123         BC_WindowBase *parent_window;
00124 // Points directly to the frame buffer
00125         unsigned char *data[BITMAP_RING];   
00126 // Row pointers to the frame buffer
00127         unsigned char **row_data[BITMAP_RING];   
00128         int xv_portid;
00129 // This differs from the depth parameter of top_level
00130         int bits_per_pixel;
00131 // From the ximage
00132         long bytes_per_line;
00133 // For resetting XVideo
00134         int last_pixmap_used;
00135 // Background color
00136         unsigned char bg_r, bg_g, bg_b;
00137 // For less than 8 bit depths
00138         int bit_counter;
00139 
00140 // X11 objects
00141 // Need last pixmap to stop XVideo
00142         Drawable last_pixmap;
00143         XImage *ximage[BITMAP_RING];
00144         XvImage *xv_image[BITMAP_RING];
00145         XShmSegmentInfo shm_info;
00146 };
00147 
00148 
00149 
00150 
00151 
00152 
00153 
00154 #endif

Generated on Sun Jan 8 13:26:31 2006 for Guicast-svn by  doxygen 1.4.4