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.43 by gbeauche, 2004-06-29T21:50:23Z

# 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_TRIES = 3;                    // Make 3 attempts for full screen update
193 + const int VOSF_PROFITABLE_THRESHOLD = 16667;    // 60 Hz
194 +
195 + static bool video_vosf_profitable(void)
196 + {
197 +        int64 durations[VOSF_PROFITABLE_TRIES];
198 +        int mean_duration = 0;
199 +
200 +        for (int i = 0; i < VOSF_PROFITABLE_TRIES; i++) {
201 +                uint64 start = GetTicks_usec();
202 +                for (int p = 0; p < mainBuffer.pageCount; p++) {
203 +                        uint8 *addr = (uint8 *)(mainBuffer.memStart + (p * mainBuffer.pageSize));
204 +                        addr[0] = 0; // Trigger Screen_fault_handler()
205 +                }
206 +                int64 duration = GetTicks_usec() - start;
207 +                mean_duration += duration;
208 +                durations[i] = duration;
209 +
210 +                PFLAG_CLEAR_ALL;
211 +                mainBuffer.dirty = false;
212 +                if (vm_protect((char *)mainBuffer.memStart, mainBuffer.memLength, VM_PAGE_READ) != 0)
213 +                        return false;
214 +        }
215 +
216 +        mean_duration /= VOSF_PROFITABLE_TRIES;
217 +        D(bug("Triggered %d screen faults in %ld usec on average\n", mainBuffer.pageCount, mean_duration));
218 +        return (mean_duration < (VOSF_PROFITABLE_THRESHOLD * (frame_skip ? frame_skip : 1)));
219 + }
220 +
221 +
222 + /*
223   *  Initialize the VOSF system (mainBuffer structure, SIGSEGV handler)
224   */
225  
226 < static bool video_vosf_init(X11_MONITOR_INIT)
226 > static bool video_vosf_init(MONITOR_INIT)
227   {
228 <        VIDEO_MODE_INIT;
228 >        VIDEO_MODE_INIT_MONITOR;
229  
230          const uintptr page_size = getpagesize();
231          const uintptr page_mask = page_size - 1;
# Line 313 | Line 332 | bool Screen_fault_handler(sigsegv_addres
332   *      Update display for Windowed mode and VOSF
333   */
334  
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
335   /*      How can we deal with array overrun conditions ?
336          
337          The state of the framebuffer pages that have been touched are maintained
# Line 373 | Line 387 | static inline void update_display_window
387                  const int y1 = mainBuffer.pageInfo[first_page].top;
388                  const int y2 = mainBuffer.pageInfo[page - 1].bottom;
389                  const int height = y2 - y1 + 1;
390 <                
391 <                if (VIDEO_MODE_DEPTH < VIDEO_DEPTH_8BIT) {
390 >
391 >                VIDEO_DRV_LOCK_PIXELS;
392 >
393 >                if ((int)VIDEO_MODE_DEPTH < VIDEO_DEPTH_8BIT) {
394  
395                          // Update the_host_buffer and copy of the_buffer
396                          const int src_bytes_per_row = VIDEO_MODE_ROW_BYTES;
397 <                        const int dst_bytes_per_row = VIDEO_DRV_IMAGE->bytes_per_line;
397 >                        const int dst_bytes_per_row = VIDEO_DRV_ROW_BYTES;
398                          const int pixels_per_byte = VIDEO_MODE_X / src_bytes_per_row;
399                          int i1 = y1 * src_bytes_per_row, i2 = y1 * dst_bytes_per_row, j;
400                          for (j = y1; j <= y2; j++) {
# Line 391 | Line 407 | static inline void update_display_window
407  
408                          // Update the_host_buffer and copy of the_buffer
409                          const int src_bytes_per_row = VIDEO_MODE_ROW_BYTES;
410 <                        const int dst_bytes_per_row = VIDEO_DRV_IMAGE->bytes_per_line;
410 >                        const int dst_bytes_per_row = VIDEO_DRV_ROW_BYTES;
411                          const int bytes_per_pixel = src_bytes_per_row / VIDEO_MODE_X;
412                          int i1 = y1 * src_bytes_per_row, i2 = y1 * dst_bytes_per_row, j;
413                          for (j = y1; j <= y2; j++) {
# Line 401 | Line 417 | static inline void update_display_window
417                          }
418                  }
419  
420 +                VIDEO_DRV_UNLOCK_PIXELS;
421 +
422 + #ifdef USE_SDL_VIDEO
423 +                SDL_UpdateRect(drv->s, 0, y1, VIDEO_MODE_X, height);
424 + #else
425                  if (VIDEO_DRV_HAVE_SHM)
426                          XShmPutImage(x_display, VIDEO_DRV_WINDOW, VIDEO_DRV_GC, VIDEO_DRV_IMAGE, 0, y1, 0, y1, VIDEO_MODE_X, height, 0);
427                  else
428                          XPutImage(x_display, VIDEO_DRV_WINDOW, VIDEO_DRV_GC, VIDEO_DRV_IMAGE, 0, y1, 0, y1, VIDEO_MODE_X, height);
429 + #endif
430          }
431          mainBuffer.dirty = false;
432   }
# Line 472 | Line 494 | static inline void update_display_dga_vo
494                  
495                  // Update the_host_buffer and copy of the_buffer
496                  // There should be at least one pixel to copy
497 +                VIDEO_DRV_LOCK_PIXELS;
498                  const int width = x2 - x1 + 1;
499                  i = y1 * bytes_per_row + x1 * bytes_per_pixel;
500                  for (j = y1; j <= y2; j++) {
# Line 479 | Line 502 | static inline void update_display_dga_vo
502                          memcpy(the_buffer_copy + i, the_buffer + i, bytes_per_pixel * width);
503                          i += bytes_per_row;
504                  }
505 +                VIDEO_DRV_UNLOCK_PIXELS;
506          }
507          mainBuffer.dirty = false;
508   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines