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"
31 #include "wine/unicode.h"
32 #include "wine/debug.h"
34 BOOL X11DRV_XRender_Installed = FALSE;
35 WINE_DEFAULT_DEBUG_CHANNEL(xrender);
37 #ifdef HAVE_X11_EXTENSIONS_XRENDER_H
40 #include <X11/extensions/Xrender.h>
42 static XRenderPictFormat *screen_format; /* format of screen */
43 static XRenderPictFormat *mono_format; /* format of mono bitmap */
48 XFORM xform; /* this is dum as we don't care about offsets */
52 #define INITIAL_REALIZED_BUF_SIZE 128
59 XRenderPictFormat *font_format;
68 gsCacheEntry *cacheEntry;
72 COLORREF lastTextColor;
76 static gsCacheEntry *glyphsetCache = NULL;
77 static DWORD glyphsetCacheSize = 0;
78 static INT lastfree = -1;
81 #define INIT_CACHE_SIZE 10
83 static int antialias = 1;
85 static void *xrender_handle;
87 #define MAKE_FUNCPTR(f) static typeof(f) * p##f;
88 MAKE_FUNCPTR(XRenderAddGlyphs)
89 MAKE_FUNCPTR(XRenderCompositeString8)
90 MAKE_FUNCPTR(XRenderCompositeString16)
91 MAKE_FUNCPTR(XRenderCompositeString32)
92 MAKE_FUNCPTR(XRenderCreateGlyphSet)
93 MAKE_FUNCPTR(XRenderCreatePicture)
94 MAKE_FUNCPTR(XRenderFillRectangle)
95 MAKE_FUNCPTR(XRenderFindFormat)
96 MAKE_FUNCPTR(XRenderFindVisualFormat)
97 MAKE_FUNCPTR(XRenderFreeGlyphSet)
98 MAKE_FUNCPTR(XRenderFreePicture)
99 MAKE_FUNCPTR(XRenderSetPictureClipRectangles)
100 MAKE_FUNCPTR(XRenderQueryExtension)
103 /***********************************************************************
104 * X11DRV_XRender_Init
106 * Let's see if our XServer has the extension available
109 void X11DRV_XRender_Init(void)
111 int error_base, event_base, i;
112 XRenderPictFormat pf;
114 /* FIXME: should find correct soname at compile time */
115 if (!wine_dlopen("libX11.so", RTLD_NOW|RTLD_GLOBAL, NULL, 0)) return;
116 if (!wine_dlopen("libXext.so", RTLD_NOW|RTLD_GLOBAL, NULL, 0)) return;
117 xrender_handle = wine_dlopen("libXrender.so", RTLD_NOW, NULL, 0);
118 if(!xrender_handle) return;
120 #define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(xrender_handle, #f, NULL, 0)) == NULL) goto sym_not_found;
121 LOAD_FUNCPTR(XRenderAddGlyphs)
122 LOAD_FUNCPTR(XRenderCompositeString8)
123 LOAD_FUNCPTR(XRenderCompositeString16)
124 LOAD_FUNCPTR(XRenderCompositeString32)
125 LOAD_FUNCPTR(XRenderCreateGlyphSet)
126 LOAD_FUNCPTR(XRenderCreatePicture)
127 LOAD_FUNCPTR(XRenderFillRectangle)
128 LOAD_FUNCPTR(XRenderFindFormat)
129 LOAD_FUNCPTR(XRenderFindVisualFormat)
130 LOAD_FUNCPTR(XRenderFreeGlyphSet)
131 LOAD_FUNCPTR(XRenderFreePicture)
132 LOAD_FUNCPTR(XRenderSetPictureClipRectangles)
133 LOAD_FUNCPTR(XRenderQueryExtension)
137 if(pXRenderQueryExtension(gdi_display, &event_base, &error_base)) {
138 X11DRV_XRender_Installed = TRUE;
139 TRACE("Xrender is up and running error_base = %d\n", error_base);
140 screen_format = pXRenderFindVisualFormat(gdi_display, visual);
141 pf.type = PictTypeDirect;
144 pf.direct.alphaMask = 1;
145 mono_format = pXRenderFindFormat(gdi_display, PictFormatType |
146 PictFormatDepth | PictFormatAlpha |
147 PictFormatAlphaMask, &pf, 0);
149 glyphsetCache = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
150 sizeof(*glyphsetCache) * INIT_CACHE_SIZE);
152 glyphsetCacheSize = INIT_CACHE_SIZE;
154 for(i = 0; i < INIT_CACHE_SIZE; i++) {
155 glyphsetCache[i].next = i + 1;
156 glyphsetCache[i].count = -1;
158 glyphsetCache[i-1].next = -1;
160 TRACE("Xrender is not available on this server\n");
166 wine_dlclose(xrender_handle, NULL, 0);
167 xrender_handle = NULL;
170 static BOOL fontcmp(LFANDSIZE *p1, LFANDSIZE *p2)
172 if(p1->hash != p2->hash) return TRUE;
173 if(memcmp(&p1->xform, &p2->xform, sizeof(p1->xform))) return TRUE;
174 if(memcmp(&p1->lf, &p2->lf, offsetof(LOGFONTW, lfFaceName))) return TRUE;
175 return strcmpW(p1->lf.lfFaceName, p2->lf.lfFaceName);
179 static void walk_cache(void)
183 for(i=mru; i >= 0; i = glyphsetCache[i].next)
184 TRACE("item %d\n", i);
188 static gsCacheEntry *LookupEntry(LFANDSIZE *plfsz)
192 for(i = mru; i >= 0; i = glyphsetCache[i].next) {
194 if(glyphsetCache[i].count == -1) { /* reached free list so stop */
199 if(!fontcmp(&glyphsetCache[i].lfsz, plfsz)) {
200 glyphsetCache[i].count++;
202 glyphsetCache[prev_i].next = glyphsetCache[i].next;
203 glyphsetCache[i].next = mru;
206 TRACE("found font in cache %d\n", i);
207 return glyphsetCache + i;
211 TRACE("font not in cache\n");
215 static gsCacheEntry *AllocEntry(void)
217 int best = -1, prev_best = -1, i, prev_i = -1;
220 assert(glyphsetCache[lastfree].count == -1);
221 glyphsetCache[lastfree].count = 1;
223 lastfree = glyphsetCache[lastfree].next;
225 glyphsetCache[best].next = mru;
228 TRACE("empty space at %d, next lastfree = %d\n", mru, lastfree);
229 return glyphsetCache + mru;
232 for(i = mru; i >= 0; i = glyphsetCache[i].next) {
233 if(glyphsetCache[i].count == 0) {
241 TRACE("freeing unused glyphset at cache %d\n", best);
243 pXRenderFreeGlyphSet(gdi_display, glyphsetCache[best].glyphset);
245 glyphsetCache[best].glyphset = 0;
246 if(glyphsetCache[best].nrealized) { /* do we really want to do this? */
247 HeapFree(GetProcessHeap(), 0, glyphsetCache[best].realized);
248 glyphsetCache[best].realized = NULL;
249 glyphsetCache[best].nrealized = 0;
251 glyphsetCache[best].count = 1;
253 glyphsetCache[prev_best].next = glyphsetCache[best].next;
254 glyphsetCache[best].next = mru;
259 return glyphsetCache + mru;
262 TRACE("Growing cache\n");
263 glyphsetCache = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
265 (glyphsetCacheSize + INIT_CACHE_SIZE)
266 * sizeof(*glyphsetCache));
267 for(best = i = glyphsetCacheSize; i < glyphsetCacheSize + INIT_CACHE_SIZE;
269 glyphsetCache[i].next = i + 1;
270 glyphsetCache[i].count = -1;
272 glyphsetCache[i-1].next = -1;
273 glyphsetCacheSize += INIT_CACHE_SIZE;
275 lastfree = glyphsetCache[best].next;
276 glyphsetCache[best].count = 1;
277 glyphsetCache[best].next = mru;
279 TRACE("new free cache slot at %d\n", mru);
280 return glyphsetCache + mru;
283 static gsCacheEntry *GetCacheEntry(LFANDSIZE *plfsz)
285 XRenderPictFormat pf;
288 if((ret = LookupEntry(plfsz)) != NULL) return ret;
292 assert(ret->nrealized == 0);
295 if(antialias && abs(plfsz->lf.lfHeight) > 16) {
297 pf.direct.alphaMask = 0xff;
300 pf.direct.alphaMask = 1;
302 pf.type = PictTypeDirect;
306 ret->font_format = pXRenderFindFormat(gdi_display,
313 ret->glyphset = pXRenderCreateGlyphSet(gdi_display, ret->font_format);
318 static void dec_ref_cache(gsCacheEntry *entry)
320 TRACE("dec'ing entry %d to %d\n", entry - glyphsetCache, entry->count - 1);
321 assert(entry->count > 0);
325 static void lfsz_calc_hash(LFANDSIZE *plfsz)
327 DWORD hash = 0, *ptr;
330 for(ptr = (DWORD*)&plfsz->xform; ptr < (DWORD*)(&plfsz->xform + 1); ptr++)
332 for(i = 0, ptr = (DWORD*)&plfsz->lf; i < 7; i++, ptr++)
334 for(i = 0, ptr = (DWORD*)&plfsz->lf.lfFaceName; i < LF_FACESIZE/2; i++, ptr++) {
335 WCHAR *pwc = (WCHAR *)ptr;
345 /***********************************************************************
346 * X11DRV_XRender_Finalize
348 void X11DRV_XRender_Finalize(void)
350 FIXME("Free cached glyphsets\n");
351 if (xrender_handle) wine_dlclose(xrender_handle, NULL, 0);
352 xrender_handle = NULL;
356 /***********************************************************************
357 * X11DRV_XRender_SelectFont
359 BOOL X11DRV_XRender_SelectFont(X11DRV_PDEVICE *physDev, HFONT hfont)
363 GetObjectW(hfont, sizeof(lfsz.lf), &lfsz.lf);
364 TRACE("h=%ld w=%ld weight=%ld it=%d charset=%d name=%s\n",
365 lfsz.lf.lfHeight, lfsz.lf.lfWidth, lfsz.lf.lfWeight,
366 lfsz.lf.lfItalic, lfsz.lf.lfCharSet, debugstr_w(lfsz.lf.lfFaceName));
367 lfsz.xform = physDev->dc->xformWorld2Vport;
368 lfsz_calc_hash(&lfsz);
370 if(!physDev->xrender)
371 physDev->xrender = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
372 sizeof(*physDev->xrender));
374 else if(physDev->xrender->cacheEntry)
375 dec_ref_cache(physDev->xrender->cacheEntry);
376 physDev->xrender->cacheEntry = GetCacheEntry(&lfsz);
380 /***********************************************************************
381 * X11DRV_XRender_DeleteDC
383 void X11DRV_XRender_DeleteDC(X11DRV_PDEVICE *physDev)
386 if(physDev->xrender->tile_pict)
387 pXRenderFreePicture(gdi_display, physDev->xrender->tile_pict);
389 if(physDev->xrender->tile_xpm)
390 XFreePixmap(gdi_display, physDev->xrender->tile_xpm);
392 if(physDev->xrender->pict) {
393 TRACE("freeing pict = %lx dc = %p\n", physDev->xrender->pict, physDev->dc);
394 pXRenderFreePicture(gdi_display, physDev->xrender->pict);
398 if(physDev->xrender->cacheEntry)
399 dec_ref_cache(physDev->xrender->cacheEntry);
401 HeapFree(GetProcessHeap(), 0, physDev->xrender);
402 physDev->xrender = NULL;
406 /***********************************************************************
407 * X11DRV_XRender_UpdateDrawable
409 * This gets called from X11DRV_SetDrawable and deletes the pict when the
410 * drawable changes. However at the moment we delete the pict at the end of
411 * every ExtTextOut so this is basically a NOP.
413 void X11DRV_XRender_UpdateDrawable(X11DRV_PDEVICE *physDev)
415 if(physDev->xrender->pict) {
416 TRACE("freeing pict %08lx from dc %p\n", physDev->xrender->pict, physDev->dc);
418 pXRenderFreePicture(gdi_display, physDev->xrender->pict);
421 physDev->xrender->pict = 0;
425 static BOOL UploadGlyph(X11DRV_PDEVICE *physDev, int glyph)
432 gsCacheEntry *entry = physDev->xrender->cacheEntry;
433 UINT ggo_format = GGO_GLYPH_INDEX;
436 if(entry->nrealized <= glyph) {
437 entry->nrealized = (glyph / 128 + 1) * 128;
438 entry->realized = HeapReAlloc(GetProcessHeap(),
441 entry->nrealized * sizeof(BOOL));
443 entry->realized[glyph] = TRUE;
445 if(entry->font_format->depth == 8) {
447 ggo_format |= WINE_GGO_GRAY16_BITMAP;
450 ggo_format |= GGO_BITMAP;
453 buflen = GetGlyphOutlineW(physDev->hdc, glyph, ggo_format, &gm, 0, NULL,
455 if(buflen == GDI_ERROR)
458 buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buflen);
459 GetGlyphOutlineW(physDev->hdc, glyph, ggo_format, &gm, buflen, buf, NULL);
461 TRACE("buflen = %d. Got metrics: %dx%d adv=%d,%d origin=%ld,%ld\n",
463 gm.gmBlackBoxX, gm.gmBlackBoxY, gm.gmCellIncX, gm.gmCellIncY,
464 gm.gmptGlyphOrigin.x, gm.gmptGlyphOrigin.y);
466 gi.width = gm.gmBlackBoxX;
467 gi.height = gm.gmBlackBoxY;
468 gi.x = -gm.gmptGlyphOrigin.x;
469 gi.y = gm.gmptGlyphOrigin.y;
470 gi.xOff = gm.gmCellIncX;
471 gi.yOff = gm.gmCellIncY;
473 if(TRACE_ON(xrender)) {
479 pitch = ((gi.width + 31) / 32) * 4;
480 for(i = 0; i < gi.height; i++) {
481 line = buf + i * pitch;
483 for(j = 0; j < pitch * 8; j++) {
484 strcat(output, (line[j / 8] & (1 << (7 - (j % 8)))) ? "#" : " ");
486 strcat(output, "\n");
490 char blks[] = " .:;!o*#";
494 pitch = ((gi.width + 3) / 4) * 4;
495 for(i = 0; i < gi.height; i++) {
496 line = buf + i * pitch;
498 for(j = 0; j < pitch; j++) {
499 str[0] = blks[line[j] >> 5];
502 strcat(output, "\n");
508 if(!aa && BitmapBitOrder(gdi_display) != MSBFirst) {
509 unsigned char *byte = buf, c;
515 /* magic to flip bit order */
516 c = ((c << 1) & 0xaa) | ((c >> 1) & 0x55);
517 c = ((c << 2) & 0xcc) | ((c >> 2) & 0x33);
518 c = ((c << 4) & 0xf0) | ((c >> 4) & 0x0f);
525 pXRenderAddGlyphs(gdi_display, entry->glyphset, &gid, &gi, 1,
528 HeapFree(GetProcessHeap(), 0, buf);
532 /***********************************************************************
533 * X11DRV_XRender_ExtTextOut
535 BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
536 const RECT *lprect, LPCWSTR wstr, UINT count,
546 BOOL done_extents = FALSE;
547 INT width, xwidth, ywidth;
548 double cosEsc, sinEsc;
551 int render_op = PictOpOver;
553 HDC hdc = physDev->hdc;
554 DC *dc = physDev->dc;
556 TRACE("%04x, %d, %d, %08x, %p, %s, %d, %p)\n", hdc, x, y, flags,
557 lprect, debugstr_wn(wstr, count), count, lpDx);
559 if(flags & ETO_GLYPH_INDEX)
560 glyphs = (LPWORD)wstr;
562 glyphs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR));
563 GetGlyphIndicesW(hdc, wstr, count, glyphs, 0);
567 TRACE("rect: %d,%d - %d,%d\n", lprect->left, lprect->top, lprect->right,
569 TRACE("align = %x bkmode = %x mapmode = %x\n", dc->textAlign, GetBkMode(hdc), dc->MapMode);
571 if(dc->textAlign & TA_UPDATECP) {
576 GetObjectW(GetCurrentObject(hdc, OBJ_FONT), sizeof(lf), &lf);
577 if(lf.lfEscapement != 0) {
578 cosEsc = cos(lf.lfEscapement * M_PI / 1800);
579 sinEsc = sin(lf.lfEscapement * M_PI / 1800);
585 if(flags & (ETO_CLIPPED | ETO_OPAQUE)) {
587 if(flags & ETO_CLIPPED) return FALSE;
588 GetTextExtentPointI(hdc, glyphs, count, &sz);
592 rc.right = x + sz.cx;
593 rc.bottom = y + sz.cy;
598 rc.left = INTERNAL_XWPTODP(dc, rc.left, rc.top);
599 rc.top = INTERNAL_YWPTODP(dc, rc.left, rc.top);
600 rc.right = INTERNAL_XWPTODP(dc, rc.right, rc.bottom);
601 rc.bottom = INTERNAL_YWPTODP(dc, rc.right, rc.bottom);
603 if(rc.left > rc.right) {INT tmp = rc.left; rc.left = rc.right; rc.right = tmp;}
604 if(rc.top > rc.bottom) {INT tmp = rc.top; rc.top = rc.bottom; rc.bottom = tmp;}
607 xgcval.function = GXcopy;
608 xgcval.background = physDev->backgroundPixel;
609 xgcval.fill_style = FillSolid;
610 TSXChangeGC( gdi_display, physDev->gc,
611 GCFunction | GCBackground | GCFillStyle, &xgcval );
613 X11DRV_LockDIBSection( physDev, DIB_Status_GdiMod, FALSE );
615 if(flags & ETO_OPAQUE) {
616 TSXSetForeground( gdi_display, physDev->gc, physDev->backgroundPixel );
617 TSXFillRectangle( gdi_display, physDev->drawable, physDev->gc,
618 dc->DCOrgX + rc.left, dc->DCOrgY + rc.top,
619 rc.right - rc.left, rc.bottom - rc.top );
623 X11DRV_UnlockDIBSection( physDev, TRUE );
627 x = INTERNAL_XWPTODP( dc, x, y );
628 y = INTERNAL_YWPTODP( dc, x, y );
630 TRACE("real x,y %d,%d\n", x, y);
634 for(idx = 0; idx < count; idx++)
638 GetTextExtentPointI(hdc, glyphs, count, &sz);
643 width = INTERNAL_XWSTODS(dc, width);
644 xwidth = width * cosEsc;
645 ywidth = width * sinEsc;
647 GetTextMetricsW(hdc, &tm);
649 tm.tmAscent = INTERNAL_YWSTODS(dc, tm.tmAscent);
650 tm.tmDescent = INTERNAL_YWSTODS(dc, tm.tmDescent);
651 switch( dc->textAlign & (TA_LEFT | TA_RIGHT | TA_CENTER) ) {
653 if (dc->textAlign & TA_UPDATECP) {
654 dc->CursPosX = INTERNAL_XDPTOWP( dc, x + xwidth, y - ywidth );
655 dc->CursPosY = INTERNAL_YDPTOWP( dc, x + xwidth, y - ywidth );
667 if (dc->textAlign & TA_UPDATECP) {
668 dc->CursPosX = INTERNAL_XDPTOWP( dc, x + xwidth, y - ywidth );
669 dc->CursPosY = INTERNAL_YDPTOWP( dc, x + xwidth, y - ywidth );
674 switch( dc->textAlign & (TA_TOP | TA_BOTTOM | TA_BASELINE) ) {
676 y += tm.tmAscent * cosEsc;
677 x += tm.tmAscent * sinEsc;
681 y -= tm.tmDescent * cosEsc;
682 x -= tm.tmDescent * sinEsc;
689 if (flags & ETO_CLIPPED)
692 CLIPPING_IntersectVisRect( dc, rc.left, rc.top, rc.right,
698 if(!physDev->xrender->pict) {
699 XRenderPictureAttributes pa;
700 pa.subwindow_mode = IncludeInferiors;
703 physDev->xrender->pict = pXRenderCreatePicture(gdi_display,
705 (dc->bitsPerPixel == 1) ?
706 mono_format : screen_format,
707 CPSubwindowMode, &pa);
710 TRACE("allocing pict = %lx dc = %p drawable = %08lx\n", physDev->xrender->pict, dc, physDev->drawable);
712 TRACE("using existing pict = %lx dc = %p\n", physDev->xrender->pict, dc);
715 obj = (RGNOBJ *) GDI_GetObjPtr(dc->hGCClipRgn, REGION_MAGIC);
718 ERR("Rgn is 0. Please report this.\n");
722 if (obj->rgn->numRects > 0)
725 RECT *pRect = obj->rgn->rects;
726 RECT *pEndRect = obj->rgn->rects + obj->rgn->numRects;
728 pXrect = HeapAlloc( GetProcessHeap(), 0,
729 sizeof(*pXrect) * obj->rgn->numRects );
732 WARN("Can't alloc buffer\n");
733 GDI_ReleaseObj( dc->hGCClipRgn );
737 for(pXr = pXrect; pRect < pEndRect; pRect++, pXr++)
739 pXr->x = pRect->left;
741 pXr->width = pRect->right - pRect->left;
742 pXr->height = pRect->bottom - pRect->top;
743 TRACE("Adding clip rect %d,%d - %d,%d\n", pRect->left, pRect->top,
744 pRect->right, pRect->bottom);
748 TRACE("no clip rgn\n");
753 pXRenderSetPictureClipRectangles( gdi_display, physDev->xrender->pict,
754 0, 0, pXrect, obj->rgn->numRects );
758 HeapFree( GetProcessHeap(), 0, pXrect );
760 GDI_ReleaseObj( dc->hGCClipRgn );
762 if(GetBkMode(hdc) != TRANSPARENT) {
763 if(!((flags & ETO_CLIPPED) && (flags & ETO_OPAQUE))) {
764 if(!(flags & ETO_OPAQUE) || x < rc.left || x + width >= rc.right ||
765 y - tm.tmAscent < rc.top || y + tm.tmDescent >= rc.bottom) {
766 TSXSetForeground( gdi_display, physDev->gc, physDev->backgroundPixel );
767 TSXFillRectangle( gdi_display, physDev->drawable, physDev->gc,
768 dc->DCOrgX + x, dc->DCOrgY + y - tm.tmAscent,
769 width, tm.tmAscent + tm.tmDescent );
774 /* Create a 1x1 pixmap to tile over the font mask */
775 if(!physDev->xrender->tile_xpm) {
776 XRenderPictureAttributes pa;
778 XRenderPictFormat *format = (dc->bitsPerPixel == 1) ? mono_format : screen_format;
780 physDev->xrender->tile_xpm = XCreatePixmap(gdi_display,
785 physDev->xrender->tile_pict = pXRenderCreatePicture(gdi_display,
786 physDev->xrender->tile_xpm,
790 TRACE("Created pixmap of depth %d\n", format->depth);
791 /* init lastTextColor to something different from dc->textColor */
792 physDev->xrender->lastTextColor = ~dc->textColor;
796 if(dc->textColor != physDev->xrender->lastTextColor) {
797 if(dc->bitsPerPixel != 1) {
798 /* Map 0 -- 0xff onto 0 -- 0xffff */
799 col.red = GetRValue(dc->textColor);
800 col.red |= col.red << 8;
801 col.green = GetGValue(dc->textColor);
802 col.green |= col.green << 8;
803 col.blue = GetBValue(dc->textColor);
804 col.blue |= col.blue << 8;
806 } else { /* for a 1bpp bitmap we always need a 1 in the tile */
807 col.red = col.green = col.blue = 0;
811 pXRenderFillRectangle(gdi_display, PictOpSrc,
812 physDev->xrender->tile_pict,
815 physDev->xrender->lastTextColor = dc->textColor;
818 /* FIXME the mapping of Text/BkColor onto 1 or 0 needs investigation.
820 if((dc->bitsPerPixel == 1) && ((dc->textColor & 0xffffff) == 0))
821 render_op = PictOpOutReverse; /* This gives us 'black' text */
823 for(idx = 0; idx < count; idx++) {
824 if(glyphs[idx] >= physDev->xrender->cacheEntry->nrealized ||
825 physDev->xrender->cacheEntry->realized[glyphs[idx]] == FALSE) {
826 UploadGlyph(physDev, glyphs[idx]);
831 TRACE("Writing %s at %d,%d\n", debugstr_wn(wstr,count), dc->DCOrgX + x,
836 pXRenderCompositeString16(gdi_display, render_op,
837 physDev->xrender->tile_pict,
838 physDev->xrender->pict,
839 physDev->xrender->cacheEntry->font_format,
840 physDev->xrender->cacheEntry->glyphset,
841 0, 0, dc->DCOrgX + x, dc->DCOrgY + y,
845 INT offset = 0, xoff = 0, yoff = 0;
846 for(idx = 0; idx < count; idx++) {
847 pXRenderCompositeString16(gdi_display, render_op,
848 physDev->xrender->tile_pict,
849 physDev->xrender->pict,
850 physDev->xrender->cacheEntry->font_format,
851 physDev->xrender->cacheEntry->glyphset,
852 0, 0, dc->DCOrgX + x + xoff,
853 dc->DCOrgY + y + yoff,
855 offset += INTERNAL_XWSTODS(dc, lpDx[idx]);
856 xoff = offset * cosEsc;
857 yoff = offset * -sinEsc;
861 if(physDev->xrender->pict) {
862 pXRenderFreePicture(gdi_display, physDev->xrender->pict);
864 physDev->xrender->pict = 0;
867 if (flags & ETO_CLIPPED)
868 RestoreVisRgn16( hdc );
870 X11DRV_UnlockDIBSection( physDev, TRUE );
871 if(glyphs != wstr) HeapFree(GetProcessHeap(), 0, glyphs);
875 #else /* HAVE_X11_EXTENSIONS_XRENDER_H */
877 void X11DRV_XRender_Init(void)
879 TRACE("XRender support not compiled in.\n");
883 void X11DRV_XRender_Finalize(void)
887 BOOL X11DRV_XRender_SelectFont(X11DRV_PDEVICE *physDev, HFONT hfont)
893 void X11DRV_XRender_DeleteDC(X11DRV_PDEVICE *physDev)
899 BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
900 const RECT *lprect, LPCWSTR wstr, UINT count,
907 void X11DRV_XRender_UpdateDrawable(X11DRV_PDEVICE *physDev)
913 #endif /* HAVE_X11_EXTENSIONS_XRENDER_H */