~ubuntu-branches/ubuntu/vivid/xorg-server/vivid

« back to all changes in this revision

Viewing changes to fb/fbpict.c

  • Committer: Package Import Robot
  • Author(s): Maarten Lankhorst
  • Date: 2013-07-03 12:03:57 UTC
  • mfrom: (1.1.56)
  • Revision ID: package-import@ubuntu.com-20130703120357-caosebpn11zu2zj0
Tags: 2:1.14.1-0ubuntu0.8
Use correct version for libxfixes3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
    free_pixman_pict(pDst, dest);
71
71
}
72
72
 
 
73
static pixman_glyph_cache_t *glyphCache;
 
74
 
 
75
void
 
76
fbDestroyGlyphCache(void)
 
77
{
 
78
    if (glyphCache)
 
79
    {
 
80
        pixman_glyph_cache_destroy (glyphCache);
 
81
        glyphCache = NULL;
 
82
    }
 
83
}
 
84
 
 
85
static void
 
86
fbUnrealizeGlyph(ScreenPtr pScreen,
 
87
                 GlyphPtr pGlyph)
 
88
{
 
89
    if (glyphCache)
 
90
        pixman_glyph_cache_remove (glyphCache, pGlyph, NULL);
 
91
}
 
92
 
 
93
static void
 
94
fbGlyphs(CARD8 op,
 
95
         PicturePtr pSrc,
 
96
         PicturePtr pDst,
 
97
         PictFormatPtr maskFormat,
 
98
         INT16 xSrc,
 
99
         INT16 ySrc, int nlist,
 
100
         GlyphListPtr list,
 
101
         GlyphPtr *glyphs)
 
102
{
 
103
#define N_STACK_GLYPHS 512
 
104
    ScreenPtr pScreen = pDst->pDrawable->pScreen;
 
105
    pixman_glyph_t stack_glyphs[N_STACK_GLYPHS];
 
106
    pixman_glyph_t *pglyphs = stack_glyphs;
 
107
    pixman_image_t *srcImage, *dstImage;
 
108
    int srcXoff, srcYoff, dstXoff, dstYoff;
 
109
    GlyphPtr glyph;
 
110
    int n_glyphs;
 
111
    int x, y;
 
112
    int i, n;
 
113
    int xDst = list->xOff, yDst = list->yOff;
 
114
 
 
115
    miCompositeSourceValidate(pSrc);
 
116
    
 
117
    n_glyphs = 0;
 
118
    for (i = 0; i < nlist; ++i)
 
119
        n_glyphs += list[i].len;
 
120
 
 
121
    if (!glyphCache)
 
122
        glyphCache = pixman_glyph_cache_create();
 
123
 
 
124
    pixman_glyph_cache_freeze (glyphCache);
 
125
    
 
126
    if (n_glyphs > N_STACK_GLYPHS) {
 
127
        if (!(pglyphs = malloc (n_glyphs * sizeof (pixman_glyph_t))))
 
128
            goto out;
 
129
    }
 
130
    
 
131
    i = 0;
 
132
    x = y = 0;
 
133
    while (nlist--) {
 
134
        x += list->xOff;
 
135
        y += list->yOff;
 
136
        n = list->len;
 
137
        while (n--) {
 
138
            const void *g;
 
139
 
 
140
            glyph = *glyphs++;
 
141
 
 
142
            if (!(g = pixman_glyph_cache_lookup (glyphCache, glyph, NULL))) {
 
143
                pixman_image_t *glyphImage;
 
144
                PicturePtr pPicture;
 
145
                int xoff, yoff;
 
146
 
 
147
                pPicture = GetGlyphPicture(glyph, pScreen);
 
148
                if (!pPicture) {
 
149
                    n_glyphs--;
 
150
                    goto next;
 
151
                }
 
152
 
 
153
                if (!(glyphImage = image_from_pict(pPicture, FALSE, &xoff, &yoff)))
 
154
                    goto out;
 
155
 
 
156
                g = pixman_glyph_cache_insert(glyphCache, glyph, NULL,
 
157
                                              glyph->info.x,
 
158
                                              glyph->info.y,
 
159
                                              glyphImage);
 
160
 
 
161
                free_pixman_pict(pPicture, glyphImage);
 
162
 
 
163
                if (!g)
 
164
                    goto out;
 
165
            }
 
166
 
 
167
            pglyphs[i].x = x;
 
168
            pglyphs[i].y = y;
 
169
            pglyphs[i].glyph = g;
 
170
            i++;
 
171
 
 
172
        next:
 
173
            x += glyph->info.xOff;
 
174
            y += glyph->info.yOff;
 
175
        }
 
176
        list++;
 
177
    }
 
178
 
 
179
    if (!(srcImage = image_from_pict(pSrc, FALSE, &srcXoff, &srcYoff)))
 
180
        goto out;
 
181
 
 
182
    if (!(dstImage = image_from_pict(pDst, TRUE, &dstXoff, &dstYoff)))
 
183
        goto out_free_src;
 
184
 
 
185
    if (maskFormat) {
 
186
        pixman_format_code_t format;
 
187
        pixman_box32_t extents;
 
188
        int x, y;
 
189
 
 
190
        format = maskFormat->format | (maskFormat->depth << 24);
 
191
 
 
192
        pixman_glyph_get_extents(glyphCache, n_glyphs, pglyphs, &extents);
 
193
 
 
194
        x = extents.x1;
 
195
        y = extents.y1;
 
196
 
 
197
        pixman_composite_glyphs(op, srcImage, dstImage, format,
 
198
                                xSrc + srcXoff + xDst, ySrc + srcYoff + yDst,
 
199
                                x, y,
 
200
                                x + dstXoff, y + dstYoff,
 
201
                                extents.x2 - extents.x1,
 
202
                                extents.y2 - extents.y1,
 
203
                                glyphCache, n_glyphs, pglyphs);
 
204
    }
 
205
    else {
 
206
        pixman_composite_glyphs_no_mask(op, srcImage, dstImage,
 
207
                                        xSrc + srcXoff - xDst, ySrc + srcYoff - yDst,
 
208
                                        dstXoff, dstYoff,
 
209
                                        glyphCache, n_glyphs, pglyphs);
 
210
    }
 
211
 
 
212
    free_pixman_pict(pDst, dstImage);
 
213
 
 
214
out_free_src:
 
215
    free_pixman_pict(pSrc, srcImage);
 
216
 
 
217
out:
 
218
    pixman_glyph_cache_thaw(glyphCache);
 
219
    if (pglyphs != stack_glyphs)
 
220
        free(pglyphs);
 
221
}
 
222
 
73
223
static pixman_image_t *
74
224
create_solid_fill_image(PicturePtr pict)
75
225
{
357
507
        return FALSE;
358
508
    ps = GetPictureScreen(pScreen);
359
509
    ps->Composite = fbComposite;
360
 
    ps->Glyphs = miGlyphs;
 
510
    ps->Glyphs = fbGlyphs;
 
511
    ps->UnrealizeGlyph = fbUnrealizeGlyph;
361
512
    ps->CompositeRects = miCompositeRects;
362
513
    ps->RasterizeTrapezoid = fbRasterizeTrapezoid;
363
514
    ps->Trapezoids = fbTrapezoids;