ReactOS 0.4.16-dev-334-g4d9f67c
pshrec.c File Reference
#include <ft2build.h>
#include "pshrec.h"
#include "pshalgo.h"
#include "pshnterr.h"
Include dependency graph for pshrec.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FT_COMPONENT   trace_pshrec
 

Functions

static void ps_hint_table_done (PS_Hint_Table table, FT_Memory memory)
 
static FT_Error ps_hint_table_ensure (PS_Hint_Table table, FT_UInt count, FT_Memory memory)
 
static FT_Error ps_hint_table_alloc (PS_Hint_Table table, FT_Memory memory, PS_Hint *ahint)
 
static void ps_mask_done (PS_Mask mask, FT_Memory memory)
 
static FT_Error ps_mask_ensure (PS_Mask mask, FT_UInt count, FT_Memory memory)
 
static FT_Int ps_mask_test_bit (PS_Mask mask, FT_Int idx)
 
static void ps_mask_clear_bit (PS_Mask mask, FT_UInt idx)
 
static FT_Error ps_mask_set_bit (PS_Mask mask, FT_UInt idx, FT_Memory memory)
 
static void ps_mask_table_done (PS_Mask_Table table, FT_Memory memory)
 
static FT_Error ps_mask_table_ensure (PS_Mask_Table table, FT_UInt count, FT_Memory memory)
 
static FT_Error ps_mask_table_alloc (PS_Mask_Table table, FT_Memory memory, PS_Mask *amask)
 
static FT_Error ps_mask_table_last (PS_Mask_Table table, FT_Memory memory, PS_Mask *amask)
 
static FT_Error ps_mask_table_set_bits (PS_Mask_Table table, const FT_Byte *source, FT_UInt bit_pos, FT_UInt bit_count, FT_Memory memory)
 
static FT_Int ps_mask_table_test_intersect (PS_Mask_Table table, FT_UInt index1, FT_UInt index2)
 
static FT_Error ps_mask_table_merge (PS_Mask_Table table, FT_UInt index1, FT_UInt index2, FT_Memory memory)
 
static FT_Error ps_mask_table_merge_all (PS_Mask_Table table, FT_Memory memory)
 
static void ps_dimension_done (PS_Dimension dimension, FT_Memory memory)
 
static void ps_dimension_init (PS_Dimension dimension)
 
static void ps_dimension_end_mask (PS_Dimension dim, FT_UInt end_point)
 
static FT_Error ps_dimension_reset_mask (PS_Dimension dim, FT_UInt end_point, FT_Memory memory)
 
static FT_Error ps_dimension_set_mask_bits (PS_Dimension dim, const FT_Byte *source, FT_UInt source_pos, FT_UInt source_bits, FT_UInt end_point, FT_Memory memory)
 
static FT_Error ps_dimension_add_t1stem (PS_Dimension dim, FT_Int pos, FT_Int len, FT_Memory memory, FT_Int *aindex)
 
static FT_Error ps_dimension_add_counter (PS_Dimension dim, FT_Int hint1, FT_Int hint2, FT_Int hint3, FT_Memory memory)
 
static FT_Error ps_dimension_end (PS_Dimension dim, FT_UInt end_point, FT_Memory memory)
 
 ps_hints_done (PS_Hints hints)
 
 ps_hints_init (PS_Hints hints, FT_Memory memory)
 
static void ps_hints_open (PS_Hints hints, PS_Hint_Type hint_type)
 
static void ps_hints_stem (PS_Hints hints, FT_UInt dimension, FT_Int count, FT_Long *stems)
 
static void ps_hints_t1stem3 (PS_Hints hints, FT_UInt dimension, FT_Fixed *stems)
 
static void ps_hints_t1reset (PS_Hints hints, FT_UInt end_point)
 
static void ps_hints_t2mask (PS_Hints hints, FT_UInt end_point, FT_UInt bit_count, const FT_Byte *bytes)
 
static void ps_hints_t2counter (PS_Hints hints, FT_UInt bit_count, const FT_Byte *bytes)
 
static FT_Error ps_hints_close (PS_Hints hints, FT_UInt end_point)
 
static void t1_hints_open (T1_Hints hints)
 
static void t1_hints_stem (T1_Hints hints, FT_UInt dimension, FT_Fixed *coords)
 
 t1_hints_funcs_init (T1_Hints_FuncsRec *funcs)
 
static void t2_hints_open (T2_Hints hints)
 
static void t2_hints_stems (T2_Hints hints, FT_UInt dimension, FT_Int count, FT_Fixed *coords)
 
 t2_hints_funcs_init (T2_Hints_FuncsRec *funcs)
 

Macro Definition Documentation

◆ FT_COMPONENT

#define FT_COMPONENT   trace_pshrec

Definition at line 31 of file pshrec.c.

Function Documentation

◆ ps_dimension_add_counter()

static FT_Error ps_dimension_add_counter ( PS_Dimension  dim,
FT_Int  hint1,
FT_Int  hint2,
FT_Int  hint3,
FT_Memory  memory 
)
static

Definition at line 723 of file pshrec.c.

