Fixed initialisation of tf in file_open(). Without setting the memory to 0,
[cinelerra_cv/mob.git] / guicast / bcbitmap.h
blobe5d5899ca5677ad4b8d8ed0a82f41eb3e7fe4fd0
1 #ifndef BCBITMAP_H
2 #define BCBITMAP_H
4 #include <X11/Xlib.h>
5 #include <sys/ipc.h>
6 #include <sys/shm.h>
7 #include <X11/extensions/XShm.h>
8 #include <X11/extensions/Xvlib.h>
10 #include "bcwindowbase.inc"
11 #include "colors.h"
12 #include "sizes.h"
13 #include "vframe.inc"
15 //#define BITMAP_RING 1
16 #define BITMAP_RING 4
18 class BC_Bitmap
20 public:
21 BC_Bitmap(BC_WindowBase *parent_window, unsigned char *png_data);
22 BC_Bitmap(BC_WindowBase *parent_window, VFrame *frame);
24 // Shared memory is a problem in X because it's asynchronous and there's
25 // no easy way to join with the blitting process.
26 BC_Bitmap(BC_WindowBase *parent_window,
27 int w,
28 int h,
29 int color_model,
30 int use_shm = 1);
31 virtual ~BC_Bitmap();
33 // transfer VFrame
34 int read_frame(VFrame *frame,
35 int in_x, int in_y, int in_w, int in_h,
36 int out_x, int out_y, int out_w, int out_h);
37 // x1, y1, x2, y2 dimensions of output area
38 int read_frame(VFrame *frame,
39 int x1, int y1, int x2, int y2);
40 // Reset bitmap to match the new parameters
41 int match_params(int w,
42 int h,
43 int color_model,
44 int use_shm);
45 // Test if bitmap already matches parameters
46 int params_match(int w, int h, int color_model, int use_shm);
48 // When showing the same frame twice need to rewind
49 void rewind_ring();
50 // If dont_wait is true, the XSync comes before the flash.
51 // For YUV bitmaps, the image is scaled to fill dest_x ... w * dest_y ... h
52 int write_drawable(Drawable &pixmap,
53 GC &gc,
54 int source_x,
55 int source_y,
56 int source_w,
57 int source_h,
58 int dest_x,
59 int dest_y,
60 int dest_w,
61 int dest_h,
62 int dont_wait);
63 int write_drawable(Drawable &pixmap,
64 GC &gc,
65 int dest_x,
66 int dest_y,
67 int source_x,
68 int source_y,
69 int dest_w,
70 int dest_h,
71 int dont_wait);
72 // the bitmap must be wholly contained in the source during a GetImage
73 int read_drawable(Drawable &pixmap, int source_x, int source_y);
75 int rotate_90(int side);
76 int get_w();
77 int get_h();
78 void transparency_bitswap();
79 // Data pointers for current ring buffer
80 unsigned char* get_data();
81 unsigned char* get_y_plane();
82 unsigned char* get_u_plane();
83 unsigned char* get_v_plane();
84 // Get the frame buffer itself
85 int get_color_model();
86 int hardware_scaling();
87 unsigned char** get_row_pointers();
88 int get_bytes_per_line();
89 long get_shm_id();
90 long get_shm_size();
91 // Offset of current ringbuffer in shared memory
92 long get_shm_offset();
93 // Returns plane offset + ringbuffer offset
94 long get_y_shm_offset();
95 long get_u_shm_offset();
96 long get_v_shm_offset();
97 // Returns just the plane offset
98 long get_y_offset();
99 long get_u_offset();
100 long get_v_offset();
102 // Rewing ringbuffer to the previous frame
103 void rewind_ringbuffer();
104 int set_bg_color(int color);
105 int invert();
107 private:
108 int initialize(BC_WindowBase *parent_window, int w, int h, int color_model, int use_shm);
109 int allocate_data();
110 int delete_data();
111 int get_default_depth();
112 char byte_bitswap(char src);
114 int ring_buffers, current_ringbuffer;
115 int w, h;
116 // Color model from colormodels.h
117 int color_model;
118 // Background color for using pngs
119 int bg_color;
120 // Override top_level for small bitmaps
121 int use_shm;
122 BC_WindowBase *top_level;
123 BC_WindowBase *parent_window;
124 // Points directly to the frame buffer
125 unsigned char *data[BITMAP_RING];
126 // Row pointers to the frame buffer
127 unsigned char **row_data[BITMAP_RING];
128 int xv_portid;
129 // This differs from the depth parameter of top_level
130 int bits_per_pixel;
131 // From the ximage
132 long bytes_per_line;
133 // For resetting XVideo
134 int last_pixmap_used;
135 // Background color
136 unsigned char bg_r, bg_g, bg_b;
137 // For less than 8 bit depths
138 int bit_counter;
140 // X11 objects
141 // Need last pixmap to stop XVideo
142 Drawable last_pixmap;
143 XImage *ximage[BITMAP_RING];
144 XvImage *xv_image[BITMAP_RING];
145 XShmSegmentInfo shm_info;
154 #endif