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
ff6225c1
Commit
ff6225c1
authored
Nov 18, 2015
by
Henri Verbeet
Committed by
Alexandre Julliard
Nov 19, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d2d1/tests: Add some tests for opacity brushes.
Signed-off-by:
Henri Verbeet
<
hverbeet@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
f1f2d0f5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
183 additions
and
0 deletions
+183
-0
d2d1.c
dlls/d2d1/tests/d2d1.c
+183
-0
No files found.
dlls/d2d1/tests/d2d1.c
View file @
ff6225c1
...
...
@@ -2246,6 +2246,188 @@ static void test_bitmap_updates(void)
DestroyWindow
(
window
);
}
static
void
test_opacity_brush
(
void
)
{
ID2D1BitmapBrush
*
bitmap_brush
,
*
opacity_brush
;
D2D1_BITMAP_PROPERTIES
bitmap_desc
;
ID2D1RectangleGeometry
*
geometry
;
ID2D1SolidColorBrush
*
color_brush
;
IDXGISwapChain
*
swapchain
;
D2D1_MATRIX_3X2_F
matrix
;
ID2D1RenderTarget
*
rt
;
ID3D10Device1
*
device
;
IDXGISurface
*
surface
;
ID2D1Factory
*
factory
;
ID2D1Bitmap
*
bitmap
;
D2D1_COLOR_F
color
;
D2D1_RECT_F
rect
;
D2D1_SIZE_U
size
;
ULONG
refcount
;
HWND
window
;
HRESULT
hr
;
BOOL
match
;
static
const
DWORD
bitmap_data
[]
=
{
0xffff0000
,
0x40ffff00
,
0x4000ff00
,
0xff00ffff
,
0x7f0000ff
,
0x00ff00ff
,
0x00000000
,
0x7f7f7f7f
,
0x7fffffff
,
0x00ffffff
,
0x00ffffff
,
0x7f000000
,
0xffffffff
,
0x40000000
,
0x40000000
,
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_GetFactory
(
rt
,
&
factory
);
ID2D1RenderTarget_SetDpi
(
rt
,
192
.
0
f
,
48
.
0
f
);
ID2D1RenderTarget_SetAntialiasMode
(
rt
,
D2D1_ANTIALIAS_MODE_ALIASED
);
set_color
(
&
color
,
0
.
0
f
,
1
.
0
f
,
0
.
0
f
,
0
.
8
f
);
hr
=
ID2D1RenderTarget_CreateSolidColorBrush
(
rt
,
&
color
,
NULL
,
&
color_brush
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create color brush, hr %#x.
\n
"
,
hr
);
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
,
bitmap_data
,
4
*
sizeof
(
*
bitmap_data
),
&
bitmap_desc
,
&
bitmap
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create bitmap, hr %#x.
\n
"
,
hr
);
hr
=
ID2D1RenderTarget_CreateBitmapBrush
(
rt
,
bitmap
,
NULL
,
NULL
,
&
opacity_brush
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create bitmap brush, hr %#x.
\n
"
,
hr
);
ID2D1BitmapBrush_SetInterpolationMode
(
opacity_brush
,
D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR
);
refcount
=
ID2D1Bitmap_Release
(
bitmap
);
ok
(
refcount
==
1
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
set_size_u
(
&
size
,
1
,
1
);
bitmap_desc
.
pixelFormat
.
format
=
DXGI_FORMAT_B8G8R8A8_UNORM
;
bitmap_desc
.
pixelFormat
.
alphaMode
=
D2D1_ALPHA_MODE_IGNORE
;
bitmap_desc
.
dpiX
=
96
.
0
f
;
bitmap_desc
.
dpiY
=
96
.
0
f
;
hr
=
ID2D1RenderTarget_CreateBitmap
(
rt
,
size
,
&
bitmap_data
[
2
],
sizeof
(
*
bitmap_data
),
&
bitmap_desc
,
&
bitmap
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create bitmap, hr %#x.
\n
"
,
hr
);
hr
=
ID2D1RenderTarget_CreateBitmapBrush
(
rt
,
bitmap
,
NULL
,
NULL
,
&
bitmap_brush
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create bitmap brush, hr %#x.
\n
"
,
hr
);
ID2D1BitmapBrush_SetInterpolationMode
(
bitmap_brush
,
D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR
);
refcount
=
ID2D1Bitmap_Release
(
bitmap
);
ok
(
refcount
==
1
,
"Got unexpected refcount %u.
\n
"
,
refcount
);
ID2D1RenderTarget_BeginDraw
(
rt
);
set_color
(
&
color
,
0
.
0
f
,
0
.
0
f
,
1
.
0
f
,
1
.
0
f
);
ID2D1RenderTarget_Clear
(
rt
,
&
color
);
set_rect
(
&
rect
,
40
.
0
f
,
120
.
0
f
,
120
.
0
f
,
360
.
0
f
);
ID2D1RenderTarget_FillRectangle
(
rt
,
&
rect
,
(
ID2D1Brush
*
)
color_brush
);
set_matrix_identity
(
&
matrix
);
translate_matrix
(
&
matrix
,
120
.
0
f
,
120
.
0
f
);
scale_matrix
(
&
matrix
,
20
.
0
f
,
60
.
0
f
);
ID2D1BitmapBrush_SetTransform
(
opacity_brush
,
&
matrix
);
set_rect
(
&
rect
,
120
.
0
f
,
120
.
0
f
,
200
.
0
f
,
360
.
0
f
);
ID2D1RenderTarget_FillRectangle
(
rt
,
&
rect
,
(
ID2D1Brush
*
)
opacity_brush
);
set_rect
(
&
rect
,
200
.
0
f
,
120
.
0
f
,
280
.
0
f
,
360
.
0
f
);
ID2D1RenderTarget_FillRectangle
(
rt
,
&
rect
,
(
ID2D1Brush
*
)
bitmap_brush
);
set_matrix_identity
(
&
matrix
);
translate_matrix
(
&
matrix
,
40
.
0
f
,
360
.
0
f
);
scale_matrix
(
&
matrix
,
20
.
0
f
,
60
.
0
f
);
ID2D1BitmapBrush_SetTransform
(
opacity_brush
,
&
matrix
);
set_rect
(
&
rect
,
40
.
0
f
,
360
.
0
f
,
120
.
0
f
,
600
.
0
f
);
ID2D1Factory_CreateRectangleGeometry
(
factory
,
&
rect
,
&
geometry
);
ID2D1RenderTarget_FillGeometry
(
rt
,
(
ID2D1Geometry
*
)
geometry
,
(
ID2D1Brush
*
)
opacity_brush
,
(
ID2D1Brush
*
)
color_brush
);
ID2D1RectangleGeometry_Release
(
geometry
);
set_matrix_identity
(
&
matrix
);
translate_matrix
(
&
matrix
,
120
.
0
f
,
360
.
0
f
);
scale_matrix
(
&
matrix
,
20
.
0
f
,
60
.
0
f
);
ID2D1BitmapBrush_SetTransform
(
opacity_brush
,
&
matrix
);
set_rect
(
&
rect
,
120
.
0
f
,
360
.
0
f
,
200
.
0
f
,
600
.
0
f
);
ID2D1Factory_CreateRectangleGeometry
(
factory
,
&
rect
,
&
geometry
);
ID2D1RenderTarget_FillGeometry
(
rt
,
(
ID2D1Geometry
*
)
geometry
,
(
ID2D1Brush
*
)
color_brush
,
(
ID2D1Brush
*
)
opacity_brush
);
ID2D1RectangleGeometry_Release
(
geometry
);
set_matrix_identity
(
&
matrix
);
translate_matrix
(
&
matrix
,
200
.
0
f
,
360
.
0
f
);
scale_matrix
(
&
matrix
,
20
.
0
f
,
60
.
0
f
);
ID2D1BitmapBrush_SetTransform
(
opacity_brush
,
&
matrix
);
set_rect
(
&
rect
,
200
.
0
f
,
360
.
0
f
,
280
.
0
f
,
600
.
0
f
);
ID2D1Factory_CreateRectangleGeometry
(
factory
,
&
rect
,
&
geometry
);
ID2D1RenderTarget_FillGeometry
(
rt
,
(
ID2D1Geometry
*
)
geometry
,
(
ID2D1Brush
*
)
bitmap_brush
,
(
ID2D1Brush
*
)
opacity_brush
);
hr
=
ID2D1RenderTarget_EndDraw
(
rt
,
NULL
,
NULL
);
ok
(
hr
==
D2DERR_INCOMPATIBLE_BRUSH_TYPES
,
"Got unexpected hr %#x.
\n
"
,
hr
);
match
=
compare_surface
(
surface
,
"7141c6c7b3decb91196428efb1856bcbf9872935"
);
ok
(
match
,
"Surface does not match.
\n
"
);
ID2D1RenderTarget_BeginDraw
(
rt
);
ID2D1RenderTarget_FillGeometry
(
rt
,
(
ID2D1Geometry
*
)
geometry
,
(
ID2D1Brush
*
)
bitmap_brush
,
(
ID2D1Brush
*
)
opacity_brush
);
ID2D1RectangleGeometry_Release
(
geometry
);
ID2D1SolidColorBrush_SetOpacity
(
color_brush
,
0
.
5
f
);
set_matrix_identity
(
&
matrix
);
translate_matrix
(
&
matrix
,
40
.
0
f
,
600
.
0
f
);
scale_matrix
(
&
matrix
,
20
.
0
f
,
60
.
0
f
);
ID2D1BitmapBrush_SetTransform
(
opacity_brush
,
&
matrix
);
set_rect
(
&
rect
,
40
.
0
f
,
600
.
0
f
,
120
.
0
f
,
840
.
0
f
);
ID2D1Factory_CreateRectangleGeometry
(
factory
,
&
rect
,
&
geometry
);
ID2D1RenderTarget_FillGeometry
(
rt
,
(
ID2D1Geometry
*
)
geometry
,
(
ID2D1Brush
*
)
opacity_brush
,
(
ID2D1Brush
*
)
color_brush
);
ID2D1RectangleGeometry_Release
(
geometry
);
ID2D1BitmapBrush_SetOpacity
(
opacity_brush
,
0
.
8
f
);
set_matrix_identity
(
&
matrix
);
translate_matrix
(
&
matrix
,
120
.
0
f
,
600
.
0
f
);
scale_matrix
(
&
matrix
,
20
.
0
f
,
60
.
0
f
);
ID2D1BitmapBrush_SetTransform
(
opacity_brush
,
&
matrix
);
set_rect
(
&
rect
,
120
.
0
f
,
600
.
0
f
,
200
.
0
f
,
840
.
0
f
);
ID2D1Factory_CreateRectangleGeometry
(
factory
,
&
rect
,
&
geometry
);
ID2D1RenderTarget_FillGeometry
(
rt
,
(
ID2D1Geometry
*
)
geometry
,
(
ID2D1Brush
*
)
opacity_brush
,
(
ID2D1Brush
*
)
bitmap_brush
);
ID2D1RectangleGeometry_Release
(
geometry
);
set_matrix_identity
(
&
matrix
);
translate_matrix
(
&
matrix
,
200
.
0
f
,
600
.
0
f
);
scale_matrix
(
&
matrix
,
20
.
0
f
,
60
.
0
f
);
ID2D1BitmapBrush_SetTransform
(
opacity_brush
,
&
matrix
);
set_rect
(
&
rect
,
200
.
0
f
,
600
.
0
f
,
280
.
0
f
,
840
.
0
f
);
ID2D1Factory_CreateRectangleGeometry
(
factory
,
&
rect
,
&
geometry
);
ID2D1RenderTarget_FillGeometry
(
rt
,
(
ID2D1Geometry
*
)
geometry
,
(
ID2D1Brush
*
)
bitmap_brush
,
(
ID2D1Brush
*
)
opacity_brush
);
ID2D1RectangleGeometry_Release
(
geometry
);
hr
=
ID2D1RenderTarget_EndDraw
(
rt
,
NULL
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"Failed to end draw, hr %#x.
\n
"
,
hr
);
match
=
compare_surface
(
surface
,
"c3a5802d1750efa3e9122c1a92f6064df3872732"
);
ok
(
match
,
"Surface does not match.
\n
"
);
ID2D1BitmapBrush_Release
(
bitmap_brush
);
ID2D1BitmapBrush_Release
(
opacity_brush
);
ID2D1SolidColorBrush_Release
(
color_brush
);
ID2D1RenderTarget_Release
(
rt
);
refcount
=
ID2D1Factory_Release
(
factory
);
ok
(
!
refcount
,
"Factory has %u references left.
\n
"
,
refcount
);
IDXGISurface_Release
(
surface
);
IDXGISwapChain_Release
(
swapchain
);
ID3D10Device1_Release
(
device
);
DestroyWindow
(
window
);
}
START_TEST
(
d2d1
)
{
test_clip
();
...
...
@@ -2257,4 +2439,5 @@ START_TEST(d2d1)
test_alpha_mode
();
test_shared_bitmap
();
test_bitmap_updates
();
test_opacity_brush
();
}
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