Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
5e25a454
Commit
5e25a454
authored
May 29, 2022
by
Nikolay Sivov
Committed by
Alexandre Julliard
May 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d2d1: Implement bitmap mapping.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
parent
470fe590
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
24 deletions
+70
-24
bitmap.c
dlls/d2d1/bitmap.c
+68
-4
d2d1_private.h
dlls/d2d1/d2d1_private.h
+1
-0
d2d1.c
dlls/d2d1/tests/d2d1.c
+1
-20
No files found.
dlls/d2d1/bitmap.c
View file @
5e25a454
...
...
@@ -26,6 +26,25 @@ static inline struct d2d_bitmap *impl_from_ID2D1Bitmap1(ID2D1Bitmap1 *iface)
return
CONTAINING_RECORD
(
iface
,
struct
d2d_bitmap
,
ID2D1Bitmap1_iface
);
}
static
HRESULT
d2d_bitmap_unmap
(
struct
d2d_bitmap
*
bitmap
)
{
ID3D11DeviceContext
*
context
;
ID3D11Device
*
device
;
if
(
!
bitmap
->
mapped_resource
.
pData
)
return
D2DERR_WRONG_STATE
;
ID3D11Resource_GetDevice
(
bitmap
->
resource
,
&
device
);
ID3D11Device_GetImmediateContext
(
device
,
&
context
);
ID3D11DeviceContext_Unmap
(
context
,
bitmap
->
resource
,
0
);
ID3D11DeviceContext_Release
(
context
);
ID3D11Device_Release
(
device
);
memset
(
&
bitmap
->
mapped_resource
,
0
,
sizeof
(
bitmap
->
mapped_resource
));
return
S_OK
;
}
static
HRESULT
STDMETHODCALLTYPE
d2d_bitmap_QueryInterface
(
ID2D1Bitmap1
*
iface
,
REFIID
iid
,
void
**
out
)
{
TRACE
(
"iface %p, iid %s, out %p.
\n
"
,
iface
,
debugstr_guid
(
iid
),
out
);
...
...
@@ -229,16 +248,61 @@ static HRESULT STDMETHODCALLTYPE d2d_bitmap_GetSurface(ID2D1Bitmap1 *iface, IDXG
static
HRESULT
STDMETHODCALLTYPE
d2d_bitmap_Map
(
ID2D1Bitmap1
*
iface
,
D2D1_MAP_OPTIONS
options
,
D2D1_MAPPED_RECT
*
mapped_rect
)
{
FIXME
(
"iface %p, options %#x, mapped_rect %p stub!
\n
"
,
iface
,
options
,
mapped_rect
);
struct
d2d_bitmap
*
bitmap
=
impl_from_ID2D1Bitmap1
(
iface
);
D3D11_MAPPED_SUBRESOURCE
mapped_resource
;
ID3D11DeviceContext
*
context
;
ID3D11Device
*
device
;
D3D11_MAP
map_type
;
HRESULT
hr
;
return
E_NOTIMPL
;
TRACE
(
"iface %p, options %#x, mapped_rect %p.
\n
"
,
iface
,
options
,
mapped_rect
);
if
(
bitmap
->
mapped_resource
.
pData
)
return
D2DERR_WRONG_STATE
;
if
(
options
==
D2D1_MAP_OPTIONS_READ
)
map_type
=
D3D11_MAP_READ
;
else
if
(
options
==
D2D1_MAP_OPTIONS_WRITE
)
map_type
=
D3D11_MAP_WRITE
;
else
if
(
options
==
(
D2D1_MAP_OPTIONS_READ
|
D2D1_MAP_OPTIONS_WRITE
))
map_type
=
D3D11_MAP_READ_WRITE
;
else
if
(
options
==
(
D2D1_MAP_OPTIONS_WRITE
|
D2D1_MAP_OPTIONS_DISCARD
))
map_type
=
D3D11_MAP_WRITE_DISCARD
;
else
{
WARN
(
"Invalid mapping options %#x.
\n
"
,
options
);
return
E_INVALIDARG
;
}
ID3D11Resource_GetDevice
(
bitmap
->
resource
,
&
device
);
ID3D11Device_GetImmediateContext
(
device
,
&
context
);
if
(
SUCCEEDED
(
hr
=
ID3D11DeviceContext_Map
(
context
,
bitmap
->
resource
,
0
,
map_type
,
0
,
&
mapped_resource
)))
{
bitmap
->
mapped_resource
=
mapped_resource
;
}
ID3D11DeviceContext_Release
(
context
);
ID3D11Device_Release
(
device
);
if
(
FAILED
(
hr
))
{
WARN
(
"Failed to map resource, hr %#lx.
\n
"
,
hr
);
return
E_INVALIDARG
;
}
mapped_rect
->
pitch
=
bitmap
->
mapped_resource
.
RowPitch
;
mapped_rect
->
bits
=
bitmap
->
mapped_resource
.
pData
;
return
S_OK
;
}
static
HRESULT
STDMETHODCALLTYPE
d2d_bitmap_Unmap
(
ID2D1Bitmap1
*
iface
)
{
FIXME
(
"iface %p stub!
\n
"
,
iface
);
struct
d2d_bitmap
*
bitmap
=
impl_from_ID2D1Bitmap1
(
iface
);
return
E_NOTIMPL
;
TRACE
(
"iface %p.
\n
"
,
iface
);
return
d2d_bitmap_unmap
(
bitmap
);
}
static
const
struct
ID2D1Bitmap1Vtbl
d2d_bitmap_vtbl
=
...
...
dlls/d2d1/d2d1_private.h
View file @
5e25a454
...
...
@@ -395,6 +395,7 @@ struct d2d_bitmap
ID3D11RenderTargetView
*
rtv
;
IDXGISurface
*
surface
;
ID3D11Resource
*
resource
;
D3D11_MAPPED_SUBRESOURCE
mapped_resource
;
D2D1_SIZE_U
pixel_size
;
D2D1_PIXEL_FORMAT
format
;
float
dpi_x
;
...
...
dlls/d2d1/tests/d2d1.c
View file @
5e25a454
...
...
@@ -11634,13 +11634,10 @@ static void test_bitmap_map(BOOL d3d11)
ok
(
hr
==
S_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Map
(
bitmap
,
D2D1_MAP_OPTIONS_NONE
,
&
mapped_rect
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Map
(
bitmap
,
D2D1_MAP_OPTIONS_READ
,
&
mapped_rect
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Map
(
bitmap
,
D2D1_MAP_OPTIONS_WRITE
,
&
mapped_rect
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_GetSurface
(
bitmap
,
&
surface
);
...
...
@@ -11672,37 +11669,28 @@ static void test_bitmap_map(BOOL d3d11)
ok
(
hr
==
S_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Map
(
bitmap
,
D2D1_MAP_OPTIONS_NONE
,
&
mapped_rect
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Map
(
bitmap
,
D2D1_MAP_OPTIONS_READ
,
&
mapped_rect
);
todo_wine
ok
(
hr
==
S_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Map
(
bitmap
,
D2D1_MAP_OPTIONS_READ
,
&
mapped_rect
);
todo_wine
ok
(
hr
==
D2DERR_WRONG_STATE
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Map
(
bitmap
,
D2D1_MAP_OPTIONS_WRITE
,
&
mapped_rect
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Unmap
(
bitmap
);
todo_wine
ok
(
hr
==
S_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Unmap
(
bitmap
);
todo_wine
ok
(
hr
==
D2DERR_WRONG_STATE
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Map
(
bitmap
,
D2D1_MAP_OPTIONS_WRITE
,
&
mapped_rect
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Map
(
bitmap
,
D2D1_MAP_OPTIONS_READ
|
D2D1_MAP_OPTIONS_DISCARD
,
&
mapped_rect
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Map
(
bitmap
,
D2D1_MAP_OPTIONS_WRITE
|
D2D1_MAP_OPTIONS_DISCARD
,
&
mapped_rect
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Map
(
bitmap
,
D2D1_MAP_OPTIONS_READ
|
D2D1_MAP_OPTIONS_WRITE
,
&
mapped_rect
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_GetSurface
(
bitmap
,
&
surface
);
...
...
@@ -11748,34 +11736,27 @@ static void test_bitmap_map(BOOL d3d11)
ok
(
hr
==
S_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Map
(
bitmap
,
D2D1_MAP_OPTIONS_READ
|
D2D1_MAP_OPTIONS_DISCARD
,
&
mapped_rect
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Map
(
bitmap
,
D2D1_MAP_OPTIONS_READ
,
&
mapped_rect
);
todo_wine
ok
(
hr
==
S_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Unmap
(
bitmap
);
todo_wine
ok
(
hr
==
S_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Map
(
bitmap
,
D2D1_MAP_OPTIONS_WRITE
,
&
mapped_rect
);
todo_wine
ok
(
hr
==
S_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Unmap
(
bitmap
);
todo_wine
ok
(
hr
==
S_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Map
(
bitmap
,
D2D1_MAP_OPTIONS_WRITE
|
D2D1_MAP_OPTIONS_READ
,
&
mapped_rect
);
todo_wine
ok
(
hr
==
S_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Unmap
(
bitmap
);
todo_wine
ok
(
hr
==
S_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
hr
=
ID2D1Bitmap1_Map
(
bitmap
,
D2D1_MAP_OPTIONS_WRITE
|
D2D1_MAP_OPTIONS_DISCARD
,
&
mapped_rect
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr
))
ID2D1Bitmap1_Unmap
(
bitmap
);
hr
=
ID2D1Bitmap1_Map
(
bitmap
,
D2D1_MAP_OPTIONS_WRITE
|
D2D1_MAP_OPTIONS_READ
|
D2D1_MAP_OPTIONS_DISCARD
,
&
mapped_rect
);
todo_wine
ok
(
hr
==
E_INVALIDARG
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
ID2D1Bitmap1_Release
(
bitmap
);
...
...
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