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

Comparing SheepShaver/src/Unix/video_x.cpp (file contents):
Revision 1.38 by gbeauche, 2005-03-27T19:05:18Z vs.
Revision 1.40 by gbeauche, 2005-03-28T16:19:28Z

# Line 577 | Line 577 | static bool open_window(int width, int h
577          use_vosf = true;
578          // Allocate memory for frame buffer (SIZE is extended to page-boundary)
579          the_host_buffer = the_buffer_copy;
580 <        the_buffer_size = page_extend((aligned_height + 2) * img->bytes_per_line);
580 >        the_buffer_size = page_extend((aligned_height + 2) * (the_host_buffer_row_bytes = img->bytes_per_line));
581          the_buffer = (uint8 *)vm_acquire(the_buffer_size);
582          the_buffer_copy = (uint8 *)malloc(the_buffer_size);
583          D(bug("the_buffer = %p, the_buffer_copy = %p, the_host_buffer = %p\n", the_buffer, the_buffer_copy, the_host_buffer));
# Line 643 | Line 643 | static bool open_fbdev(int width, int he
643          }
644          D(bug("[fbdev] Device ID: %s\n", fb_finfo.id));
645          D(bug("[fbdev] smem_start: %p [%d bytes]\n", fb_finfo.smem_start, fb_finfo.smem_len));
646 +
647          int fb_type = fb_finfo.type;
648          const char *fb_type_str = NULL;
649          switch (fb_type) {
# Line 654 | Line 655 | static bool open_fbdev(int width, int he
655          default:                                                        fb_type_str = "<unknown>";                              break;
656          }
657          D(bug("[fbdev] type: %s\n", fb_type_str));
658 +
659 +        if (fb_type != FB_TYPE_PACKED_PIXELS) {
660 +                D(bug("[fbdev] type '%s' not supported\n", fb_type_str));
661 +                return false;
662 +        }
663 +
664          int fb_visual = fb_finfo.visual;
665          const char *fb_visual_str;
666          switch (fb_visual) {
# Line 667 | Line 674 | static bool open_fbdev(int width, int he
674          }
675          D(bug("[fbdev] visual: %s\n", fb_visual_str));
676  
677 <        if (fb_type != FB_TYPE_PACKED_PIXELS) {
678 <                D(bug("[fbdev] type %s not supported\n", fb_type_str));
677 >        if (fb_visual != FB_VISUAL_TRUECOLOR) {
678 >                D(bug("[fbdev] visual '%s' not supported\n", fb_visual_str));
679                  return false;
680          }
681          
# Line 686 | Line 693 | static bool open_fbdev(int width, int he
693          XSetWindowAttributes wattr;
694          wattr.event_mask = eventmask = dga_eventmask;
695          wattr.override_redirect = True;
689        wattr.colormap = (depth == 1 ? DefaultColormap(x_display, screen) : cmap[0]);
696          the_win = XCreateWindow(x_display, rootwin, 0, 0, width, height, 0, xdepth,
697 <                                                        InputOutput, vis, CWEventMask | CWOverrideRedirect |
698 <                                                        (color_class == DirectColor ? CWColormap : 0), &wattr);
697 >                                                        InputOutput, DefaultVisual(x_display, screen),
698 >                                                        CWEventMask | CWOverrideRedirect, &wattr);
699  
700          // Show window
701          XMapRaised(x_display, the_win);
# Line 711 | Line 717 | static bool open_fbdev(int width, int he
717          XDefineCursor(x_display, the_win, mac_cursor);
718  
719          // Init blitting routines
714        int bytes_per_row = TrivialBytesPerRow((width + 7) & ~7, DepthModeForPixelDepth(depth));
720   #if ENABLE_VOSF
721 <        bool native_byte_order;
722 < #ifdef WORDS_BIGENDIAN
723 <        native_byte_order = (XImageByteOrder(x_display) == MSBFirst);
724 < #else
725 <        native_byte_order = (XImageByteOrder(x_display) == LSBFirst);
726 < #endif
727 < #if REAL_ADDRESSING || DIRECT_ADDRESSING
721 >        // Extract current screen color masks (we are in True Color mode)
722 >        VisualFormat visualFormat;
723 >        visualFormat.depth = xdepth = DefaultDepth(x_display, screen);
724 >        XMatchVisualInfo(x_display, screen, xdepth, TrueColor, &visualInfo);
725 >        assert(visualFormat.depth == visualInfo.depth);
726 >        visualFormat.Rmask = visualInfo.red_mask;
727 >        visualFormat.Gmask = visualInfo.green_mask;
728 >        visualFormat.Bmask = visualInfo.blue_mask;
729 >        D(bug("[fbdev] %d bpp, (%08x,%08x,%08x)\n",
730 >                  visualFormat.depth,
731 >                  visualFormat.Rmask, visualFormat.Gmask, visualFormat.Bmask));
732 >        D(bug("[fbdev] Mac depth %d bpp\n", depth));
733 >
734          // Screen_blitter_init() returns TRUE if VOSF is mandatory
735          // i.e. the framebuffer update function is not Blit_Copy_Raw
736 <        use_vosf = Screen_blitter_init(visualFormat, native_byte_order, depth);
737 <        
727 <        if (use_vosf) {
728 <          // Allocate memory for frame buffer (SIZE is extended to page-boundary)
729 <          the_host_buffer = the_buffer;
730 <          the_buffer_size = page_extend((height + 2) * bytes_per_row);
731 <          the_buffer_copy = (uint8 *)malloc(the_buffer_size);
732 <          the_buffer = (uint8 *)vm_acquire(the_buffer_size);
733 <          D(bug("the_buffer = %p, the_buffer_copy = %p, the_host_buffer = %p\n", the_buffer, the_buffer_copy, the_host_buffer));
734 <        }
736 > #ifdef WORDS_BIGENDIAN
737 >        const bool native_byte_order = (XImageByteOrder(x_display) == MSBFirst);
738   #else
739 <        use_vosf = false;
739 >        const bool native_byte_order = (XImageByteOrder(x_display) == LSBFirst);
740   #endif
741 +        Screen_blitter_init(visualFormat, native_byte_order, depth);
742 +        
743 +        // Allocate memory for frame buffer (SIZE is extended to page-boundary)
744 +        the_host_buffer = the_buffer;
745 +        the_host_buffer_row_bytes = TrivialBytesPerRow((width + 7) & ~7, DepthModeForPixelDepth(visualFormat.depth));
746 +        the_buffer_size = page_extend((height + 2) * the_host_buffer_row_bytes);
747 +        the_buffer_copy = (uint8 *)malloc(the_buffer_size);
748 +        the_buffer = (uint8 *)vm_acquire(the_buffer_size);
749 +        D(bug("the_buffer = %p, the_buffer_copy = %p, the_host_buffer = %p\n", the_buffer, the_buffer_copy, the_host_buffer));
750   #endif
751  
752          // Set frame buffer base
753          D(bug("the_buffer = %p, use_vosf = %d\n", the_buffer, use_vosf));
754          screen_base = Host2MacAddr(the_buffer);
755 <        VModes[cur_mode].viRowBytes = bytes_per_row;
755 >        VModes[cur_mode].viRowBytes = TrivialBytesPerRow((width + 7) & ~7, DepthModeForPixelDepth(depth));
756          return true;
757   #else
758          ErrorAlert("SheepShaver has been compiled with DGA support disabled.");
# Line 822 | Line 834 | static bool open_dga(int width, int heig
834          if (use_vosf) {
835            // Allocate memory for frame buffer (SIZE is extended to page-boundary)
836            the_host_buffer = the_buffer;
837 <          the_buffer_size = page_extend((height + 2) * bytes_per_row);
837 >          the_buffer_size = page_extend((height + 2) * (the_host_buffer_row_bytes = bytes_per_row));
838            the_buffer_copy = (uint8 *)malloc(the_buffer_size);
839            the_buffer = (uint8 *)vm_acquire(the_buffer_size);
840            D(bug("the_buffer = %p, the_buffer_copy = %p, the_host_buffer = %p\n", the_buffer, the_buffer_copy, the_host_buffer));
# Line 858 | Line 870 | static bool open_display(void)
870          }
871  
872          // Build up visualFormat structure
873 +        visualFormat.fullscreen = (display_type == DIS_SCREEN);
874          visualFormat.depth = visualInfo.depth;
875          visualFormat.Rmask = visualInfo.red_mask;
876          visualFormat.Gmask = visualInfo.green_mask;
# Line 1359 | Line 1372 | bool VideoInit(void)
1372  
1373   #ifdef ENABLE_FBDEV_DGA
1374          // FBDev available?
1375 <        if (!has_dga && local_X11) {
1375 >        bool has_fbdev_dga = false;
1376 >        if (local_X11) {
1377                  if ((fb_dev_fd = open("/dev/fb0", O_RDWR)) > 0) {
1378                          if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo) != 0)
1379                                  close(fb_dev_fd);
1380                          else {
1381 <                                has_dga = true;
1382 <                                is_fbdev_dga_mode = true;
1381 >                                has_fbdev_dga = true;
1382 >                                if (!has_dga) {
1383 >                                        // Fallback to FBDev DGA mode if XF86 DGA is not possible
1384 >                                        has_dga = true;
1385 >                                        is_fbdev_dga_mode = true;
1386 >                                }
1387                                  fb_orig_vinfo = fb_vinfo;
1388                                  D(bug("Frame buffer device initial resolution: %dx%dx%d\n", fb_vinfo.xres, fb_vinfo.yres, fb_vinfo.bits_per_pixel));
1389                          }
# Line 1409 | Line 1427 | bool VideoInit(void)
1427                  else if (has_dga && sscanf(mode_str, "dga/%d/%d", &default_width, &default_height) == 2)
1428                          display_type = DIS_SCREEN;
1429   #endif
1430 + #ifdef ENABLE_FBDEV_DGA
1431 +                else if (has_fbdev_dga && sscanf(mode_str, "fbdev/%d/%d", &default_width, &default_height) == 2) {
1432 +                        is_fbdev_dga_mode = true;
1433 +                        display_type = DIS_SCREEN;
1434 +                }
1435 + #endif
1436                  if (display_type == DIS_INVALID) {
1437                          D(bug("Invalid screen mode specified, defaulting to old modes selection\n"));
1438                          mode_str = NULL;
# Line 1447 | Line 1471 | bool VideoInit(void)
1471                                          add_custom_mode(p, display_type, default_width, default_height, d, APPLE_CUSTOM);
1472                                  }
1473                          }
1474 + #ifdef ENABLE_VOSF
1475 +                } else if (display_type == DIS_SCREEN && is_fbdev_dga_mode) {
1476 +                        for (unsigned int d = APPLE_1_BIT; d <= default_mode; d++)
1477 +                                if (find_visual_for_depth(d))
1478 +                                        add_custom_mode(p, display_type, default_width, default_height, d, APPLE_CUSTOM);
1479 + #endif
1480                  } else
1481                          add_custom_mode(p, display_type, default_width, default_height, default_mode, APPLE_CUSTOM);
1482          } else if (window_modes) {
# Line 1676 | Line 1706 | static void resume_emul(void)
1706                  free(fb_save);
1707                  fb_save = NULL;
1708          }
1679        if (depth == 8)
1680                palette_changed = true;
1709  
1710          // Unlock frame buffer (and continue MacOS thread)
1711          UNLOCK_FRAME_BUFFER;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines