[vlc-devel] [PATCH 7/8] doc: D3D11 callbacks: set the rendering size when the window size changes
Steve Lhomme
robux4 at ycbcr.xyz
Mon May 13 13:54:52 CEST 2019
---
doc/libvlc/d3d11_player.cpp | 38 ++++++++++++++++++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
diff --git a/doc/libvlc/d3d11_player.cpp b/doc/libvlc/d3d11_player.cpp
index a739730455..60e424b2ab 100644
--- a/doc/libvlc/d3d11_player.cpp
+++ b/doc/libvlc/d3d11_player.cpp
@@ -39,6 +39,10 @@ struct render_context
ID3D11Texture2D *texture;
ID3D11ShaderResourceView *textureShaderInput;
ID3D11RenderTargetView *textureRenderTarget;
+
+ unsigned width, height;
+ void (*RepotSize)(void *ReportOpaque, unsigned width, unsigned height);
+ void *ReportOpaque;
};
static bool UpdateOutput_cb( void *opaque, const libvlc_video_direct3d_cfg_t *cfg, libvlc_video_output_cfg_t *out )
@@ -185,6 +189,15 @@ static bool Setup_cb( void **opaque, const libvlc_video_direct3d_device_cfg_t *c
{
struct render_context *ctx = static_cast<struct render_context *>(*opaque);
out->device_context = ctx->d3dctx;
+ ctx->RepotSize = cfg->repot_size_change;
+ ctx->ReportOpaque = cfg->report_opaque;
+
+ if (ctx->RepotSize != nullptr)
+ {
+ /* report our initial size */
+ ctx->RepotSize(ctx->ReportOpaque, ctx->width, ctx->height);
+ }
+
return true;
}
@@ -378,8 +391,31 @@ static void release_direct3d(struct render_context *ctx)
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
+ if( message == WM_CREATE )
+ {
+ /* Store p_mp for future use */
+ CREATESTRUCT *c = (CREATESTRUCT *)lParam;
+ SetWindowLongPtr( hWnd, GWLP_USERDATA, (LONG_PTR)c->lpCreateParams );
+ return 0;
+ }
+
+ LONG_PTR p_user_data = GetWindowLongPtr( hWnd, GWLP_USERDATA );
+ if( p_user_data == 0 )
+ return DefWindowProc(hWnd, message, wParam, lParam);
+ struct render_context *ctx = (struct render_context *)p_user_data;
+
switch(message)
{
+ case WM_SIZE:
+ {
+ /* tell libvlc that our size has changed */
+ ctx->width = LOWORD(lParam) * (BORDER_RIGHT - BORDER_LEFT) / 2.0f; /* remove the orange part ! */
+ ctx->height = HIWORD(lParam) * (BORDER_TOP - BORDER_BOTTOM) / 2.0f;
+ if (ctx->RepotSize != nullptr)
+ ctx->RepotSize(ctx->ReportOpaque, ctx->width, ctx->height);
+ }
+ break;
+
case WM_DESTROY:
PostQuitMessage(0);
return 0;
@@ -441,7 +477,7 @@ int WINAPI WinMain(HINSTANCE hInstance,
NULL,
NULL,
hInstance,
- p_mp);
+ &Context);
ShowWindow(hWnd, nCmdShow);
--
2.17.1
More information about the vlc-devel
mailing list