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.55 by cebix, 2001-07-06T22:37:23Z vs.
Revision 1.56 by gbeauche, 2001-07-07T09:14:47Z

# Line 93 | Line 93 | static int display_type = DISPLAY_WINDOW
93   static bool local_X11;                                                          // Flag: X server running on local machine?
94   static uint8 *the_buffer = NULL;                                        // Mac frame buffer (where MacOS draws into)
95   static uint8 *the_buffer_copy = NULL;                           // Copy of Mac frame buffer (for refreshed modes)
96 + static uint32 the_buffer_size;                                          // Size of allocated the_buffer
97  
98   static bool redraw_thread_active = false;                       // Flag: Redraw thread installed
99   #ifdef HAVE_PTHREADS
# Line 509 | Line 510 | driver_base::~driver_base()
510                          free(the_host_buffer);
511                          the_host_buffer = NULL;
512                  }
513 <                if (the_buffer != (uint8 *)VM_MAP_FAILED) {
514 <                        vm_release(the_buffer, the_buffer_size);
513 >                if (the_buffer) {
514 >                        free(the_buffer);
515                          the_buffer = NULL;
516                  }
517 <                if (the_buffer_copy != (uint8 *)VM_MAP_FAILED) {
518 <                        vm_release(the_buffer_copy, the_buffer_size);
517 >                if (the_buffer_copy) {
518 >                        free(the_buffer_copy);
519                          the_buffer_copy = NULL;
520                  }
521          }
# Line 629 | Line 630 | driver_window::driver_window(const video
630          }
631  
632   #ifdef ENABLE_VOSF
633 +        use_vosf = true;
634          // Allocate memory for frame buffer (SIZE is extended to page-boundary)
635          the_host_buffer = the_buffer_copy;
636          the_buffer_size = page_extend((aligned_height + 2) * img->bytes_per_line);
# Line 682 | Line 684 | driver_window::~driver_window()
684                  the_buffer_copy = NULL; // don't free() in driver_base dtor
685   #endif
686          }
687 + #ifdef ENABLE_VOSF
688 +        if (use_vosf) {
689 +                // don't free() memory mapped buffers in driver_base dtor
690 +                if (the_buffer != VM_MAP_FAILED) {
691 +                        vm_release(the_buffer, the_buffer_size);
692 +                        the_buffer = NULL;
693 +                }
694 +                if (the_buffer_copy != VM_MAP_FAILED) {
695 +                        vm_release(the_buffer_copy, the_buffer_size);
696 +                        the_buffer_copy = NULL;
697 +                }
698 +        }
699 + #endif
700          if (img)
701                  XDestroyImage(img);
702          if (have_shm) {
# Line 1001 | Line 1016 | driver_fbdev::driver_fbdev(const video_m
1016          int bytes_per_row = TrivialBytesPerRow(mode.x, mode.depth);
1017          
1018          // Map frame buffer
1019 <        if ((the_buffer = (uint8 *) mmap(NULL, height * bytes_per_row, PROT_READ | PROT_WRITE, MAP_PRIVATE, fbdev_fd, fb_offset)) == MAP_FAILED) {
1020 <                if ((the_buffer = (uint8 *) mmap(NULL, height * bytes_per_row, PROT_READ | PROT_WRITE, MAP_SHARED, fbdev_fd, fb_offset)) == MAP_FAILED) {
1019 >        the_buffer_size = height * bytes_per_row;
1020 >        if ((the_buffer = (uint8 *) mmap(NULL, the_buffer_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fbdev_fd, fb_offset)) == MAP_FAILED) {
1021 >                if ((the_buffer = (uint8 *) mmap(NULL, the_buffer_size, PROT_READ | PROT_WRITE, MAP_SHARED, fbdev_fd, fb_offset)) == MAP_FAILED) {
1022                          char str[256];
1023                          sprintf(str, GetString(STR_FBDEV_MMAP_ERR), strerror(errno));
1024                          ErrorAlert(str);
# Line 1041 | Line 1057 | driver_fbdev::driver_fbdev(const video_m
1057   // Close display
1058   driver_fbdev::~driver_fbdev()
1059   {
1060 +        if (!use_vosf) {
1061 +                if (the_buffer != MAP_FAILED) {
1062 +                        // don't free() the screen buffer in driver_base dtor
1063 +                        munmap(the_buffer, the_buffer_size);
1064 +                        the_buffer = NULL;
1065 +                }
1066 +        }
1067 + #ifdef ENABLE_VOSF
1068 +        else {
1069 +                if (the_host_buffer != MAP_FAILED) {
1070 +                        // don't free() the screen buffer in driver_base dtor
1071 +                        munmap(the_host_buffer, the_buffer_size);
1072 +                        the_host_buffer = NULL;
1073 +                }
1074 +                if (the_buffer_copy != VM_MAP_FAILED) {
1075 +                        vm_release(the_buffer_copy, the_buffer_size);
1076 +                        the_buffer_copy = NULL;
1077 +                }
1078 +                if (the_buffer != VM_MAP_FAILED) {
1079 +                        vm_release(the_buffer, the_buffer_size);
1080 +                        the_buffer = NULL;
1081 +                }
1082 +        }
1083 + #endif
1084   }
1085   #endif
1086  
# Line 1126 | Line 1166 | driver_xf86dga::driver_xf86dga(const vid
1166  
1167          // Init blitting routines
1168          int bytes_per_row = TrivialBytesPerRow((v_width + 7) & ~7, mode.depth);
1169 < #ifdef VIDEO_VOSF
1169 > #if VIDEO_VOSF
1170   #if REAL_ADDRESSING || DIRECT_ADDRESSING
1171          // Screen_blitter_init() returns TRUE if VOSF is mandatory
1172          // i.e. the framebuffer update function is not Blit_Copy_Raw
# Line 1157 | Line 1197 | driver_xf86dga::driver_xf86dga(const vid
1197   driver_xf86dga::~driver_xf86dga()
1198   {
1199          XF86DGADirectVideo(x_display, screen, 0);
1200 +        if (!use_vosf) {
1201 +                // don't free() the screen buffer in driver_base dtor
1202 +                the_buffer = NULL;
1203 +        }
1204 + #ifdef ENABLE_VOSF
1205 +        else {
1206 +                // don't free() the screen buffer in driver_base dtor
1207 +                the_host_buffer = NULL;
1208 +                
1209 +                if (the_buffer_copy != VM_MAP_FAILED) {
1210 +                        vm_release(the_buffer_copy, the_buffer_size);
1211 +                        the_buffer_copy = NULL;
1212 +                }
1213 +                if (the_buffer != VM_MAP_FAILED) {
1214 +                        vm_release(the_buffer, the_buffer_size);
1215 +                        the_buffer = NULL;
1216 +                }
1217 +        }
1218 + #endif
1219   #ifdef ENABLE_XF86_VIDMODE
1220          if (has_vidmode)
1221                  XF86VidModeSwitchToMode(x_display, screen, x_video_modes[0]);
# Line 1343 | Line 1402 | static bool video_open(const video_mode
1402  
1403   #ifdef ENABLE_VOSF
1404          if (use_vosf) {
1405 <                // Initialize the mainBuffer structure
1406 <                if (!video_init_buffer()) {
1405 >                // Initialize the VOSF system
1406 >                if (!video_vosf_init()) {
1407                          ErrorAlert(STR_VOSF_INIT_ERR);
1408                  return false;
1409                  }
1351
1352                // Initialize the handler for SIGSEGV
1353                if (!sigsegv_install_handler(screen_fault_handler)) {
1354                        ErrorAlert("Could not initialize Video on SEGV signals");
1355                        return false;
1356                }
1410          }
1411   #endif
1412          
# Line 1569 | Line 1622 | static void video_close(void)
1622          XSync(x_display, false);
1623  
1624   #ifdef ENABLE_VOSF
1572        // Deinitialize VOSF
1625          if (use_vosf) {
1626 <                if (mainBuffer.pageInfo) {
1627 <                        free(mainBuffer.pageInfo);
1576 <                        mainBuffer.pageInfo = NULL;
1577 <                }
1578 <                if (mainBuffer.dirtyPages) {
1579 <                        free(mainBuffer.dirtyPages);
1580 <                        mainBuffer.dirtyPages = NULL;
1581 <                }
1626 >                // Deinitialize VOSF
1627 >                video_vosf_exit();
1628          }
1629   #endif
1630  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines