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

Tim Dijkstra newsuser at famdijkstra.org
Sat Aug 12 22:40:38 UTC 2006


[4/6 was to big for the list]
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_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);
 
 }
-------------- 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/20060813/31466796/signature-0001.pgp


More information about the Splashy-devel mailing list