~ubuntu-branches/ubuntu/feisty/basilisk2/feisty

« back to all changes in this revision

Viewing changes to src/Unix/video_x.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2006-06-01 01:11:16 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060601011116-xjhegbgyfsxag5fl
Tags: 0.9.20060529-1
* New upstream CVS snapshot.
* Update local cdbs snippet copyright-check.mk:
  + Broaden scan to also look for "(c)" by default.
  + Make egrep options configurable.
  + Ignore auto-tools files.
* Bump up standards-version to 3.7.2 (no changes needed).
* Let dh_strip do the stripping (not the make install target).

Show diffs side-by-side

added added

removed removed

Lines of Context:
140
140
static Visual *vis;
141
141
static int color_class;
142
142
 
 
143
static bool x_native_byte_order;                                                // XImage has native byte order?
143
144
static int rshift, rloss, gshift, gloss, bshift, bloss; // Pixel format of DirectColor/TrueColor modes
144
145
 
145
146
static Colormap cmap[2] = {0, 0};                                       // Colormaps for indexed modes (DGA needs two of them)
146
147
 
147
 
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
148
149
static bool x_palette_changed = false;                          // Flag: Palette changed, redraw thread must set new colors
149
150
 
150
151
#ifdef ENABLE_FBDEV_DGA
254
255
}
255
256
 
256
257
// 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)
 
258
static inline uint32 map_rgb(uint8 red, uint8 green, uint8 blue, bool fix_byte_order = false)
258
259
{
259
 
        return ((red >> rloss) << rshift) | ((green >> gloss) << gshift) | ((blue >> bloss) << bshift);
 
260
        uint32 val = ((red >> rloss) << rshift) | ((green >> gloss) << gshift) | ((blue >> bloss) << bshift);
 
261
        if (fix_byte_order && !x_native_byte_order) {
 
262
                // We have to fix byte order in the ExpandMap[]
 
263
                // NOTE: this is only an optimization since Screen_blitter_init()
 
264
                // could be arranged to choose an NBO or OBO (with
 
265
                // byteswapping) Blit_Expand_X_To_Y() function
 
266
                switch (visualFormat.depth) {
 
267
                case 15: case 16:
 
268
                        val = do_byteswap_16(val);
 
269
                        break;
 
270
                case 24: case 32:
 
271
                        val = do_byteswap_32(val);
 
272
                        break;
 
273
                }
 
274
        }
 
275
        return val;
260
276
}
261
277
 
262
278
// Do we have a visual for handling the specified Mac depth? If so, set the
787
803
        XDefineCursor(x_display, w, mac_cursor);
788
804
 
789
805
        // 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
796
806
#ifdef ENABLE_VOSF
797
 
        Screen_blitter_init(visualFormat, native_byte_order, depth_of_video_mode(mode));
 
807
        Screen_blitter_init(visualFormat, x_native_byte_order, depth_of_video_mode(mode));
798
808
#endif
799
809
 
800
810
        // Set frame buffer base
801
 
        set_mac_frame_buffer(monitor, mode.depth, native_byte_order);
 
811
        set_mac_frame_buffer(monitor, mode.depth, x_native_byte_order);
802
812
 
803
813
        // Everything went well
804
814
        init_ok = true;
1279
1289
        // Init blitting routines
1280
1290
        int bytes_per_row = TrivialBytesPerRow((v_width + 7) & ~7, mode.depth);
1281
1291
#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
1288
1292
#if REAL_ADDRESSING || DIRECT_ADDRESSING
1289
1293
        // Screen_blitter_init() returns TRUE if VOSF is mandatory
1290
1294
        // i.e. the framebuffer update function is not Blit_Copy_Raw
1291
 
        use_vosf = Screen_blitter_init(visualFormat, native_byte_order, depth_of_video_mode(mode));
 
1295
        use_vosf = Screen_blitter_init(visualFormat, x_native_byte_order, depth_of_video_mode(mode));
1292
1296
        
1293
1297
        if (use_vosf) {
1294
1298
          // Allocate memory for frame buffer (SIZE is extended to page-boundary)
1437
1441
                return false;
1438
1442
        }
1439
1443
 
 
1444
        // Determine the byte order of an XImage content
 
1445
#ifdef WORDS_BIGENDIAN
 
1446
        x_native_byte_order = (XImageByteOrder(x_display) == MSBFirst);
 
1447
#else
 
1448
        x_native_byte_order = (XImageByteOrder(x_display) == LSBFirst);
 
1449
#endif
 
1450
 
1440
1451
        // Build up visualFormat structure
1441
1452
        visualFormat.fullscreen = (display_type == DISPLAY_DGA);
1442
1453
        visualFormat.depth = visualInfo.depth;
1504
1515
        // Load gray ramp to 8->16/32 expand map
1505
1516
        if (!IsDirectMode(mode) && xdepth > 8)
1506
1517
                for (int i=0; i<256; i++)
1507
 
                        ExpandMap[i] = map_rgb(i, i, i);
 
1518
                        ExpandMap[i] = map_rgb(i, i, i, true);
1508
1519
#endif
1509
1520
 
1510
1521
        // Create display driver object of requested type
1873
1884
        if (!IsDirectMode(mode) && xdepth > 8) {
1874
1885
                for (int i=0; i<256; i++) {
1875
1886
                        int c = i & (num_in-1); // If there are less than 256 colors, we repeat the first entries (this makes color expansion easier)
1876
 
                        ExpandMap[i] = map_rgb(pal[c*3+0], pal[c*3+1], pal[c*3+2]);
 
1887
                        ExpandMap[i] = map_rgb(pal[c*3+0], pal[c*3+1], pal[c*3+2], true);
1877
1888
                }
1878
1889
 
1879
1890
                // We have to redraw everything because the interpretation of pixel values changed