[vlc-devel] [PATCH 35/41] vout:win32: only mark the output size changed when it actually changed

Steve Lhomme robux4 at ycbcr.xyz
Fri Mar 22 16:14:13 CET 2019


---
 modules/video_output/win32/common.c    | 21 ++++++++++++++-------
 modules/video_output/win32/common.h    |  2 +-
 modules/video_output/win32/direct3d9.c |  4 ++--
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/modules/video_output/win32/common.c b/modules/video_output/win32/common.c
index 40625c218d..e59a1f95f6 100644
--- a/modules/video_output/win32/common.c
+++ b/modules/video_output/win32/common.c
@@ -54,7 +54,13 @@ static bool GetRect(const vout_display_sys_win32_t *sys, RECT *out)
     return GetClientRect(sys->hwnd, out);
 }
 #else /* VLC_WINSTORE_APP */
-static BOOL SetRectEmpty(RECT *rect)
+static inline BOOL EqualRect(const RECT *r1, const RECT *r2)
+{
+    return r1->left == r2->left && r1->right == r2->right &&
+            r1->top == r2->top && r1->bottom == r2->bottom;
+}
+
+static inline BOOL SetRectEmpty(RECT *rect)
 {
     rect->left = rect->right = rect->top = rect->bottom = 0;
     return TRUE;
@@ -63,7 +69,7 @@ static BOOL SetRectEmpty(RECT *rect)
 
 static void InitArea(display_win32_area_t *sys, const vout_display_cfg_t *vdcfg)
 {
-    sys->changes   = 0;
+    sys->rect_dest_changed = false;
     SetRectEmpty(&sys->rect_display);
     sys->vdcfg = *vdcfg;
 }
@@ -209,6 +215,7 @@ static void UpdateRectsInternal(vout_display_t *vd, vout_display_sys_win32_t *sy
 #endif
 
 #define rect_dest           sys->area.rect_dest
+    RECT before_rect_dest = rect_dest;
     /* Destination image position and dimensions */
 #if (defined(MODULE_NAME_IS_direct3d9) || defined(MODULE_NAME_IS_direct3d11)) && !VLC_WINSTORE_APP
     rect_dest.left = 0;
@@ -222,6 +229,10 @@ static void UpdateRectsInternal(vout_display_t *vd, vout_display_sys_win32_t *sy
     rect_dest.bottom = rect_dest.top + place.height;
 #endif
 
+    /* Signal the change in size/position */
+    if (!EqualRect(&before_rect_dest, &rect_dest))
+        sys->area.rect_dest_changed |= true;
+
 #ifndef NDEBUG
     msg_Dbg(vd, "DirectXUpdateRects source"
         " offset: %i,%i visible: %ix%i decoded: %ix%i",
@@ -233,15 +244,11 @@ static void UpdateRectsInternal(vout_display_t *vd, vout_display_sys_win32_t *sy
         rect_dest.left, rect_dest.top,
         rect_dest.right, rect_dest.bottom);
 #endif
+#undef rect_dest
 
 #if !VLC_WINSTORE_APP
     CommonChangeThumbnailClip(VLC_OBJECT(vd), sys, true);
 #endif
-
-    /* Signal the change in size/position */
-    sys->area.changes |= DX_POSITION_CHANGE;
-
-#undef rect_dest
 }
 
 void UpdateRects(vout_display_t *vd, vout_display_sys_win32_t *sys)
diff --git a/modules/video_output/win32/common.h b/modules/video_output/win32/common.h
index 16ffbc52eb..964637ab2e 100644
--- a/modules/video_output/win32/common.h
+++ b/modules/video_output/win32/common.h
@@ -32,7 +32,7 @@ typedef struct display_win32_area_t
     /* size of the display */
     RECT         rect_display;
 
-    unsigned changes;        /* changes made to the video display */
+    bool         rect_dest_changed;
 
     /* Coordinates of dest images (used when blitting to display) */
     RECT         rect_dest;
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 45cb1d041f..5a5c382b6b 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -934,7 +934,7 @@ static void Manage (vout_display_t *vd)
         UpdateDesktopMode(vd);
 
     /* Position Change */
-    if (sys->sys.area.changes & DX_POSITION_CHANGE) {
+    if (sys->sys.area.rect_dest_changed) {
 #if 0 /* need that when bicubic filter is available */
         RECT rect;
         UINT width, height;
@@ -952,7 +952,7 @@ static void Manage (vout_display_t *vd)
         }
 #endif
         sys->clear_scene = true;
-        sys->sys.area.changes &= ~DX_POSITION_CHANGE;
+        sys->sys.area.rect_dest_changed = false;
     }
 }
 
-- 
2.17.1



More information about the vlc-devel mailing list