improve delays created by vicon drawing locks, reset_cache segv fix, gang track toolt...
[goodguy/cinelerra.git] / cinelerra-5.1 / guicast / bcbitmap.C
index e430c071058df5b1789f2b9de103631ae8b1754f..81842bbb30850a88a14305129f58fb572611b81b 100644 (file)
 
 #include <string.h>
 #include <unistd.h>
+
+#ifdef HAVE_XV
 #include <X11/extensions/Xvlib.h>
+#endif
 
 int BC_Bitmap::max_active_buffers = 0;
 int BC_Bitmap::zombies = 0;
@@ -124,6 +127,8 @@ void BC_Bitmap::reque(BC_BitmapImage *bfr)
        avail_lock->unlock();
 }
 
+
+#ifdef HAVE_XV
 BC_XvShmImage::BC_XvShmImage(BC_Bitmap *bitmap, int index,
        int w, int h, int color_model)
  : BC_BitmapImage(bitmap, index)
@@ -166,6 +171,7 @@ BC_XvShmImage::~BC_XvShmImage()
        XShmDetach(top_level->display, &shm_info);
        shmdt(shm_info.shmaddr);
 }
+#endif
 
 
 BC_XShmImage::BC_XShmImage(BC_Bitmap *bitmap, int index,
@@ -211,6 +217,7 @@ BC_XShmImage::~BC_XShmImage()
 
 
 
+#ifdef HAVE_XV
 BC_XvImage::BC_XvImage(BC_Bitmap *bitmap, int index,
        int w, int h, int color_model)
  : BC_BitmapImage(bitmap, index)
@@ -237,6 +244,7 @@ BC_XvImage::~BC_XvImage()
 {
        XFree(xv_image);
 }
+#endif
 
 
 BC_XImage::BC_XImage(BC_Bitmap *bitmap, int index,
@@ -329,7 +337,6 @@ int BC_Bitmap::initialize(BC_WindowBase *parent_window,
        this->use_shm = !use_shm ? 0 : need_shm();
         this->shm_reply = this->use_shm && resources->shm_reply ? 1 : 0;
        // dont use shm for less than one page
-       this->bg_color = parent_window->bg_color;
        if( !this->avail_lock )
                this->avail_lock = new Mutex("BC_Bitmap::avail_lock");
        else
@@ -372,13 +379,16 @@ BC_BitmapImage *BC_Bitmap::new_buffer(int type, int idx)
        BC_BitmapImage *buffer = 0;
        if( idx < 0 ) {
                if( type == bmXShmImage ) type = bmXImage;
+#ifdef HAVE_XV
                else if( type ==  bmXvShmImage ) type = bmXvImage;
+#endif
        }
        switch( type ) {
        default:
        case bmXImage:
                buffer = new BC_XImage(this, idx, w, h, color_model);
                break;
+#ifdef HAVE_XV
        case bmXvImage:
                buffer = new BC_XvImage(this, idx, w, h, color_model);
                break;
@@ -388,6 +398,7 @@ BC_BitmapImage *BC_Bitmap::new_buffer(int type, int idx)
        case bmXvShmImage:
                buffer = new BC_XvShmImage(this, idx, w, h, color_model);
                break;
+#endif
        }
        if( buffer->is_zombie() ) ++zombies;
        return buffer;
@@ -446,11 +457,19 @@ int BC_Bitmap::allocate_data()
                else if( bsz >= 0x400000 ) max_buffer_count /= 8;
                else if( bsz >= 0x100000 ) max_buffer_count /= 4;
                else if( bsz >= 0x10000 ) max_buffer_count /= 2;
-               type = hardware_scaling() ? bmXvShmImage : bmXShmImage;
+               type =
+#ifdef HAVE_XV
+                       hardware_scaling() ? bmXvShmImage :
+#endif
+                       bmXShmImage;
                count = MIN_BITMAP_BUFFERS;
        }
        else // use unshared memory.
-               type = hardware_scaling() ? bmXvImage : bmXImage;
+               type =
+#ifdef HAVE_XV
+                       hardware_scaling() ? bmXvImage :
+#endif
+                       bmXImage;
        update_buffers(count);
        return 0;
 }
@@ -483,12 +502,6 @@ int BC_Bitmap::need_shm()
                parent_window->get_resources()->use_shm > 0 ? 1 : 0;
 }
 
-int BC_Bitmap::set_bg_color(int color)
-{
-       this->bg_color = color;
-       return 0;
-}
-
 int BC_Bitmap::invert()
 {
        for( int j=0; j<buffer_count; ++j ) {
@@ -538,6 +551,7 @@ int BC_XShmImage::write_drawable(Drawable &pixmap, GC &gc,
        return 0;
 }
 
+#ifdef HAVE_XV
 int BC_XvImage::write_drawable(Drawable &pixmap, GC &gc,
        int source_x, int source_y, int source_w, int source_h,
        int dest_x, int dest_y, int dest_w, int dest_h)
@@ -559,6 +573,7 @@ int BC_XvShmImage::write_drawable(Drawable &pixmap, GC &gc,
                dest_x, dest_y, dest_w, dest_h, bitmap->shm_reply);
        return 0;
 }
+#endif
 
 int BC_Bitmap::write_drawable(Drawable &pixmap, GC &gc,
                int source_x, int source_y, int source_w, int source_h,
@@ -620,16 +635,21 @@ int BC_Bitmap::read_drawable(Drawable &pixmap, int source_x, int source_y, VFram
 // ============================ Decoding VFrames
 
 int BC_Bitmap::read_frame(VFrame *frame, int x1, int y1, int x2, int y2)
+{
+       return read_frame(frame, x1, y1, x2, y2, parent_window->get_bg_color());
+}
+
+int BC_Bitmap::read_frame(VFrame *frame, int x1, int y1, int x2, int y2, int bg_color)
 {
        return read_frame(frame,
                0, 0, frame->get_w(), frame->get_h(),
-               x1, y1, x2 - x1, y2 - y1);
+               x1, y1, x2 - x1, y2 - y1, bg_color);
 }
 
 
 int BC_Bitmap::read_frame(VFrame *frame,
        int in_x, int in_y, int in_w, int in_h,
-       int out_x, int out_y, int out_w, int out_h)
+       int out_x, int out_y, int out_w, int out_h, int bg_color)
 {
        BC_BitmapImage *bfr = cur_bfr();
        if( hardware_scaling() && frame->get_color_model() == color_model ) {