Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
2474f5e3
Commit
2474f5e3
authored
Aug 18, 2015
by
Henri Verbeet
Committed by
Alexandre Julliard
Aug 18, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d2d1: Implement d2d_bitmap_CopyFromMemory().
parent
62a02a04
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
136 additions
and
2 deletions
+136
-2
bitmap.c
dlls/d2d1/bitmap.c
+23
-2
d2d1.c
dlls/d2d1/tests/d2d1.c
+113
-0
No files found.
dlls/d2d1/bitmap.c
View file @
2474f5e3
...
@@ -143,9 +143,30 @@ static HRESULT STDMETHODCALLTYPE d2d_bitmap_CopyFromRenderTarget(ID2D1Bitmap *if
...
@@ -143,9 +143,30 @@ static HRESULT STDMETHODCALLTYPE d2d_bitmap_CopyFromRenderTarget(ID2D1Bitmap *if
static
HRESULT
STDMETHODCALLTYPE
d2d_bitmap_CopyFromMemory
(
ID2D1Bitmap
*
iface
,
static
HRESULT
STDMETHODCALLTYPE
d2d_bitmap_CopyFromMemory
(
ID2D1Bitmap
*
iface
,
const
D2D1_RECT_U
*
dst_rect
,
const
void
*
src_data
,
UINT32
pitch
)
const
D2D1_RECT_U
*
dst_rect
,
const
void
*
src_data
,
UINT32
pitch
)
{
{
FIXME
(
"iface %p, dst_rect %p, src_data %p, pitch %u stub!
\n
"
,
iface
,
dst_rect
,
src_data
,
pitch
);
struct
d2d_bitmap
*
bitmap
=
impl_from_ID2D1Bitmap
(
iface
);
ID3D10Device
*
device
;
ID3D10Resource
*
dst
;
D3D10_BOX
box
;
return
E_NOTIMPL
;
TRACE
(
"iface %p, dst_rect %p, src_data %p, pitch %u.
\n
"
,
iface
,
dst_rect
,
src_data
,
pitch
);
if
(
dst_rect
)
{
box
.
left
=
dst_rect
->
left
;
box
.
top
=
dst_rect
->
top
;
box
.
front
=
0
;
box
.
right
=
dst_rect
->
right
;
box
.
bottom
=
dst_rect
->
bottom
;
box
.
back
=
1
;
}
ID3D10ShaderResourceView_GetResource
(
bitmap
->
view
,
&
dst
);
ID3D10ShaderResourceView_GetDevice
(
bitmap
->
view
,
&
device
);
ID3D10Device_UpdateSubresource
(
device
,
dst
,
0
,
dst_rect
?
&
box
:
NULL
,
src_data
,
pitch
,
0
);
ID3D10Device_Release
(
device
);
ID3D10Resource_Release
(
dst
);
return
S_OK
;
}
}
static
const
struct
ID2D1BitmapVtbl
d2d_bitmap_vtbl
=
static
const
struct
ID2D1BitmapVtbl
d2d_bitmap_vtbl
=
...
...
dlls/d2d1/tests/d2d1.c
View file @
2474f5e3
...
@@ -54,6 +54,14 @@ static void set_rect(D2D1_RECT_F *rect, float left, float top, float right, floa
...
@@ -54,6 +54,14 @@ static void set_rect(D2D1_RECT_F *rect, float left, float top, float right, floa
rect
->
bottom
=
bottom
;
rect
->
bottom
=
bottom
;
}
}
static
void
set_rect_u
(
D2D1_RECT_U
*
rect
,
UINT32
left
,
UINT32
top
,
UINT32
right
,
UINT32
bottom
)
{
rect
->
left
=
left
;
rect
->
top
=
top
;
rect
->
right
=
right
;
rect
->
bottom
=
bottom
;
}
static
void
set_color
(
D2D1_COLOR_F
*
color
,
float
r
,
float
g
,
float
b
,
float
a
)
static
void
set_color
(
D2D1_COLOR_F
*
color
,
float
r
,
float
g
,
float
b
,
float
a
)
{
{
color
->
r
=
r
;
color
->
r
=
r
;
...
@@ -1998,6 +2006,110 @@ static void test_shared_bitmap(void)
...
@@ -1998,6 +2006,110 @@ static void test_shared_bitmap(void)
CoUninitialize
();
CoUninitialize
();
}
}
static
void
test_bitmap_updates
(
void
)
{
D2D1_BITMAP_PROPERTIES
bitmap_desc
;
IDXGISwapChain
*
swapchain
;
ID2D1RenderTarget
*
rt
;
ID3D10Device1
*
device
;
IDXGISurface
*
surface
;
D2D1_RECT_U
dst_rect
;
ID2D1Bitmap
*
bitmap
;
D2D1_COLOR_F
color
;
D2D1_RECT_F
rect
;
D2D1_SIZE_U
size
;
HWND
window
;
HRESULT
hr
;
BOOL
match
;
static
const
DWORD
bitmap_data
[]
=
{
0xffff0000
,
0xffffff00
,
0xff00ff00
,
0xff00ffff
,
0xff0000ff
,
0xffff00ff
,
0xff000000
,
0xff7f7f7f
,
0xffffffff
,
0xffffffff
,
0xffffffff
,
0xff000000
,
0xffffffff
,
0xff000000
,
0xff000000
,
0xff000000
,
};
if
(
!
(
device
=
create_device
()))
{
skip
(
"Failed to create device, skipping tests.
\n
"
);
return
;
}
window
=
CreateWindowA
(
"static"
,
"d2d1_test"
,
WS_OVERLAPPEDWINDOW
|
WS_VISIBLE
,
0
,
0
,
640
,
480
,
NULL
,
NULL
,
NULL
,
NULL
);
swapchain
=
create_swapchain
(
device
,
window
,
TRUE
);
hr
=
IDXGISwapChain_GetBuffer
(
swapchain
,
0
,
&
IID_IDXGISurface
,
(
void
**
)
&
surface
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get buffer, hr %#x.
\n
"
,
hr
);
rt
=
create_render_target
(
surface
);
ok
(
!!
rt
,
"Failed to create render target.
\n
"
);
ID2D1RenderTarget_SetAntialiasMode
(
rt
,
D2D1_ANTIALIAS_MODE_ALIASED
);
ID2D1RenderTarget_BeginDraw
(
rt
);
set_color
(
&
color
,
0
.
0
f
,
0
.
0
f
,
1
.
0
f
,
1
.
0
f
);
ID2D1RenderTarget_Clear
(
rt
,
&
color
);
set_size_u
(
&
size
,
4
,
4
);
bitmap_desc
.
pixelFormat
.
format
=
DXGI_FORMAT_B8G8R8A8_UNORM
;
bitmap_desc
.
pixelFormat
.
alphaMode
=
D2D1_ALPHA_MODE_PREMULTIPLIED
;
bitmap_desc
.
dpiX
=
96
.
0
f
;
bitmap_desc
.
dpiY
=
96
.
0
f
;
hr
=
ID2D1RenderTarget_CreateBitmap
(
rt
,
size
,
NULL
,
0
,
&
bitmap_desc
,
&
bitmap
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create bitmap, hr %#x.
\n
"
,
hr
);
set_rect
(
&
rect
,
0
.
0
f
,
0
.
0
f
,
320
.
0
f
,
240
.
0
f
);
ID2D1RenderTarget_DrawBitmap
(
rt
,
bitmap
,
&
rect
,
1
.
0
f
,
D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR
,
NULL
);
ID2D1Bitmap_Release
(
bitmap
);
bitmap_desc
.
pixelFormat
.
alphaMode
=
D2D1_ALPHA_MODE_IGNORE
;
hr
=
ID2D1RenderTarget_CreateBitmap
(
rt
,
size
,
NULL
,
0
,
&
bitmap_desc
,
&
bitmap
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create bitmap, hr %#x.
\n
"
,
hr
);
set_rect
(
&
rect
,
0
.
0
f
,
240
.
0
f
,
320
.
0
f
,
480
.
0
f
);
ID2D1RenderTarget_DrawBitmap
(
rt
,
bitmap
,
&
rect
,
1
.
0
f
,
D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR
,
NULL
);
set_rect_u
(
&
dst_rect
,
1
,
1
,
3
,
3
);
hr
=
ID2D1Bitmap_CopyFromMemory
(
bitmap
,
&
dst_rect
,
bitmap_data
,
4
*
sizeof
(
*
bitmap_data
));
ok
(
SUCCEEDED
(
hr
),
"Failed to update bitmap, hr %#x.
\n
"
,
hr
);
set_rect_u
(
&
dst_rect
,
0
,
3
,
3
,
4
);
hr
=
ID2D1Bitmap_CopyFromMemory
(
bitmap
,
&
dst_rect
,
&
bitmap_data
[
6
],
4
*
sizeof
(
*
bitmap_data
));
ok
(
SUCCEEDED
(
hr
),
"Failed to update bitmap, hr %#x.
\n
"
,
hr
);
set_rect_u
(
&
dst_rect
,
0
,
0
,
4
,
1
);
hr
=
ID2D1Bitmap_CopyFromMemory
(
bitmap
,
&
dst_rect
,
&
bitmap_data
[
10
],
4
*
sizeof
(
*
bitmap_data
));
ok
(
SUCCEEDED
(
hr
),
"Failed to update bitmap, hr %#x.
\n
"
,
hr
);
set_rect_u
(
&
dst_rect
,
0
,
1
,
1
,
3
);
hr
=
ID2D1Bitmap_CopyFromMemory
(
bitmap
,
&
dst_rect
,
&
bitmap_data
[
2
],
sizeof
(
*
bitmap_data
));
ok
(
SUCCEEDED
(
hr
),
"Failed to update bitmap, hr %#x.
\n
"
,
hr
);
set_rect_u
(
&
dst_rect
,
4
,
4
,
3
,
1
);
hr
=
ID2D1Bitmap_CopyFromMemory
(
bitmap
,
&
dst_rect
,
bitmap_data
,
sizeof
(
*
bitmap_data
));
ok
(
SUCCEEDED
(
hr
),
"Failed to update bitmap, hr %#x.
\n
"
,
hr
);
set_rect
(
&
rect
,
320
.
0
f
,
240
.
0
f
,
640
.
0
f
,
480
.
0
f
);
ID2D1RenderTarget_DrawBitmap
(
rt
,
bitmap
,
&
rect
,
1
.
0
f
,
D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR
,
NULL
);
hr
=
ID2D1Bitmap_CopyFromMemory
(
bitmap
,
NULL
,
bitmap_data
,
4
*
sizeof
(
*
bitmap_data
));
ok
(
SUCCEEDED
(
hr
),
"Failed to update bitmap, hr %#x.
\n
"
,
hr
);
set_rect
(
&
rect
,
320
.
0
f
,
0
.
0
f
,
640
.
0
f
,
240
.
0
f
);
ID2D1RenderTarget_DrawBitmap
(
rt
,
bitmap
,
&
rect
,
1
.
0
f
,
D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR
,
NULL
);
hr
=
ID2D1RenderTarget_EndDraw
(
rt
,
NULL
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to end draw, hr %#x.
\n
"
,
hr
);
match
=
compare_surface
(
surface
,
"cb8136c91fbbdc76bb83b8c09edc1907b0a5d0a6"
);
ok
(
match
,
"Surface does not match.
\n
"
);
ID2D1Bitmap_Release
(
bitmap
);
ID2D1RenderTarget_Release
(
rt
);
IDXGISurface_Release
(
surface
);
IDXGISwapChain_Release
(
swapchain
);
ID3D10Device1_Release
(
device
);
DestroyWindow
(
window
);
}
START_TEST
(
d2d1
)
START_TEST
(
d2d1
)
{
{
test_clip
();
test_clip
();
...
@@ -2008,4 +2120,5 @@ START_TEST(d2d1)
...
@@ -2008,4 +2120,5 @@ START_TEST(d2d1)
test_bitmap_formats
();
test_bitmap_formats
();
test_alpha_mode
();
test_alpha_mode
();
test_shared_bitmap
();
test_shared_bitmap
();
test_bitmap_updates
();
}
}
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