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
3bb382aa
Commit
3bb382aa
authored
Jul 14, 2015
by
Henri Verbeet
Committed by
Alexandre Julliard
Jul 14, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d2d1: Introduce a separate function to construct pixel shader constant buffers for brushes.
parent
1f4e3765
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
70 deletions
+103
-70
brush.c
dlls/d2d1/brush.c
+87
-0
d2d1_private.h
dlls/d2d1/d2d1_private.h
+14
-0
render_target.c
dlls/d2d1/render_target.c
+2
-70
No files found.
dlls/d2d1/brush.c
View file @
3bb382aa
...
...
@@ -709,6 +709,93 @@ static D3D10_TEXTURE_ADDRESS_MODE texture_addres_mode_from_extend_mode(D2D1_EXTE
}
}
HRESULT
d2d_brush_get_ps_cb
(
struct
d2d_brush
*
brush
,
struct
d2d_d3d_render_target
*
render_target
,
ID3D10Buffer
**
ps_cb
)
{
D3D10_SUBRESOURCE_DATA
buffer_data
;
D3D10_BUFFER_DESC
buffer_desc
;
struct
{
float
_11
,
_21
,
_31
,
pad0
;
float
_12
,
_22
,
_32
,
pad1
;
}
transform
;
D2D1_COLOR_F
color
;
HRESULT
hr
;
buffer_desc
.
Usage
=
D3D10_USAGE_DEFAULT
;
buffer_desc
.
BindFlags
=
D3D10_BIND_CONSTANT_BUFFER
;
buffer_desc
.
CPUAccessFlags
=
0
;
buffer_desc
.
MiscFlags
=
0
;
buffer_data
.
SysMemPitch
=
0
;
buffer_data
.
SysMemSlicePitch
=
0
;
if
(
brush
->
type
==
D2D_BRUSH_TYPE_SOLID
)
{
color
=
brush
->
u
.
solid
.
color
;
color
.
a
*=
brush
->
opacity
;
buffer_desc
.
ByteWidth
=
sizeof
(
color
);
buffer_data
.
pSysMem
=
&
color
;
}
else
if
(
brush
->
type
==
D2D_BRUSH_TYPE_BITMAP
)
{
struct
d2d_bitmap
*
bitmap
=
brush
->
u
.
bitmap
.
bitmap
;
D2D_MATRIX_3X2_F
w
,
b
;
float
dpi_scale
,
d
;
/* Scale for dpi. */
w
=
render_target
->
drawing_state
.
transform
;
dpi_scale
=
render_target
->
dpi_x
/
96
.
0
f
;
w
.
_11
*=
dpi_scale
;
w
.
_21
*=
dpi_scale
;
w
.
_31
*=
dpi_scale
;
dpi_scale
=
render_target
->
dpi_y
/
96
.
0
f
;
w
.
_12
*=
dpi_scale
;
w
.
_22
*=
dpi_scale
;
w
.
_32
*=
dpi_scale
;
/* Scale for bitmap size and dpi. */
b
=
brush
->
transform
;
dpi_scale
=
bitmap
->
pixel_size
.
width
*
(
bitmap
->
dpi_x
/
96
.
0
f
);
b
.
_11
*=
dpi_scale
;
b
.
_21
*=
dpi_scale
;
dpi_scale
=
bitmap
->
pixel_size
.
height
*
(
bitmap
->
dpi_y
/
96
.
0
f
);
b
.
_12
*=
dpi_scale
;
b
.
_22
*=
dpi_scale
;
d2d_matrix_multiply
(
&
b
,
&
w
);
/* Invert the matrix. (Because the matrix is applied to the sampling
* coordinates. I.e., to scale the bitmap by 2 we need to divide the
* coordinates by 2.) */
d
=
b
.
_11
*
b
.
_22
-
b
.
_21
*
b
.
_12
;
if
(
d
!=
0
.
0
f
)
{
transform
.
_11
=
b
.
_22
/
d
;
transform
.
_21
=
-
b
.
_21
/
d
;
transform
.
_31
=
(
b
.
_21
*
b
.
_32
-
b
.
_31
*
b
.
_22
)
/
d
;
transform
.
_12
=
-
b
.
_12
/
d
;
transform
.
_22
=
b
.
_11
/
d
;
transform
.
_32
=
-
(
b
.
_11
*
b
.
_32
-
b
.
_31
*
b
.
_12
)
/
d
;
}
transform
.
pad1
=
brush
->
opacity
;
buffer_desc
.
ByteWidth
=
sizeof
(
transform
);
buffer_data
.
pSysMem
=
&
transform
;
}
else
{
FIXME
(
"Unhandled brush type %#x.
\n
"
,
brush
->
type
);
return
E_NOTIMPL
;
}
if
(
FAILED
(
hr
=
ID3D10Device_CreateBuffer
(
render_target
->
device
,
&
buffer_desc
,
&
buffer_data
,
ps_cb
)))
ERR
(
"Failed to create constant buffer, hr %#x.
\n
"
,
hr
);
return
hr
;
}
void
d2d_brush_bind_resources
(
struct
d2d_brush
*
brush
,
struct
d2d_d3d_render_target
*
render_target
)
{
static
const
float
blend_factor
[]
=
{
1
.
0
f
,
1
.
0
f
,
1
.
0
f
,
1
.
0
f
};
...
...
dlls/d2d1/d2d1_private.h
View file @
3bb382aa
...
...
@@ -142,6 +142,8 @@ HRESULT d2d_bitmap_brush_init(struct d2d_brush *brush, struct d2d_d3d_render_tar
ID2D1Bitmap
*
bitmap
,
const
D2D1_BITMAP_BRUSH_PROPERTIES
*
bitmap_brush_desc
,
const
D2D1_BRUSH_PROPERTIES
*
brush_desc
)
DECLSPEC_HIDDEN
;
void
d2d_brush_bind_resources
(
struct
d2d_brush
*
brush
,
struct
d2d_d3d_render_target
*
render_target
)
DECLSPEC_HIDDEN
;
HRESULT
d2d_brush_get_ps_cb
(
struct
d2d_brush
*
brush
,
struct
d2d_d3d_render_target
*
render_target
,
ID3D10Buffer
**
ps_cb
)
DECLSPEC_HIDDEN
;
struct
d2d_brush
*
unsafe_impl_from_ID2D1Brush
(
ID2D1Brush
*
iface
)
DECLSPEC_HIDDEN
;
struct
d2d_stroke_style
...
...
@@ -233,4 +235,16 @@ struct d2d_geometry
void
d2d_path_geometry_init
(
struct
d2d_geometry
*
geometry
)
DECLSPEC_HIDDEN
;
HRESULT
d2d_rectangle_geometry_init
(
struct
d2d_geometry
*
geometry
,
const
D2D1_RECT_F
*
rect
)
DECLSPEC_HIDDEN
;
static
inline
void
d2d_matrix_multiply
(
D2D_MATRIX_3X2_F
*
a
,
const
D2D_MATRIX_3X2_F
*
b
)
{
D2D_MATRIX_3X2_F
tmp
=
*
a
;
a
->
_11
=
tmp
.
_11
*
b
->
_11
+
tmp
.
_12
*
b
->
_21
;
a
->
_12
=
tmp
.
_11
*
b
->
_12
+
tmp
.
_12
*
b
->
_22
;
a
->
_21
=
tmp
.
_21
*
b
->
_11
+
tmp
.
_22
*
b
->
_21
;
a
->
_22
=
tmp
.
_21
*
b
->
_12
+
tmp
.
_22
*
b
->
_22
;
a
->
_31
=
tmp
.
_31
*
b
->
_11
+
tmp
.
_32
*
b
->
_21
+
b
->
_31
;
a
->
_32
=
tmp
.
_31
*
b
->
_12
+
tmp
.
_32
*
b
->
_22
+
b
->
_32
;
}
#endif
/* __WINE_D2D1_PRIVATE_H */
dlls/d2d1/render_target.c
View file @
3bb382aa
...
...
@@ -32,18 +32,6 @@ struct d2d_draw_text_layout_ctx
D2D1_DRAW_TEXT_OPTIONS
options
;
};
static
void
d2d_matrix_multiply
(
D2D_MATRIX_3X2_F
*
a
,
const
D2D_MATRIX_3X2_F
*
b
)
{
D2D_MATRIX_3X2_F
tmp
=
*
a
;
a
->
_11
=
tmp
.
_11
*
b
->
_11
+
tmp
.
_12
*
b
->
_21
;
a
->
_12
=
tmp
.
_11
*
b
->
_12
+
tmp
.
_12
*
b
->
_22
;
a
->
_21
=
tmp
.
_21
*
b
->
_11
+
tmp
.
_22
*
b
->
_21
;
a
->
_22
=
tmp
.
_21
*
b
->
_12
+
tmp
.
_22
*
b
->
_22
;
a
->
_31
=
tmp
.
_31
*
b
->
_11
+
tmp
.
_32
*
b
->
_21
+
b
->
_31
;
a
->
_32
=
tmp
.
_31
*
b
->
_12
+
tmp
.
_32
*
b
->
_22
+
b
->
_32
;
}
static
void
d2d_point_set
(
D2D1_POINT_2F
*
dst
,
float
x
,
float
y
)
{
dst
->
x
=
x
;
...
...
@@ -550,7 +538,6 @@ static void STDMETHODCALLTYPE d2d_d3d_render_target_FillRectangle(ID2D1RenderTar
D3D10_SUBRESOURCE_DATA
buffer_data
;
D3D10_BUFFER_DESC
buffer_desc
;
ID3D10Buffer
*
vs_cb
,
*
ps_cb
;
D2D1_COLOR_F
color
;
float
tmp_x
,
tmp_y
;
HRESULT
hr
;
struct
...
...
@@ -609,64 +596,9 @@ static void STDMETHODCALLTYPE d2d_d3d_render_target_FillRectangle(ID2D1RenderTar
return
;
}
if
(
brush_impl
->
type
==
D2D_BRUSH_TYPE_BITMAP
)
{
struct
d2d_bitmap
*
bitmap
=
brush_impl
->
u
.
bitmap
.
bitmap
;
D2D_MATRIX_3X2_F
w
,
b
;
float
dpi_scale
,
d
;
/* Scale for dpi. */
w
=
render_target
->
drawing_state
.
transform
;
dpi_scale
=
render_target
->
dpi_x
/
96
.
0
f
;
w
.
_11
*=
dpi_scale
;
w
.
_21
*=
dpi_scale
;
w
.
_31
*=
dpi_scale
;
dpi_scale
=
render_target
->
dpi_y
/
96
.
0
f
;
w
.
_12
*=
dpi_scale
;
w
.
_22
*=
dpi_scale
;
w
.
_32
*=
dpi_scale
;
/* Scale for bitmap size and dpi. */
b
=
brush_impl
->
transform
;
dpi_scale
=
bitmap
->
pixel_size
.
width
*
(
bitmap
->
dpi_x
/
96
.
0
f
);
b
.
_11
*=
dpi_scale
;
b
.
_21
*=
dpi_scale
;
dpi_scale
=
bitmap
->
pixel_size
.
height
*
(
bitmap
->
dpi_y
/
96
.
0
f
);
b
.
_12
*=
dpi_scale
;
b
.
_22
*=
dpi_scale
;
d2d_matrix_multiply
(
&
b
,
&
w
);
/* Invert the matrix. (Because the matrix is applied to the sampling
* coordinates. I.e., to scale the bitmap by 2 we need to divide the
* coordinates by 2.) */
d
=
b
.
_11
*
b
.
_22
-
b
.
_21
*
b
.
_12
;
if
(
d
!=
0
.
0
f
)
{
transform
.
_11
=
b
.
_22
/
d
;
transform
.
_21
=
-
b
.
_21
/
d
;
transform
.
_31
=
(
b
.
_21
*
b
.
_32
-
b
.
_31
*
b
.
_22
)
/
d
;
transform
.
_12
=
-
b
.
_12
/
d
;
transform
.
_22
=
b
.
_11
/
d
;
transform
.
_32
=
-
(
b
.
_11
*
b
.
_32
-
b
.
_31
*
b
.
_12
)
/
d
;
}
transform
.
pad1
=
brush_impl
->
opacity
;
buffer_desc
.
ByteWidth
=
sizeof
(
transform
);
buffer_data
.
pSysMem
=
&
transform
;
}
else
{
color
=
brush_impl
->
u
.
solid
.
color
;
color
.
a
*=
brush_impl
->
opacity
;
buffer_desc
.
ByteWidth
=
sizeof
(
color
);
buffer_data
.
pSysMem
=
&
color
;
}
if
(
FAILED
(
hr
=
ID3D10Device_CreateBuffer
(
render_target
->
device
,
&
buffer_desc
,
&
buffer_data
,
&
ps_cb
)))
if
(
FAILED
(
hr
=
d2d_brush_get_ps_cb
(
brush_impl
,
render_target
,
&
ps_cb
)))
{
WARN
(
"Failed to
create
constant buffer, hr %#x.
\n
"
,
hr
);
WARN
(
"Failed to
get ps
constant buffer, hr %#x.
\n
"
,
hr
);
ID3D10Buffer_Release
(
vs_cb
);
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