Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
8f6f7a2e
Commit
8f6f7a2e
authored
Apr 11, 2011
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved video resize from surface IDirect3DDevice9_StretchRect to texture rendering (direct3d).
parent
758de49d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
49 deletions
+46
-49
modules/video_output/msw/direct3d.c
modules/video_output/msw/direct3d.c
+46
-49
No files found.
modules/video_output/msw/direct3d.c
View file @
8f6f7a2e
...
@@ -651,7 +651,7 @@ static int Direct3DReset(vout_display_t *vd)
...
@@ -651,7 +651,7 @@ static int Direct3DReset(vout_display_t *vd)
static
int
Direct3DCreatePool
(
vout_display_t
*
vd
,
video_format_t
*
fmt
);
static
int
Direct3DCreatePool
(
vout_display_t
*
vd
,
video_format_t
*
fmt
);
static
void
Direct3DDestroyPool
(
vout_display_t
*
vd
);
static
void
Direct3DDestroyPool
(
vout_display_t
*
vd
);
static
int
Direct3DCreateScene
(
vout_display_t
*
vd
);
static
int
Direct3DCreateScene
(
vout_display_t
*
vd
,
const
video_format_t
*
fmt
);
static
void
Direct3DDestroyScene
(
vout_display_t
*
vd
);
static
void
Direct3DDestroyScene
(
vout_display_t
*
vd
);
/**
/**
...
@@ -663,7 +663,7 @@ static int Direct3DCreateResources(vout_display_t *vd, video_format_t *fmt)
...
@@ -663,7 +663,7 @@ static int Direct3DCreateResources(vout_display_t *vd, video_format_t *fmt)
msg_Err
(
vd
,
"Direct3D picture pool initialization failed"
);
msg_Err
(
vd
,
"Direct3D picture pool initialization failed"
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
if
(
Direct3DCreateScene
(
vd
))
{
if
(
Direct3DCreateScene
(
vd
,
fmt
))
{
msg_Err
(
vd
,
"Direct3D scene initialization failed !"
);
msg_Err
(
vd
,
"Direct3D scene initialization failed !"
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
...
@@ -917,7 +917,7 @@ typedef struct
...
@@ -917,7 +917,7 @@ typedef struct
/**
/**
* It allocates and initializes the resources needed to render the scene.
* It allocates and initializes the resources needed to render the scene.
*/
*/
static
int
Direct3DCreateScene
(
vout_display_t
*
vd
)
static
int
Direct3DCreateScene
(
vout_display_t
*
vd
,
const
video_format_t
*
fmt
)
{
{
vout_display_sys_t
*
sys
=
vd
->
sys
;
vout_display_sys_t
*
sys
=
vd
->
sys
;
LPDIRECT3DDEVICE9
d3ddev
=
sys
->
d3ddev
;
LPDIRECT3DDEVICE9
d3ddev
=
sys
->
d3ddev
;
...
@@ -930,8 +930,8 @@ static int Direct3DCreateScene(vout_display_t *vd)
...
@@ -930,8 +930,8 @@ static int Direct3DCreateScene(vout_display_t *vd)
*/
*/
LPDIRECT3DTEXTURE9
d3dtex
;
LPDIRECT3DTEXTURE9
d3dtex
;
hr
=
IDirect3DDevice9_CreateTexture
(
d3ddev
,
hr
=
IDirect3DDevice9_CreateTexture
(
d3ddev
,
sys
->
d3dpp
.
BackBufferW
idth
,
fmt
->
i_w
idth
,
sys
->
d3dpp
.
BackBufferH
eight
,
fmt
->
i_h
eight
,
1
,
1
,
D3DUSAGE_RENDERTARGET
,
D3DUSAGE_RENDERTARGET
,
sys
->
d3dpp
.
BackBufferFormat
,
sys
->
d3dpp
.
BackBufferFormat
,
...
@@ -1034,8 +1034,9 @@ static void Direct3DDestroyScene(vout_display_t *vd)
...
@@ -1034,8 +1034,9 @@ static void Direct3DDestroyScene(vout_display_t *vd)
static
int
Direct3DSetupVertices
(
vout_display_t
*
vd
,
static
int
Direct3DSetupVertices
(
vout_display_t
*
vd
,
LPDIRECT3DVERTEXBUFFER9
d3dvtc
,
LPDIRECT3DVERTEXBUFFER9
d3dvtc
,
float
f_x
,
float
f_y
,
const
RECT
src_full
,
float
f_width
,
float
f_height
)
const
RECT
src_crop
,
const
RECT
dst
)
{
{
HRESULT
hr
;
HRESULT
hr
;
...
@@ -1046,39 +1047,38 @@ static int Direct3DSetupVertices(vout_display_t *vd,
...
@@ -1046,39 +1047,38 @@ static int Direct3DSetupVertices(vout_display_t *vd,
return
-
1
;
return
-
1
;
}
}
const
float
src_full_width
=
src_full
.
right
-
src_full
.
left
;
const
float
src_full_height
=
src_full
.
bottom
-
src_full
.
top
;
vertices
[
0
].
x
=
dst
.
left
;
vertices
[
0
].
y
=
dst
.
top
;
vertices
[
0
].
tu
=
src_crop
.
left
/
src_full_width
;
vertices
[
0
].
tv
=
src_crop
.
top
/
src_full_height
;
vertices
[
1
].
x
=
dst
.
right
;
vertices
[
1
].
y
=
dst
.
top
;
vertices
[
1
].
tu
=
src_crop
.
right
/
src_full_width
;
vertices
[
1
].
tv
=
src_crop
.
top
/
src_full_height
;
vertices
[
2
].
x
=
dst
.
right
;
vertices
[
2
].
y
=
dst
.
bottom
;
vertices
[
2
].
tu
=
src_crop
.
right
/
src_full_width
;
vertices
[
2
].
tv
=
src_crop
.
bottom
/
src_full_height
;
vertices
[
3
].
x
=
dst
.
left
;
vertices
[
3
].
y
=
dst
.
bottom
;
vertices
[
3
].
tu
=
src_crop
.
left
/
src_full_width
;
vertices
[
3
].
tv
=
src_crop
.
bottom
/
src_full_height
;
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
/* -0.5f is a "feature" of DirectX and it seems to apply to Direct3d also */
/* -0.5f is a "feature" of DirectX and it seems to apply to Direct3d also */
/* http://www.sjbrown.co.uk/2003/05/01/fix-directx-rasterisation/ */
/* http://www.sjbrown.co.uk/2003/05/01/fix-directx-rasterisation/ */
vertices
[
0
].
x
=
f_x
-
0
.
5
f
;
// left
vertices
[
i
].
x
-=
0
.
5
;
vertices
[
0
].
y
=
f_y
-
0
.
5
f
;
// top
vertices
[
i
].
y
-=
0
.
5
;
vertices
[
0
].
z
=
0
.
0
f
;
vertices
[
0
].
diffuse
=
D3DCOLOR_ARGB
(
255
,
255
,
255
,
255
);
vertices
[
i
].
z
=
0
.
0
f
;
vertices
[
0
].
rhw
=
1
.
0
f
;
vertices
[
i
].
rhw
=
1
.
0
f
;
vertices
[
0
].
tu
=
0
.
0
f
;
vertices
[
i
].
diffuse
=
D3DCOLOR_ARGB
(
255
,
255
,
255
,
255
);
vertices
[
0
].
tv
=
0
.
0
f
;
}
vertices
[
1
].
x
=
f_x
+
f_width
-
0
.
5
f
;
// right
vertices
[
1
].
y
=
f_y
-
0
.
5
f
;
// top
vertices
[
1
].
z
=
0
.
0
f
;
vertices
[
1
].
diffuse
=
D3DCOLOR_ARGB
(
255
,
255
,
255
,
255
);
vertices
[
1
].
rhw
=
1
.
0
f
;
vertices
[
1
].
tu
=
1
.
0
f
;
vertices
[
1
].
tv
=
0
.
0
f
;
vertices
[
2
].
x
=
f_x
+
f_width
-
0
.
5
f
;
// right
vertices
[
2
].
y
=
f_y
+
f_height
-
0
.
5
f
;
// bottom
vertices
[
2
].
z
=
0
.
0
f
;
vertices
[
2
].
diffuse
=
D3DCOLOR_ARGB
(
255
,
255
,
255
,
255
);
vertices
[
2
].
rhw
=
1
.
0
f
;
vertices
[
2
].
tu
=
1
.
0
f
;
vertices
[
2
].
tv
=
1
.
0
f
;
vertices
[
3
].
x
=
f_x
-
0
.
5
f
;
// left
vertices
[
3
].
y
=
f_y
+
f_height
-
0
.
5
f
;
// bottom
vertices
[
3
].
z
=
0
.
0
f
;
vertices
[
3
].
diffuse
=
D3DCOLOR_ARGB
(
255
,
255
,
255
,
255
);
vertices
[
3
].
rhw
=
1
.
0
f
;
vertices
[
3
].
tu
=
0
.
0
f
;
vertices
[
3
].
tv
=
1
.
0
f
;
hr
=
IDirect3DVertexBuffer9_Unlock
(
d3dvtc
);
hr
=
IDirect3DVertexBuffer9_Unlock
(
d3dvtc
);
if
(
FAILED
(
hr
))
{
if
(
FAILED
(
hr
))
{
...
@@ -1178,11 +1178,8 @@ static void Direct3DRenderScene(vout_display_t *vd, LPDIRECT3DSURFACE9 surface)
...
@@ -1178,11 +1178,8 @@ static void Direct3DRenderScene(vout_display_t *vd, LPDIRECT3DSURFACE9 surface)
}
}
/* Copy picture surface into texture surface
/* Copy picture surface into texture surface
* color space conversion and scaling happen here */
* color space conversion happen here */
RECT
src
=
vd
->
sys
->
rect_src_clipped
;
hr
=
IDirect3DDevice9_StretchRect
(
d3ddev
,
d3dsrc
,
NULL
,
d3ddest
,
NULL
,
D3DTEXF_NONE
);
RECT
dst
=
vd
->
sys
->
rect_dest_clipped
;
hr
=
IDirect3DDevice9_StretchRect
(
d3ddev
,
d3dsrc
,
&
src
,
d3ddest
,
&
dst
,
D3DTEXF_LINEAR
);
IDirect3DSurface9_Release
(
d3ddest
);
IDirect3DSurface9_Release
(
d3ddest
);
if
(
FAILED
(
hr
))
{
if
(
FAILED
(
hr
))
{
msg_Dbg
(
vd
,
"%s:%d (hr=0x%0lX)"
,
__FUNCTION__
,
__LINE__
,
hr
);
msg_Dbg
(
vd
,
"%s:%d (hr=0x%0lX)"
,
__FUNCTION__
,
__LINE__
,
hr
);
...
@@ -1196,11 +1193,11 @@ static void Direct3DRenderScene(vout_display_t *vd, LPDIRECT3DSURFACE9 surface)
...
@@ -1196,11 +1193,11 @@ static void Direct3DRenderScene(vout_display_t *vd, LPDIRECT3DSURFACE9 surface)
return
;
return
;
}
}
/* Update the vertex buffer */
/* Update the vertex buffer
(scaling is setup here)
*/
if
(
Direct3DSetupVertices
(
vd
,
d3dvtc
,
if
(
Direct3DSetupVertices
(
vd
,
d3dvtc
,
0
,
0
,
vd
->
sys
->
rect_src
,
vd
->
sys
->
d3dpp
.
BackBufferWidth
,
vd
->
sys
->
rect_src_clipped
,
vd
->
sys
->
d3dpp
.
BackBufferHeight
))
{
vd
->
sys
->
rect_dest_clipped
))
{
IDirect3DDevice9_EndScene
(
d3ddev
);
IDirect3DDevice9_EndScene
(
d3ddev
);
return
;
return
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment