[Splashy-devel] 4/6 Make simple interface for splashy_video.h

Tim Dijkstra newsuser at famdijkstra.org
Sat Aug 12 21:36:54 UTC 2006


Remove "splashy_video_t * video" from the functions argument list,
make an instance of splashy_video_t local to splashy_video.c instead.
That way the rest of splashy doesn't have to know about splashy_video_t
at all. 


diff -u splashy_functions.c splashy_functions.c
--- splashy_functions.c	2006-08-12 14:20:00.000000000 +0200
+++ splashy_functions.c	2006-08-12 13:43:35.000000000 +0200
@@ -80,8 +80,6 @@
 static gint arg_progress = 0;   /* value to be sent to last_progress from
                                  * FIFO. @see keyevent_loop() */
 
-static splashy_video_t video;
-
 static gboolean exiting = FALSE;        /* threads should read this before
                                          * doing anything at all. this is set 
                                          * to true at cmd_exit() */
@@ -149,7 +147,7 @@
                 if (g_ascii_strncasecmp (fadeout, "yes", 3) == 0)
                 {
                         DEBUG_PRINT ("cmd_exit fadeout routine %s", "");
-                        video_fade_out (&video);
+                        video_fade_out ();
                 }
         }
 
@@ -176,7 +174,7 @@
 
         DEBUG_PRINT ("cmd_exit releasing memory %s", "");
 
-        video_stop_splash (&video);
+        video_stop_splash ();
 
         exit (0);
         return 0;               /* we never reach this */
@@ -200,7 +198,7 @@
         {
                 DEBUG_PRINT ("cmd_progress: Setting progressbar to %d ticks",
                              arg_progress);
-                video_update_progressbar (&video, arg_progress);
+                video_update_progressbar (arg_progress);
         }
 
         last_progress = arg_progress;
@@ -213,14 +211,14 @@
 gint
 cmd_print (void **args)
 {
-        video_printline (&video, args[0]);
+        video_printline (args[0]);
         return 0;
 }
 
 gint
 cmd_print_clear (void **args)
 {
-        video_printline (&video, "");
+        video_printline ("");
         return 0;
 }
 
@@ -257,7 +255,7 @@
          * TODO change background to current image 
          */
         /*
-         * video_printline (&video, ""); 
+         * video_printline (""); 
          */
         return 0;
 }
@@ -490,7 +488,7 @@
                 background =
                         _splashy_theme_image_path
                         (SPL_DEFAULT_THEME, "/splashy/background/errorimg");
-        video_change_splash (&video, background);
+        video_change_splash (background);
 
         /*
          * safe for future reference 
@@ -707,8 +705,7 @@
                                     || F2_toggle_pressed == TRUE)
                                 {
                                         if (!exiting)
-                                                video_printline_s (&video,
-                                                                   (char *)
+                                                video_printline_s ((char *)
                                                                    buf_str->
                                                                    str);
 
@@ -824,13 +821,12 @@
                                  * re-draw the image so that we can get our
                                  * progressbar filled 
                                  */
-                                video_change_splash (&video,
-                                                     _current_background);
+                                video_change_splash (_current_background);
                                 sched_yield ();
                                 nanosleep (&_sleep, NULL);
                         }
                         g_printerr ("Updating progressbar by %d+10\n", i);
-                        video_update_progressbar (&video, i += 10);
+                        video_update_progressbar (i += 10);
                         sched_yield ();
                         nanosleep (&_sleep, NULL);
                 }
@@ -962,13 +958,13 @@
                 /*
                  * sub-parent (we are a fork after all). init is our parent 
                  */
-                video_wait_for_event(&video);
+                video_wait_for_event();
 
                 /*
                  * get all events from our event buffer (fifo style) and
                  * process them. 
                  */
-                while (video_get_key_event (&video, &key))
+                while (video_get_key_event (&key))
                 {
                         /*
                          * exit if ESC or F2 is pressed also kill our
@@ -992,7 +988,7 @@
                                                 F2_toggle_pressed = TRUE;
                                                 show_textbox_area = TRUE;
                                                 /* now show the box */
-                                                video_printline_s (&video,"");
+                                                video_printline_s ("");
                                         }
                                         else
                                         {
@@ -1004,8 +1000,7 @@
                                                  * @see verbose_text_loop
                                                  * we need to re-draw the screen
                                                  */
-                                                video_change_splash (&video,
-                                                                     _current_background);
+                                                video_change_splash (_current_background);
                                         }
                                 }
                 }               /* ends while ev_buffer */
@@ -1172,7 +1167,7 @@
                 close (i);
         }
 
-        video_start_splash (&video, background);
+        video_start_splash (background);
         _current_background = background;       /* safe for future reference */
 
         if (show_progress == TRUE)
@@ -1181,7 +1176,7 @@
                  * starting bars stuff! 
                  */
                 DEBUG_PRINT ("_splashy_child() starting progressbar %s", "");
-                video_draw_progressbar (&video);
+                video_draw_progressbar ();
         }
 
         /*
@@ -1192,10 +1187,10 @@
          * Note that this won't actually show the text area until we print
          * to it. @see verbose_text_loop() and the create thread below
          */
-        video_start_text_area (&video);
+        video_start_text_area ();
 
         /* Maybe this can be moved to video_start_splash? */
-        video_create_event_buffer(&video);
+        video_create_event_buffer();
 
         /*
          * here is where the magic happens: because WaitForEvent*() waits idle
diff -u splashy_video.c splashy_video.c
--- splashy_video.c	2006-08-12 14:20:00.000000000 +0200
+++ splashy_video.c	2006-08-12 14:15:27.000000000 +0200
@@ -49,6 +49,47 @@
 #include "xml_config.h"
 #include "splashy_video.h"
 
+typedef struct splashy_videomode_s
+{
+        gint width;
+        gint height;
+        gint out_width;
+        gint out_height;
+        gint overx;
+        gint overy;
+        gint bpp;
+} splashy_videomode_t;
+
+typedef struct
+{
+        gboolean enabled;
+        IDirectFBSurface *offscreen;    /** off-screen storage */
+        IDirectFBSurface *surface;      /** Subsurface to draw text on */
+        DFBSurfaceDescription desc;
+        DFBRectangle area;
+        DFBFontDescription fontdesc;
+} splashy_textbox_t;
+
+typedef struct
+{
+        IDirectFB *dfb;                         /** our directfb object */
+        IDirectFBImageProvider *provider;       /** our image class */
+        IDirectFBWindow *primary_window;        /** our main window. where opacity takes place */
+        IDirectFBSurface *primary_window_surface; /** interface to window's surface */
+
+        IDirectFBDisplayLayer *primary_layer;   /** interface to our layer */
+        DFBDisplayLayerConfig  primary_layer_config; /** configuration for our primary_layer */
+        IDirectFBSurface *primary_surface;      /** our main background */
+        IDirectFBInputDevice *keyboard;         /** our main input dev */
+        IDirectFBEventBuffer *ev_buffer;        /** our events listener */
+        splashy_videomode_t *mode;              /** video mode supported by surface */
+        splashy_textbox_t *textbox;             /** text box parameters */
+        DFBRectangle progressbar;               /** our progressbar */
+        __u8 opacity;                           /** current opacity level */
+} splashy_video_t;
+
+static splashy_video_t video;
+
 static const gchar *_current_background = NULL;
 static gchar *fb_dev_name = NULL;       /* such as /dev/fb0 */
 static gint fb_dev_fd;          /* handle for fb_dev_name */
@@ -173,8 +213,7 @@
 }
 
 void
