Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
bdfcacf6
Commit
bdfcacf6
authored
Jul 19, 2003
by
Sigmund Augdal Helberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Render the glyph for each character only once, and not once for each frame.
Should speed up things a bit.
parent
4c2181e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
20 deletions
+19
-20
modules/misc/freetype.c
modules/misc/freetype.c
+19
-20
No files found.
modules/misc/freetype.c
View file @
bdfcacf6
...
...
@@ -2,7 +2,7 @@
* freetype.c : Put text on the video, using freetype2
*****************************************************************************
* Copyright (C) 2002, 2003 VideoLAN
* $Id: freetype.c,v 1.
2 2003/07/19 14:41:30
sigmunau Exp $
* $Id: freetype.c,v 1.
3 2003/07/19 15:15:01
sigmunau Exp $
*
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
*
...
...
@@ -82,7 +82,7 @@ struct subpicture_sys_t
/** The string associated with this subpicture */
byte_t
*
psz_text
;
/** NULL-terminated list of glyphs making the string */
FT_Glyph
*
pp_glyphs
;
FT_
Bitmap
Glyph
*
pp_glyphs
;
/** list of relative positions for the glyphs */
FT_Vector
*
p_glyph_pos
;
};
...
...
@@ -206,7 +206,7 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic,
const
subpicture_t
*
p_subpic
)
{
subpicture_sys_t
*
p_string
=
p_subpic
->
p_sys
;
int
i_plane
,
i_error
,
x
,
y
,
pen_x
,
pen_y
;
int
i_plane
,
x
,
y
,
pen_x
,
pen_y
;
unsigned
int
i
;
for
(
i_plane
=
0
;
i_plane
<
p_pic
->
i_planes
;
i_plane
++
)
...
...
@@ -241,19 +241,12 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic,
{
if
(
p_string
->
pp_glyphs
[
i
]
)
{
FT_Glyph
p_glyph
=
p_string
->
pp_glyphs
[
i
];
FT_BitmapGlyph
p_image
;
i_error
=
FT_Glyph_To_Bitmap
(
&
p_glyph
,
FT_RENDER_MODE_NORMAL
,
&
p_string
->
p_glyph_pos
[
i
],
0
);
if
(
i_error
)
continue
;
p_image
=
(
FT_BitmapGlyph
)
p_glyph
;
#define alpha p_vout->p_text_renderer_data->pi_gamma[p_image->bitmap.buffer[x+ y*p_image->bitmap.width]]
#define pixel p_in[(p_string->p_glyph_pos[i].y + pen_y + y - p_image->top)*i_pitch+x+pen_x+p_string->p_glyph_pos[i].x+p_image->left]
for
(
y
=
0
;
y
<
p_image
->
bitmap
.
rows
;
y
++
)
FT_BitmapGlyph
p_glyph
=
p_string
->
pp_glyphs
[
i
];
#define alpha p_vout->p_text_renderer_data->pi_gamma[ p_glyph->bitmap.buffer[ x + y * p_glyph->bitmap.width ] ]
#define pixel p_in[ ( p_string->p_glyph_pos[ i ].y + pen_y + y - p_glyph->top ) * i_pitch+x + pen_x + p_string->p_glyph_pos[ i ].x + p_glyph->left ]
for
(
y
=
0
;
y
<
p_glyph
->
bitmap
.
rows
;
y
++
)
{
for
(
x
=
0
;
x
<
p_
image
->
bitmap
.
width
;
x
++
)
for
(
x
=
0
;
x
<
p_
glyph
->
bitmap
.
width
;
x
++
)
{
// pixel = alpha;
// pixel = (pixel^alpha)^pixel;
...
...
@@ -261,7 +254,6 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic,
(
255
*
alpha
>>
8
);
}
}
FT_Done_Glyph
(
p_glyph
);
}
}
}
...
...
@@ -284,6 +276,7 @@ static int AddText ( vout_thread_t *p_vout, byte_t *psz_string,
FT_BBox
line
;
FT_BBox
glyph_size
;
FT_Vector
result
;
FT_Glyph
tmp_glyph
;
result
.
x
=
0
;
result
.
y
=
0
;
...
...
@@ -380,14 +373,20 @@ static int AddText ( vout_thread_t *p_vout, byte_t *psz_string,
msg_Err
(
p_vout
,
"FT_Load_Glyph returned %d"
,
i_error
);
return
VLC_EGENERIC
;
}
i_error
=
FT_Get_Glyph
(
glyph
,
&
p_string
->
pp_glyphs
[
i
]
);
i_error
=
FT_Get_Glyph
(
glyph
,
&
tmp_glyph
);
if
(
i_error
)
{
msg_Err
(
p_vout
,
"FT_Get_Glyph returned %d"
,
i_error
);
return
VLC_EGENERIC
;
}
FT_Glyph_Get_CBox
(
p_string
->
pp_glyphs
[
i
],
ft_glyph_bbox_pixels
,
&
glyph_size
);
FT_Glyph_Get_CBox
(
tmp_glyph
,
ft_glyph_bbox_pixels
,
&
glyph_size
);
i_error
=
FT_Glyph_To_Bitmap
(
&
tmp_glyph
,
FT_RENDER_MODE_NORMAL
,
&
p_string
->
p_glyph_pos
[
i
],
1
);
if
(
i_error
)
continue
;
p_string
->
pp_glyphs
[
i
]
=
(
FT_BitmapGlyph
)
tmp_glyph
;
/* Do rest */
line
.
xMax
=
p_string
->
p_glyph_pos
[
i
].
x
+
glyph_size
.
xMax
-
glyph_size
.
xMin
;
line
.
yMax
=
__MAX
(
line
.
yMax
,
glyph_size
.
yMax
);
...
...
@@ -416,7 +415,7 @@ static void FreeString( subpicture_t *p_subpic )
subpicture_sys_t
*
p_string
=
p_subpic
->
p_sys
;
for
(
i
=
0
;
p_string
->
pp_glyphs
[
i
]
!=
NULL
;
i
++
)
{
FT_Done_Glyph
(
p_string
->
pp_glyphs
[
i
]
);
FT_Done_Glyph
(
(
FT_Glyph
)
p_string
->
pp_glyphs
[
i
]
);
}
free
(
p_string
->
psz_text
);
free
(
p_string
->
p_glyph_pos
);
...
...
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