[vlc-commits] vout: caca: refactor for next changes

Thomas Guillem git at videolan.org
Tue Nov 27 15:48:58 CET 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Sun Oct 28 16:02:27 2018 +0100| [fd1d7eb90a42859b55c08f16e71ee16a62ac60ca] | committer: Steve Lhomme

vout: caca: refactor for next changes

vd->fmt and vd->cfg will be removed.
fmt and cfg will be passed by Open() and controls.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fd1d7eb90a42859b55c08f16e71ee16a62ac60ca
---

 modules/video_output/caca.c | 54 ++++++++++++++++++++++++---------------------
 1 file changed, 29 insertions(+), 25 deletions(-)

diff --git a/modules/video_output/caca.c b/modules/video_output/caca.c
index faadda7fcf..e92a7bce31 100644
--- a/modules/video_output/caca.c
+++ b/modules/video_output/caca.c
@@ -56,6 +56,8 @@ struct vout_display_sys_t {
     picture_pool_t *pool;
     block_fifo_t *fifo;
     vlc_thread_t thread;
+    vout_window_t *window;
+    vout_display_place_t place;
 
     vlc_tick_t cursor_timeout;
     vlc_tick_t cursor_deadline;
@@ -75,7 +77,7 @@ noreturn static void *VoutDisplayEventKeyDispatch(void *data)
 
         memcpy(&key, event->p_buffer, sizeof (key));
         block_Release(event);
-        vout_window_ReportKeyPress(vd->cfg->window, key);
+        vout_window_ReportKeyPress(sys->window, key);
         vlc_restorecancel(cancel);
     }
 }
@@ -104,11 +106,11 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
 /**
  * Compute the place in canvas unit.
  */
-static void Place(vout_display_t *vd, vout_display_place_t *place)
+static void Place(vout_display_t *vd, const vout_display_cfg_t *cfg)
 {
     vout_display_sys_t *sys = vd->sys;
 
-    vout_display_PlacePicture(place, &vd->source, vd->cfg, false);
+    vout_display_PlacePicture(&sys->place, &vd->source, cfg, false);
 
     const int canvas_width   = cucul_get_canvas_width(sys->cv);
     const int canvas_height  = cucul_get_canvas_height(sys->cv);
@@ -116,15 +118,15 @@ static void Place(vout_display_t *vd, vout_display_place_t *place)
     const int display_height = caca_get_display_height(sys->dp);
 
     if (display_width > 0 && display_height > 0) {
-        place->x      =  place->x      * canvas_width  / display_width;
-        place->y      =  place->y      * canvas_height / display_height;
-        place->width  = (place->width  * canvas_width  + display_width/2)  / display_width;
-        place->height = (place->height * canvas_height + display_height/2) / display_height;
+        sys->place.x      =  sys->place.x      * canvas_width  / display_width;
+        sys->place.y      =  sys->place.y      * canvas_height / display_height;
+        sys->place.width  = (sys->place.width  * canvas_width  + display_width/2)  / display_width;
+        sys->place.height = (sys->place.height * canvas_height + display_height/2) / display_height;
     } else {
-        place->x = 0;
-        place->y = 0;
-        place->width  = canvas_width;
-        place->height = display_height;
+        sys->place.x = 0;
+        sys->place.y = 0;
+        sys->place.width  = canvas_width;
+        sys->place.height = display_height;
     }
 }
 
@@ -146,9 +148,9 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
                                             vd->source.i_visible_width,
                                             vd->source.i_visible_height,
                                             picture->p[0].i_pitch,
-                                            vd->fmt.i_rmask,
-                                            vd->fmt.i_gmask,
-                                            vd->fmt.i_bmask,
+                                            picture->format.i_rmask,
+                                            picture->format.i_gmask,
+                                            picture->format.i_bmask,
                                             0x00000000);
 
         if (!sys->dither) {
@@ -157,16 +159,13 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
         }
     }
 
-    vout_display_place_t place;
-    Place(vd, &place);
-
     cucul_set_color_ansi(sys->cv, CUCUL_COLOR_DEFAULT, CUCUL_COLOR_BLACK);
     cucul_clear_canvas(sys->cv);
 
     const int crop_offset = vd->source.i_y_offset * picture->p->i_pitch +
                             vd->source.i_x_offset * picture->p->i_pixel_pitch;
-    cucul_dither_bitmap(sys->cv, place.x, place.y,
-                        place.width, place.height,
+    cucul_dither_bitmap(sys->cv, sys->place.x, sys->place.y,
+                        sys->place.width, sys->place.height,
                         sys->dither,
                         &picture->p->p_pixels[crop_offset]);
     VLC_UNUSED(subpicture);
@@ -334,7 +333,7 @@ static void Manage(vout_display_t *vd)
         case CACA_EVENT_MOUSE_MOTION:
             caca_set_mouse(sys->dp, 1);
             sys->cursor_deadline = vlc_tick_now() + sys->cursor_timeout;
-            vout_window_ReportMouseMoved(vd->cfg->window,
+            vout_window_ReportMouseMoved(sys->window,
                                          caca_get_event_mouse_x(&ev),
                                          caca_get_event_mouse_y(&ev));
             break;
@@ -347,10 +346,10 @@ static void Manage(vout_display_t *vd)
             for (int i = 0; mouses[i].caca != -1; i++) {
                 if (mouses[i].caca == caca) {
                     if (caca_get_event_type(&ev) == CACA_EVENT_MOUSE_PRESS)
-                        vout_window_ReportMousePressed(vd->cfg->window,
+                        vout_window_ReportMousePressed(sys->window,
                                                        mouses[i].vlc);
                     else
-                        vout_window_ReportMouseReleased(vd->cfg->window,
+                        vout_window_ReportMouseReleased(sys->window,
                                                         mouses[i].vlc);
                     return;
                 }
@@ -358,7 +357,7 @@ static void Manage(vout_display_t *vd)
             break;
         }
         case CACA_EVENT_QUIT:
-            vout_window_ReportClose(vd->cfg->window);
+            vout_window_ReportClose(sys->window);
             break;
         default:
             break;
@@ -372,6 +371,8 @@ static void Manage(vout_display_t *vd)
 static int Open(vlc_object_t *object)
 {
     vout_display_t *vd = (vout_display_t *)object;
+    const vout_display_cfg_t *cfg = vd->cfg;
+    video_format_t *fmtp = &vd->fmt;
     vout_display_sys_t *sys;
 
     if (vout_display_IsWindowed(vd))
@@ -443,6 +444,7 @@ static int Open(vlc_object_t *object)
         goto error;
     }
 
+    sys->window = cfg->window;
     const char *driver = NULL;
 #ifdef __APPLE__
     // Make sure we don't try to open a window.
@@ -475,7 +477,7 @@ static int Open(vlc_object_t *object)
     sys->cursor_deadline = INVALID_DEADLINE;
 
     /* Fix format */
-    video_format_t fmt = vd->fmt;
+    video_format_t fmt = *fmtp;
     if (fmt.i_chroma != VLC_CODEC_RGB32) {
         fmt.i_chroma = VLC_CODEC_RGB32;
         fmt.i_rmask = 0x00ff0000;
@@ -484,7 +486,7 @@ static int Open(vlc_object_t *object)
     }
 
     /* Setup vout_display now that everything is fine */
-    vd->fmt = fmt;
+    *fmtp = fmt;
 
     vd->pool    = Pool;
     vd->prepare = Prepare;
@@ -494,6 +496,8 @@ static int Open(vlc_object_t *object)
     /* Fix initial state */
     caca_refresh_display(sys->dp);
 
+    Place(vd, cfg);
+
     return VLC_SUCCESS;
 
 error:



More information about the vlc-commits mailing list