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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [lto/] [20091013-1_2.c] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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