728 {
732
733
734 /* try to find an existing counter mask that already uses */
735 /* one of these stems here */
736 for ( ; count > 0; count--, counter++ )
737 {
738 if ( ps_mask_test_bit( counter, hint1 ) ||
739 ps_mask_test_bit( counter, hint2 ) ||
740 ps_mask_test_bit( counter, hint3 ) )
741 break;
742 }
743
744 /* create a new counter when needed */
745 if ( count == 0 )
746 {
748 if ( error )
749 goto Exit;
750 }
751
752 /* now, set the bits for our hints in the counter mask */
753 if ( hint1 >= 0 )
754 {
756 if ( error )
757 goto Exit;
758 }
759
760 if ( hint2 >= 0 )
761 {
763 if ( error )
764 goto Exit;
765 }
766
767 if ( hint3 >= 0 )
768 {
770 if ( error )
771 goto Exit;
772 }
773
774 Exit:
775 return error;
776 }
return FT_Err_Ok
Definition: ftbbox.c:511
int FT_Error
Definition: fttypes.h:300
unsigned int FT_UInt
Definition: fttypes.h:231
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define error(str)
Definition: mkdosfs.c:1605
static char memory[1024 *256]
Definition: process.c:116
static FT_Error ps_mask_set_bit(PS_Mask mask, FT_UInt idx, FT_Memory memory)
Definition: pshrec.c:185
static FT_Int ps_mask_test_bit(PS_Mask mask, FT_Int idx)
Definition: pshrec.c:157
static FT_Error ps_mask_table_alloc(PS_Mask_Table table, FT_Memory memory, PS_Mask *amask)
Definition: pshrec.c:251
static void Exit(void)
Definition: sock.c:1330
PS_Mask_TableRec counters
Definition: pshrec.h:119
PS_Mask masks
Definition: pshrec.h:109
FT_UInt num_masks
Definition: pshrec.h:107

Referenced by ps_hints_t1stem3().

◆ ps_dimension_add_t1stem()

static FT_Error ps_dimension_add_t1stem ( PS_Dimension  dim,
FT_Int  pos,
FT_Int  len,
FT_Memory  memory,
FT_Int aindex 
)
static

Definition at line 652 of file pshrec.c.

657 {
659 FT_UInt flags = 0;
660
661
662 /* detect ghost stem */
663 if ( len < 0 )
664 {
666 if ( len == -21 )
667 {
669 pos += len;
670 }
671 len = 0;
672 }
673
674 if ( aindex )
675 *aindex = -1;
676
677 /* now, lookup stem in the current hints table */
678 {
680 FT_UInt idx;
681 FT_UInt max = dim->hints.num_hints;
682 PS_Hint hint = dim->hints.hints;
683
684
685 for ( idx = 0; idx < max; idx++, hint++ )
686 {
687 if ( hint->pos == pos && hint->len == len )
688 break;
689 }
690
691 /* we need to create a new hint in the table */
692 if ( idx >= max )
693 {
695 if ( error )
696 goto Exit;
697
698 hint->pos = pos;
699 hint->len = len;
700 hint->flags = flags;
701 }
702
703 /* now, store the hint in the current mask */
705 if ( error )
706 goto Exit;
707
709 if ( error )
710 goto Exit;
711
712 if ( aindex )
713 *aindex = (FT_Int)idx;
714 }
715
716 Exit:
717 return error;
718 }
unsigned int idx
Definition: utils.c:41
signed int FT_Int
Definition: fttypes.h:220
GLenum GLint GLuint mask
Definition: glext.h:6028
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
static FT_Error ps_hint_table_alloc(PS_Hint_Table table, FT_Memory memory, PS_Hint *ahint)
Definition: pshrec.c:82
static FT_Error ps_mask_table_last(PS_Mask_Table table, FT_Memory memory, PS_Mask *amask)
Definition: pshrec.c:283
#define PS_HINT_FLAG_GHOST
Definition: pshrec.h:64
#define PS_HINT_FLAG_BOTTOM
Definition: pshrec.h:65
typedefFT_BEGIN_HEADER struct PS_HintRec_ * PS_Hint
Definition: pshrec.h:52
PS_Mask_TableRec masks
Definition: pshrec.h:118
PS_Hint_TableRec hints
Definition: pshrec.h:117
PS_Hint hints
Definition: pshrec.h:88
FT_UInt num_hints
Definition: pshrec.h:86
#define max(a, b)
Definition: svc.c:63
DWORD hint
Definition: vfdcmd.c:88

Referenced by ps_hints_stem(), and ps_hints_t1stem3().

◆ ps_dimension_done()

static void ps_dimension_done ( PS_Dimension  dimension,
FT_Memory  memory 
)
static

Definition at line 544 of file pshrec.c.

546 {
547 ps_mask_table_done( &dimension->counters, memory );
548 ps_mask_table_done( &dimension->masks, memory );
549 ps_hint_table_done( &dimension->hints, memory );
550 }
static void ps_hint_table_done(PS_Hint_Table table, FT_Memory memory)
Definition: pshrec.c:50
static void ps_mask_table_done(PS_Mask_Table table, FT_Memory memory)
Definition: pshrec.c:212

Referenced by ps_hints_done().

◆ ps_dimension_end()

static FT_Error ps_dimension_end ( PS_Dimension  dim,
FT_UInt  end_point,
FT_Memory  memory 
)
static

Definition at line 781 of file pshrec.c.

784 {
785 /* end hint mask table */
786 ps_dimension_end_mask( dim, end_point );
787
788 /* merge all counter masks into independent "paths" */
789 return ps_mask_table_merge_all( &dim->counters, memory );
790 }
static void ps_dimension_end_mask(PS_Dimension dim, FT_UInt end_point)
Definition: pshrec.c:590
static FT_Error ps_mask_table_merge_all(PS_Mask_Table table, FT_Memory memory)
Definition: pshrec.c:500

Referenced by ps_hints_close().

◆ ps_dimension_end_mask()

static void ps_dimension_end_mask ( PS_Dimension  dim,
FT_UInt  end_point 
)
static

Definition at line 590 of file pshrec.c.

592 {
594
595
596 if ( count > 0 )
597 {
598 PS_Mask mask = dim->masks.masks + count - 1;
599
600
601 mask->end_point = end_point;
602 }
603 }
FT_UInt end_point
Definition: pshrec.h:99

Referenced by ps_dimension_end(), and ps_dimension_reset_mask().

◆ ps_dimension_init()

static void ps_dimension_init ( PS_Dimension  dimension)
static

Definition at line 555 of file pshrec.c.

556 {
557 dimension->hints.num_hints = 0;
558 dimension->masks.num_masks = 0;
559 dimension->counters.num_masks = 0;
560 }

Referenced by ps_hints_open().

◆ ps_dimension_reset_mask()

static FT_Error ps_dimension_reset_mask ( PS_Dimension  dim,
FT_UInt  end_point,
FT_Memory  memory 
)
static

Definition at line 609 of file pshrec.c.

612 {
614
615
616 /* end current mask */
617 ps_dimension_end_mask( dim, end_point );
618
619 /* allocate new one */
620 return ps_mask_table_alloc( &dim->masks, memory, &mask );
621 }

Referenced by ps_dimension_set_mask_bits(), and ps_hints_t1reset().

◆ ps_dimension_set_mask_bits()

static FT_Error ps_dimension_set_mask_bits ( PS_Dimension  dim,
const FT_Byte source,
FT_UInt  source_pos,
FT_UInt  source_bits,
FT_UInt  end_point,
FT_Memory  memory 
)
static

Definition at line 626 of file pshrec.c.

632 {
634
635
636 /* reset current mask, if any */
637 error = ps_dimension_reset_mask( dim, end_point, memory );
638 if ( error )
639 goto Exit;
640
641 /* set bits in new mask */
643 source_pos, source_bits, memory );
644
645 Exit:
646 return error;
647 }
static FT_Error ps_mask_table_set_bits(PS_Mask_Table table, const FT_Byte *source, FT_UInt bit_pos, FT_UInt bit_count, FT_Memory memory)
Definition: pshrec.c:310
static FT_Error ps_dimension_reset_mask(PS_Dimension dim, FT_UInt end_point, FT_Memory memory)
Definition: pshrec.c:609

Referenced by ps_hints_t2counter(), and ps_hints_t2mask().

◆ ps_hint_table_alloc()

static FT_Error ps_hint_table_alloc ( PS_Hint_Table  table,
FT_Memory  memory,
PS_Hint ahint 
)
static

Definition at line 82 of file pshrec.c.

85 {
89
90
91 count = table->num_hints;
92 count++;
93
94 if ( count >= table->max_hints )
95 {
97 if ( error )
98 goto Exit;
99 }
100
101 hint = table->hints + count - 1;
102 hint->pos = 0;
103 hint->len = 0;
104 hint->flags = 0;
105
106 table->num_hints = count;
107
108 Exit:
109 *ahint = hint;
110 return error;
111 }
#define NULL
Definition: types.h:112
static FT_Error ps_hint_table_ensure(PS_Hint_Table table, FT_UInt count, FT_Memory memory)
Definition: pshrec.c:61

Referenced by ps_dimension_add_t1stem().

◆ ps_hint_table_done()

static void ps_hint_table_done ( PS_Hint_Table  table,
FT_Memory  memory 
)
static

Definition at line 50 of file pshrec.c.

52 {
53 FT_FREE( table->hints );
54 table->num_hints = 0;
55 table->max_hints = 0;
56 }
#define FT_FREE(ptr)
Definition: ftmemory.h:329

Referenced by ps_dimension_done().

◆ ps_hint_table_ensure()

static FT_Error ps_hint_table_ensure ( PS_Hint_Table  table,
FT_UInt  count,
FT_Memory  memory 
)
static

Definition at line 61 of file pshrec.c.

64 {
65 FT_UInt old_max = table->max_hints;
66 FT_UInt new_max = count;
68
69
70 if ( new_max > old_max )
71 {
72 /* try to grow the table */
73 new_max = FT_PAD_CEIL( new_max, 8 );
74 if ( !FT_RENEW_ARRAY( table->hints, old_max, new_max ) )
75 table->max_hints = new_max;
76 }
77 return error;
78 }
#define FT_RENEW_ARRAY(ptr, curcnt, newcnt)
Definition: ftmemory.h:336
#define FT_PAD_CEIL(x, n)
Definition: ftobjs.h:90

Referenced by ps_hint_table_alloc().

◆ ps_hints_close()

static FT_Error ps_hints_close ( PS_Hints  hints,
FT_UInt  end_point 
)
static

Definition at line 1083 of file pshrec.c.

1085 {
1087
1088
1089 error = hints->error;
1090 if ( !error )
1091 {
1092 FT_Memory memory = hints->memory;
1093 PS_Dimension dim = hints->dimension;
1094
1095
1096 error = ps_dimension_end( &dim[0], end_point, memory );
1097 if ( !error )
1098 {
1099 error = ps_dimension_end( &dim[1], end_point, memory );
1100 }
1101 }
1102
1103#ifdef DEBUG_HINTER
1104 if ( !error )
1105 ps_debug_hints = hints;
1106#endif
1107 return error;
1108 }
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
static FT_Error ps_dimension_end(PS_Dimension dim, FT_UInt end_point, FT_Memory memory)
Definition: pshrec.c:781
namespace GUID const ADDRINFOEXW * hints
Definition: sock.c:80

Referenced by t1_hints_funcs_init(), and t2_hints_funcs_init().

◆ ps_hints_done()

ps_hints_done ( PS_Hints  hints)

Definition at line 804 of file pshrec.c.

805 {
806 FT_Memory memory = hints->memory;
807
808
809 ps_dimension_done( &hints->dimension[0], memory );
810 ps_dimension_done( &hints->dimension[1], memory );
811
812 hints->error = FT_Err_Ok;
813 hints->memory = NULL;
814 }
static void ps_dimension_done(PS_Dimension dimension, FT_Memory memory)
Definition: pshrec.c:544

Referenced by ps_hinter_done().

◆ ps_hints_init()

ps_hints_init ( PS_Hints  hints,
FT_Memory  memory 
)

Definition at line 818 of file pshrec.c.

820 {
821 FT_ZERO( hints );
822 hints->memory = memory;
823 }
#define FT_ZERO(p)
Definition: ftmemory.h:237

Referenced by ps_hinter_init().

◆ ps_hints_open()

static void ps_hints_open ( PS_Hints  hints,
PS_Hint_Type  hint_type 
)
static

Definition at line 828 of file pshrec.c.

830 {
831 hints->error = FT_Err_Ok;
832 hints->hint_type = hint_type;
833
834 ps_dimension_init( &hints->dimension[0] );
835 ps_dimension_init( &hints->dimension[1] );
836 }
static void ps_dimension_init(PS_Dimension dimension)
Definition: pshrec.c:555

Referenced by t1_hints_open(), and t2_hints_open().

◆ ps_hints_stem()

static void ps_hints_stem ( PS_Hints  hints,
FT_UInt  dimension,
FT_Int  count,
FT_Long stems 
)
static

Definition at line 841 of file pshrec.c.

845 {
846 PS_Dimension dim;
847
848
849 if ( hints->error )
850 return;
851
852 /* limit "dimension" to 0..1 */
853 if ( dimension > 1 )
854 {
855 FT_TRACE0(( "ps_hints_stem: invalid dimension (%d) used\n",
856 dimension ));
857 dimension = ( dimension != 0 );
858 }
859
860 /* record the stems in the current hints/masks table */
861 /* (Type 1 & 2's `hstem' or `vstem' operators) */
862 dim = &hints->dimension[dimension];
863
864 for ( ; count > 0; count--, stems += 2 )
865 {
867 FT_Memory memory = hints->memory;
868
869
871 (FT_Int)stems[0],
872 (FT_Int)stems[1],
873 memory,
874 NULL );
875 if ( error )
876 {
877 FT_ERROR(( "ps_hints_stem: could not add stem"
878 " (%d,%d) to hints table\n", stems[0], stems[1] ));
879
880 hints->error = error;
881 return;
882 }
883 }
884 }
#define FT_TRACE0(varformat)
Definition: ftdebug.h:157
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
static FT_Error ps_dimension_add_t1stem(PS_Dimension dim, FT_Int pos, FT_Int len, FT_Memory memory, FT_Int *aindex)
Definition: pshrec.c:652

Referenced by t1_hints_stem(), and t2_hints_stems().

◆ ps_hints_t1reset()

static void ps_hints_t1reset ( PS_Hints  hints,
FT_UInt  end_point 
)
static

Definition at line 952 of file pshrec.c.

954 {
956
957
958 if ( !hints->error )
959 {
960 FT_Memory memory = hints->memory;
961
962
963 if ( hints->hint_type == PS_HINT_TYPE_1 )
964 {
965 error = ps_dimension_reset_mask( &hints->dimension[0],
966 end_point, memory );
967 if ( error )
968 goto Fail;
969
970 error = ps_dimension_reset_mask( &hints->dimension[1],
971 end_point, memory );
972 if ( error )
973 goto Fail;
974 }
975 else
976 {
977 /* invalid hint type */
978 error = FT_THROW( Invalid_Argument );
979 goto Fail;
980 }
981 }
982 return;
983
984 Fail:
985 hints->error = error;
986 }
int Fail
Definition: ehthrow.cxx:24
#define FT_THROW(e)
Definition: ftdebug.h:213
@ PS_HINT_TYPE_1
Definition: pshrec.h:57

Referenced by t1_hints_funcs_init().

◆ ps_hints_t1stem3()

static void ps_hints_t1stem3 ( PS_Hints  hints,
FT_UInt  dimension,
FT_Fixed stems 
)
static

Definition at line 889 of file pshrec.c.

892 {
894
895
896 if ( !hints->error )
897 {
898 PS_Dimension dim;
899 FT_Memory memory = hints->memory;
901 FT_Int idx[3];
902
903
904 /* limit "dimension" to 0..1 */
905 if ( dimension > 1 )
906 {
907 FT_TRACE0(( "ps_hints_t1stem3: invalid dimension (%d) used\n",
908 dimension ));
909 dimension = ( dimension != 0 );
910 }
911
912 dim = &hints->dimension[dimension];
913
914 /* there must be 6 elements in the 'stem' array */
915 if ( hints->hint_type == PS_HINT_TYPE_1 )
916 {
917 /* add the three stems to our hints/masks table */
918 for ( count = 0; count < 3; count++, stems += 2 )
919 {
921 (FT_Int)FIXED_TO_INT( stems[0] ),
922 (FT_Int)FIXED_TO_INT( stems[1] ),
923 memory, &idx[count] );
924 if ( error )
925 goto Fail;
926 }
927
928 /* now, add the hints to the counters table */
929 error = ps_dimension_add_counter( dim, idx[0], idx[1], idx[2],
930 memory );
931 if ( error )
932 goto Fail;
933 }
934 else
935 {
936 FT_ERROR(( "ps_hints_t1stem3: called with invalid hint type\n" ));
937 error = FT_THROW( Invalid_Argument );
938 goto Fail;
939 }
940 }
941
942 return;
943
944 Fail:
945 FT_ERROR(( "ps_hints_t1stem3: could not add counter stems to table\n" ));
946 hints->error = error;
947 }
#define FIXED_TO_INT(x)
Definition: ftcalc.h:406
static FT_Error ps_dimension_add_counter(PS_Dimension dim, FT_Int hint1, FT_Int hint2, FT_Int hint3, FT_Memory memory)
Definition: pshrec.c:723

Referenced by t1_hints_funcs_init().

◆ ps_hints_t2counter()

static void ps_hints_t2counter ( PS_Hints  hints,
FT_UInt  bit_count,
const FT_Byte bytes 
)
static

Definition at line 1037 of file pshrec.c.

1040 {
1042
1043
1044 if ( !hints->error )
1045 {
1046 PS_Dimension dim = hints->dimension;
1047 FT_Memory memory = hints->memory;
1048 FT_UInt count1 = dim[0].hints.num_hints;
1049 FT_UInt count2 = dim[1].hints.num_hints;
1050
1051
1052 /* check bit count, must be equal to current total hint count */
1053 if ( bit_count != count1 + count2 )
1054 {
1055 FT_TRACE0(( "ps_hints_t2counter:"
1056 " called with invalid bitcount %d (instead of %d)\n",
1057 bit_count, count1 + count2 ));
1058
1059 /* simply ignore the operator */
1060 return;
1061 }
1062
1063 /* set-up new horizontal and vertical hint mask now */
1064 error = ps_dimension_set_mask_bits( &dim[0], bytes, 0, count1,
1065 0, memory );
1066 if ( error )
1067 goto Fail;
1068
1069 error = ps_dimension_set_mask_bits( &dim[1], bytes, count1, count2,
1070 0, memory );
1071 if ( error )
1072 goto Fail;
1073 }
1074 return;
1075
1076 Fail:
1077 hints->error = error;
1078 }
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
static FT_Error ps_dimension_set_mask_bits(PS_Dimension dim, const FT_Byte *source, FT_UInt source_pos, FT_UInt source_bits, FT_UInt end_point, FT_Memory memory)
Definition: pshrec.c:626

Referenced by t2_hints_funcs_init().

◆ ps_hints_t2mask()

static void ps_hints_t2mask ( PS_Hints  hints,
FT_UInt  end_point,
FT_UInt  bit_count,
const FT_Byte bytes 
)
static

Definition at line 991 of file pshrec.c.

995 {
997
998
999 if ( !hints->error )
1000 {
1001 PS_Dimension dim = hints->dimension;
1002 FT_Memory memory = hints->memory;
1003 FT_UInt count1 = dim[0].hints.num_hints;
1004 FT_UInt count2 = dim[1].hints.num_hints;
1005
1006
1007 /* check bit count; must be equal to current total hint count */
1008 if ( bit_count != count1 + count2 )
1009 {
1010 FT_TRACE0(( "ps_hints_t2mask:"
1011 " called with invalid bitcount %d (instead of %d)\n",
1012 bit_count, count1 + count2 ));
1013
1014 /* simply ignore the operator */
1015 return;
1016 }
1017
1018 /* set-up new horizontal and vertical hint mask now */
1019 error = ps_dimension_set_mask_bits( &dim[0], bytes, count2, count1,
1020 end_point, memory );
1021 if ( error )
1022 goto Fail;
1023
1024 error = ps_dimension_set_mask_bits( &dim[1], bytes, 0, count2,
1025 end_point, memory );
1026 if ( error )
1027 goto Fail;
1028 }
1029 return;
1030
1031 Fail:
1032 hints->error = error;
1033 }

Referenced by t2_hints_funcs_init().

◆ ps_mask_clear_bit()

static void ps_mask_clear_bit ( PS_Mask  mask,
FT_UInt  idx 
)
static

Definition at line 169 of file pshrec.c.

171 {
172 FT_Byte* p;
173
174
175 if ( idx >= mask->num_bits )
176 return;
177
178 p = mask->bytes + ( idx >> 3 );
179 p[0] = (FT_Byte)( p[0] & ~( 0x80 >> ( idx & 7 ) ) );
180 }
unsigned char FT_Byte
Definition: fttypes.h:154
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by ps_mask_table_merge().

◆ ps_mask_done()

static void ps_mask_done ( PS_Mask  mask,
FT_Memory  memory 
)
static

Definition at line 124 of file pshrec.c.

126 {
127 FT_FREE( mask->bytes );
128 mask->num_bits = 0;
129 mask->max_bits = 0;
130 mask->end_point = 0;
131 }

Referenced by ps_mask_table_done().

◆ ps_mask_ensure()

static FT_Error ps_mask_ensure ( PS_Mask  mask,
FT_UInt  count,
FT_Memory  memory 
)
static

Definition at line 136 of file pshrec.c.

139 {
140 FT_UInt old_max = ( mask->max_bits + 7 ) >> 3;
141 FT_UInt new_max = ( count + 7 ) >> 3;
143
144
145 if ( new_max > old_max )
146 {
147 new_max = FT_PAD_CEIL( new_max, 8 );
148 if ( !FT_RENEW_ARRAY( mask->bytes, old_max, new_max ) )
149 mask->max_bits = new_max * 8;
150 }
151 return error;
152 }

Referenced by ps_mask_set_bit(), ps_mask_table_merge(), and ps_mask_table_set_bits().

◆ ps_mask_set_bit()

static FT_Error ps_mask_set_bit ( PS_Mask  mask,
FT_UInt  idx,
FT_Memory  memory 
)
static

Definition at line 185 of file pshrec.c.

188 {
190 FT_Byte* p;
191
192
193 if ( idx >= mask->num_bits )
194 {
196 if ( error )
197 goto Exit;
198
199 mask->num_bits = idx + 1;
200 }
201
202 p = mask->bytes + ( idx >> 3 );
203 p[0] = (FT_Byte)( p[0] | ( 0x80 >> ( idx & 7 ) ) );
204
205 Exit:
206 return error;
207 }
static FT_Error ps_mask_ensure(PS_Mask mask, FT_UInt count, FT_Memory memory)
Definition: pshrec.c:136

Referenced by ps_dimension_add_counter(), and ps_dimension_add_t1stem().

◆ ps_mask_table_alloc()

static FT_Error ps_mask_table_alloc ( PS_Mask_Table  table,
FT_Memory  memory,
PS_Mask amask 
)
static

Definition at line 251 of file pshrec.c.

254 {
257 PS_Mask mask = NULL;
258
259
260 count = table->num_masks;
261 count++;
262
263 if ( count > table->max_masks )
264 {
266 if ( error )
267 goto Exit;
268 }
269
270 mask = table->masks + count - 1;
271 mask->num_bits = 0;
272 mask->end_point = 0;
273 table->num_masks = count;
274
275 Exit:
276 *amask = mask;
277 return error;
278 }
DWORD amask
Definition: surface.c:189
static FT_Error ps_mask_table_ensure(PS_Mask_Table table, FT_UInt count, FT_Memory memory)
Definition: pshrec.c:230

Referenced by ps_dimension_add_counter(), ps_dimension_reset_mask(), and ps_mask_table_last().

◆ ps_mask_table_done()

static void ps_mask_table_done ( PS_Mask_Table  table,
FT_Memory  memory 
)
static

Definition at line 212 of file pshrec.c.

214 {
215 FT_UInt count = table->max_masks;
216 PS_Mask mask = table->masks;
217
218
219 for ( ; count > 0; count--, mask++ )
221
222 FT_FREE( table->masks );
223 table->num_masks = 0;
224 table->max_masks = 0;
225 }
static void ps_mask_done(PS_Mask mask, FT_Memory memory)
Definition: pshrec.c:124

Referenced by ps_dimension_done().

◆ ps_mask_table_ensure()

static FT_Error ps_mask_table_ensure ( PS_Mask_Table  table,
FT_UInt  count,
FT_Memory  memory 
)
static

Definition at line 230 of file pshrec.c.

233 {
234 FT_UInt old_max = table->max_masks;
235 FT_UInt new_max = count;
237
238
239 if ( new_max > old_max )
240 {
241 new_max = FT_PAD_CEIL( new_max, 8 );
242 if ( !FT_RENEW_ARRAY( table->masks, old_max, new_max ) )
243 table->max_masks = new_max;
244 }
245 return error;
246 }

Referenced by ps_mask_table_alloc().

◆ ps_mask_table_last()

static FT_Error ps_mask_table_last ( PS_Mask_Table  table,
FT_Memory  memory,
PS_Mask amask 
)
static

Definition at line 283 of file pshrec.c.

286 {
290
291
292 count = table->num_masks;
293 if ( count == 0 )
294 {
296 if ( error )
297 goto Exit;
298 }
299 else
300 mask = table->masks + count - 1;
301
302 Exit:
303 *amask = mask;
304 return error;
305 }

Referenced by ps_dimension_add_t1stem(), and ps_mask_table_set_bits().

◆ ps_mask_table_merge()

static FT_Error ps_mask_table_merge ( PS_Mask_Table  table,
FT_UInt  index1,
FT_UInt  index2,
FT_Memory  memory 
)
static

Definition at line 403 of file pshrec.c.

407 {
409
410
411 /* swap index1 and index2 so that index1 < index2 */
412 if ( index1 > index2 )
413 {
415
416
417 temp = index1;
418 index1 = index2;
419 index2 = temp;
420 }
421
422 if ( index1 < index2 && index2 < table->num_masks )
423 {
424 /* we need to merge the bitsets of index1 and index2 with a */
425 /* simple union */
426 PS_Mask mask1 = table->masks + index1;
427 PS_Mask mask2 = table->masks + index2;
428 FT_UInt count1 = mask1->num_bits;
429 FT_UInt count2 = mask2->num_bits;
430 FT_Int delta;
431
432
433 if ( count2 > 0 )
434 {
435 FT_UInt pos;
436 FT_Byte* read;
437 FT_Byte* write;
438
439
440 /* if "count2" is greater than "count1", we need to grow the */
441 /* first bitset, and clear the highest bits */
442 if ( count2 > count1 )
443 {
444 error = ps_mask_ensure( mask1, count2, memory );
445 if ( error )
446 goto Exit;
447
448 for ( pos = count1; pos < count2; pos++ )
449 ps_mask_clear_bit( mask1, pos );
450 }
451
452 /* merge (unite) the bitsets */
453 read = mask2->bytes;
454 write = mask1->bytes;
455 pos = ( count2 + 7 ) >> 3;
456
457 for ( ; pos > 0; pos-- )
458 {
459 write[0] = (FT_Byte)( write[0] | read[0] );
460 write++;
461 read++;
462 }
463 }
464
465 /* Now, remove "mask2" from the list. We need to keep the masks */
466 /* sorted in order of importance, so move table elements. */
467 mask2->num_bits = 0;
468 mask2->end_point = 0;
469
470 /* number of masks to move */
471 delta = (FT_Int)( table->num_masks - 1 - index2 );
472 if ( delta > 0 )
473 {
474 /* move to end of table for reuse */
475 PS_MaskRec dummy = *mask2;
476
477
478 ft_memmove( mask2,
479 mask2 + 1,
480 (FT_UInt)delta * sizeof ( PS_MaskRec ) );
481
482 mask2[delta] = dummy;
483 }
484
485 table->num_masks--;
486 }
487 else
488 FT_TRACE0(( "ps_mask_table_merge: ignoring invalid indices (%d,%d)\n",
489 index1, index2 ));
490
491 Exit:
492 return error;
493 }
#define read
Definition: acwin.h:96
#define write
Definition: acwin.h:97
#define ft_memmove
Definition: ftstdlib.h:83
static void ps_mask_clear_bit(PS_Mask mask, FT_UInt idx)
Definition: pshrec.c:169
static calc_node_t temp
Definition: rpn_ieee.c:38
FT_UInt num_bits
Definition: pshrec.h:96
FT_Byte * bytes
Definition: pshrec.h:98

Referenced by ps_mask_table_merge_all().

◆ ps_mask_table_merge_all()

static FT_Error ps_mask_table_merge_all ( PS_Mask_Table  table,
FT_Memory  memory 
)
static

Definition at line 500 of file pshrec.c.

502 {
503 FT_Int index1, index2;
505
506
507 /* both loops go down to 0, thus FT_Int for index1 and index2 */
508 for ( index1 = (FT_Int)table->num_masks - 1; index1 > 0; index1-- )
509 {
510 for ( index2 = index1 - 1; index2 >= 0; index2-- )
511 {
513 (FT_UInt)index1,
514 (FT_UInt)index2 ) )
515 {
517 (FT_UInt)index2,
518 (FT_UInt)index1,
519 memory );
520 if ( error )
521 goto Exit;
522
523 break;
524 }
525 }
526 }
527
528 Exit:
529 return error;
530 }
static FT_Int ps_mask_table_test_intersect(PS_Mask_Table table, FT_UInt index1, FT_UInt index2)
Definition: pshrec.c:371
static FT_Error ps_mask_table_merge(PS_Mask_Table table, FT_UInt index1, FT_UInt index2, FT_Memory memory)
Definition: pshrec.c:403

Referenced by ps_dimension_end().

◆ ps_mask_table_set_bits()

static FT_Error ps_mask_table_set_bits ( PS_Mask_Table  table,
const FT_Byte source,
FT_UInt  bit_pos,
FT_UInt  bit_count,
FT_Memory  memory 
)
static

Definition at line 310 of file pshrec.c.

315 {
318
319
321 if ( error )
322 goto Exit;
323
324 error = ps_mask_ensure( mask, bit_count, memory );
325 if ( error )
326 goto Exit;
327
328 mask->num_bits = bit_count;
329
330 /* now, copy bits */
331 {
332 FT_Byte* read = (FT_Byte*)source + ( bit_pos >> 3 );
333 FT_Int rmask = 0x80 >> ( bit_pos & 7 );
334 FT_Byte* write = mask->bytes;
335 FT_Int wmask = 0x80;
336 FT_Int val;
337
338
339 for ( ; bit_count > 0; bit_count-- )
340 {
341 val = write[0] & ~wmask;
342
343 if ( read[0] & rmask )
344 val |= wmask;
345
346 write[0] = (FT_Byte)val;
347
348 rmask >>= 1;
349 if ( rmask == 0 )
350 {
351 read++;
352 rmask = 0x80;
353 }
354
355 wmask >>= 1;
356 if ( wmask == 0 )
357 {
358 write++;
359 wmask = 0x80;
360 }
361 }
362 }
363
364 Exit:
365 return error;
366 }
DWORD rmask
Definition: surface.c:186
GLuint GLfloat * val
Definition: glext.h:7180

Referenced by ps_dimension_set_mask_bits().

◆ ps_mask_table_test_intersect()

static FT_Int ps_mask_table_test_intersect ( PS_Mask_Table  table,
FT_UInt  index1,
FT_UInt  index2 
)
static

Definition at line 371 of file pshrec.c.

374 {
375 PS_Mask mask1 = table->masks + index1;
376 PS_Mask mask2 = table->masks + index2;
377 FT_Byte* p1 = mask1->bytes;
378 FT_Byte* p2 = mask2->bytes;
379 FT_UInt count1 = mask1->num_bits;
380 FT_UInt count2 = mask2->num_bits;
382
383
384 count = FT_MIN( count1, count2 );
385 for ( ; count >= 8; count -= 8 )
386 {
387 if ( p1[0] & p2[0] )
388 return 1;
389
390 p1++;
391 p2++;
392 }
393
394 if ( count == 0 )
395 return 0;
396
397 return ( p1[0] & p2[0] ) & ~( 0xFF >> count );
398 }
#define FT_MIN(a, b)
Definition: ftobjs.h:71

Referenced by ps_mask_table_merge_all().

◆ ps_mask_test_bit()

static FT_Int ps_mask_test_bit ( PS_Mask  mask,
FT_Int  idx 
)
static

Definition at line 157 of file pshrec.c.

159 {
160 if ( (FT_UInt)idx >= mask->num_bits )
161 return 0;
162
163 return mask->bytes[idx >> 3] & ( 0x80 >> ( idx & 7 ) );
164 }

Referenced by ps_dimension_add_counter().

◆ t1_hints_funcs_init()

t1_hints_funcs_init ( T1_Hints_FuncsRec funcs)

Definition at line 1141 of file pshrec.c.

1142 {
1143 FT_ZERO( funcs );
1144
1151 }
void(* T1_Hints_SetStemFunc)(T1_Hints hints, FT_UInt dimension, FT_Fixed *coords)
Definition: pshints.h:179
void(* T1_Hints_OpenFunc)(T1_Hints hints)
Definition: pshints.h:139
void(* T1_Hints_SetStem3Func)(T1_Hints hints, FT_UInt dimension, FT_Fixed *coords)
Definition: pshints.h:213
FT_Error(* T1_Hints_CloseFunc)(T1_Hints hints, FT_UInt end_point)
Definition: pshints.h:266
FT_Error(* T1_Hints_ApplyFunc)(T1_Hints hints, FT_Outline *outline, PSH_Globals globals, FT_Render_Mode hint_mode)
Definition: pshints.h:305
void(* T1_Hints_ResetFunc)(T1_Hints hints, FT_UInt end_point)
Definition: pshints.h:237
FT_Error ps_hints_apply(PS_Hints ps_hints, FT_Outline *outline, PSH_Globals globals, FT_Render_Mode hint_mode)
Definition: pshalgo.c:2070
static void t1_hints_open(T1_Hints hints)
Definition: pshrec.c:1120
static FT_Error ps_hints_close(PS_Hints hints, FT_UInt end_point)
Definition: pshrec.c:1083
static void t1_hints_stem(T1_Hints hints, FT_UInt dimension, FT_Fixed *coords)
Definition: pshrec.c:1126
static void ps_hints_t1stem3(PS_Hints hints, FT_UInt dimension, FT_Fixed *stems)
Definition: pshrec.c:889
static void ps_hints_t1reset(PS_Hints hints, FT_UInt end_point)
Definition: pshrec.c:952
static struct __wine_debug_functions funcs
Definition: debug.c:59

Referenced by ps_hinter_init().

◆ t1_hints_open()

static void t1_hints_open ( T1_Hints  hints)
static

Definition at line 1120 of file pshrec.c.

1121 {
1123 }
static void ps_hints_open(PS_Hints hints, PS_Hint_Type hint_type)
Definition: pshrec.c:828

Referenced by t1_hints_funcs_init().

◆ t1_hints_stem()

static void t1_hints_stem ( T1_Hints  hints,
FT_UInt  dimension,
FT_Fixed coords 
)
static

Definition at line 1126 of file pshrec.c.

1129 {
1130 FT_Pos stems[2];
1131
1132
1133 stems[0] = FIXED_TO_INT( coords[0] );
1134 stems[1] = FIXED_TO_INT( coords[1] );
1135
1136 ps_hints_stem( (PS_Hints)hints, dimension, 1, stems );
1137 }
FT_BEGIN_HEADER typedef signed long FT_Pos
Definition: ftimage.h:58
GLuint coords
Definition: glext.h:7368
static void ps_hints_stem(PS_Hints hints, FT_UInt dimension, FT_Int count, FT_Long *stems)
Definition: pshrec.c:841

Referenced by t1_hints_funcs_init().

◆ t2_hints_funcs_init()

t2_hints_funcs_init ( T2_Hints_FuncsRec funcs)

Definition at line 1207 of file pshrec.c.

1208 {
1209 FT_ZERO( funcs );
1210
1217 }
FT_Error(* T2_Hints_CloseFunc)(T2_Hints hints, FT_UInt end_point)
Definition: pshints.h:580
void(* T2_Hints_CounterFunc)(T2_Hints hints, FT_UInt bit_count, const FT_Byte *bytes)
Definition: pshints.h:550
void(* T2_Hints_StemsFunc)(T2_Hints hints, FT_UInt dimension, FT_Int count, FT_Fixed *coordinates)
Definition: pshints.h:466
void(* T2_Hints_OpenFunc)(T2_Hints hints)
Definition: pshints.h:426
void(* T2_Hints_MaskFunc)(T2_Hints hints, FT_UInt end_point, FT_UInt bit_count, const FT_Byte *bytes)
Definition: pshints.h:508
FT_Error(* T2_Hints_ApplyFunc)(T2_Hints hints, FT_Outline *outline, PSH_Globals globals, FT_Render_Mode hint_mode)
Definition: pshints.h:619
static void ps_hints_t2mask(PS_Hints hints, FT_UInt end_point, FT_UInt bit_count, const FT_Byte *bytes)
Definition: pshrec.c:991
static void t2_hints_stems(T2_Hints hints, FT_UInt dimension, FT_Int count, FT_Fixed *coords)
Definition: pshrec.c:1170
static void ps_hints_t2counter(PS_Hints hints, FT_UInt bit_count, const FT_Byte *bytes)
Definition: pshrec.c:1037
static void t2_hints_open(T2_Hints hints)
Definition: pshrec.c:1163

Referenced by ps_hinter_init().

◆ t2_hints_open()

static void t2_hints_open ( T2_Hints  hints)
static

Definition at line 1163 of file pshrec.c.

1164 {
1166 }
@ PS_HINT_TYPE_2
Definition: pshrec.h:58

Referenced by t2_hints_funcs_init().

◆ t2_hints_stems()

static void t2_hints_stems ( T2_Hints  hints,
FT_UInt  dimension,
FT_Int  count,
FT_Fixed coords 
)
static

Definition at line 1170 of file pshrec.c.

1174 {
1175 FT_Pos stems[32], y;
1176 FT_Int total = count, n;
1177
1178
1179 y = 0;
1180 while ( total > 0 )
1181 {
1182 /* determine number of stems to write */
1183 count = total;
1184 if ( count > 16 )
1185 count = 16;
1186
1187 /* compute integer stem positions in font units */
1188 for ( n = 0; n < count * 2; n++ )
1189 {
1190 y += coords[n];
1191 stems[n] = FIXED_TO_INT( y );
1192 }
1193
1194 /* compute lengths */
1195 for ( n = 0; n < count * 2; n += 2 )
1196 stems[n + 1] = stems[n + 1] - stems[n];
1197
1198 /* add them to the current dimension */
1199 ps_hints_stem( (PS_Hints)hints, dimension, count, stems );
1200
1201 total -= count;
1202 }
1203 }
size_t total
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLdouble n
Definition: glext.h:7729

Referenced by t2_hints_funcs_init().