[vlc-commits] vout:win32: simplify the code to detect size changes
Steve Lhomme
git at videolan.org
Mon Apr 1 16:50:06 CEST 2019
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Mar 25 11:51:42 2019 +0100| [9effcbbd7b29e435794e1e7c4523886f15123deb] | committer: Steve Lhomme
vout:win32: simplify the code to detect size changes
We don't care if the position has changed. Only DirectDraw had this requirement.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9effcbbd7b29e435794e1e7c4523886f15123deb
---
modules/video_output/win32/common.c | 30 ++++++++++++------------------
modules/video_output/win32/common.h | 6 ++----
modules/video_output/win32/events.c | 4 +---
modules/video_output/win32/events.h | 2 +-
4 files changed, 16 insertions(+), 26 deletions(-)
diff --git a/modules/video_output/win32/common.c b/modules/video_output/win32/common.c
index 52b2ed0c7a..b02a66a8a1 100644
--- a/modules/video_output/win32/common.c
+++ b/modules/video_output/win32/common.c
@@ -84,16 +84,16 @@ int CommonInit(vout_display_t *vd, vout_display_sys_win32_t *sys, bool b_windowl
sys->b_windowless = b_windowless;
sys->is_first_placement = true;
sys->is_on_top = false;
+ sys->display_width = 0;
+ sys->display_height = 0;
sys->pf_GetDisplayDimensions = GetExternalDimensions;
sys->opaque_dimensions = vd;
+#if !VLC_WINSTORE_APP
#if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H)
sys->dxgidebug_dll = LoadLibrary(TEXT("DXGIDEBUG.DLL"));
#endif
-#if VLC_WINSTORE_APP
- memset(&sys->rect_display, 0, sizeof(sys->rect_display));
-#else /* !VLC_WINSTORE_APP */
if (!b_windowless)
{
sys->pf_GetDisplayDimensions = GetWindowDimensions;
@@ -165,18 +165,8 @@ void UpdateRects(vout_display_t *vd, vout_display_sys_win32_t *sys, bool is_forc
}
/* If nothing changed, we can return */
- bool moved_or_resized;
-#if VLC_WINSTORE_APP
- moved_or_resized = display_width != RECTWidth(sys->sys.rect_display) ||
- display_height != RECTHeight(sys->sys.rect_display);
- sys->sys.display_width = display_width;
- sys->sys.display_height = display_height;
-#else
- if (sys->b_windowless)
- {
- moved_or_resized = false;
- }
- else
+#if !VLC_WINSTORE_APP
+ if (!sys->b_windowless)
{
/* Retrieve the window position */
ClientToScreen(sys->hwnd, &point);
@@ -187,10 +177,14 @@ void UpdateRects(vout_display_t *vd, vout_display_sys_win32_t *sys, bool is_forc
.top = point.y,
.bottom = point.y + display_height,
};
- moved_or_resized = EventThreadUpdateWindowPosition(sys->event, &rect);
+ EventThreadUpdateWindowPosition(sys->event, &rect);
}
-#endif
- if (!is_forced && !moved_or_resized)
+#endif /* !VLC_WINSTORE_APP */
+ bool resized = display_width != sys->display_width ||
+ display_height != sys->display_height;
+ sys->display_width = display_width;
+ sys->display_height = display_height;
+ if (!is_forced && !resized)
return;
/* Update the window position and size */
diff --git a/modules/video_output/win32/common.h b/modules/video_output/win32/common.h
index ee850c3d7e..025699adb7 100644
--- a/modules/video_output/win32/common.h
+++ b/modules/video_output/win32/common.h
@@ -50,10 +50,8 @@ typedef struct vout_display_sys_win32_t
HWND hparent; /* Handle of the parent window */
HWND hfswnd; /* Handle of the fullscreen window */
-#if VLC_WINSTORE_APP
- /* size of the display */
- RECT rect_display;
-#endif
+ /* current size of the display */
+ UINT display_width, display_height;
/* size of the overall window (including black bands) */
RECT rect_parent;
diff --git a/modules/video_output/win32/events.c b/modules/video_output/win32/events.c
index 74e9ed3dac..1af265712a 100644
--- a/modules/video_output/win32/events.c
+++ b/modules/video_output/win32/events.c
@@ -408,13 +408,11 @@ int EventThreadGetWindowStyle( event_thread_t *p_event )
return p_event->i_window_style;
}
-bool EventThreadUpdateWindowPosition( event_thread_t *p_event, const RECT *area )
+void EventThreadUpdateWindowPosition( event_thread_t *p_event, const RECT *area )
{
vlc_mutex_lock( &p_event->lock );
- bool changed = !EqualRect(&p_event->window_area, area);
p_event->window_area = *area;
vlc_mutex_unlock( &p_event->lock );
- return changed;
}
void EventThreadUpdateSourceAndPlace( event_thread_t *p_event,
diff --git a/modules/video_output/win32/events.h b/modules/video_output/win32/events.h
index 25c9a27041..04b69b69ee 100644
--- a/modules/video_output/win32/events.h
+++ b/modules/video_output/win32/events.h
@@ -52,7 +52,7 @@ void EventThreadStop( event_thread_t * );
void EventThreadUpdateTitle( event_thread_t *, const char *psz_fallback );
int EventThreadGetWindowStyle( event_thread_t * );
-bool EventThreadUpdateWindowPosition( event_thread_t *, const RECT * );
+void EventThreadUpdateWindowPosition( event_thread_t *, const RECT * );
void EventThreadUpdateSourceAndPlace( event_thread_t *p_event,
const video_format_t *p_source,
const vout_display_place_t *p_place );
More information about the vlc-commits
mailing list