ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/video_x.cpp
(Generate patch)

Comparing BasiliskII/src/Unix/video_x.cpp (file contents):
Revision 1.35 by gbeauche, 2001-01-11T18:00:40Z vs.
Revision 1.38 by gbeauche, 2001-05-20T20:31:50Z

# Line 1 | Line 1
1   /*
2   *  video_x.cpp - Video/graphics emulation, X11 specific stuff
3   *
4 < *  Basilisk II (C) 1997-2000 Christian Bauer
4 > *  Basilisk II (C) 1997-2001 Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 53 | Line 53
53   #endif
54  
55   #ifdef ENABLE_VOSF
56 # include <unistd.h>
57 # include <signal.h>
56   # include <fcntl.h>
57   # include <sys/mman.h>
58 + # include "sigsegv.h"
59   #endif
60  
61   #include "cpu_emulation.h"
# Line 197 | Line 196 | struct ScreenInfo {
196      int pageBits;                               // Shift count to get the page number
197      uint32 pageCount;                   // Number of pages allocated to the screen
198      
199 +        bool dirty;                                     // Flag: set if the frame buffer was touched
200      char * dirtyPages;                  // Table of flags set if page was altered
201      ScreenPageInfo * pageInfo;  // Table of mappings page -> Mac scanlines
202   };
# Line 234 | Line 234 | static ScreenInfo mainBuffer;
234          memset(mainBuffer.dirtyPages + (first_page), PFLAG_CLEAR_VALUE, \
235                  (last_page) - (first_page))
236  
237 < #define PFLAG_SET_ALL \
238 <        PFLAG_SET_RANGE(0, mainBuffer.pageCount)
239 <
240 < #define PFLAG_CLEAR_ALL \
241 <        PFLAG_CLEAR_RANGE(0, mainBuffer.pageCount)
237 > #define PFLAG_SET_ALL do { \
238 >        PFLAG_SET_RANGE(0, mainBuffer.pageCount); \
239 >        mainBuffer.dirty = true; \
240 > } while (0)
241 >
242 > #define PFLAG_CLEAR_ALL do { \
243 >        PFLAG_CLEAR_RANGE(0, mainBuffer.pageCount); \
244 >        mainBuffer.dirty = false; \
245 > } while (0)
246  
247   // Set the following macro definition to 1 if your system
248   // provides a really fast strchr() implementation
# Line 273 | Line 277 | static inline int find_next_page_clear(i
277   }
278  
279   static int zero_fd = -1;
276 static bool Screen_fault_handler_init();
277 static struct sigaction vosf_sa;
280  
281   #ifdef HAVE_PTHREADS
282   static pthread_mutex_t vosf_lock = PTHREAD_MUTEX_INITIALIZER;   // Mutex to protect frame buffer (dirtyPages in fact)
# Line 575 | Line 577 | static bool init_window(int width, int h
577          native_byte_order = (XImageByteOrder(x_display) == LSBFirst);
578   #endif
579   #ifdef ENABLE_VOSF
580 <        do_update_framebuffer = GET_FBCOPY_FUNC(depth, native_byte_order, DISPLAY_WINDOW);
580 >        Screen_blitter_init(&visualInfo, native_byte_order);
581   #endif
582          set_video_monitor(width, height, img->bytes_per_line, native_byte_order);
583          
# Line 714 | Line 716 | static bool init_fbdev_dga(char *in_fb_n
716          
717   #if ENABLE_VOSF
718   #if REAL_ADDRESSING || DIRECT_ADDRESSING
719 <        // If the blit function is null, i.e. just a copy of the buffer,
720 <        // we first try to avoid the allocation of a temporary frame buffer
721 <        use_vosf = true;
720 <        do_update_framebuffer = GET_FBCOPY_FUNC(depth, true, DISPLAY_DGA);
721 <        if (do_update_framebuffer == FBCOPY_FUNC(fbcopy_raw))
722 <                use_vosf = false;
719 >        // Screen_blitter_init() returns TRUE if VOSF is mandatory
720 >        // i.e. the framebuffer update function is not Blit_Copy_Raw
721 >        use_vosf = Screen_blitter_init(&visualInfo, true);
722          
723          if (use_vosf) {
724                  the_host_buffer = the_buffer;
# Line 824 | Line 823 | static bool init_xf86_dga(int width, int
823          }
824          
825   #if REAL_ADDRESSING || DIRECT_ADDRESSING
826 <        // If the blit function is null, i.e. just a copy of the buffer,
827 <        // we first try to avoid the allocation of a temporary frame buffer
828 <        use_vosf = true;
830 <        do_update_framebuffer = GET_FBCOPY_FUNC(depth, true, DISPLAY_DGA);
831 <        if (do_update_framebuffer == FBCOPY_FUNC(fbcopy_raw))
832 <                use_vosf = false;
826 >        // Screen_blitter_init() returns TRUE if VOSF is mandatory
827 >        // i.e. the framebuffer update function is not Blit_Copy_Raw
828 >        use_vosf = Screen_blitter_init(&visualInfo, true);
829          
830          if (use_vosf) {
831                  the_host_buffer = the_buffer;
# Line 952 | Line 948 | bool VideoInitBuffer()
948  
949                  if ((mainBuffer.dirtyPages == 0) || (mainBuffer.pageInfo == 0))
950                          return false;
951 +                
952 +                mainBuffer.dirty = false;
953  
954                  PFLAG_CLEAR_ALL;
955                  // Safety net to insure the loops in the update routines will terminate
# Line 1171 | Line 1169 | bool VideoInit(bool classic)
1169                  }
1170  
1171                  // Initialize the handler for SIGSEGV
1172 <                if (!Screen_fault_handler_init()) {
1172 >                if (!sigsegv_install_handler(screen_fault_handler)) {
1173                          // TODO: STR_VOSF_INIT_ERR ?
1174                          ErrorAlert("Could not initialize Video on SEGV signals");
1175                          return false;
# Line 2024 | Line 2022 | static void video_refresh_dga_vosf(void)
2022          static int tick_counter = 0;
2023          if (++tick_counter >= frame_skip) {
2024                  tick_counter = 0;
2025 <                LOCK_VOSF;
2026 <                update_display_dga_vosf();
2027 <                UNLOCK_VOSF;
2025 >                if (mainBuffer.dirty) {
2026 >                        LOCK_VOSF;
2027 >                        update_display_dga_vosf();
2028 >                        UNLOCK_VOSF;
2029 >                }
2030          }
2031   }
2032   #endif
# Line 2046 | Line 2046 | static void video_refresh_window_vosf(vo
2046          static int tick_counter = 0;
2047          if (++tick_counter >= frame_skip) {
2048                  tick_counter = 0;
2049 <                LOCK_VOSF;
2050 <                update_display_window_vosf();
2051 <                UNLOCK_VOSF;
2049 >                if (mainBuffer.dirty) {
2050 >                        LOCK_VOSF;
2051 >                        update_display_window_vosf();
2052 >                        UNLOCK_VOSF;
2053 >                        XSync(x_display, false); // Let the server catch up
2054 >                }
2055          }
2056   }
2057   #endif // def ENABLE_VOSF
# Line 2135 | Line 2138 | static void *redraw_func(void *arg)
2138                  ticks++;
2139          }
2140          uint64 end = GetTicks_usec();
2141 <        printf("%Ld ticks in %Ld usec = %Ld ticks/sec\n", ticks, end - start, ticks * 1000000 / (end - start));
2141 >        // printf("%Ld ticks in %Ld usec = %Ld ticks/sec\n", ticks, end - start, ticks * 1000000 / (end - start));
2142          return NULL;
2143   }
2144   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines