[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] gsoc-anurag-2023 78df2b651: Add preload support in smooth
From: |
Werner Lemberg |
Subject: |
[freetype2] gsoc-anurag-2023 78df2b651: Add preload support in smooth |
Date: |
Mon, 2 Oct 2023 17:39:53 -0400 (EDT) |
branch: gsoc-anurag-2023
commit 78df2b651f9abc01f373e5749a0f37a5ce641a7a
Author: Anurag Thakur <anurag105csec21@bpitindia.edu.in>
Commit: Anurag Thakur <anurag105csec21@bpitindia.edu.in>
Add preload support in smooth
---
include/freetype/freetype.h | 1 +
modules.cfg | 2 +-
src/base/ftobjs.c | 8 ++++++--
src/smooth/ftgrays.c | 31 ++++++++++++++++++++++++++-----
src/smooth/ftsmooth.c | 23 +++++++++++++++++++----
5 files changed, 53 insertions(+), 12 deletions(-)
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index dd5706de8..44c223f3c 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -2298,6 +2298,7 @@ FT_BEGIN_HEADER
void* other;
FT_PreLine prelines;
+ int prel_shifted;
FT_Slot_Internal internal;
diff --git a/modules.cfg b/modules.cfg
index 548893213..c141b14ba 100644
--- a/modules.cfg
+++ b/modules.cfg
@@ -100,7 +100,7 @@ HINTING_MODULES += pshinter
####
# Dense Rasterizer
-RASTER_MODULES += dense
+#RASTER_MODULES += dense
# Anti-aliasing rasterizer.
RASTER_MODULES += smooth
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 4ce2f8a6e..7a5623d31 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -579,6 +579,7 @@
{
/* free bitmap if needed */
ft_glyphslot_free_bitmap( slot );
+
/* clear all public fields in the glyph slot */
slot->glyph_index = 0;
@@ -1180,6 +1181,8 @@
}
+
+
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE5(( "FT_Load_Glyph: index %d, flags 0x%x\n",
glyph_index, load_flags ));
@@ -2645,7 +2648,7 @@ int conic_to2(FT_GlyphSlot* slot, FT_Vector *control,
FT_Vector *from, FT_Vector
}
- static FT_Error ft_decompose_outline(FT_GlyphSlot* slot){
+ FT_Error ft_decompose_outline(FT_GlyphSlot* slot){
FT_Vector v_last;
FT_Vector v_control;
FT_Vector v_start;
@@ -3138,7 +3141,7 @@ int conic_to2(FT_GlyphSlot* slot, FT_Vector *control,
FT_Vector *from, FT_Vector
face->garray = (FT_GlyphSlot*)malloc(
face->driver->clazz->slot_object_size * face->num_glyphs );
//error = FT_Set_Char_Size( face, 0, 160 * 64, 300, 300 );
- error = FT_Set_Pixel_Sizes( face, 0, 500);
+ error = FT_Set_Pixel_Sizes( face, 0, 100);
// int glyph_index = FT_Get_Char_Index( face, 'A' );
// error = FT_Load_Glyph( face, glyph_index,
FT_LOAD_NO_HINTING );
@@ -3150,6 +3153,7 @@ int conic_to2(FT_GlyphSlot* slot, FT_Vector *control,
FT_Vector *from, FT_Vector
FT_ALLOC(face->garray[gindex], clazz->slot_object_size);
face->garray[gindex]->face = face;
+ face->garray[gindex]->prel_shifted = 0;
face->garray[gindex]->glyph_index = gindex;
ft_glyphslot_init(face->garray[gindex]);
face->garray[gindex]->next = NULL;
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 55628af9e..67c31d2d8 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -1921,7 +1921,7 @@ typedef ptrdiff_t FT_PtrDist;
static int
gray_convert_glyph_inner( RAS_ARG_
- int continued )
+ int continued , FT_PreLine pl)
{
volatile int error;
@@ -1930,7 +1930,28 @@ typedef ptrdiff_t FT_PtrDist;
{
if ( continued )
FT_Trace_Disable();
- error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras );
+ //error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras );
+ FT_Vector point1 = {pl->x1, pl->y1};
+
+ FT_Vector point2 = {100, 100};
+
+ error = gray_move_to(&point1, worker);
+ while (pl!=NULL)
+ {
+ point1.x = pl->x1;
+ point1.y = pl->y1;
+ point2.x = pl->x2;
+ point2.y = pl->y2;
+
+ if(pl->ismove){
+ gray_move_to(&point2, worker);
+ }else{
+ gray_line_to(&point2, worker);
+ }
+ pl= pl->next;
+ }
+
+
if ( continued )
FT_Trace_Enable();
@@ -1953,7 +1974,7 @@ typedef ptrdiff_t FT_PtrDist;
static int
- gray_convert_glyph( RAS_ARG )
+ gray_convert_glyph( RAS_ARG , FT_PreLine pl)
{
const TCoord yMin = ras.min_ey;
const TCoord yMax = ras.max_ey;
@@ -2015,7 +2036,7 @@ typedef ptrdiff_t FT_PtrDist;
ras.max_ey = band[0];
ras.count_ey = width;
- error = gray_convert_glyph_inner( RAS_VAR_ continued );
+ error = gray_convert_glyph_inner( RAS_VAR_ continued, pl );
continued = 1;
if ( !error )
@@ -2132,7 +2153,7 @@ typedef ptrdiff_t FT_PtrDist;
if ( ras.max_ex <= ras.min_ex || ras.max_ey <= ras.min_ey )
return Smooth_Err_Ok;
- return gray_convert_glyph( RAS_VAR );
+ return gray_convert_glyph( RAS_VAR, params->prelines );
}
diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c
index 9b0e8886c..b2af6a820 100644
--- a/src/smooth/ftsmooth.c
+++ b/src/smooth/ftsmooth.c
@@ -501,8 +501,20 @@
}
/* translate outline to render it into the bitmap */
- if ( x_shift || y_shift )
- FT_Outline_Translate( outline, x_shift, y_shift );
+ if ( (x_shift || y_shift) && !slot->prel_shifted){
+ //FT_Outline_Translate( outline, x_shift, y_shift );
+ FT_PreLine pl = slot->prelines;
+ while (pl!=NULL)
+ {
+ pl->x1 += x_shift;
+ pl->y1 += y_shift;
+ pl->x2 += x_shift;
+ pl->y2 += y_shift;
+
+ pl = pl->next;
+ }
+ slot->prel_shifted = 1;
+ }
if ( mode == FT_RENDER_MODE_NORMAL ||
mode == FT_RENDER_MODE_LIGHT )
@@ -517,6 +529,8 @@
params.target = bitmap;
params.source = outline;
params.flags = FT_RASTER_FLAG_AA;
+ params.prelines = slot->prelines;
+
error = render->raster_render( render->raster, ¶ms );
}
@@ -568,8 +582,9 @@
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
- if ( x_shift || y_shift )
- FT_Outline_Translate( outline, -x_shift, -y_shift );
+ // if ( x_shift || y_shift ){
+ // FT_Outline_Translate( outline, -x_shift, -y_shift );
+ // }
return error;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] gsoc-anurag-2023 78df2b651: Add preload support in smooth,
Werner Lemberg <=