-video_get_divider (splashy_video_t * video, gint * divider_w,
-                   gint * divider_h)
+video_get_divider (gint * divider_w, gint * divider_h)
 {
         /*
          * Source image width and height 
@@ -209,13 +248,13 @@
 }
 
 gint
-video_draw_progressbar (splashy_video_t * video)
+video_draw_progressbar ()
 {
         gint screen_width, screen_height;
         gint divider_w, divider_h;
         guint rectangle_red, rectangle_green, rectangle_blue, rectangle_alpha;
 
-        DFBRectangle * progressbar = &video->progressbar;
+        DFBRectangle * progressbar = &video.progressbar;
 
 	/* We set a flag here now that change_splash can see to know
 	 * if it has to redraw the progress bar.
@@ -233,9 +272,9 @@
                                          0) ? TRUE : FALSE;
         DEBUG_PRINT ("Printing progress border: %d", draw_progress_border);
 
-        video_get_divider (video, &divider_w, &divider_h);
+        video_get_divider (&divider_w, &divider_h);
 
-        video->primary_surface->GetSize (video->primary_surface,
+        video.primary_surface->GetSize (video.primary_surface,
                                          &screen_width, &screen_height);
 
         progressbar->x = screen_width *
@@ -296,7 +335,7 @@
                         DEBUG_PRINT ("Border color: alpha = %d",
                                      rectangle_alpha);
 
-                        video->primary_surface->SetColor (video->
+                        video.primary_surface->SetColor (video.
                                                           primary_surface,
                                                           rectangle_red,
                                                           rectangle_green,
@@ -306,7 +345,7 @@
                         /*
                          * Draw border so that it is one pixel around the bar 
                          */
-                        video->primary_surface->DrawRectangle (video->
+                        video.primary_surface->DrawRectangle (video.
                                                                primary_surface,
                                                                progressbar->
                                                                x - 1,
@@ -366,18 +405,18 @@
                  * fill the rectangle so that it's easier to do the reverse progress trick
                  * @see video_update_progress()
                  */
-                video->primary_surface->SetColor (video->primary_surface,
+                video.primary_surface->SetColor (video.primary_surface,
                                                   127, 127, 127, 255);
         }
         else
         {
-                video->primary_surface->SetColor (video->primary_surface,
+                video.primary_surface->SetColor (video.primary_surface,
                                                   rectangle_red,
                                                   rectangle_green,
                                                   rectangle_blue,
                                                   rectangle_alpha);
         }
-        video->primary_surface->FillRectangle (video->primary_surface,
+        video.primary_surface->FillRectangle (video.primary_surface,
                                                progressbar->x,
                                                progressbar->y,
                                                progressbar->w,
@@ -387,12 +426,12 @@
          */
         if (draw_progressbar_forward != TRUE)
         {
-                video->primary_surface->SetColor (video->primary_surface,
+                video.primary_surface->SetColor (video.primary_surface,
                                                   127, 127, 127, 255);
         }
         else
         {
-                video->primary_surface->SetColor (video->primary_surface,
+                video.primary_surface->SetColor (video.primary_surface,
                                                   rectangle_red,
                                                   rectangle_green,
                                                   rectangle_blue,
@@ -409,12 +448,12 @@
 
 /*        IDirectFBSurface *_layer_surface;
 
-        DFBCHECK (video->primary_layer->
-                  GetSurface (video->primary_layer,
+        DFBCHECK (video.primary_layer->
+                  GetSurface (video.primary_layer,
                               &_layer_surface));
 
         _layer_surface->Blit(_layer_surface,
-                        video->primary_surface,
+                        video.primary_surface,
                         NULL, 0, 0);*/
 
         return 0;
@@ -426,7 +465,7 @@
  * update the progressbar in reverse
  */
 gint
-video_update_progressbar (splashy_video_t * video, gint perc)
+video_update_progressbar (gint perc)
 {
         /*
          * how many nanoseconds we sleep while updating the progress bar 
@@ -434,7 +473,7 @@
         struct timespec _progress_sleep;
         guint i = 0, _w = 0;
 
-        DFBRectangle * progressbar = &video->progressbar;
+        DFBRectangle * progressbar = &video.progressbar;
 
         DEBUG_PRINT ("video_update_progressbar(%d) called", perc);
         /*
@@ -442,7 +481,7 @@
          */
         if (perc < 0)
                 return 1;
-        if (video == NULL)
+        if (&video == NULL)
                 return 1;
         if (perc > 100)
                 return 0;
@@ -475,7 +514,7 @@
                  */
                 for (i = _last_x; i > _x; i--)
                 {
-                        video->primary_surface->FillRectangle (video->
+                        video.primary_surface->FillRectangle (video.
                                                                primary_surface,
                                                                i,
                                                                progressbar->y,
@@ -497,7 +536,7 @@
                  */
                 for (i = _last_w; i <= _w; i++)
                 {
-                        video->primary_surface->FillRectangle (video->
+                        video.primary_surface->FillRectangle (video.
                                                                primary_surface,
                                                                progressbar->x,
                                                                progressbar->y,
@@ -517,11 +556,11 @@
  * updates the progress bar without smoothing it out
  */
 gint
-video_update_progressbar_quick (splashy_video_t * video, gint perc)
+video_update_progressbar_quick (gint perc)
 {
         guint _w = 0;
 
-        DFBRectangle * progressbar = &video->progressbar;
+        DFBRectangle * progressbar = &video.progressbar;
 
         DEBUG_PRINT ("video_update_progressbar_quick(%d) called", perc);
         /*
@@ -529,7 +568,7 @@
          */
         if (perc < 0)
                 return 1;
-        if (video == NULL)
+        if (&video == NULL)
                 return 1;
         if (perc > 100)
                 return 0;
@@ -555,7 +594,7 @@
                 /*
                  * guint _x = progressbar->x + (progressbar->w - _w); 
                  */
-                video->primary_surface->FillRectangle (video->
+                video.primary_surface->FillRectangle (video.
                                                        primary_surface,
                                                        _w,
                                                        progressbar->y,
@@ -567,7 +606,7 @@
         }
         else
         {
-                video->primary_surface->FillRectangle (video->
+                video.primary_surface->FillRectangle (video.
                                                        primary_surface,
                                                        progressbar->x,
                                                        progressbar->y,
@@ -582,7 +621,7 @@
 static DFBEnumerationResult
 video_modes_callback (gint width, gint height, gint bpp, void *data)
 {
-        splashy_videomode_t *video = (splashy_videomode_t *) data;
+        splashy_videomode_t *video_m = (splashy_videomode_t *) data;
         gint overx = 0, overy = 0, closer = 0, over = 0;
         gint we_are_under = 0;
 
@@ -594,14 +633,14 @@
         DEBUG_PRINT ("%s", msg);
         g_free (msg);
 #endif
-        overx = width - video->out_width;
-        overy = height - video->out_height;
-        if (!video->width)
-        {
-                video->width = width;
-                video->height = height;
-                video->overx = overx;
-                video->overy = overy;
+        overx = width - video_m->out_width;
+        overy = height - video_m->out_height;
+        if (!video_m->width)
+        {
+                video_m->width = width;
+                video_m->height = height;
+                video_m->overx = overx;
+                video_m->overy = overy;
 #ifdef DEBUG
                 gchar *msg =
                         g_strdup_printf
@@ -611,20 +650,20 @@
                 g_free (msg);
 #endif
         }
-        if ((video->overy < 0) || (video->overx < 0))
+        if ((video_m->overy < 0) || (video_m->overx < 0))
                 we_are_under = 1;       /* stored mode is smaller than req
                                          * mode */
-        if (abs (overx * overy) < abs (video->overx * video->overy))
+        if (abs (overx * overy) < abs (video_m->overx * video_m->overy))
                 closer = 1;     /* current mode is closer to desired res */
         if ((overx >= 0) && (overy >= 0))
                 over = 1;       /* current mode is bigger or equaul to
                                  * desired res */
         if ((closer && (over || we_are_under)) || (we_are_under && over))
         {
-                video->width = width;
-                video->height = height;
-                video->overx = overx;
-                video->overy = overy;
+                video_m->width = width;
+                video_m->height = height;
+                video_m->overx = overx;
+                video_m->overy = overy;
 #ifdef DEBUG
                 gchar *msg =
                         g_strdup_printf
@@ -638,29 +677,29 @@
 }
 
 void
-video_set_mode (splashy_video_t * video)
+video_set_mode ()
 {
         /*
          * used to disable inputs from mouse and reduce overhead (about 15%
          * of CPU usage)
          */
         /*
-         * FIXME video->dfb->SetCooperativeLevel (video->dfb,
+         * FIXME video.dfb->SetCooperativeLevel (video.dfb,
          * DFSCL_FULLSCREEN); 
          */
-        video->primary_layer->SetCooperativeLevel (video->primary_layer,
+        video.primary_layer->SetCooperativeLevel (video.primary_layer,
                                                    DLSCL_EXCLUSIVE);
-        video->primary_layer->GetConfiguration (video->primary_layer,
-                                                &video->primary_layer_config);
+        video.primary_layer->GetConfiguration (video.primary_layer,
+                                                &video.primary_layer_config);
 
         DFBResult ret =
-                video->dfb->EnumVideoModes (video->dfb, video_modes_callback,
-                                            video->mode);
+                video.dfb->EnumVideoModes (video.dfb, video_modes_callback,
+                                            video.mode);
         if (ret)
         {
                 DEBUG_PRINT
                         ("%s: Error while detecting full screen video modes",
-                         "video->dfb->EnumVideoModes");
+                         "video.dfb->EnumVideoModes");
         }
         /*
          * http://directfb.org/docs/DirectFB_Reference/types.html#DFBSurfacePixelFormat 
@@ -669,26 +708,26 @@
         /*
          * DLCONF_WIDTH|DLCONF_HEIGHT|DLCONF_PIXELFORMAT|DLCONF_SURFACE_CAPS 
          */
-        video->primary_layer_config.width = video->mode->width;
-        video->primary_layer_config.height = video->mode->height;
+        video.primary_layer_config.width = video.mode->width;
+        video.primary_layer_config.height = video.mode->height;
         /*
-         * FIXME video->primary_layer_config.pixelformat = DSPF_ARGB; 
+         * FIXME video.primary_layer_config.pixelformat = DSPF_ARGB; 
          */
         /*
          * DLOP_ALPHACHANNEL|DLOP_OPACITY 
          */
 
-        ret = video->primary_layer->SetConfiguration (video->primary_layer,
-                                                      &video->
+        ret = video.primary_layer->SetConfiguration (video.primary_layer,
+                                                      &video.
                                                       primary_layer_config);
 
-        DEBUG_PRINT ("Set resolution for %s:", "video->dfb");
-        DEBUG_PRINT ("Width: %d", video->mode->width);
-        DEBUG_PRINT ("Height: %d", video->mode->height);
+        DEBUG_PRINT ("Set resolution for %s:", "video.dfb");
+        DEBUG_PRINT ("Width: %d", video.mode->width);
+        DEBUG_PRINT ("Height: %d", video.mode->height);
 }
 
 void
-video_start_splash (splashy_video_t * video, const gchar * background)
+video_start_splash (const gchar * background)
 {
         DFBSurfaceDescription desc;
         DFBWindowDescription win_desc;
@@ -714,24 +753,24 @@
         /* TODO too dangerous DirectFBSetOption ("block-all-signals", NULL); */
 
 
-        DFBCHECK (DirectFBCreate (&video->dfb));
+        DFBCHECK (DirectFBCreate (&video.dfb));
 
-        video->mode = g_new0 (splashy_videomode_t, 1);
+        video.mode = g_new0 (splashy_videomode_t, 1);
         /*
          * set our expectation to a very big number 
          */
         preinit (NULL);
-        video->mode->out_height = fb_vinfo.yres;
-        video->mode->out_width = fb_vinfo.xres;
+        video.mode->out_height = fb_vinfo.yres;
+        video.mode->out_width = fb_vinfo.xres;
 
         DEBUG_PRINT ("Setting min Width (x) resolution to %d",
-                     video->mode->out_width);
+                     video.mode->out_width);
         DEBUG_PRINT ("Setting min Height (y) resolution to %d",
-                     video->mode->out_height);
+                     video.mode->out_height);
 
-        DFBCHECK (video->dfb->CreateImageProvider (video->dfb, background,
-                                                   &video->provider));
-        DFBCHECK (video->provider->GetSurfaceDescription (video->provider,
+        DFBCHECK (video.dfb->CreateImageProvider (video.dfb, background,
+                                                   &video.provider));
+        DFBCHECK (video.provider->GetSurfaceDescription (video.provider,
                                                           &desc));
         /*
          * flags to set the default surface as main surface
@@ -743,9 +782,9 @@
          * store our primary layer as this will be use for setting the opacity
          * levels later
          */
-        DFBCHECK (video->dfb->GetDisplayLayer (video->dfb,
+        DFBCHECK (video.dfb->GetDisplayLayer (video.dfb,
                                                DLID_PRIMARY,
-                                               &video->primary_layer));
+                                               &video.primary_layer));
 
         /*
          * we need to call this after primary_layer was set. @see video_set_mode()
@@ -756,30 +795,30 @@
          * get our primary_surface, this will hold the progressbar, textbox
          * and others
          */
-        DFBCHECK (video->primary_layer->
-                  GetSurface (video->primary_layer,
-                              &video->primary_surface));
+        DFBCHECK (video.primary_layer->
+                  GetSurface (video.primary_layer,
+                              &video.primary_surface));
 
         win_desc.flags = (DWDESC_POSX | DWDESC_POSY |
                           DWDESC_WIDTH | DWDESC_HEIGHT);
         win_desc.posx = 0;
         win_desc.posy = 0;
-        win_desc.width = video->mode->out_width;
-        win_desc.height = video->mode->out_height;
+        win_desc.width = video.mode->out_width;
+        win_desc.height = video.mode->out_height;
         /* TODO do we really need this? win_desc.caps = DWCAPS_ALPHACHANNEL; */
 
-        DFBCHECK (video->primary_layer->CreateWindow (video->primary_layer,
+        DFBCHECK (video.primary_layer->CreateWindow (video.primary_layer,
                                                       &win_desc,
-                                                      &video->
+                                                      &video.
                                                       primary_window));
         
-        DFBCHECK (video->primary_window->
-                  GetSurface (video->primary_window,
-                              &video->primary_window_surface));
+        DFBCHECK (video.primary_window->
+                  GetSurface (video.primary_window,
+                              &video.primary_window_surface));
 
         if (g_ascii_strncasecmp
             (xml_parser_get_text ("/splashy/fadein"), "yes", 3) == 0)
-                video->primary_window->SetOpacity (video->primary_window,
+                video.primary_window->SetOpacity (video.primary_window,
                                                    0x0);
 
         /*
@@ -789,16 +828,16 @@
          * above
          */
         /*
-         * DFBCHECK (video->primary_surface->SetBlittingFlags
-         * (video->primary_surface, DSBLIT_BLEND_ALPHACHANNEL));
+         * DFBCHECK (video.primary_surface->SetBlittingFlags
+         * (video.primary_surface, DSBLIT_BLEND_ALPHACHANNEL));
          */
 
         /*
          * it writes on the framebuffer the background image
          */
-        video->provider->RenderTo (video->provider, video->primary_window_surface,
+        video.provider->RenderTo (video.provider, video.primary_window_surface,
                                    NULL);
-        video->provider->RenderTo (video->provider, video->primary_surface,
+        video.provider->RenderTo (video.provider, video.primary_surface,
                                    NULL);
 
         /*
@@ -812,22 +851,22 @@
 }
 
 void
-video_stop_splash (splashy_video_t * video)
+video_stop_splash ()
 {
         /*
          * free up memory 
          */
         /* TODO Do we need to check if keyboard and ev_buffer were init'd ?*/
-        video->ev_buffer->Release (video->ev_buffer);     /* input buffer */
-        video->keyboard->Release (video->keyboard);       /* keyevents gone */
-        video->primary_surface->Release (video->primary_surface); /* pix holder 
+        video.ev_buffer->Release (video.ev_buffer);     /* input buffer */
+        video.keyboard->Release (video.keyboard);       /* keyevents gone */
+        video.primary_surface->Release (video.primary_surface); /* pix holder 
                                                                  */
-        video->primary_window->Release (video->primary_window);
-        video->dfb->Release (video->dfb); /* kill it ! */
+        video.primary_window->Release (video.primary_window);
+        video.dfb->Release (video.dfb); /* kill it ! */
 }
 
 void
-video_create_event_buffer (splashy_video_t * video)
+video_create_event_buffer ()
 {
         /*
          * setup our main input: keyboard 
@@ -837,30 +876,30 @@
          * ? We should make sure splashy can't be launched twice from this
          * same thread 
          */
-        DFBCHECK (video->dfb->
-                  GetInputDevice (video->dfb, DIDID_KEYBOARD,
-                                  &video->keyboard));
+        DFBCHECK (video.dfb->
+                  GetInputDevice (video.dfb, DIDID_KEYBOARD,
+                                  &video.keyboard));
         /*
          * create event buffer for the keyboard: to listen for events 
          */
-        DFBCHECK (video->keyboard->
-                  CreateEventBuffer (video->keyboard, &video->ev_buffer));
+        DFBCHECK (video.keyboard->
+                  CreateEventBuffer (video.keyboard, &video.ev_buffer));
 }
 
 void
-video_wait_for_event (splashy_video_t * video)
+video_wait_for_event ()
 {
         /* TODO Do some checks here first? */
-        DFBCHECK (video->ev_buffer->WaitForEvent (video->ev_buffer));
+        DFBCHECK (video.ev_buffer->WaitForEvent (video.ev_buffer));
 }
 
 int
-video_get_key_event (splashy_video_t * video, int *key_id)
+video_get_key_event (int *key_id)
 {
         DFBInputEvent DFBevent;
         
-        while (video->ev_buffer->HasEvent (video->ev_buffer) == DFB_OK
-                       && video->ev_buffer->GetEvent (video->ev_buffer,
+        while (video.ev_buffer->HasEvent (video.ev_buffer) == DFB_OK
+                       && video.ev_buffer->GetEvent (video.ev_buffer,
                                                      DFB_EVENT (&DFBevent)) ==
                        DFB_OK) 
         {
@@ -874,12 +913,11 @@
 }
 
 void
-video_change_splash (splashy_video_t * video,
-                     const gchar * newimage)
+video_change_splash (const gchar * newimage)
 {
-        video->dfb->CreateImageProvider (video->dfb, newimage,
-                                         &video->provider);
-        video->provider->RenderTo (video->provider, video->primary_surface,
+        video.dfb->CreateImageProvider (video.dfb, newimage,
+                                         &video.provider);
+        video.provider->RenderTo (video.provider, video.primary_surface,
                                    NULL);
         /*
          * restore progressbar 
@@ -891,8 +929,7 @@
                 {
                         DEBUG_PRINT ("Restoring progressbar to %d ticks\n",
                                      _last_progress);
-                        video_update_progressbar_quick (video,
-                                                        _last_progress);
+                        video_update_progressbar_quick (_last_progress);
                 }
         }
         _current_background = newimage;
@@ -914,19 +951,19 @@
  * helper for video_fade_in/out()
  */
 static void
-_window_fade (splashy_video_t * win, __u8 opacity, long ms_duration)
+_window_fade (__u8 opacity, long ms_duration)
 {
         long t1, t2;
         int diff;
         /*
          * IDirectFBDisplayLayer *layer = win->primary_layer;
          */
-        IDirectFBWindow *window = win->primary_window;
+        IDirectFBWindow *window = video.primary_window;
 
         /*
          * Retrieve its current opacity. 
          */
-        window->GetOpacity (window, &win->opacity);
+        window->GetOpacity (window, &video.opacity);
 
         /*
          * TODO how do we know the current opacity level 
@@ -941,7 +978,7 @@
         /*
          * Calculate the opacity difference. 
          */
-        diff = opacity - win->opacity;
+        diff = opacity - video.opacity;
         /*
          * fprintf(stderr,"diff %d\n",diff); 
          */
@@ -958,7 +995,7 @@
                 /*
                  * Calculate an intermediate opacity. 
                  */
-                __u8 op = win->opacity + ((t2 - t1 + 1) * diff / ms_duration);
+                __u8 op = video.opacity + ((t2 - t1 + 1) * diff / ms_duration);
                 /*
                  * fprintf(stderr,"op %d\n",op); 
                  */
@@ -988,25 +1025,25 @@
  * @param video main video holding our primary window
  */
 void
-video_fade_in (splashy_video_t * video)
+video_fade_in ()
 {
         /*
          * fprintf(stderr,"video_fade_in called %s\n",""); 
          */
 
-        IDirectFBWindow *window = video->primary_window;
+        IDirectFBWindow *window = video.primary_window;
         /*
          * start from almost black 
          */
         window->SetOpacity (window, 1);
 
-        _window_fade (video, 255, 1000);
+        _window_fade (255, 1000);
 
         /*
          * Set the exact opacity. 
          */
         window->SetOpacity (window, 255);
-        video->opacity = 255;
+        video.opacity = 255;
 }
 
 /**
@@ -1016,25 +1053,25 @@
  * @param video main video holding our primary window
  */
 void
-video_fade_out (splashy_video_t * video)
+video_fade_out ()
 {
         /*
          * fprintf(stderr,"video_fade_out called %s\n","");
          */
 
-        IDirectFBWindow *window = video->primary_window;
+        IDirectFBWindow *window = video.primary_window;
         /*
          * start from fully opaque 
          */
         window->SetOpacity (window, 255);
 
-        _window_fade (video, 0, 1000);
+        _window_fade (0, 1000);
 
         /*
          * Set the exact opacity. 
          */
         window->SetOpacity (window, 0);
-        video->opacity = 0;
+        video.opacity = 0;
 }
 
 /**
@@ -1042,10 +1079,10 @@
  */
 
 void
-video_clear_offscreen (splashy_video_t * video)
+video_clear_offscreen ()
 {
         gint red, green, blue, alpha;
-        if (video->textbox == NULL)
+        if (video.textbox == NULL)
                 return;
         /*
          * TODO later we will need to add textbox border support here: const
@@ -1067,31 +1104,31 @@
         /*
          * copy the "clean" surface from our primary surface to offscreen 
          */
-        video_change_splash (video, _current_background);
+        video_change_splash (_current_background);
 
         /*
          * now we need to flip these surfaces so that the background tint
          * gets displayed correctly 
          */
-        video->textbox->offscreen->Blit (video->textbox->offscreen,
-                                         video->primary_surface,
-                                         &video->textbox->area, 0, 0);
-
-        video->textbox->offscreen->Blit (video->primary_surface,
-                                         video->textbox->offscreen,
-                                         &video->textbox->area, 0, 0);
+        video.textbox->offscreen->Blit (video.textbox->offscreen,
+                                         video.primary_surface,
+                                         &video.textbox->area, 0, 0);
+
+        video.textbox->offscreen->Blit (video.primary_surface,
+                                         video.textbox->offscreen,
+                                         &video.textbox->area, 0, 0);
 
         /*
          * Tint the box in the off-screen surface 
          */
-        video->textbox->offscreen->SetDrawingFlags (video->textbox->offscreen,
+        video.textbox->offscreen->SetDrawingFlags (video.textbox->offscreen,
                                                     DSDRAW_BLEND);
-        video->textbox->offscreen->SetColor (video->textbox->offscreen, red,
+        video.textbox->offscreen->SetColor (video.textbox->offscreen, red,
                                              green, blue, alpha);
-        video->textbox->offscreen->FillRectangle (video->textbox->offscreen,
+        video.textbox->offscreen->FillRectangle (video.textbox->offscreen,
                                                   0, 0,
-                                                  video->textbox->area.w,
-                                                  video->textbox->area.h);
+                                                  video.textbox->area.w,
+                                                  video.textbox->area.h);
 }
 
 /**
@@ -1100,7 +1137,7 @@
 * @return
 */
 void
-video_start_text_area (splashy_video_t * video)
+video_start_text_area ()
 {
         gint divider_w, divider_h;
         gint screen_width, screen_height;
@@ -1119,53 +1156,53 @@
         if (g_ascii_strncasecmp (enable, "yes", 3) != 0)
                 return;
 
-        video->primary_surface->GetSize (video->primary_surface,
+        video.primary_surface->GetSize (video.primary_surface,
                                          &screen_width, &screen_height);
-        video_get_divider (video, &divider_w, &divider_h);
+        video_get_divider (&divider_w, &divider_h);
 
-        video->textbox = g_new0 (splashy_textbox_t, 1);
+        video.textbox = g_new0 (splashy_textbox_t, 1);
 
         /*
          * Set some defaults so that there are no divide by zeroes if the
          * checks below fail 
          */
-        video->textbox->area.x = video->textbox->area.w = divider_w / 4;
-        video->textbox->area.y = video->textbox->area.h = divider_h / 4;
+        video.textbox->area.x = video.textbox->area.w = divider_w / 4;
+        video.textbox->area.y = video.textbox->area.h = divider_h / 4;
 
         /*
          * Read in the text box dimensions 
          */
         temp = xml_parser_get_int ("/splashy/textbox/dimension/x", 10);
         if (temp >= 0 && temp < divider_w)
-                video->textbox->area.x = temp * screen_width / divider_w;
+                video.textbox->area.x = temp * screen_width / divider_w;
 
         temp = xml_parser_get_int ("/splashy/textbox/dimension/y", 10);
         if (temp >= 0 && temp < divider_h)
-                video->textbox->area.y = temp * screen_height / divider_h;
+                video.textbox->area.y = temp * screen_height / divider_h;
 
         temp = xml_parser_get_int ("/splashy/textbox/dimension/width", 10);
         if (temp > 0 && temp <= divider_w)
-                video->textbox->area.w = temp * screen_width / divider_w;
+                video.textbox->area.w = temp * screen_width / divider_w;
 
         temp = xml_parser_get_int ("/splashy/textbox/dimension/height", 10);
         if (temp > 0 && temp <= divider_h)
-                video->textbox->area.h = temp * screen_height / divider_h;
+                video.textbox->area.h = temp * screen_height / divider_h;
 
-        video->textbox->desc.width = video->textbox->area.w;
-        video->textbox->desc.height = video->textbox->area.h;
-        video->textbox->desc.caps = DSCAPS_SYSTEMONLY;  // Only in system
+        video.textbox->desc.width = video.textbox->area.w;
+        video.textbox->desc.height = video.textbox->area.h;
+        video.textbox->desc.caps = DSCAPS_SYSTEMONLY;  // Only in system
         // memory
-        video->textbox->desc.flags =
+        video.textbox->desc.flags =
                 DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT;
 
         /*
          * Grab the textbox area to a seperate surface 
          */
-        video->dfb->CreateSurface (video->dfb, &video->textbox->desc,
-                                   &video->textbox->offscreen);
-        video->textbox->offscreen->Blit (video->textbox->offscreen,
-                                         video->primary_surface,
-                                         &video->textbox->area, 0, 0);
+        video.dfb->CreateSurface (video.dfb, &video.textbox->desc,
+                                   &video.textbox->offscreen);
+        video.textbox->offscreen->Blit (video.textbox->offscreen,
+                                         video.primary_surface,
+                                         &video.textbox->area, 0, 0);
 
         /*
          * clear the offscreen surface and set the drawing flags
@@ -1188,29 +1225,29 @@
         /*
          * Establish the subsurface to which we print 
          */
-        video->primary_surface->GetSubSurface (video->primary_surface,
-                                               &video->textbox->area,
-                                               &video->textbox->surface);
-        video->textbox->surface->SetColor (video->textbox->surface, red,
+        video.primary_surface->GetSubSurface (video.primary_surface,
+                                               &video.textbox->area,
+                                               &video.textbox->surface);
+        video.textbox->surface->SetColor (video.textbox->surface, red,
                                            green, blue, 255);
 
         /*
          * Initialize the font 
          */
-        video->textbox->fontdesc.flags = DFDESC_HEIGHT;
+        video.textbox->fontdesc.flags = DFDESC_HEIGHT;
         fontface = xml_parser_get_text ("/splashy/textbox/text/font/file");
         temp = xml_parser_get_int ("/splashy/textbox/text/font/size", 10);
-        video->textbox->fontdesc.height = temp * screen_height / divider_h;
-        video->dfb->CreateFont (video->dfb, fontface,
-                                &video->textbox->fontdesc, &font);
+        video.textbox->fontdesc.height = temp * screen_height / divider_h;
+        video.dfb->CreateFont (video.dfb, fontface,
+                                &video.textbox->fontdesc, &font);
         if (font == NULL)
-                video->dfb->CreateFont (video->dfb, NULL, NULL, &font);
-        video->textbox->surface->SetFont (video->textbox->surface, font);
+                video.dfb->CreateFont (video.dfb, NULL, NULL, &font);
+        video.textbox->surface->SetFont (video.textbox->surface, font);
 
         /*
          * Set the position of the text line
          */
-        last_text_y_position = abs (video->textbox->fontdesc.height);
+        last_text_y_position = abs (video.textbox->fontdesc.height);
 }
 
 /**
@@ -1219,9 +1256,9 @@
  * @return
  */
 void
-video_printline (splashy_video_t * video, gchar * string)
+video_printline (gchar * string)
 {
-        if (video->textbox == NULL)
+        if (video.textbox == NULL)
                 return;
 
         /*
@@ -1238,17 +1275,17 @@
         /*
          * Copy the textbox background from off-screen surface 
          */
-        video->textbox->offscreen->Blit (video->textbox->surface,
-                                         video->textbox->offscreen,
+        video.textbox->offscreen->Blit (video.textbox->surface,
+                                         video.textbox->offscreen,
                                          NULL, 0, 0);
 
         /*
          * Draw string to the clipped surface 
          */
-        video->textbox->surface->DrawString (video->textbox->surface, string,
-                                             -1, video->textbox->area.w / 2,
-                                             (video->textbox->area.h / 2) +
-                                             (video->textbox->fontdesc.
+        video.textbox->surface->DrawString (video.textbox->surface, string,
+                                             -1, video.textbox->area.w / 2,
+                                             (video.textbox->area.h / 2) +
+                                             (video.textbox->fontdesc.
                                               height / 2),
                                              DSTF_CENTER | DSTF_BOTTOM);
 }
@@ -1259,9 +1296,9 @@
  * @return
  */
 void
-video_printline_s (splashy_video_t * video, gchar * string)
+video_printline_s (gchar * string)
 {
-        if (video->textbox == NULL)
+        if (video.textbox == NULL)
                 return;
 
         /*
@@ -1273,8 +1310,8 @@
          * offscreen. which makes the background darker and darker...
          */
         if (last_text_y_position >=
-            (video->textbox->area.h -
-             abs (video->textbox->fontdesc.height * 2)))
+            (video.textbox->area.h -
+             abs (video.textbox->fontdesc.height * 2)))
         {
                 video_clear_offscreen (video);
                 last_text_y_position = 0;
@@ -1282,26 +1319,26 @@
         /*
          * Copy the textbox background from off-screen surface 
          */
-        video->textbox->offscreen->Blit (video->textbox->surface,
-                                         video->textbox->offscreen,
+        video.textbox->offscreen->Blit (video.textbox->surface,
+                                         video.textbox->offscreen,
                                          NULL, 0, 0);
 
-        last_text_y_position += abs (video->textbox->fontdesc.height * 2);
+        last_text_y_position += abs (video.textbox->fontdesc.height * 2);
 
         /*
          * Draw string to the clipped surface 
          */
-        video->textbox->surface->DrawString (video->textbox->surface, string,
+        video.textbox->surface->DrawString (video.textbox->surface, string,
                                              -1, 4,
                                              last_text_y_position, DSTF_LEFT);
         /*
          * Save the textbox background to off-screen surface 
          * Note, we clean, blend and save
          */
-        video->textbox->offscreen->Blit (video->textbox->offscreen,
-                                         video->primary_surface,
-                                         &video->textbox->area, 0, 0);
-        video->primary_surface->Blit (video->textbox->offscreen,
-                                      video->textbox->surface, NULL, 0, 0);
+        video.textbox->offscreen->Blit (video.textbox->offscreen,
+                                         video.primary_surface,
+                                         &video.textbox->area, 0, 0);
+        video.primary_surface->Blit (video.textbox->offscreen,
+                                      video.textbox->surface, NULL, 0, 0);
 
 }
diff -u splashy_video.h splashy_video.h
--- splashy_video.h	2006-08-12 14:20:00.000000000 +0200
+++ splashy_video.h	2006-08-12 14:01:20.000000000 +0200
@@ -21,84 +21,43 @@
 #define _video_H
 
 #include <glib.h>
-#include <directfb.h>
-
-typedef struct splashy_videomode_s
-{
-        gint width;
-        gint height;
-        gint out_width;
-        gint out_height;
-        gint overx;
-        gint overy;
-        gint bpp;
-} splashy_videomode_t;
-
-typedef struct
-{
-        gboolean enabled;
-        IDirectFBSurface *offscreen;    /** off-screen storage */
-        IDirectFBSurface *surface;      /** Subsurface to draw text on */
-        DFBSurfaceDescription desc;
-        DFBRectangle area;
-        DFBFontDescription fontdesc;
-} splashy_textbox_t;
-
-typedef struct
-{
-        IDirectFB *dfb;                         /** our directfb object */
-        IDirectFBImageProvider *provider;       /** our image class */
-        IDirectFBWindow *primary_window;        /** our main window. where opacity takes place */
-        IDirectFBSurface *primary_window_surface; /** interface to window's surface */
-
-        IDirectFBDisplayLayer *primary_layer;   /** interface to our layer */
-        DFBDisplayLayerConfig  primary_layer_config; /** configuration for our primary_layer */
-        IDirectFBSurface *primary_surface;      /** our main background */
-        IDirectFBInputDevice *keyboard;         /** our main input dev */
-        IDirectFBEventBuffer *ev_buffer;        /** our events listener */
-        splashy_videomode_t *mode;              /** video mode supported by surface */
-        splashy_textbox_t *textbox;             /** text box parameters */
-        DFBRectangle progressbar;               /** our progressbar */
-        __u8 opacity;                           /** current opacity level */
-} splashy_video_t;
 
 /*
  * public functions 
  */
-void
-video_reset_progressbar_counters();
+void video_reset_progressbar_counters();
 void video_set_progressbar_forward(gboolean go_forward);
-gint video_draw_progressbar (splashy_video_t * video);
-gint video_update_progressbar (splashy_video_t * video, gint perc);
-void video_start_splash (splashy_video_t * video, const gchar * background);
-void video_change_splash (splashy_video_t * video, const gchar * newimage);
-void video_start_text_area (splashy_video_t * video);
-void video_set_mode (splashy_video_t * video);
+gint video_draw_progressbar ();
+gint video_update_progressbar (gint perc);
+void video_start_splash (const gchar * background);
+void video_change_splash (const gchar * newimage);
+void video_start_text_area ();
+void video_set_mode ();
 void video_allow_vt_switching ();
 /*
  * allows to print a single message to the center of the textbox area
  * reseting the old one
  */
-void video_printline (splashy_video_t * video, gchar * string);
+void video_printline (gchar * string);
 /*
  * allows to print a message appended to the end of the textbox area
  * keeping the old one
  */
-void video_printline_s (splashy_video_t * video, gchar * string);
+void video_printline_s (gchar * string);
 /* 
  * write data to our textbox the right way. it uses video_printline_s() to do
  * the actual writing. @see verbose_text_loop() in splashy_functions.c
  */
-void video_writelog (splashy_video_t * video, unsigned char *ptr, 
+void video_writelog (unsigned char *ptr, 
                 gint len, char *ringbuf, char *outptr, char *endptr);
 
-void video_fade_in (splashy_video_t * video);
-void video_fade_out (splashy_video_t * video);
+void video_fade_in ();
+void video_fade_out ();
 
-void video_stop_splash (splashy_video_t * video);
+void video_stop_splash ();
 
-void video_create_event_buffer (splashy_video_t * video);
-void video_wait_for_event (splashy_video_t * video);
-int video_get_key_event (splashy_video_t * video, int * key_id);
+void video_create_event_buffer ();
+void video_wait_for_event ();
+int video_get_key_event (int * key_id);
 
 #endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/splashy-devel/attachments/20060812/d5f6489b/signature-0001.pgp


More information about the Splashy-devel mailing list