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
11d94a11
Commit
11d94a11
authored
Oct 20, 2012
by
Nikolay Sivov
Committed by
Alexandre Julliard
Oct 22, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dwrite: Store text string in layout object.
parent
516731c8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
5 deletions
+61
-5
dwrite_private.h
dlls/dwrite/dwrite_private.h
+16
-2
layout.c
dlls/dwrite/layout.c
+7
-1
main.c
dlls/dwrite/main.c
+2
-2
layout.c
dlls/dwrite/tests/layout.c
+36
-0
No files found.
dlls/dwrite/dwrite_private.h
View file @
11d94a11
...
...
@@ -38,7 +38,7 @@ static inline BOOL heap_free(void *mem)
return
HeapFree
(
GetProcessHeap
(),
0
,
mem
);
}
static
inline
LPWSTR
heap_strdupW
(
LPCWSTR
str
)
static
inline
LPWSTR
heap_strdupW
(
const
WCHAR
*
str
)
{
LPWSTR
ret
=
NULL
;
...
...
@@ -53,10 +53,24 @@ static inline LPWSTR heap_strdupW(LPCWSTR str)
return
ret
;
}
static
inline
LPWSTR
heap_strdupnW
(
const
WCHAR
*
str
,
UINT32
len
)
{
WCHAR
*
ret
=
NULL
;
if
(
len
)
{
ret
=
heap_alloc
((
len
+
1
)
*
sizeof
(
WCHAR
));
memcpy
(
ret
,
str
,
len
*
sizeof
(
WCHAR
));
ret
[
len
]
=
0
;
}
return
ret
;
}
extern
HRESULT
create_font_from_logfont
(
const
LOGFONTW
*
,
IDWriteFont
**
)
DECLSPEC_HIDDEN
;
extern
HRESULT
create_textformat
(
const
WCHAR
*
,
DWRITE_FONT_WEIGHT
,
DWRITE_FONT_STYLE
,
DWRITE_FONT_STRETCH
,
FLOAT
,
const
WCHAR
*
,
IDWriteTextFormat
**
)
DECLSPEC_HIDDEN
;
extern
HRESULT
create_textlayout
(
IDWriteTextLayout
**
)
DECLSPEC_HIDDEN
;
extern
HRESULT
create_textlayout
(
const
WCHAR
*
,
UINT32
,
IDWriteTextLayout
**
)
DECLSPEC_HIDDEN
;
extern
HRESULT
create_gdiinterop
(
IDWriteGdiInterop
**
)
DECLSPEC_HIDDEN
;
extern
HRESULT
create_localizedstrings
(
IDWriteLocalizedStrings
**
)
DECLSPEC_HIDDEN
;
extern
HRESULT
add_localizedstring
(
IDWriteLocalizedStrings
*
,
const
WCHAR
*
,
const
WCHAR
*
)
DECLSPEC_HIDDEN
;
dlls/dwrite/layout.c
View file @
11d94a11
...
...
@@ -35,6 +35,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
struct
dwrite_textlayout
{
IDWriteTextLayout
IDWriteTextLayout_iface
;
LONG
ref
;
WCHAR
*
str
;
};
struct
dwrite_textformat
{
...
...
@@ -97,7 +99,10 @@ static ULONG WINAPI dwritetextlayout_Release(IDWriteTextLayout *iface)
TRACE
(
"(%p)->(%d)
\n
"
,
This
,
ref
);
if
(
!
ref
)
{
heap_free
(
This
->
str
);
heap_free
(
This
);
}
return
S_OK
;
}
...
...
@@ -646,7 +651,7 @@ static const IDWriteTextLayoutVtbl dwritetextlayoutvtbl = {
dwritetextlayout_HitTestTextRange
};
HRESULT
create_textlayout
(
IDWriteTextLayout
**
layout
)
HRESULT
create_textlayout
(
const
WCHAR
*
str
,
UINT32
len
,
IDWriteTextLayout
**
layout
)
{
struct
dwrite_textlayout
*
This
;
...
...
@@ -657,6 +662,7 @@ HRESULT create_textlayout(IDWriteTextLayout **layout)
This
->
IDWriteTextLayout_iface
.
lpVtbl
=
&
dwritetextlayoutvtbl
;
This
->
ref
=
1
;
This
->
str
=
heap_strdupnW
(
str
,
len
);
*
layout
=
&
This
->
IDWriteTextLayout_iface
;
...
...
dlls/dwrite/main.c
View file @
11d94a11
...
...
@@ -506,7 +506,7 @@ static HRESULT WINAPI dwritefactory_CreateTextLayout(IDWriteFactory *iface, WCHA
FIXME
(
"(%s %u %p %f %f %p): stub
\n
"
,
debugstr_w
(
string
),
len
,
format
,
max_width
,
max_height
,
layout
);
if
(
!
format
)
return
E_INVALIDARG
;
return
create_textlayout
(
layout
);
return
create_textlayout
(
string
,
len
,
layout
);
}
static
HRESULT
WINAPI
dwritefactory_CreateGdiCompatibleTextLayout
(
IDWriteFactory
*
iface
,
WCHAR
const
*
string
,
...
...
@@ -517,7 +517,7 @@ static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory
pixels_per_dip
,
transform
,
use_gdi_natural
,
layout
);
if
(
!
format
)
return
E_INVALIDARG
;
return
create_textlayout
(
layout
);
return
create_textlayout
(
string
,
len
,
layout
);
}
static
HRESULT
WINAPI
dwritefactory_CreateEllipsisTrimmingSign
(
IDWriteFactory
*
iface
,
IDWriteTextFormat
*
format
,
...
...
dlls/dwrite/tests/layout.c
View file @
11d94a11
...
...
@@ -27,6 +27,16 @@
static
IDWriteFactory
*
factory
;
static
const
WCHAR
tahomaW
[]
=
{
'T'
,
'a'
,
'h'
,
'o'
,
'm'
,
'a'
,
0
};
#define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__)
static
void
_expect_ref
(
IUnknown
*
obj
,
ULONG
ref
,
int
line
)
{
ULONG
rc
=
IUnknown_AddRef
(
obj
);
IUnknown_Release
(
obj
);
ok_
(
__FILE__
,
line
)(
rc
-
1
==
ref
,
"expected refcount %d, got %d
\n
"
,
ref
,
rc
-
1
);
}
static
void
test_CreateTextLayout
(
void
)
{
static
const
WCHAR
strW
[]
=
{
's'
,
't'
,
'r'
,
'i'
,
'n'
,
'g'
,
0
};
...
...
@@ -52,7 +62,9 @@ static void test_CreateTextLayout(void)
static
void
test_CreateGdiCompatibleTextLayout
(
void
)
{
static
const
WCHAR
strW
[]
=
{
's'
,
't'
,
'r'
,
'i'
,
'n'
,
'g'
,
0
};
static
const
WCHAR
enusW
[]
=
{
'e'
,
'n'
,
'-'
,
'u'
,
's'
,
0
};
IDWriteTextLayout
*
layout
;
IDWriteTextFormat
*
format
;
HRESULT
hr
;
hr
=
IDWriteFactory_CreateGdiCompatibleTextLayout
(
factory
,
NULL
,
0
,
NULL
,
0
.
0
,
0
.
0
,
0
.
0
,
NULL
,
FALSE
,
&
layout
);
...
...
@@ -69,6 +81,30 @@ static void test_CreateGdiCompatibleTextLayout(void)
hr
=
IDWriteFactory_CreateGdiCompatibleTextLayout
(
factory
,
strW
,
6
,
NULL
,
1000
.
0
,
1000
.
0
,
1
.
0
,
NULL
,
FALSE
,
&
layout
);
ok
(
hr
==
E_INVALIDARG
,
"got 0x%08x
\n
"
,
hr
);
/* create with text format */
hr
=
IDWriteFactory_CreateTextFormat
(
factory
,
tahomaW
,
NULL
,
DWRITE_FONT_WEIGHT_NORMAL
,
DWRITE_FONT_STYLE_NORMAL
,
DWRITE_FONT_STRETCH_NORMAL
,
10
.
0
,
enusW
,
&
format
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
EXPECT_REF
(
format
,
1
);
hr
=
IDWriteFactory_CreateGdiCompatibleTextLayout
(
factory
,
strW
,
6
,
format
,
100
.
0
,
100
.
0
,
1
.
0
,
NULL
,
FALSE
,
&
layout
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
EXPECT_REF
(
format
,
1
);
EXPECT_REF
(
layout
,
1
);
IDWriteTextLayout_AddRef
(
layout
);
EXPECT_REF
(
format
,
1
);
EXPECT_REF
(
layout
,
2
);
IDWriteTextLayout_Release
(
layout
);
IDWriteTextLayout_Release
(
layout
);
/* zero length string is okay */
hr
=
IDWriteFactory_CreateGdiCompatibleTextLayout
(
factory
,
strW
,
0
,
format
,
100
.
0
,
100
.
0
,
1
.
0
,
NULL
,
FALSE
,
&
layout
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
IDWriteTextLayout_Release
(
layout
);
IDWriteTextFormat_Release
(
format
);
}
START_TEST
(
layout
)
...
...
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