OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [lto/] [20091013-1_2.c] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
typedef struct HDC__ { int unused; } *HDC;
2
typedef struct HFONT__ { int unused; } *HFONT;
3
 
4
void* HeapAlloc(void*,unsigned int,unsigned long);
5
 
6
typedef struct tagLOGFONTW
7
{
8
    int lfPitchAndFamily;
9
    unsigned short lfFaceName[32];
10
} LOGFONTW, *PLOGFONTW, *LPLOGFONTW;
11
 
12
typedef struct tagGdiFont GdiFont;
13
typedef struct tagDC DC;
14
 
15
extern unsigned int WineEngGetFontData(GdiFont*, unsigned int, unsigned int, void*, unsigned int);
16
 
17
struct list
18
{
19
    struct list *next;
20
    struct list *prev;
21
};
22
 
23
typedef struct FT_FaceRec_
24
{
25
  signed long face_flags;
26
} FT_FaceRec, *FT_Face;
27
 
28
typedef struct { } GM;
29
 
30
typedef struct { } FMAT2;
31
 
32
typedef struct {
33
    unsigned int hash;
34
    LOGFONTW lf;
35
    int can_use_bitmap;
36
} FONT_DESC;
37
 
38
 
39
 
40
typedef struct tagHFONTLIST {
41
    struct list entry;
42
    HFONT hfont;
43
} HFONTLIST;
44
 
45
typedef struct {
46
    struct list entry;
47
    void *face;
48
    GdiFont *font;
49
} CHILD_FONT;
50
 
51
 
52
struct tagGdiFont {
53
    struct list entry;
54
    GM **gm;
55
    struct list hfontlist;
56
    struct list child_fonts;
57
 
58
    FT_Face ft_face;
59
    FONT_DESC font_desc;
60
    long ppem;
61
};
62
 
63
 
64
 
65
static struct list gdi_font_list = { &(gdi_font_list), &(gdi_font_list) };
66
 
67
 
68
 
69
 
70
static int get_glyph_index_linked(GdiFont *font, unsigned int c, GdiFont **linked_font, unsigned int *glyph);
71
static long load_VDMX(GdiFont*, long);
72
 
73
extern int f1(void*,int);
74
 
75
static FT_Face OpenFontFace(GdiFont *font, void *face, long width, long height)
76
{
77
   FT_Face ft_face;
78
 
79
   font->ppem = load_VDMX(font, height);
80
   if(font->ppem == 0)
81
       font->ppem = f1(ft_face, height);
82
   return ft_face;
83
}
84
 
85
 
86
static GdiFont *alloc_font(void)
87
{
88
    GdiFont *ret = HeapAlloc(0, 0x00000008, sizeof(*ret));
89
    ret->gm = HeapAlloc(0, 0x00000008, sizeof(GM*));
90
    return ret;
91
}
92
 
93
 
94
static long load_VDMX(GdiFont *font,long height)
95
{
96
    unsigned short hdr[3];
97
 
98
    WineEngGetFontData(font, 0x42424242, 0, hdr, 6);
99
    return 0;
100
}
101
 
102
static int fontcmp(const GdiFont *font, FONT_DESC *fd)
103
{
104
    if(font->font_desc.hash != fd->hash) return 1;
105
    if(memcmp(&font->font_desc.lf, &fd->lf, __builtin_offsetof (LOGFONTW, lfFaceName))) return 1;
106
    if(!font->font_desc.can_use_bitmap != !fd->can_use_bitmap) return 1;
107
    return strcmpiW(font->font_desc.lf.lfFaceName, fd->lf.lfFaceName);
108
}
109
 
110
static GdiFont *find_in_cache(HFONT hfont, const LOGFONTW *plf, const FMAT2 *pmat, int can_use_bitmap)
111
{
112
    GdiFont *ret;
113
    FONT_DESC fd;
114
    HFONTLIST *hflist;
115
    struct list *font_elem_ptr, *hfontlist_elem_ptr;
116
 
117
    fd.lf = *plf;
118
    fd.can_use_bitmap = can_use_bitmap;
119
 
120
 
121
    for ((font_elem_ptr) = (&gdi_font_list)->next; (font_elem_ptr) != (&gdi_font_list); (font_elem_ptr) = (font_elem_ptr)->next) {
122
        ret = ((struct tagGdiFont *)((char *)(font_elem_ptr) - (unsigned long)(&((struct tagGdiFont *)0)->entry)));
123
        if(!fontcmp(ret, &fd)) {
124
            if(!can_use_bitmap && !( ret->ft_face->face_flags & ( 1L << 0 ) )) continue;
125
            for ((hfontlist_elem_ptr) = (&ret->hfontlist)->next; (hfontlist_elem_ptr) != (&ret->hfontlist); (hfontlist_elem_ptr) = (hfontlist_elem_ptr)->next) {
126
                hflist = ((struct tagHFONTLIST *)((char *)(hfontlist_elem_ptr) - (unsigned long)(&((struct tagHFONTLIST *)0)->entry)));
127
                if(hflist->hfont == hfont)
128
                    return ret;
129
            }
130
            hflist = HeapAlloc(0, 0, sizeof(*hflist));
131
            hflist->hfont = hfont;
132
            return ret;
133
        }
134
    }
135
 
136
    while(font_elem_ptr) {
137
        ret = ((struct tagGdiFont *)((char *)(font_elem_ptr) - (unsigned long)(&((struct tagGdiFont *)0)->entry)));
138
        if(!fontcmp(ret, &fd)) {
139
            if(!can_use_bitmap && !( ret->ft_face->face_flags & ( 1L << 0 ) )) continue;
140
            hflist = HeapAlloc(0, 0, sizeof(*hflist));
141
            hflist->hfont = hfont;
142
            return ret;
143
        }
144
    }
145
    return ((void *)0);
146
}
147
 
148
 
149
 
150
 
151
GdiFont *WineEngCreateFontInstance(DC *dc, HFONT hfont)
152
{
153
    GdiFont *ret;
154
    int can_use_bitmap;
155
    LOGFONTW lf;
156
    FMAT2 dcmat;
157
 
158
    if((ret = find_in_cache(hfont, &lf, &dcmat, can_use_bitmap)) != ((void *)0))
159
        return ret;
160
    return alloc_font();
161
}
162
 
163
extern unsigned int f(void*,unsigned int g);
164
 
165
static unsigned int get_glyph_index(void*font, unsigned int glyph)
166
{
167
    return f(font, glyph);
168
}
169
 
170
unsigned int WineEngGetGlyphOutline(GdiFont *incoming_font, unsigned int glyph, unsigned int format,
171
        void* lpgm, unsigned int buflen, void* buf,
172
        const void* lpmat)
173
{
174
    unsigned int glyph_index;
175
 
176
    get_glyph_index_linked(incoming_font, glyph, &incoming_font, &glyph_index);
177
    return 0;
178
}
179
 
180
static int load_child_font(GdiFont *font, CHILD_FONT *child)
181
{
182
    child->font = alloc_font();
183
    child->font->ft_face = OpenFontFace(child->font, child->face, 0, -font->ppem);
184
    if(!child->font->ft_face)
185
        return 0;
186
    return 1;
187
}
188
 
189
static int get_glyph_index_linked(GdiFont *font, unsigned int c, GdiFont **linked_font, unsigned int *glyph)
190
{
191
    unsigned int g;
192
    CHILD_FONT *child_font;
193
 
194
    for ((child_font) = ((CHILD_FONT *)((char *)((&font->child_fonts)->next) - (unsigned long)(&((CHILD_FONT *)0)->entry))); &(child_font)->entry != (&font->child_fonts); (child_font) = ((CHILD_FONT *)((char *)((child_font)->entry.next) - (unsigned long)(&((CHILD_FONT *)0)->entry))))
195
    {
196
        if(!load_child_font(font, child_font))
197
            continue;
198
 
199
        g = get_glyph_index(child_font->font, c);
200
        if(g) {
201
            *glyph = g;
202
            *linked_font = child_font->font;
203
            return 1;
204
        }
205
    }
206
    return 0;
207
}
208
 
209
unsigned int WineEngGetFontData(GdiFont *font, unsigned int table, unsigned int offset, void* buf,
210
    unsigned int cbData)
211
{
212
    unsigned long len;
213
    load_sfnt_table(font->ft_face, table, offset, buf, &len);
214
    return len;
215
}
216
 
217
int WineEngGetLinkedHFont(DC *dc, unsigned short c, HFONT *new_hfont, unsigned int *glyph) {
218
    return get_glyph_index_linked(0, 0, 0, 0);
219
}
220
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.