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.75 by gbeauche, 2004-12-18T19:28:33Z vs.
Revision 1.81 by gbeauche, 2005-06-11T06:52:22Z

# Line 1 | Line 1
1   /*
2   *  video_x.cpp - Video/graphics emulation, X11 specific stuff
3   *
4 < *  Basilisk II (C) 1997-2004 Christian Bauer
4 > *  Basilisk II (C) 1997-2005 Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 99 | Line 99 | static bool redraw_thread_active = false
99   #ifdef HAVE_PTHREADS
100   static pthread_attr_t redraw_thread_attr;                       // Redraw thread attributes
101   static volatile bool redraw_thread_cancel;                      // Flag: Cancel Redraw thread
102 + static volatile bool redraw_thread_cancel_ack;          // Flag: Acknowledge for redraw thread cancellation
103   static pthread_t redraw_thread;                                         // Redraw thread
104   #endif
105  
# Line 541 | Line 542 | private:
542          int mouse_last_x, mouse_last_y; // Last mouse position (for relative mode)
543   };
544  
545 + class driver_dga;
546 + static void update_display_dga_vosf(driver_dga *drv);
547 +
548 + class driver_dga : public driver_base {
549 +        friend void update_display_dga_vosf(driver_dga *drv);
550 +
551 + public:
552 +        driver_dga(X11_monitor_desc &monitor);
553 +        ~driver_dga();
554 +
555 +        void suspend(void);
556 +        void resume(void);
557 +
558 + protected:
559 +        struct FakeXImage {
560 +                int width, height;              // size of image
561 +                int depth;                              // depth of image
562 +                int bytes_per_line;             // accelerator to next line
563 +
564 +                FakeXImage(int w, int h, int d)
565 +                        : width(w), height(h), depth(d)
566 +                        { bytes_per_line = TrivialBytesPerRow(width, DepthModeForPixelDepth(depth)); }
567 +        };
568 +        FakeXImage *img;
569 +
570 + private:
571 +        Window suspend_win;             // "Suspend" information window
572 +        void *fb_save;                  // Saved frame buffer for suspend/resume
573 + };
574 +
575   static driver_base *drv = NULL; // Pointer to currently used driver object
576  
577   #ifdef ENABLE_VOSF
# Line 882 | Line 913 | void driver_window::mouse_moved(int x, i
913   *  DGA display driver base class
914   */
915  
885 class driver_dga : public driver_base {
886 public:
887        driver_dga(X11_monitor_desc &monitor);
888        ~driver_dga();
889
890        void suspend(void);
891        void resume(void);
892
893 private:
894        Window suspend_win;             // "Suspend" information window
895        void *fb_save;                  // Saved frame buffer for suspend/resume
896 };
897
916   driver_dga::driver_dga(X11_monitor_desc &m)
917 < : driver_base(m), suspend_win(0), fb_save(NULL)
917 >        : driver_base(m), suspend_win(0), fb_save(NULL), img(NULL)
918   {
919   }
920  
# Line 904 | Line 922 | driver_dga::~driver_dga()
922   {
923          XUngrabPointer(x_display, CurrentTime);
924          XUngrabKeyboard(x_display, CurrentTime);
925 +
926 +        if (img)
927 +                delete img;
928   }
929  
930   // Suspend emulation
# Line 1132 | Line 1153 | driver_fbdev::driver_fbdev(X11_monitor_d
1153            the_buffer_size = page_extend((height + 2) * bytes_per_row);
1154            the_buffer_copy = (uint8 *)malloc(the_buffer_size);
1155            the_buffer = (uint8 *)vm_acquire_mac(the_buffer_size);
1156 +
1157 +          // Fake image for DGA/VOSF mode to know about display bounds
1158 +          img = new FakeXImage(width, height, depth_of_video_mode(mode));
1159          }
1160   #else
1161          use_vosf = false;
# Line 1272 | Line 1296 | driver_xf86dga::driver_xf86dga(X11_monit
1296            the_buffer_size = page_extend((height + 2) * bytes_per_row);
1297            the_buffer_copy = (uint8 *)malloc(the_buffer_size);
1298            the_buffer = (uint8 *)vm_acquire_mac(the_buffer_size);
1299 +
1300 +          // Fake image for DGA/VOSF mode to know about display bounds
1301 +          img = new FakeXImage((v_width + 7) & ~7, height, depth_of_video_mode(mode));
1302          }
1303   #else
1304          use_vosf = false;
# Line 1411 | Line 1438 | bool X11_monitor_desc::video_open(void)
1438          }
1439  
1440          // Build up visualFormat structure
1441 +        visualFormat.fullscreen = (display_type == DISPLAY_DGA);
1442          visualFormat.depth = visualInfo.depth;
1443          visualFormat.Rmask = visualInfo.red_mask;
1444          visualFormat.Gmask = visualInfo.green_mask;
# Line 1521 | Line 1549 | bool X11_monitor_desc::video_open(void)
1549          LOCK_FRAME_BUFFER;
1550  
1551          // Start redraw/input thread
1552 < #ifdef HAVE_PTHREADS
1552 > #ifdef USE_PTHREADS_SERVICES
1553          redraw_thread_cancel = false;
1554          Set_pthread_attr(&redraw_thread_attr, 0);
1555          redraw_thread_active = (pthread_create(&redraw_thread, &redraw_thread_attr, redraw_func, NULL) == 0);
# Line 1717 | Line 1745 | void X11_monitor_desc::video_close(void)
1745          D(bug("video_close()\n"));
1746  
1747          // Stop redraw thread
1748 < #ifdef HAVE_PTHREADS
1748 > #ifdef USE_PTHREADS_SERVICES
1749          if (redraw_thread_active) {
1750                  redraw_thread_cancel = true;
1751 < #ifdef HAVE_PTHREAD_CANCEL
1724 <                pthread_cancel(redraw_thread);
1725 < #endif
1751 >                redraw_thread_cancel_ack = false;
1752                  pthread_join(redraw_thread, NULL);
1753 +                while (!redraw_thread_cancel_ack) ;
1754          }
1755   #endif
1756          redraw_thread_active = false;
# Line 2467 | Line 2494 | static void video_refresh_dga_vosf(void)
2494                  tick_counter = 0;
2495                  if (mainBuffer.dirty) {
2496                          LOCK_VOSF;
2497 <                        update_display_dga_vosf();
2497 >                        update_display_dga_vosf(static_cast<driver_dga *>(drv));
2498                          UNLOCK_VOSF;
2499                  }
2500          }
# Line 2569 | Line 2596 | void VideoRefresh(void)
2596   const int VIDEO_REFRESH_HZ = 60;
2597   const int VIDEO_REFRESH_DELAY = 1000000 / VIDEO_REFRESH_HZ;
2598  
2599 < #ifdef HAVE_PTHREADS
2599 > #ifdef USE_PTHREADS_SERVICES
2600   static void *redraw_func(void *arg)
2601   {
2602          int fd = ConnectionNumber(x_display);
# Line 2610 | Line 2637 | static void *redraw_func(void *arg)
2637          }
2638  
2639          uint64 end = GetTicks_usec();
2640 <        D(bug("%Ld refreshes in %Ld usec = %f refreshes/sec\n", ticks, end - start, ticks * 1000000.0 / (end - start)));
2640 >        D(bug("%lld refreshes in %lld usec = %f refreshes/sec\n", ticks, end - start, ticks * 1000000.0 / (end - start)));
2641 >
2642 >        redraw_thread_cancel_ack = true;
2643          return NULL;
2644   }
2645   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines