Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lorenzo Ferrillo
wine
Commits
11d94a11
Commit
11d94a11
authored
12 years ago
by
Nikolay Sivov
Committed by
Alexandre Julliard
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
dwrite: Store text string in layout object.
parent
516731c8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
dlls/dwrite/dwrite_private.h
+16
-2
16 additions, 2 deletions
dlls/dwrite/dwrite_private.h
dlls/dwrite/layout.c
+7
-1
7 additions, 1 deletion
dlls/dwrite/layout.c
dlls/dwrite/main.c
+2
-2
2 additions, 2 deletions
dlls/dwrite/main.c
dlls/dwrite/tests/layout.c
+36
-0
36 additions, 0 deletions
dlls/dwrite/tests/layout.c
with
61 additions
and
5 deletions
dlls/dwrite/dwrite_private.h
+
16
−
2
View file @
11d94a11
...
...
@@ -38,7 +38,7 @@ static inline BOOL heap_free(void *mem)
return
HeapFree
(
GetProcessHeap
(),
0
,
mem
);
}
static
inline
LPWSTR
heap_strdupW
(
LPCWST
R
str
)
static
inline
LPWSTR
heap_strdupW
(
const
WCHA
R
*
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
;
This diff is collapsed.
Click to expand it.
dlls/dwrite/layout.c
+
7
−
1
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
;
...
...
This diff is collapsed.
Click to expand it.
dlls/dwrite/main.c
+
2
−
2
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
,
...
...
This diff is collapsed.
Click to expand it.
dlls/dwrite/tests/layout.c
+
36
−
0
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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment