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

Comparing BasiliskII/src/Unix/video_vosf.h (file contents):
Revision 1.37 by cebix, 2004-01-12T15:29:25Z vs.
Revision 1.40 by gbeauche, 2004-06-26T15:22:02Z

# Line 29 | Line 29
29   #include "sigsegv.h"
30   #include "vm_alloc.h"
31  
32 < // Glue for SheepShaver and BasiliskII
33 < #if POWERPC_ROM
34 < #define X11_MONITOR_INIT                /* nothing */
32 > // Glue for SDL and X11 support
33 > #ifdef USE_SDL_VIDEO
34 > #define MONITOR_INIT                    SDL_monitor_desc &monitor
35 > #define VIDEO_DRV_INIT                  driver_window *drv
36 > #define VIDEO_DRV_ROW_BYTES             drv->s->pitch
37 > #define VIDEO_DRV_LOCK_PIXELS   if (SDL_MUSTLOCK(drv->s)) SDL_LockSurface(drv->s)
38 > #define VIDEO_DRV_UNLOCK_PIXELS if (SDL_MUSTLOCK(drv->s)) SDL_UnlockSurface(drv->s)
39 > #else
40 > #ifdef SHEEPSHAVER
41 > #define MONITOR_INIT                    /* nothing */
42   #define VIDEO_DRV_INIT                  /* nothing */
43   #define VIDEO_DRV_WINDOW                the_win
44   #define VIDEO_DRV_GC                    the_gc
45   #define VIDEO_DRV_IMAGE                 img
46   #define VIDEO_DRV_HAVE_SHM              have_shm
40 #define VIDEO_MODE_INIT                 VideoInfo const & mode = VModes[cur_mode]
41 #define VIDEO_MODE_ROW_BYTES    mode.viRowBytes
42 #define VIDEO_MODE_X                    mode.viXsize
43 #define VIDEO_MODE_Y                    mode.viYsize
44 #define VIDEO_MODE_DEPTH                mode.viAppleMode
45 enum {
46  VIDEO_DEPTH_1BIT = APPLE_1_BIT,
47  VIDEO_DEPTH_2BIT = APPLE_2_BIT,
48  VIDEO_DEPTH_4BIT = APPLE_4_BIT,
49  VIDEO_DEPTH_8BIT = APPLE_8_BIT,
50  VIDEO_DEPTH_16BIT = APPLE_16_BIT,
51  VIDEO_DEPTH_32BIT = APPLE_32_BIT
52 };
47   #else
48 < #define X11_MONITOR_INIT                X11_monitor_desc &monitor
48 > #define MONITOR_INIT                    X11_monitor_desc &monitor
49   #define VIDEO_DRV_INIT                  driver_window *drv
50   #define VIDEO_DRV_WINDOW                drv->w
51   #define VIDEO_DRV_GC                    drv->gc
52   #define VIDEO_DRV_IMAGE                 drv->img
53   #define VIDEO_DRV_HAVE_SHM              drv->have_shm
54 < #define VIDEO_MODE_INIT                 video_mode const & mode = drv->monitor.get_current_mode();
55 < #define VIDEO_MODE_ROW_BYTES    mode.bytes_per_row
56 < #define VIDEO_MODE_X                    mode.x
57 < #define VIDEO_MODE_Y                    mode.y
64 < #define VIDEO_MODE_DEPTH                (int)mode.depth
65 < enum {
66 <  VIDEO_DEPTH_1BIT = VDEPTH_1BIT,
67 <  VIDEO_DEPTH_2BIT = VDEPTH_2BIT,
68 <  VIDEO_DEPTH_4BIT = VDEPTH_4BIT,
69 <  VIDEO_DEPTH_8BIT = VDEPTH_8BIT,
70 <  VIDEO_DEPTH_16BIT = VDEPTH_16BIT,
71 <  VIDEO_DEPTH_32BIT = VDEPTH_32BIT
72 < };
54 > #endif
55 > #define VIDEO_DRV_LOCK_PIXELS   /* nothing */
56 > #define VIDEO_DRV_UNLOCK_PIXELS /* nothing */
57 > #define VIDEO_DRV_ROW_BYTES             VIDEO_DRV_IMAGE->bytes_per_line
58   #endif
59  
60   // Variables for Video on SEGV support
# Line 201 | Line 186 | static uint32 page_extend(uint32 size)
186  
187  
188   /*
189 + *  Check if VOSF acceleration is profitable on this platform
190 + */
191 +
192 + const int VOSF_PROFITABLE_THRESHOLD = 8000; // 8 ms, aka (60 Hz / 2) for work processing
193 +
194 + static bool video_vosf_profitable(void)
195 + {
196 +        uint64 start = GetTicks_usec();
197 +
198 +        for (int i = 0; i < mainBuffer.pageCount; i++) {
199 +                uint8 *addr = (uint8 *)(mainBuffer.memStart + (i * mainBuffer.pageSize));
200 +                memset(addr, 0, mainBuffer.pageSize); // Trigger Screen_fault_handler()
201 +        }
202 +
203 +        uint64 end = GetTicks_usec();
204 +        const int diff = end - start;
205 +        D(bug("Triggered %d screen faults in %ld usec\n", mainBuffer.pageCount, diff));
206 +
207 +        if (diff > (VOSF_PROFITABLE_THRESHOLD * (frame_skip + 1)))
208 +                return false;
209 +
210 +        // Reset VOSF variables to initial state
211 +        PFLAG_CLEAR_ALL;
212 +        if (vm_protect((char *)mainBuffer.memStart, mainBuffer.memLength, VM_PAGE_READ) != 0)
213 +                return false;
214 +        mainBuffer.dirty = false;
215 +        return true;
216 + }
217 +
218 +
219 + /*
220   *  Initialize the VOSF system (mainBuffer structure, SIGSEGV handler)
221   */
222  
223 < static bool video_vosf_init(X11_MONITOR_INIT)
223 > static bool video_vosf_init(MONITOR_INIT)
224   {
225          VIDEO_MODE_INIT;
226  
# Line 313 | Line 329 | bool Screen_fault_handler(sigsegv_addres
329   *      Update display for Windowed mode and VOSF
330   */
331  
316 // From video_blit.cpp
317 extern void (*Screen_blit)(uint8 * dest, const uint8 * source, uint32 length);
318 extern bool Screen_blitter_init(XVisualInfo * visual_info, bool native_byte_order, int mac_depth);
319 extern uint32 ExpandMap[256];
320
332   /*      How can we deal with array overrun conditions ?
333          
334          The state of the framebuffer pages that have been touched are maintained
# Line 373 | Line 384 | static inline void update_display_window
384                  const int y1 = mainBuffer.pageInfo[first_page].top;
385                  const int y2 = mainBuffer.pageInfo[page - 1].bottom;
386                  const int height = y2 - y1 + 1;
387 <                
387 >
388 >                VIDEO_DRV_LOCK_PIXELS;
389 >
390                  if (VIDEO_MODE_DEPTH < VIDEO_DEPTH_8BIT) {
391  
392                          // Update the_host_buffer and copy of the_buffer
393                          const int src_bytes_per_row = VIDEO_MODE_ROW_BYTES;
394 <                        const int dst_bytes_per_row = VIDEO_DRV_IMAGE->bytes_per_line;
394 >                        const int dst_bytes_per_row = VIDEO_DRV_ROW_BYTES;
395                          const int pixels_per_byte = VIDEO_MODE_X / src_bytes_per_row;
396                          int i1 = y1 * src_bytes_per_row, i2 = y1 * dst_bytes_per_row, j;
397                          for (j = y1; j <= y2; j++) {
# Line 391 | Line 404 | static inline void update_display_window
404  
405                          // Update the_host_buffer and copy of the_buffer
406                          const int src_bytes_per_row = VIDEO_MODE_ROW_BYTES;
407 <                        const int dst_bytes_per_row = VIDEO_DRV_IMAGE->bytes_per_line;
407 >                        const int dst_bytes_per_row = VIDEO_DRV_ROW_BYTES;
408                          const int bytes_per_pixel = src_bytes_per_row / VIDEO_MODE_X;
409                          int i1 = y1 * src_bytes_per_row, i2 = y1 * dst_bytes_per_row, j;
410                          for (j = y1; j <= y2; j++) {
# Line 401 | Line 414 | static inline void update_display_window
414                          }
415                  }
416  
417 +                VIDEO_DRV_UNLOCK_PIXELS;
418 +
419 + #ifdef USE_SDL_VIDEO
420 +                SDL_UpdateRect(drv->s, 0, y1, VIDEO_MODE_X, height);
421 + #else
422                  if (VIDEO_DRV_HAVE_SHM)
423                          XShmPutImage(x_display, VIDEO_DRV_WINDOW, VIDEO_DRV_GC, VIDEO_DRV_IMAGE, 0, y1, 0, y1, VIDEO_MODE_X, height, 0);
424                  else
425                          XPutImage(x_display, VIDEO_DRV_WINDOW, VIDEO_DRV_GC, VIDEO_DRV_IMAGE, 0, y1, 0, y1, VIDEO_MODE_X, height);
426 + #endif
427          }
428          mainBuffer.dirty = false;
429   }
# Line 472 | Line 491 | static inline void update_display_dga_vo
491                  
492                  // Update the_host_buffer and copy of the_buffer
493                  // There should be at least one pixel to copy
494 +                VIDEO_DRV_LOCK_PIXELS;
495                  const int width = x2 - x1 + 1;
496                  i = y1 * bytes_per_row + x1 * bytes_per_pixel;
497                  for (j = y1; j <= y2; j++) {
# Line 479 | Line 499 | static inline void update_display_dga_vo
499                          memcpy(the_buffer_copy + i, the_buffer + i, bytes_per_pixel * width);
500                          i += bytes_per_row;
501                  }
502 +                VIDEO_DRV_UNLOCK_PIXELS;
503          }
504          mainBuffer.dirty = false;
505   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines