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
d5ddf3bd
Commit
d5ddf3bd
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: Explicitly validate bitmap options for CreateBitmap().
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
parent
a95ed154
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
3 deletions
+50
-3
bitmap.c
dlls/d2d1/bitmap.c
+20
-0
d2d1.c
dlls/d2d1/tests/d2d1.c
+30
-3
No files found.
dlls/d2d1/bitmap.c
View file @
d5ddf3bd
...
...
@@ -336,6 +336,23 @@ static void d2d_bitmap_init(struct d2d_bitmap *bitmap, struct d2d_device_context
}
}
static
BOOL
check_bitmap_options
(
unsigned
int
options
)
{
switch
(
options
)
{
case
D2D1_BITMAP_OPTIONS_NONE
:
case
D2D1_BITMAP_OPTIONS_TARGET
:
case
D2D1_BITMAP_OPTIONS_TARGET
|
D2D1_BITMAP_OPTIONS_CANNOT_DRAW
:
case
D2D1_BITMAP_OPTIONS_TARGET
|
D2D1_BITMAP_OPTIONS_CANNOT_DRAW
|
D2D1_BITMAP_OPTIONS_GDI_COMPATIBLE
:
case
D2D1_BITMAP_OPTIONS_TARGET
|
D2D1_BITMAP_OPTIONS_GDI_COMPATIBLE
:
case
D2D1_BITMAP_OPTIONS_CANNOT_DRAW
|
D2D1_BITMAP_OPTIONS_CPU_READ
:
return
TRUE
;
default:
WARN
(
"Invalid bitmap options %#x.
\n
"
,
options
);
return
FALSE
;
}
}
HRESULT
d2d_bitmap_create
(
struct
d2d_device_context
*
context
,
D2D1_SIZE_U
size
,
const
void
*
src_data
,
UINT32
pitch
,
const
D2D1_BITMAP_PROPERTIES1
*
desc
,
struct
d2d_bitmap
**
bitmap
)
{
...
...
@@ -364,6 +381,9 @@ HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size,
return
E_INVALIDARG
;
}
if
(
!
check_bitmap_options
(
desc
->
bitmapOptions
))
return
E_INVALIDARG
;
texture_desc
.
Width
=
size
.
width
;
texture_desc
.
Height
=
size
.
height
;
if
(
!
texture_desc
.
Width
||
!
texture_desc
.
Height
)
...
...
dlls/d2d1/tests/d2d1.c
View file @
d5ddf3bd
...
...
@@ -11798,6 +11798,18 @@ static void test_bitmap_create(BOOL d3d11)
{
D2D1_BITMAP_OPTIONS_CPU_READ
},
{
D2D1_BITMAP_OPTIONS_GDI_COMPATIBLE
},
};
static
const
struct
{
unsigned
int
options
;
}
valid_options
[]
=
{
{
D2D1_BITMAP_OPTIONS_NONE
},
{
D2D1_BITMAP_OPTIONS_TARGET
},
{
D2D1_BITMAP_OPTIONS_TARGET
|
D2D1_BITMAP_OPTIONS_CANNOT_DRAW
},
{
D2D1_BITMAP_OPTIONS_TARGET
|
D2D1_BITMAP_OPTIONS_CANNOT_DRAW
|
D2D1_BITMAP_OPTIONS_GDI_COMPATIBLE
},
{
D2D1_BITMAP_OPTIONS_TARGET
|
D2D1_BITMAP_OPTIONS_GDI_COMPATIBLE
},
{
D2D1_BITMAP_OPTIONS_CANNOT_DRAW
|
D2D1_BITMAP_OPTIONS_CPU_READ
},
};
D2D1_BITMAP_PROPERTIES1
bitmap_desc
;
struct
d2d1_test_context
ctx
;
ID2D1Bitmap1
*
bitmap
;
...
...
@@ -11820,10 +11832,25 @@ static void test_bitmap_create(BOOL d3d11)
bitmap_desc
.
bitmapOptions
=
invalid_options
[
i
].
options
;
bitmap_desc
.
colorContext
=
NULL
;
hr
=
ID2D1DeviceContext_CreateBitmap
(
ctx
.
context
,
size
,
NULL
,
0
,
&
bitmap_desc
,
&
bitmap
);
todo_wine_if
(
i
!=
1
)
ok
(
hr
==
E_INVALIDARG
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
if
(
SUCCEEDED
(
hr
))
ID2D1Bitmap1_Release
(
bitmap
);
winetest_pop_context
();
}
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
valid_options
);
++
i
)
{
winetest_push_context
(
"Test %u"
,
i
);
set_size_u
(
&
size
,
4
,
4
);
bitmap_desc
.
dpiX
=
96
.
0
f
;
bitmap_desc
.
dpiY
=
96
.
0
f
;
bitmap_desc
.
pixelFormat
.
format
=
DXGI_FORMAT_B8G8R8A8_UNORM
;
bitmap_desc
.
pixelFormat
.
alphaMode
=
D2D1_ALPHA_MODE_IGNORE
;
bitmap_desc
.
bitmapOptions
=
valid_options
[
i
].
options
;
bitmap_desc
.
colorContext
=
NULL
;
hr
=
ID2D1DeviceContext_CreateBitmap
(
ctx
.
context
,
size
,
NULL
,
0
,
&
bitmap_desc
,
&
bitmap
);
ok
(
hr
==
S_OK
,
"Got unexpected hr %#lx.
\n
"
,
hr
);
ID2D1Bitmap1_Release
(
bitmap
);
winetest_pop_context
();
}
...
...
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