[vlc-devel] [PATCH 06/41] vout:win32: use common macros to compute the width/height of a RECT
Steve Lhomme
robux4 at ycbcr.xyz
Fri Mar 22 16:13:44 CET 2019
---
modules/video_output/win32/common.c | 32 ++++++++++++-------------
modules/video_output/win32/common.h | 3 +++
modules/video_output/win32/d3d11_quad.c | 13 ++++------
modules/video_output/win32/direct3d11.c | 3 ---
modules/video_output/win32/direct3d9.c | 8 +++----
modules/video_output/win32/events.c | 4 ++--
modules/video_output/win32/glwin32.c | 4 ++--
modules/video_output/win32/wingdi.c | 6 ++---
8 files changed, 34 insertions(+), 39 deletions(-)
diff --git a/modules/video_output/win32/common.c b/modules/video_output/win32/common.c
index 6d15e15e52..a2a5b2e9fc 100644
--- a/modules/video_output/win32/common.c
+++ b/modules/video_output/win32/common.c
@@ -173,8 +173,8 @@ static void UpdateRectsInternal(vout_display_t *vd, bool is_forced)
/* If nothing changed, we can return */
bool moved_or_resized;
#if VLC_WINSTORE_APP
- moved_or_resized = rect.right != (sys->sys.rect_display.right - sys->sys.rect_display.left) ||
- rect.bottom != (sys->sys.rect_display.bottom - sys->sys.rect_display.top);
+ moved_or_resized = rect.right != RECTWidth(sys->sys.rect_display) ||
+ rect.bottom != RECTHeight(sys->sys.rect_display);
sys->sys.rect_display = rect;
#else
if (sys->b_windowless)
@@ -234,8 +234,8 @@ static void UpdateRectsInternal(vout_display_t *vd, bool is_forced)
rect_dest_clipped = rect_dest;
/* the 2 following lines are to fix a bug when clicking on the desktop */
- if ((rect_dest_clipped.right - rect_dest_clipped.left) == 0 ||
- (rect_dest_clipped.bottom - rect_dest_clipped.top) == 0) {
+ if (RECTWidth(rect_dest_clipped) == 0 ||
+ RECTHeight(rect_dest_clipped) == 0) {
#if !VLC_WINSTORE_APP
SetRectEmpty(&rect_src_clipped);
#endif
@@ -251,18 +251,18 @@ static void UpdateRectsInternal(vout_display_t *vd, bool is_forced)
/* Clip the source image */
rect_src_clipped.left = source->i_x_offset +
(rect_dest_clipped.left - rect_dest.left) *
- source->i_visible_width / (rect_dest.right - rect_dest.left);
+ source->i_visible_width / RECTWidth(rect_dest);
rect_src_clipped.right = source->i_x_offset +
source->i_visible_width -
(rect_dest.right - rect_dest_clipped.right) *
- source->i_visible_width / (rect_dest.right - rect_dest.left);
+ source->i_visible_width / RECTWidth(rect_dest);
rect_src_clipped.top = source->i_y_offset +
(rect_dest_clipped.top - rect_dest.top) *
- source->i_visible_height / (rect_dest.bottom - rect_dest.top);
+ source->i_visible_height / RECTHeight(rect_dest);
rect_src_clipped.bottom = source->i_y_offset +
source->i_visible_height -
(rect_dest.bottom - rect_dest_clipped.bottom) *
- source->i_visible_height / (rect_dest.bottom - rect_dest.top);
+ source->i_visible_height / RECTHeight(rect_dest);
#ifndef NDEBUG
msg_Dbg(vd, "DirectXUpdateRects source"
@@ -351,8 +351,8 @@ void CommonManage(vout_display_t *vd)
* on a move of the parent window, even if no resize occurred
*/
SetWindowPos(sys->hwnd, 0, 0, 0,
- rect_parent.right - rect_parent.left,
- rect_parent.bottom - rect_parent.top,
+ RECTWidth(rect_parent),
+ RECTHeight(rect_parent),
SWP_NOZORDER);
UpdateRectsInternal(vd, true);
@@ -418,8 +418,8 @@ static void CommonChangeThumbnailClip(vout_display_t *vd, bool show)
POINT client = {video.left, video.top};
if (ScreenToClient(hroot, &client))
{
- unsigned int width = video.right - video.left;
- unsigned int height = video.bottom - video.top;
+ unsigned int width = RECTWidth(video);
+ unsigned int height = RECTHeight(video);
video.left = client.x;
video.top = client.y;
video.right = video.left + width;
@@ -479,8 +479,8 @@ static int CommonControlSetFullscreen(vout_display_t *vd, bool is_fullscreen)
SetWindowPos(hwnd, 0,
mi.rcMonitor.left,
mi.rcMonitor.top,
- mi.rcMonitor.right - mi.rcMonitor.left,
- mi.rcMonitor.bottom - mi.rcMonitor.top,
+ RECTWidth(mi.rcMonitor),
+ RECTHeight(mi.rcMonitor),
SWP_NOZORDER|SWP_FRAMECHANGED);
} else {
/* Maximize non embedded window */
@@ -565,8 +565,8 @@ int CommonControl(vout_display_t *vd, int query, va_list args)
if (!cfg->is_fullscreen && !sys->b_windowless) {
AdjustWindowRect(&rect_window, EventThreadGetWindowStyle(sys->event), 0);
SetWindowPos(sys->hwnd, 0, 0, 0,
- rect_window.right - rect_window.left,
- rect_window.bottom - rect_window.top, SWP_NOMOVE);
+ RECTWidth(rect_window),
+ RECTHeight(rect_window), SWP_NOMOVE);
}
sys->area.vdcfg = *cfg;
UpdateRectsInternal(vd, false);
diff --git a/modules/video_output/win32/common.h b/modules/video_output/win32/common.h
index 2e6253626f..296f61283c 100644
--- a/modules/video_output/win32/common.h
+++ b/modules/video_output/win32/common.h
@@ -46,6 +46,9 @@ typedef struct display_win32_area_t
unsigned int (*pf_GetPictureHeight)(const vout_display_t *);
} display_win32_area_t;
+#define RECTWidth(r) (LONG)((r).right - (r).left)
+#define RECTHeight(r) (LONG)((r).bottom - (r).top)
+
/*****************************************************************************
* vout_sys_t: video output method descriptor
*****************************************************************************
diff --git a/modules/video_output/win32/d3d11_quad.c b/modules/video_output/win32/d3d11_quad.c
index b1648cc342..6584c82154 100644
--- a/modules/video_output/win32/d3d11_quad.c
+++ b/modules/video_output/win32/d3d11_quad.c
@@ -36,6 +36,7 @@
#include <d3d11.h>
#include "d3d11_quad.h"
+#include "common.h"
#define SPHERE_SLICES 128
#define nbLatBands SPHERE_SLICES
@@ -412,8 +413,8 @@ static void SetupQuadFlat(d3d_vertex_t *dst_data, const RECT *output,
static void SetupQuadSphere(d3d_vertex_t *dst_data, const RECT *output,
const d3d_quad_t *quad, WORD *triangle_pos)
{
- const float scaleX = (float)(output->right - output->left) / quad->i_width;
- const float scaleY = (float)(output->bottom - output->top) / quad->i_height;
+ const float scaleX = (float)(RECTWidth(*output)) / quad->i_width;
+ const float scaleY = (float)(RECTHeight(*output)) / quad->i_height;
for (unsigned lat = 0; lat <= nbLatBands; lat++) {
float theta = lat * (float) M_PI / nbLatBands;
float sinTheta, cosTheta;
@@ -1067,14 +1068,10 @@ int D3D11_SetupQuad(vlc_object_t *o, d3d11_device_t *d3d_dev, const video_format
void D3D11_UpdateViewport(d3d_quad_t *quad, const RECT *rect, const d3d_format_t *display)
{
-#define RECTWidth(r) (LONG)((r)->right - (r)->left)
-#define RECTHeight(r) (LONG)((r)->bottom - (r)->top)
LONG srcAreaWidth, srcAreaHeight;
- srcAreaWidth = RECTWidth(rect);
- srcAreaHeight = RECTHeight(rect);
-#undef RECTWidth
-#undef RECTHeight
+ srcAreaWidth = RECTWidth(*rect);
+ srcAreaHeight = RECTHeight(*rect);
quad->cropViewport[0].TopLeftX = rect->left;
quad->cropViewport[0].TopLeftY = rect->top;
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index ec917bd884..e845cdaf51 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -127,9 +127,6 @@ struct vout_display_sys_t
bool (*resizeCb)(void* opaque, unsigned, unsigned);
};
-#define RECTWidth(r) (int)((r).right - (r).left)
-#define RECTHeight(r) (int)((r).bottom - (r).top)
-
static picture_pool_t *Pool(vout_display_t *, unsigned);
static void Prepare(vout_display_t *, picture_t *, subpicture_t *subpicture, vlc_tick_t);
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index efa0132522..5da7cf9e7c 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -929,8 +929,8 @@ static void Manage (vout_display_t *vd)
UINT width, height;
GetClientRect(p_sys->sys.hvideownd, &rect);
- width = rect.right-rect.left;
- height = rect.bottom-rect.top;
+ width = RECTWidth(rect);
+ height = RECTHeight(rect);
if (width != p_sys->pp.BackBufferWidth || height != p_sys->pp.BackBufferHeight)
{
@@ -1040,8 +1040,8 @@ static void Direct3D9ImportSubpicture(vout_display_t *vd,
/* Map the subpicture to sys->sys.sys.rect_dest */
const RECT video = sys->sys.area.rect_dest;
- const float scale_w = (float)(video.right - video.left) / subpicture->i_original_picture_width;
- const float scale_h = (float)(video.bottom - video.top) / subpicture->i_original_picture_height;
+ const float scale_w = (float)(RECTWidth(video)) / subpicture->i_original_picture_width;
+ const float scale_h = (float)(RECTHeight(video)) / subpicture->i_original_picture_height;
RECT dst;
dst.left = video.left + scale_w * r->i_x,
diff --git a/modules/video_output/win32/events.c b/modules/video_output/win32/events.c
index f51e137086..e72d822aa7 100644
--- a/modules/video_output/win32/events.c
+++ b/modules/video_output/win32/events.c
@@ -779,8 +779,8 @@ static int Win32VoutCreateWindow( event_thread_t *p_event )
(UINT)p_event->x, /* default X coordinate */
(!p_event->y) ? (UINT)CW_USEDEFAULT :
(UINT)p_event->y, /* default Y coordinate */
- rect_window.right - rect_window.left, /* window width */
- rect_window.bottom - rect_window.top, /* window height */
+ RECTWidth(rect_window), /* window width */
+ RECTHeight(rect_window), /* window height */
p_event->hparent, /* parent window */
NULL, /* no menu in this window */
hInstance, /* handle of this program instance */
diff --git a/modules/video_output/win32/glwin32.c b/modules/video_output/win32/glwin32.c
index ddeb814118..edd6e4ada3 100644
--- a/modules/video_output/win32/glwin32.c
+++ b/modules/video_output/win32/glwin32.c
@@ -245,8 +245,8 @@ static void Manage (vout_display_t *vd)
CommonManage(vd);
- const int width = sys->sys.area.rect_dest.right - sys->sys.area.rect_dest.left;
- const int height = sys->sys.area.rect_dest.bottom - sys->sys.area.rect_dest.top;
+ const int width = RECTWidth(sys->sys.area.rect_dest);
+ const int height = RECTHeight(sys->sys.area.rect_dest);
vlc_gl_Resize (sys->gl, width, height);
if (vlc_gl_MakeCurrent (sys->gl) != VLC_SUCCESS)
return;
diff --git a/modules/video_output/win32/wingdi.c b/modules/video_output/win32/wingdi.c
index 8caa21c670..bf6e9909e1 100644
--- a/modules/video_output/win32/wingdi.c
+++ b/modules/video_output/win32/wingdi.c
@@ -154,10 +154,8 @@ static void Display(vout_display_t *vd, picture_t *picture)
OffsetRect(&rect_dst, -rect_dest.left, -rect_dest.top);
SelectObject(sys->off_dc, sys->off_bitmap);
- if (rect_dest_clipped.right - rect_dest_clipped.left !=
- rect_src_clipped.right - rect_src_clipped.left ||
- rect_dest_clipped.bottom - rect_dest_clipped.top !=
- rect_src_clipped.bottom - rect_src_clipped.top) {
+ if (RECTWidth(rect_dest_clipped) != RECTWidth(rect_src_clipped) ||
+ RECTHeight(rect_dest_clipped) != RECTHeight(rect_src_clipped)) {
StretchBlt(hdc, rect_dst.left, rect_dst.top,
rect_dst.right, rect_dst.bottom,
sys->off_dc,
--
2.17.1
More information about the vlc-devel
mailing list