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
c9b8a31c
Commit
c9b8a31c
authored
Aug 01, 2014
by
Nikolay Sivov
Committed by
Alexandre Julliard
Aug 04, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dwrite: Implement Resize() for bitmap render target.
parent
ece85fad
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
29 deletions
+96
-29
gdiinterop.c
dlls/dwrite/gdiinterop.c
+46
-27
font.c
dlls/dwrite/tests/font.c
+50
-2
No files found.
dlls/dwrite/gdiinterop.c
View file @
c9b8a31c
...
...
@@ -40,6 +40,28 @@ struct rendertarget {
HDC
hdc
;
};
static
HRESULT
create_target_dibsection
(
HDC
hdc
,
UINT32
width
,
UINT32
height
)
{
char
bmibuf
[
FIELD_OFFSET
(
BITMAPINFO
,
bmiColors
[
256
])];
BITMAPINFO
*
bmi
=
(
BITMAPINFO
*
)
bmibuf
;
HBITMAP
hbm
;
memset
(
bmi
,
0
,
sizeof
(
bmibuf
));
bmi
->
bmiHeader
.
biSize
=
sizeof
(
bmi
->
bmiHeader
);
bmi
->
bmiHeader
.
biHeight
=
height
;
bmi
->
bmiHeader
.
biWidth
=
width
;
bmi
->
bmiHeader
.
biBitCount
=
32
;
bmi
->
bmiHeader
.
biPlanes
=
1
;
bmi
->
bmiHeader
.
biCompression
=
BI_RGB
;
hbm
=
CreateDIBSection
(
hdc
,
bmi
,
DIB_RGB_COLORS
,
NULL
,
NULL
,
0
);
if
(
!
hbm
)
hbm
=
CreateBitmap
(
1
,
1
,
1
,
1
,
NULL
);
DeleteObject
(
SelectObject
(
hdc
,
hbm
));
return
S_OK
;
}
static
inline
struct
rendertarget
*
impl_from_IDWriteBitmapRenderTarget
(
IDWriteBitmapRenderTarget
*
iface
)
{
return
CONTAINING_RECORD
(
iface
,
struct
rendertarget
,
IDWriteBitmapRenderTarget_iface
);
...
...
@@ -145,8 +167,13 @@ static HRESULT WINAPI rendertarget_GetSize(IDWriteBitmapRenderTarget *iface, SIZ
static
HRESULT
WINAPI
rendertarget_Resize
(
IDWriteBitmapRenderTarget
*
iface
,
UINT32
width
,
UINT32
height
)
{
struct
rendertarget
*
This
=
impl_from_IDWriteBitmapRenderTarget
(
iface
);
FIXME
(
"(%p)->(%u %u): stub
\n
"
,
This
,
width
,
height
);
return
E_NOTIMPL
;
TRACE
(
"(%p)->(%u %u)
\n
"
,
This
,
width
,
height
);
if
(
This
->
size
.
cx
==
width
&&
This
->
size
.
cy
==
height
)
return
S_OK
;
return
create_target_dibsection
(
This
->
hdc
,
width
,
height
);
}
static
const
IDWriteBitmapRenderTargetVtbl
rendertargetvtbl
=
{
...
...
@@ -163,38 +190,30 @@ static const IDWriteBitmapRenderTargetVtbl rendertargetvtbl = {
rendertarget_Resize
};
static
HRESULT
create_rendertarget
(
HDC
hdc
,
UINT32
width
,
UINT32
height
,
IDWriteBitmapRenderTarget
**
targ
et
)
static
HRESULT
create_rendertarget
(
HDC
hdc
,
UINT32
width
,
UINT32
height
,
IDWriteBitmapRenderTarget
**
r
et
)
{
char
bmibuf
[
FIELD_OFFSET
(
BITMAPINFO
,
bmiColors
[
256
])];
BITMAPINFO
*
bmi
=
(
BITMAPINFO
*
)
bmibuf
;
struct
rendertarget
*
This
;
HBITMAP
dib
;
*
target
=
NULL
;
This
=
heap_alloc
(
sizeof
(
struct
rendertarget
));
if
(
!
This
)
return
E_OUTOFMEMORY
;
struct
rendertarget
*
target
;
HRESULT
hr
;
This
->
IDWriteBitmapRenderTarget_iface
.
lpVtbl
=
&
rendertargetvtbl
;
This
->
ref
=
1
;
*
ret
=
NULL
;
This
->
size
.
cx
=
width
;
This
->
size
.
cy
=
height
;
target
=
heap_alloc
(
sizeof
(
struct
rendertarget
))
;
if
(
!
target
)
return
E_OUTOFMEMORY
;
This
->
hdc
=
CreateCompatibleDC
(
hdc
);
target
->
IDWriteBitmapRenderTarget_iface
.
lpVtbl
=
&
rendertargetvtbl
;
target
->
ref
=
1
;
memset
(
bmi
,
0
,
sizeof
(
bmibuf
));
bmi
->
bmiHeader
.
biSize
=
sizeof
(
bmi
->
bmiHeader
);
bmi
->
bmiHeader
.
biHeight
=
height
;
bmi
->
bmiHeader
.
biWidth
=
width
;
bmi
->
bmiHeader
.
biBitCount
=
32
;
bmi
->
bmiHeader
.
biPlanes
=
1
;
bmi
->
bmiHeader
.
biCompression
=
BI_RGB
;
target
->
size
.
cx
=
width
;
target
->
size
.
cy
=
height
;
dib
=
CreateDIBSection
(
This
->
hdc
,
bmi
,
DIB_RGB_COLORS
,
NULL
,
NULL
,
0
);
SelectObject
(
This
->
hdc
,
dib
);
target
->
hdc
=
CreateCompatibleDC
(
hdc
);
hr
=
create_target_dibsection
(
target
->
hdc
,
width
,
height
);
if
(
FAILED
(
hr
))
{
IDWriteBitmapRenderTarget_Release
(
&
target
->
IDWriteBitmapRenderTarget_iface
);
return
hr
;
}
*
target
=
&
This
->
IDWriteBitmapRenderTarget_iface
;
*
ret
=
&
target
->
IDWriteBitmapRenderTarget_iface
;
return
S_OK
;
}
...
...
dlls/dwrite/tests/font.c
View file @
c9b8a31c
...
...
@@ -198,8 +198,8 @@ static void test_CreateBitmapRenderTarget(void)
{
IDWriteBitmapRenderTarget
*
target
,
*
target2
;
IDWriteGdiInterop
*
interop
;
HBITMAP
hbm
,
hbm2
;
DIBSECTION
ds
;
HBITMAP
hbm
;
HRESULT
hr
;
SIZE
size
;
HDC
hdc
;
...
...
@@ -272,8 +272,56 @@ if (0) /* crashes on native */
ok
(
size
.
cx
==
10
,
"got %d
\n
"
,
size
.
cx
);
ok
(
size
.
cy
==
5
,
"got %d
\n
"
,
size
.
cy
);
IDWriteBitmapRenderTarget_Release
(
target
);
/* resize to same size */
hr
=
IDWriteBitmapRenderTarget_Resize
(
target
,
10
,
5
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hbm2
=
GetCurrentObject
(
hdc
,
OBJ_BITMAP
);
ok
(
hbm2
==
hbm
,
"got %p, %p
\n
"
,
hbm2
,
hbm
);
/* shrink */
hr
=
IDWriteBitmapRenderTarget_Resize
(
target
,
5
,
5
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hbm2
=
GetCurrentObject
(
hdc
,
OBJ_BITMAP
);
ok
(
hbm2
!=
hbm
,
"got %p, %p
\n
"
,
hbm2
,
hbm
);
hr
=
IDWriteBitmapRenderTarget_Resize
(
target
,
20
,
5
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hbm2
=
GetCurrentObject
(
hdc
,
OBJ_BITMAP
);
ok
(
hbm2
!=
hbm
,
"got %p, %p
\n
"
,
hbm2
,
hbm
);
hr
=
IDWriteBitmapRenderTarget_Resize
(
target
,
1
,
5
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hbm2
=
GetCurrentObject
(
hdc
,
OBJ_BITMAP
);
ok
(
hbm2
!=
hbm
,
"got %p, %p
\n
"
,
hbm2
,
hbm
);
ret
=
GetObjectW
(
hbm2
,
sizeof
(
ds
),
&
ds
);
ok
(
ret
==
sizeof
(
ds
),
"got %d
\n
"
,
ret
);
ok
(
ds
.
dsBm
.
bmWidth
==
1
,
"got %d
\n
"
,
ds
.
dsBm
.
bmWidth
);
ok
(
ds
.
dsBm
.
bmHeight
==
5
,
"got %d
\n
"
,
ds
.
dsBm
.
bmHeight
);
ok
(
ds
.
dsBm
.
bmPlanes
==
1
,
"got %d
\n
"
,
ds
.
dsBm
.
bmPlanes
);
ok
(
ds
.
dsBm
.
bmBitsPixel
==
32
,
"got %d
\n
"
,
ds
.
dsBm
.
bmBitsPixel
);
ok
(
ds
.
dsBm
.
bmBits
!=
NULL
,
"got %p
\n
"
,
ds
.
dsBm
.
bmBits
);
/* empty rectangle */
hr
=
IDWriteBitmapRenderTarget_Resize
(
target
,
0
,
5
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hbm2
=
GetCurrentObject
(
hdc
,
OBJ_BITMAP
);
ok
(
hbm2
!=
hbm
,
"got %p, %p
\n
"
,
hbm2
,
hbm
);
ret
=
GetObjectW
(
hbm2
,
sizeof
(
ds
),
&
ds
);
ok
(
ret
==
sizeof
(
BITMAP
),
"got %d
\n
"
,
ret
);
ok
(
ds
.
dsBm
.
bmWidth
==
1
,
"got %d
\n
"
,
ds
.
dsBm
.
bmWidth
);
ok
(
ds
.
dsBm
.
bmHeight
==
1
,
"got %d
\n
"
,
ds
.
dsBm
.
bmHeight
);
ok
(
ds
.
dsBm
.
bmPlanes
==
1
,
"got %d
\n
"
,
ds
.
dsBm
.
bmPlanes
);
ok
(
ds
.
dsBm
.
bmBitsPixel
==
1
,
"got %d
\n
"
,
ds
.
dsBm
.
bmBitsPixel
);
ok
(
!
ds
.
dsBm
.
bmBits
,
"got %p
\n
"
,
ds
.
dsBm
.
bmBits
);
IDWriteBitmapRenderTarget_Release
(
target
);
IDWriteGdiInterop_Release
(
interop
);
}
...
...
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