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.81 by gbeauche, 2005-06-11T06:52:22Z vs.
Revision 1.83 by gbeauche, 2007-06-14T14:45:54Z

# Line 140 | Line 140 | static XVisualInfo visualInfo;
140   static Visual *vis;
141   static int color_class;
142  
143 + static bool x_native_byte_order;                                                // XImage has native byte order?
144   static int rshift, rloss, gshift, gloss, bshift, bloss; // Pixel format of DirectColor/TrueColor modes
145  
146   static Colormap cmap[2] = {0, 0};                                       // Colormaps for indexed modes (DGA needs two of them)
147  
148 < static XColor x_palette[256];                                                   // Color palette to be used as CLUT and gamma table
148 > static XColor x_palette[256];                                           // Color palette to be used as CLUT and gamma table
149   static bool x_palette_changed = false;                          // Flag: Palette changed, redraw thread must set new colors
150  
151   #ifdef ENABLE_FBDEV_DGA
# Line 193 | Line 194 | static void *redraw_func(void *arg);
194   // From main_unix.cpp
195   extern char *x_display_name;
196   extern Display *x_display;
196 extern void *vm_acquire_mac(size_t size);
197  
198   // From sys_unix.cpp
199   extern void SysMountFirstFloppy(void);
# Line 254 | Line 254 | static inline int depth_of_video_mode(vi
254   }
255  
256   // Map RGB color to pixel value (this only works in TrueColor/DirectColor visuals)
257 < static inline uint32 map_rgb(uint8 red, uint8 green, uint8 blue)
257 > static inline uint32 map_rgb(uint8 red, uint8 green, uint8 blue, bool fix_byte_order = false)
258   {
259 <        return ((red >> rloss) << rshift) | ((green >> gloss) << gshift) | ((blue >> bloss) << bshift);
259 >        uint32 val = ((red >> rloss) << rshift) | ((green >> gloss) << gshift) | ((blue >> bloss) << bshift);
260 >        if (fix_byte_order && !x_native_byte_order) {
261 >                // We have to fix byte order in the ExpandMap[]
262 >                // NOTE: this is only an optimization since Screen_blitter_init()
263 >                // could be arranged to choose an NBO or OBO (with
264 >                // byteswapping) Blit_Expand_X_To_Y() function
265 >                switch (visualFormat.depth) {
266 >                case 15: case 16:
267 >                        val = do_byteswap_16(val);
268 >                        break;
269 >                case 24: case 32:
270 >                        val = do_byteswap_32(val);
271 >                        break;
272 >                }
273 >        }
274 >        return val;
275   }
276  
277   // Do we have a visual for handling the specified Mac depth? If so, set the
# Line 482 | Line 497 | static int error_handler(Display *d, XEr
497  
498  
499   /*
500 + *  Framebuffer allocation routines
501 + */
502 +
503 + #ifdef ENABLE_VOSF
504 + #include "vm_alloc.h"
505 +
506 + static void *vm_acquire_framebuffer(uint32 size)
507 + {
508 +        // always try to allocate framebuffer at the same address
509 +        static void *fb = VM_MAP_FAILED;
510 +        if (fb != VM_MAP_FAILED) {
511 +                if (vm_acquire_fixed(fb, size) < 0)
512 +                        fb = VM_MAP_FAILED;
513 +        }
514 +        if (fb == VM_MAP_FAILED)
515 +                fb = vm_acquire(size, VM_MAP_DEFAULT | VM_MAP_32BIT);
516 +        return fb;
517 + }
518 +
519 + static inline void vm_release_framebuffer(void *fb, uint32 size)
520 + {
521 +        vm_release(fb, size);
522 + }
523 + #endif
524 +
525 +
526 + /*
527   *  Display "driver" classes
528   */
529  
# Line 616 | Line 658 | driver_base::~driver_base()
658                  // the_buffer shall always be mapped through vm_acquire() so that we can vm_protect() it at will
659                  if (the_buffer != VM_MAP_FAILED) {
660                          D(bug(" releasing the_buffer at %p (%d bytes)\n", the_buffer, the_buffer_size));
661 <                        vm_release(the_buffer, the_buffer_size);
661 >                        vm_release_framebuffer(the_buffer, the_buffer_size);
662                          the_buffer = NULL;
663                  }
664                  if (the_host_buffer) {
# Line 766 | Line 808 | driver_window::driver_window(X11_monitor
808          // Allocate memory for frame buffer (SIZE is extended to page-boundary)
809          the_host_buffer = the_buffer_copy;
810          the_buffer_size = page_extend((aligned_height + 2) * img->bytes_per_line);
811 <        the_buffer = (uint8 *)vm_acquire_mac(the_buffer_size);
811 >        the_buffer = (uint8 *)vm_acquire_framebuffer(the_buffer_size);
812          the_buffer_copy = (uint8 *)malloc(the_buffer_size);
813          D(bug("the_buffer = %p, the_buffer_copy = %p, the_host_buffer = %p\n", the_buffer, the_buffer_copy, the_host_buffer));
814   #else
# Line 787 | Line 829 | driver_window::driver_window(X11_monitor
829          XDefineCursor(x_display, w, mac_cursor);
830  
831          // Init blitting routines
790        bool native_byte_order;
791 #ifdef WORDS_BIGENDIAN
792        native_byte_order = (XImageByteOrder(x_display) == MSBFirst);
793 #else
794        native_byte_order = (XImageByteOrder(x_display) == LSBFirst);
795 #endif
832   #ifdef ENABLE_VOSF
833 <        Screen_blitter_init(visualFormat, native_byte_order, depth_of_video_mode(mode));
833 >        Screen_blitter_init(visualFormat, x_native_byte_order, depth_of_video_mode(mode));
834   #endif
835  
836          // Set frame buffer base
837 <        set_mac_frame_buffer(monitor, mode.depth, native_byte_order);
837 >        set_mac_frame_buffer(monitor, mode.depth, x_native_byte_order);
838  
839          // Everything went well
840          init_ok = true;
# Line 1152 | Line 1188 | driver_fbdev::driver_fbdev(X11_monitor_d
1188            the_host_buffer = the_buffer;
1189            the_buffer_size = page_extend((height + 2) * bytes_per_row);
1190            the_buffer_copy = (uint8 *)malloc(the_buffer_size);
1191 <          the_buffer = (uint8 *)vm_acquire_mac(the_buffer_size);
1191 >          the_buffer = (uint8 *)vm_acquire_framebuffer(the_buffer_size);
1192  
1193            // Fake image for DGA/VOSF mode to know about display bounds
1194            img = new FakeXImage(width, height, depth_of_video_mode(mode));
# Line 1279 | Line 1315 | driver_xf86dga::driver_xf86dga(X11_monit
1315          // Init blitting routines
1316          int bytes_per_row = TrivialBytesPerRow((v_width + 7) & ~7, mode.depth);
1317   #if ENABLE_VOSF
1282        bool native_byte_order;
1283 #ifdef WORDS_BIGENDIAN
1284        native_byte_order = (XImageByteOrder(x_display) == MSBFirst);
1285 #else
1286        native_byte_order = (XImageByteOrder(x_display) == LSBFirst);
1287 #endif
1318   #if REAL_ADDRESSING || DIRECT_ADDRESSING
1319          // Screen_blitter_init() returns TRUE if VOSF is mandatory
1320          // i.e. the framebuffer update function is not Blit_Copy_Raw
1321 <        use_vosf = Screen_blitter_init(visualFormat, native_byte_order, depth_of_video_mode(mode));
1321 >        use_vosf = Screen_blitter_init(visualFormat, x_native_byte_order, depth_of_video_mode(mode));
1322          
1323          if (use_vosf) {
1324            // Allocate memory for frame buffer (SIZE is extended to page-boundary)
1325            the_host_buffer = the_buffer;
1326            the_buffer_size = page_extend((height + 2) * bytes_per_row);
1327            the_buffer_copy = (uint8 *)malloc(the_buffer_size);
1328 <          the_buffer = (uint8 *)vm_acquire_mac(the_buffer_size);
1328 >          the_buffer = (uint8 *)vm_acquire_framebuffer(the_buffer_size);
1329  
1330            // Fake image for DGA/VOSF mode to know about display bounds
1331            img = new FakeXImage((v_width + 7) & ~7, height, depth_of_video_mode(mode));
# Line 1437 | Line 1467 | bool X11_monitor_desc::video_open(void)
1467                  return false;
1468          }
1469  
1470 +        // Determine the byte order of an XImage content
1471 + #ifdef WORDS_BIGENDIAN
1472 +        x_native_byte_order = (XImageByteOrder(x_display) == MSBFirst);
1473 + #else
1474 +        x_native_byte_order = (XImageByteOrder(x_display) == LSBFirst);
1475 + #endif
1476 +
1477          // Build up visualFormat structure
1478          visualFormat.fullscreen = (display_type == DISPLAY_DGA);
1479          visualFormat.depth = visualInfo.depth;
# Line 1504 | Line 1541 | bool X11_monitor_desc::video_open(void)
1541          // Load gray ramp to 8->16/32 expand map
1542          if (!IsDirectMode(mode) && xdepth > 8)
1543                  for (int i=0; i<256; i++)
1544 <                        ExpandMap[i] = map_rgb(i, i, i);
1544 >                        ExpandMap[i] = map_rgb(i, i, i, true);
1545   #endif
1546  
1547          // Create display driver object of requested type
# Line 1873 | Line 1910 | void X11_monitor_desc::set_palette(uint8
1910          if (!IsDirectMode(mode) && xdepth > 8) {
1911                  for (int i=0; i<256; i++) {
1912                          int c = i & (num_in-1); // If there are less than 256 colors, we repeat the first entries (this makes color expansion easier)
1913 <                        ExpandMap[i] = map_rgb(pal[c*3+0], pal[c*3+1], pal[c*3+2]);
1913 >                        ExpandMap[i] = map_rgb(pal[c*3+0], pal[c*3+1], pal[c*3+2], true);
1914                  }
1915  
1916                  // We have to redraw everything because the interpretation of pixel values changed

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines