2 * Functions to use the XRender extension
4 * Copyright 2001 Huw D M Davies for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "wine/port.h"
30 #include "wine/unicode.h"
31 #include "wine/debug.h"
33 BOOL X11DRV_XRender_Installed = FALSE;
34 WINE_DEFAULT_DEBUG_CHANNEL(xrender);
36 #ifdef HAVE_X11_EXTENSIONS_XRENDER_H
39 #include <X11/extensions/Xrender.h>
41 static XRenderPictFormat *screen_format; /* format of screen */
42 static XRenderPictFormat *mono_format; /* format of mono bitmap */
47 XFORM xform; /* this is dum as we don't care about offsets */
51 #define INITIAL_REALIZED_BUF_SIZE 128
58 XRenderPictFormat *font_format;
71 COLORREF lastTextColor;
75 static gsCacheEntry *glyphsetCache = NULL;
76 static DWORD glyphsetCacheSize = 0;
77 static INT lastfree = -1;
80 #define INIT_CACHE_SIZE 10
82 static int antialias = 1;
84 /* some default values just in case */
86 #define SONAME_LIBX11 "libX11.so"
88 #ifndef SONAME_LIBXEXT
89 #define SONAME_LIBXEXT "libXext.so"
91 #ifndef SONAME_LIBXRENDER
92 #define SONAME_LIBXRENDER "libXrender.so"
95 static void *xrender_handle;
97 #define MAKE_FUNCPTR(f) static typeof(f) * p##f;
98 MAKE_FUNCPTR(XRenderAddGlyphs)
99 MAKE_FUNCPTR(XRenderCompositeString8)
100 MAKE_FUNCPTR(XRenderCompositeString16)
101 MAKE_FUNCPTR(XRenderCompositeString32)
102 MAKE_FUNCPTR(XRenderCreateGlyphSet)
103 MAKE_FUNCPTR(XRenderCreatePicture)
104 MAKE_FUNCPTR(XRenderFillRectangle)
105 MAKE_FUNCPTR(XRenderFindFormat)
106 MAKE_FUNCPTR(XRenderFindVisualFormat)
107 MAKE_FUNCPTR(XRenderFreeGlyphSet)
108 MAKE_FUNCPTR(XRenderFreePicture)
109 MAKE_FUNCPTR(XRenderSetPictureClipRectangles)
110 MAKE_FUNCPTR(XRenderQueryExtension)
113 static CRITICAL_SECTION xrender_cs = CRITICAL_SECTION_INIT("xrender_cs");
116 /***********************************************************************
117 * X11DRV_XRender_Init
119 * Let's see if our XServer has the extension available
122 void X11DRV_XRender_Init(void)
124 int error_base, event_base, i;
125 XRenderPictFormat pf;
127 if (!wine_dlopen(SONAME_LIBX11, RTLD_NOW|RTLD_GLOBAL, NULL, 0)) return;
128 if (!wine_dlopen(SONAME_LIBXEXT, RTLD_NOW|RTLD_GLOBAL, NULL, 0)) return;
129 xrender_handle = wine_dlopen(SONAME_LIBXRENDER, RTLD_NOW, NULL, 0);
130 if(!xrender_handle) return;
132 #define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(xrender_handle, #f, NULL, 0)) == NULL) goto sym_not_found;
133 LOAD_FUNCPTR(XRenderAddGlyphs)
134 LOAD_FUNCPTR(XRenderCompositeString8)
135 LOAD_FUNCPTR(XRenderCompositeString16)
136 LOAD_FUNCPTR(XRenderCompositeString32)
137 LOAD_FUNCPTR(XRenderCreateGlyphSet)
138 LOAD_FUNCPTR(XRenderCreatePicture)
139 LOAD_FUNCPTR(XRenderFillRectangle)
140 LOAD_FUNCPTR(XRenderFindFormat)
141 LOAD_FUNCPTR(XRenderFindVisualFormat)
142 LOAD_FUNCPTR(XRenderFreeGlyphSet)
143 LOAD_FUNCPTR(XRenderFreePicture)
144 LOAD_FUNCPTR(XRenderSetPictureClipRectangles)
145 LOAD_FUNCPTR(XRenderQueryExtension)
149 if(pXRenderQueryExtension(gdi_display, &event_base, &error_base)) {
150 X11DRV_XRender_Installed = TRUE;
151 TRACE("Xrender is up and running error_base = %d\n", error_base);
152 screen_format = pXRenderFindVisualFormat(gdi_display, visual);
153 if(!screen_format) { /* This fails in buggy versions of libXrender.so */
156 "Wine has detected that you probably have a buggy version\n"
157 "of libXrender.so . Because of this client side font rendering\n"
158 "will be disabled. Please upgrade this library.\n");
159 X11DRV_XRender_Installed = FALSE;
162 pf.type = PictTypeDirect;
165 pf.direct.alphaMask = 1;
166 mono_format = pXRenderFindFormat(gdi_display, PictFormatType |
167 PictFormatDepth | PictFormatAlpha |
168 PictFormatAlphaMask, &pf, 0);
171 ERR("mono_format == NULL?\n");
172 X11DRV_XRender_Installed = FALSE;
175 glyphsetCache = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
176 sizeof(*glyphsetCache) * INIT_CACHE_SIZE);
178 glyphsetCacheSize = INIT_CACHE_SIZE;
180 for(i = 0; i < INIT_CACHE_SIZE; i++) {
181 glyphsetCache[i].next = i + 1;
182 glyphsetCache[i].count = -1;
184 glyphsetCache[i-1].next = -1;
186 TRACE("Xrender is not available on this server\n");
192 wine_dlclose(xrender_handle, NULL, 0);
193 xrender_handle = NULL;
196 static BOOL fontcmp(LFANDSIZE *p1, LFANDSIZE *p2)
198 if(p1->hash != p2->hash) return TRUE;
199 if(memcmp(&p1->xform, &p2->xform, sizeof(p1->xform))) return TRUE;
200 if(memcmp(&p1->lf, &p2->lf, offsetof(LOGFONTW, lfFaceName))) return TRUE;
201 return strcmpW(p1->lf.lfFaceName, p2->lf.lfFaceName);
205 static void walk_cache(void)
209 EnterCriticalSection(&xrender_cs);
210 for(i=mru; i >= 0; i = glyphsetCache[i].next)
211 TRACE("item %d\n", i);
212 LeaveCriticalSection(&xrender_cs);
216 static int LookupEntry(LFANDSIZE *plfsz)
220 for(i = mru; i >= 0; i = glyphsetCache[i].next) {
222 if(glyphsetCache[i].count == -1) { /* reached free list so stop */
227 if(!fontcmp(&glyphsetCache[i].lfsz, plfsz)) {
228 glyphsetCache[i].count++;
230 glyphsetCache[prev_i].next = glyphsetCache[i].next;
231 glyphsetCache[i].next = mru;
234 TRACE("found font in cache %d\n", i);
239 TRACE("font not in cache\n");
243 static int AllocEntry(void)
245 int best = -1, prev_best = -1, i, prev_i = -1;
248 assert(glyphsetCache[lastfree].count == -1);
249 glyphsetCache[lastfree].count = 1;
251 lastfree = glyphsetCache[lastfree].next;
253 glyphsetCache[best].next = mru;
256 TRACE("empty space at %d, next lastfree = %d\n", mru, lastfree);
260 for(i = mru; i >= 0; i = glyphsetCache[i].next) {
261 if(glyphsetCache[i].count == 0) {
269 TRACE("freeing unused glyphset at cache %d\n", best);
271 pXRenderFreeGlyphSet(gdi_display, glyphsetCache[best].glyphset);
273 glyphsetCache[best].glyphset = 0;
274 if(glyphsetCache[best].nrealized) { /* do we really want to do this? */
275 HeapFree(GetProcessHeap(), 0, glyphsetCache[best].realized);
276 glyphsetCache[best].realized = NULL;
277 glyphsetCache[best].nrealized = 0;
279 glyphsetCache[best].count = 1;
281 glyphsetCache[prev_best].next = glyphsetCache[best].next;
282 glyphsetCache[best].next = mru;
290 TRACE("Growing cache\n");
291 glyphsetCache = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
293 (glyphsetCacheSize + INIT_CACHE_SIZE)
294 * sizeof(*glyphsetCache));
295 for(best = i = glyphsetCacheSize; i < glyphsetCacheSize + INIT_CACHE_SIZE;
297 glyphsetCache[i].next = i + 1;
298 glyphsetCache[i].count = -1;
300 glyphsetCache[i-1].next = -1;
301 glyphsetCacheSize += INIT_CACHE_SIZE;
303 lastfree = glyphsetCache[best].next;
304 glyphsetCache[best].count = 1;
305 glyphsetCache[best].next = mru;
307 TRACE("new free cache slot at %d\n", mru);
311 static int GetCacheEntry(LFANDSIZE *plfsz)
313 XRenderPictFormat pf;
317 if((ret = LookupEntry(plfsz)) != -1) return ret;
320 entry = glyphsetCache + ret;
321 entry->lfsz = *plfsz;
322 assert(entry->nrealized == 0);
327 pf.direct.alphaMask = 0xff;
330 pf.direct.alphaMask = 1;
332 pf.type = PictTypeDirect;
336 entry->font_format = pXRenderFindFormat(gdi_display,
343 entry->glyphset = pXRenderCreateGlyphSet(gdi_display, entry->font_format);
348 static void dec_ref_cache(int index)
351 TRACE("dec'ing entry %d to %d\n", index, glyphsetCache[index].count - 1);
352 assert(glyphsetCache[index].count > 0);
353 glyphsetCache[index].count--;
356 static void lfsz_calc_hash(LFANDSIZE *plfsz)
358 DWORD hash = 0, *ptr;
361 for(ptr = (DWORD*)&plfsz->xform; ptr < (DWORD*)(&plfsz->xform + 1); ptr++)
363 for(i = 0, ptr = (DWORD*)&plfsz->lf; i < 7; i++, ptr++)
365 for(i = 0, ptr = (DWORD*)&plfsz->lf.lfFaceName; i < LF_FACESIZE/2; i++, ptr++) {
366 WCHAR *pwc = (WCHAR *)ptr;
376 /***********************************************************************
377 * X11DRV_XRender_Finalize
379 void X11DRV_XRender_Finalize(void)
381 FIXME("Free cached glyphsets\n");
383 if (xrender_handle) wine_dlclose(xrender_handle, NULL, 0);
384 xrender_handle = NULL;
389 /***********************************************************************
390 * X11DRV_XRender_SelectFont
392 BOOL X11DRV_XRender_SelectFont(X11DRV_PDEVICE *physDev, HFONT hfont)
396 GetObjectW(hfont, sizeof(lfsz.lf), &lfsz.lf);
397 TRACE("h=%ld w=%ld weight=%ld it=%d charset=%d name=%s\n",
398 lfsz.lf.lfHeight, lfsz.lf.lfWidth, lfsz.lf.lfWeight,
399 lfsz.lf.lfItalic, lfsz.lf.lfCharSet, debugstr_w(lfsz.lf.lfFaceName));
400 lfsz.xform = physDev->dc->xformWorld2Vport;
401 lfsz_calc_hash(&lfsz);
403 EnterCriticalSection(&xrender_cs);
404 if(!physDev->xrender) {
405 physDev->xrender = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
406 sizeof(*physDev->xrender));
407 physDev->xrender->cache_index = -1;
409 else if(physDev->xrender->cache_index != -1)
410 dec_ref_cache(physDev->xrender->cache_index);
411 physDev->xrender->cache_index = GetCacheEntry(&lfsz);
412 LeaveCriticalSection(&xrender_cs);
416 /***********************************************************************
417 * X11DRV_XRender_DeleteDC
419 void X11DRV_XRender_DeleteDC(X11DRV_PDEVICE *physDev)
422 if(physDev->xrender->tile_pict)
423 pXRenderFreePicture(gdi_display, physDev->xrender->tile_pict);
425 if(physDev->xrender->tile_xpm)
426 XFreePixmap(gdi_display, physDev->xrender->tile_xpm);
428 if(physDev->xrender->pict) {
429 TRACE("freeing pict = %lx dc = %p\n", physDev->xrender->pict, physDev->dc);
430 pXRenderFreePicture(gdi_display, physDev->xrender->pict);
434 EnterCriticalSection(&xrender_cs);
435 if(physDev->xrender->cache_index != -1)
436 dec_ref_cache(physDev->xrender->cache_index);
437 LeaveCriticalSection(&xrender_cs);
439 HeapFree(GetProcessHeap(), 0, physDev->xrender);
440 physDev->xrender = NULL;
444 /***********************************************************************
445 * X11DRV_XRender_UpdateDrawable
447 * This gets called from X11DRV_SetDrawable and deletes the pict when the
448 * drawable changes. However at the moment we delete the pict at the end of
449 * every ExtTextOut so this is basically a NOP.
451 void X11DRV_XRender_UpdateDrawable(X11DRV_PDEVICE *physDev)
453 if(physDev->xrender->pict) {
454 TRACE("freeing pict %08lx from dc %p\n", physDev->xrender->pict, physDev->dc);
456 pXRenderFreePicture(gdi_display, physDev->xrender->pict);
459 physDev->xrender->pict = 0;
463 /************************************************************************
466 * Helper to ExtTextOut. Must be called inside xrender_cs
468 static BOOL UploadGlyph(X11DRV_PDEVICE *physDev, int glyph)
475 gsCacheEntry *entry = glyphsetCache + physDev->xrender->cache_index;
476 UINT ggo_format = GGO_GLYPH_INDEX;
479 if(entry->nrealized <= glyph) {
480 entry->nrealized = (glyph / 128 + 1) * 128;
481 entry->realized = HeapReAlloc(GetProcessHeap(),
484 entry->nrealized * sizeof(BOOL));
487 if(entry->font_format->depth == 8) {
489 ggo_format |= WINE_GGO_GRAY16_BITMAP;
492 ggo_format |= GGO_BITMAP;
495 buflen = GetGlyphOutlineW(physDev->hdc, glyph, ggo_format, &gm, 0, NULL,
497 if(buflen == GDI_ERROR) {
498 LeaveCriticalSection(&xrender_cs);
502 entry->realized[glyph] = TRUE;
504 buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buflen);
505 GetGlyphOutlineW(physDev->hdc, glyph, ggo_format, &gm, buflen, buf, NULL);
507 TRACE("buflen = %d. Got metrics: %dx%d adv=%d,%d origin=%ld,%ld\n",
509 gm.gmBlackBoxX, gm.gmBlackBoxY, gm.gmCellIncX, gm.gmCellIncY,
510 gm.gmptGlyphOrigin.x, gm.gmptGlyphOrigin.y);
512 gi.width = gm.gmBlackBoxX;
513 gi.height = gm.gmBlackBoxY;
514 gi.x = -gm.gmptGlyphOrigin.x;
515 gi.y = gm.gmptGlyphOrigin.y;
516 gi.xOff = gm.gmCellIncX;
517 gi.yOff = gm.gmCellIncY;
519 if(TRACE_ON(xrender)) {
525 pitch = ((gi.width + 31) / 32) * 4;
526 for(i = 0; i < gi.height; i++) {
527 line = buf + i * pitch;
529 for(j = 0; j < pitch * 8; j++) {
530 strcat(output, (line[j / 8] & (1 << (7 - (j % 8)))) ? "#" : " ");
532 strcat(output, "\n");
536 char blks[] = " .:;!o*#";
540 pitch = ((gi.width + 3) / 4) * 4;
541 for(i = 0; i < gi.height; i++) {
542 line = buf + i * pitch;
544 for(j = 0; j < pitch; j++) {
545 str[0] = blks[line[j] >> 5];
548 strcat(output, "\n");
554 if(!aa && BitmapBitOrder(gdi_display) != MSBFirst) {
555 unsigned char *byte = buf, c;
561 /* magic to flip bit order */
562 c = ((c << 1) & 0xaa) | ((c >> 1) & 0x55);
563 c = ((c << 2) & 0xcc) | ((c >> 2) & 0x33);
564 c = ((c << 4) & 0xf0) | ((c >> 4) & 0x0f);
571 pXRenderAddGlyphs(gdi_display, entry->glyphset, &gid, &gi, 1,
574 HeapFree(GetProcessHeap(), 0, buf);
578 /***********************************************************************
579 * X11DRV_XRender_ExtTextOut
581 BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
582 const RECT *lprect, LPCWSTR wstr, UINT count,
591 BOOL done_extents = FALSE;
592 INT width, xwidth, ywidth;
593 double cosEsc, sinEsc;
596 int render_op = PictOpOver;
601 HDC hdc = physDev->hdc;
602 DC *dc = physDev->dc;
604 TRACE("%04x, %d, %d, %08x, %p, %s, %d, %p)\n", hdc, x, y, flags,
605 lprect, debugstr_wn(wstr, count), count, lpDx);
607 if(flags & ETO_GLYPH_INDEX)
608 glyphs = (LPWORD)wstr;
610 glyphs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR));
611 GetGlyphIndicesW(hdc, wstr, count, glyphs, 0);
615 TRACE("rect: %d,%d - %d,%d\n", lprect->left, lprect->top, lprect->right,
617 TRACE("align = %x bkmode = %x mapmode = %x\n", dc->textAlign, GetBkMode(hdc), dc->MapMode);
619 if(dc->textAlign & TA_UPDATECP) {
624 GetObjectW(GetCurrentObject(hdc, OBJ_FONT), sizeof(lf), &lf);
625 if(lf.lfEscapement != 0) {
626 cosEsc = cos(lf.lfEscapement * M_PI / 1800);
627 sinEsc = sin(lf.lfEscapement * M_PI / 1800);
633 if(flags & (ETO_CLIPPED | ETO_OPAQUE)) {
635 if(flags & ETO_CLIPPED) return FALSE;
636 GetTextExtentPointI(hdc, glyphs, count, &sz);
640 rc.right = x + sz.cx;
641 rc.bottom = y + sz.cy;
646 LPtoDP(physDev->hdc, (POINT*)&rc, 2);
648 if(rc.left > rc.right) {INT tmp = rc.left; rc.left = rc.right; rc.right = tmp;}
649 if(rc.top > rc.bottom) {INT tmp = rc.top; rc.top = rc.bottom; rc.bottom = tmp;}
652 xgcval.function = GXcopy;
653 xgcval.background = physDev->backgroundPixel;
654 xgcval.fill_style = FillSolid;
655 TSXChangeGC( gdi_display, physDev->gc,
656 GCFunction | GCBackground | GCFillStyle, &xgcval );
658 X11DRV_LockDIBSection( physDev, DIB_Status_GdiMod, FALSE );
660 if(flags & ETO_OPAQUE) {
661 TSXSetForeground( gdi_display, physDev->gc, physDev->backgroundPixel );
662 TSXFillRectangle( gdi_display, physDev->drawable, physDev->gc,
663 physDev->org.x + rc.left, physDev->org.y + rc.top,
664 rc.right - rc.left, rc.bottom - rc.top );
674 LPtoDP(physDev->hdc, &pt, 1);
678 TRACE("real x,y %d,%d\n", x, y);
682 for(idx = 0; idx < count; idx++)
686 GetTextExtentPointI(hdc, glyphs, count, &sz);
691 width = INTERNAL_XWSTODS(dc, width);
692 xwidth = width * cosEsc;
693 ywidth = width * sinEsc;
695 GetTextMetricsW(hdc, &tm);
697 tm.tmAscent = INTERNAL_YWSTODS(dc, tm.tmAscent);
698 tm.tmDescent = INTERNAL_YWSTODS(dc, tm.tmDescent);
699 switch( dc->textAlign & (TA_LEFT | TA_RIGHT | TA_CENTER) ) {
701 if (dc->textAlign & TA_UPDATECP) {
704 DPtoLP(physDev->hdc, &pt, 1);
718 if (dc->textAlign & TA_UPDATECP) {
721 DPtoLP(physDev->hdc, &pt, 1);
728 switch( dc->textAlign & (TA_TOP | TA_BOTTOM | TA_BASELINE) ) {
730 y += tm.tmAscent * cosEsc;
731 x += tm.tmAscent * sinEsc;
735 y -= tm.tmDescent * cosEsc;
736 x -= tm.tmDescent * sinEsc;
743 if (flags & ETO_CLIPPED)
746 IntersectVisRect16( dc->hSelf, lprect->left, lprect->top, lprect->right, lprect->bottom );
749 if(!physDev->xrender->pict) {
750 XRenderPictureAttributes pa;
751 pa.subwindow_mode = IncludeInferiors;
754 physDev->xrender->pict = pXRenderCreatePicture(gdi_display,
756 (dc->bitsPerPixel == 1) ?
757 mono_format : screen_format,
758 CPSubwindowMode, &pa);
761 TRACE("allocing pict = %lx dc = %p drawable = %08lx\n", physDev->xrender->pict, dc, physDev->drawable);
763 TRACE("using existing pict = %lx dc = %p\n", physDev->xrender->pict, dc);
766 if ((data = X11DRV_GetRegionData( dc->hGCClipRgn, 0 )))
769 pXRenderSetPictureClipRectangles( gdi_display, physDev->xrender->pict,
770 physDev->org.x, physDev->org.y,
771 (XRectangle *)data->Buffer, data->rdh.nCount );
773 HeapFree( GetProcessHeap(), 0, data );
776 if(GetBkMode(hdc) != TRANSPARENT) {
777 if(!((flags & ETO_CLIPPED) && (flags & ETO_OPAQUE))) {
778 if(!(flags & ETO_OPAQUE) || x < rc.left || x + width >= rc.right ||
779 y - tm.tmAscent < rc.top || y + tm.tmDescent >= rc.bottom) {
780 TSXSetForeground( gdi_display, physDev->gc, physDev->backgroundPixel );
781 TSXFillRectangle( gdi_display, physDev->drawable, physDev->gc,
782 physDev->org.x + x, physDev->org.y + y - tm.tmAscent,
783 width, tm.tmAscent + tm.tmDescent );
788 /* Create a 1x1 pixmap to tile over the font mask */
789 if(!physDev->xrender->tile_xpm) {
790 XRenderPictureAttributes pa;
792 XRenderPictFormat *format = (dc->bitsPerPixel == 1) ? mono_format : screen_format;
794 physDev->xrender->tile_xpm = XCreatePixmap(gdi_display,
799 physDev->xrender->tile_pict = pXRenderCreatePicture(gdi_display,
800 physDev->xrender->tile_xpm,
804 TRACE("Created pixmap of depth %d\n", format->depth);
805 /* init lastTextColor to something different from dc->textColor */
806 physDev->xrender->lastTextColor = ~dc->textColor;
810 if(dc->textColor != physDev->xrender->lastTextColor) {
811 if(dc->bitsPerPixel != 1) {
812 /* Map 0 -- 0xff onto 0 -- 0xffff */
813 col.red = GetRValue(dc->textColor);
814 col.red |= col.red << 8;
815 col.green = GetGValue(dc->textColor);
816 col.green |= col.green << 8;
817 col.blue = GetBValue(dc->textColor);
818 col.blue |= col.blue << 8;
820 } else { /* for a 1bpp bitmap we always need a 1 in the tile */
821 col.red = col.green = col.blue = 0;
825 pXRenderFillRectangle(gdi_display, PictOpSrc,
826 physDev->xrender->tile_pict,
829 physDev->xrender->lastTextColor = dc->textColor;
832 /* FIXME the mapping of Text/BkColor onto 1 or 0 needs investigation.
834 if((dc->bitsPerPixel == 1) && ((dc->textColor & 0xffffff) == 0))
835 render_op = PictOpOutReverse; /* This gives us 'black' text */
837 EnterCriticalSection(&xrender_cs);
838 entry = glyphsetCache + physDev->xrender->cache_index;
840 for(idx = 0; idx < count; idx++) {
841 if(glyphs[idx] >= entry->nrealized || entry->realized[glyphs[idx]] == FALSE) {
842 UploadGlyph(physDev, glyphs[idx]);
847 TRACE("Writing %s at %ld,%ld\n", debugstr_wn(wstr,count),
848 physDev->org.x + x, physDev->org.y + y);
852 pXRenderCompositeString16(gdi_display, render_op,
853 physDev->xrender->tile_pict,
854 physDev->xrender->pict,
855 entry->font_format, entry->glyphset,
856 0, 0, physDev->org.x + x, physDev->org.y + y,
860 INT offset = 0, xoff = 0, yoff = 0;
861 for(idx = 0; idx < count; idx++) {
862 pXRenderCompositeString16(gdi_display, render_op,
863 physDev->xrender->tile_pict,
864 physDev->xrender->pict,
865 entry->font_format, entry->glyphset,
866 0, 0, physDev->org.x + x + xoff,
867 physDev->org.y + y + yoff,
869 offset += INTERNAL_XWSTODS(dc, lpDx[idx]);
870 xoff = offset * cosEsc;
871 yoff = offset * -sinEsc;
875 LeaveCriticalSection(&xrender_cs);
877 if(physDev->xrender->pict) {
878 pXRenderFreePicture(gdi_display, physDev->xrender->pict);
880 physDev->xrender->pict = 0;
883 if (flags & ETO_CLIPPED)
884 RestoreVisRgn16( hdc );
889 X11DRV_UnlockDIBSection( physDev, TRUE );
890 if(glyphs != wstr) HeapFree(GetProcessHeap(), 0, glyphs);
894 #else /* HAVE_X11_EXTENSIONS_XRENDER_H */
896 void X11DRV_XRender_Init(void)
898 TRACE("XRender support not compiled in.\n");
902 void X11DRV_XRender_Finalize(void)
906 BOOL X11DRV_XRender_SelectFont(X11DRV_PDEVICE *physDev, HFONT hfont)
912 void X11DRV_XRender_DeleteDC(X11DRV_PDEVICE *physDev)
918 BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
919 const RECT *lprect, LPCWSTR wstr, UINT count,
926 void X11DRV_XRender_UpdateDrawable(X11DRV_PDEVICE *physDev)
932 #endif /* HAVE_X11_EXTENSIONS_XRENDER_H */