2002-01-29 04:07:21 +01:00
|
|
|
/*
|
|
|
|
* Functions to use the XRender extension
|
|
|
|
*
|
2002-11-14 23:31:34 +01:00
|
|
|
* Copyright 2001, 2002 Huw D M Davies for CodeWeavers
|
|
|
|
*
|
|
|
|
* Some parts also:
|
|
|
|
* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc.
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2002-01-29 04:07:21 +01:00
|
|
|
*/
|
|
|
|
#include "config.h"
|
2002-04-24 00:06:41 +02:00
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include <assert.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-04-24 00:06:41 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2002-12-10 23:56:43 +01:00
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2002-10-31 03:12:18 +01:00
|
|
|
#include "wownt32.h"
|
2002-01-29 04:07:21 +01:00
|
|
|
#include "x11drv.h"
|
2004-01-20 23:04:00 +01:00
|
|
|
#include "gdi.h"
|
|
|
|
#include "wine/library.h"
|
2002-01-29 04:07:21 +01:00
|
|
|
#include "wine/unicode.h"
|
2002-04-24 00:06:41 +02:00
|
|
|
#include "wine/debug.h"
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2002-11-14 23:31:34 +01:00
|
|
|
static BOOL X11DRV_XRender_Installed = FALSE;
|
|
|
|
int using_client_side_fonts = FALSE;
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(xrender);
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2002-04-24 00:06:41 +02:00
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XRENDER_H
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2003-11-21 22:50:59 +01:00
|
|
|
#include <X11/Xlib.h>
|
2002-04-24 00:06:41 +02:00
|
|
|
#include <X11/extensions/Xrender.h>
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2004-08-02 20:54:54 +02:00
|
|
|
/* Older version of the Xrender headers don't define these */
|
|
|
|
#ifndef PictStandardARGB32
|
|
|
|
|
|
|
|
#define PictStandardARGB32 0
|
|
|
|
XRenderPictFormat * XRenderFindStandardFormat (Display *dpy, int format);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2002-01-29 04:07:21 +01:00
|
|
|
static XRenderPictFormat *screen_format; /* format of screen */
|
|
|
|
static XRenderPictFormat *mono_format; /* format of mono bitmap */
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2002-11-14 23:31:34 +01:00
|
|
|
LOGFONTW lf;
|
2004-03-04 04:55:52 +01:00
|
|
|
SIZE devsize; /* size in device coords */
|
|
|
|
DWORD hash;
|
2002-01-29 04:07:21 +01:00
|
|
|
} LFANDSIZE;
|
|
|
|
|
|
|
|
#define INITIAL_REALIZED_BUF_SIZE 128
|
|
|
|
|
2005-01-24 20:08:02 +01:00
|
|
|
typedef enum { AA_None = 0, AA_Grey, AA_RGB, AA_BGR, AA_VRGB, AA_VBGR, AA_MAXVALUE } AA_Type;
|
2002-01-29 04:07:21 +01:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2002-11-14 23:31:34 +01:00
|
|
|
GlyphSet glyphset;
|
|
|
|
XRenderPictFormat *font_format;
|
|
|
|
int nrealized;
|
|
|
|
BOOL *realized;
|
|
|
|
void **bitmaps;
|
|
|
|
XGlyphInfo *gis;
|
2005-01-24 20:08:02 +01:00
|
|
|
} gsCacheEntryFormat;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
LFANDSIZE lfsz;
|
|
|
|
AA_Type aa_default;
|
|
|
|
gsCacheEntryFormat * format[AA_MAXVALUE];
|
2002-11-14 23:31:34 +01:00
|
|
|
UINT count;
|
|
|
|
INT next;
|
2002-01-29 04:07:21 +01:00
|
|
|
} gsCacheEntry;
|
|
|
|
|
|
|
|
struct tagXRENDERINFO
|
|
|
|
{
|
2002-06-22 03:01:34 +02:00
|
|
|
int cache_index;
|
2002-01-29 04:07:21 +01:00
|
|
|
Picture pict;
|
|
|
|
Picture tile_pict;
|
|
|
|
Pixmap tile_xpm;
|
|
|
|
COLORREF lastTextColor;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static gsCacheEntry *glyphsetCache = NULL;
|
|
|
|
static DWORD glyphsetCacheSize = 0;
|
|
|
|
static INT lastfree = -1;
|
|
|
|
static INT mru = -1;
|
|
|
|
|
|
|
|
#define INIT_CACHE_SIZE 10
|
|
|
|
|
|
|
|
static int antialias = 1;
|
|
|
|
|
2002-05-20 20:29:58 +02:00
|
|
|
/* some default values just in case */
|
|
|
|
#ifndef SONAME_LIBX11
|
|
|
|
#define SONAME_LIBX11 "libX11.so"
|
|
|
|
#endif
|
|
|
|
#ifndef SONAME_LIBXEXT
|
|
|
|
#define SONAME_LIBXEXT "libXext.so"
|
|
|
|
#endif
|
|
|
|
#ifndef SONAME_LIBXRENDER
|
|
|
|
#define SONAME_LIBXRENDER "libXrender.so"
|
|
|
|
#endif
|
|
|
|
|
2002-04-24 00:06:41 +02:00
|
|
|
static void *xrender_handle;
|
|
|
|
|
|
|
|
#define MAKE_FUNCPTR(f) static typeof(f) * p##f;
|
|
|
|
MAKE_FUNCPTR(XRenderAddGlyphs)
|
2004-08-02 20:54:54 +02:00
|
|
|
MAKE_FUNCPTR(XRenderComposite)
|
2002-04-24 00:06:41 +02:00
|
|
|
MAKE_FUNCPTR(XRenderCompositeString8)
|
|
|
|
MAKE_FUNCPTR(XRenderCompositeString16)
|
|
|
|
MAKE_FUNCPTR(XRenderCompositeString32)
|
|
|
|
MAKE_FUNCPTR(XRenderCreateGlyphSet)
|
|
|
|
MAKE_FUNCPTR(XRenderCreatePicture)
|
|
|
|
MAKE_FUNCPTR(XRenderFillRectangle)
|
|
|
|
MAKE_FUNCPTR(XRenderFindFormat)
|
2004-08-02 20:54:54 +02:00
|
|
|
MAKE_FUNCPTR(XRenderFindStandardFormat)
|
2002-04-24 00:06:41 +02:00
|
|
|
MAKE_FUNCPTR(XRenderFindVisualFormat)
|
|
|
|
MAKE_FUNCPTR(XRenderFreeGlyphSet)
|
|
|
|
MAKE_FUNCPTR(XRenderFreePicture)
|
|
|
|
MAKE_FUNCPTR(XRenderSetPictureClipRectangles)
|
2004-10-27 02:43:50 +02:00
|
|
|
#ifdef HAVE_XRENDERSETPICTURETRANSFORM
|
|
|
|
MAKE_FUNCPTR(XRenderSetPictureTransform)
|
|
|
|
#endif
|
2002-04-24 00:06:41 +02:00
|
|
|
MAKE_FUNCPTR(XRenderQueryExtension)
|
|
|
|
#undef MAKE_FUNCPTR
|
|
|
|
|
2003-08-13 01:50:54 +02:00
|
|
|
static CRITICAL_SECTION xrender_cs;
|
|
|
|
static CRITICAL_SECTION_DEBUG critsect_debug =
|
|
|
|
{
|
|
|
|
0, 0, &xrender_cs,
|
|
|
|
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
|
|
|
|
0, 0, { 0, (DWORD)(__FILE__ ": xrender_cs") }
|
|
|
|
};
|
|
|
|
static CRITICAL_SECTION xrender_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
|
2002-06-22 03:01:34 +02:00
|
|
|
|
|
|
|
|
2002-01-29 04:07:21 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_XRender_Init
|
|
|
|
*
|
|
|
|
* Let's see if our XServer has the extension available
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void X11DRV_XRender_Init(void)
|
|
|
|
{
|
|
|
|
int error_base, event_base, i;
|
|
|
|
XRenderPictFormat pf;
|
|
|
|
|
2002-11-14 23:31:34 +01:00
|
|
|
if (client_side_with_render &&
|
|
|
|
wine_dlopen(SONAME_LIBX11, RTLD_NOW|RTLD_GLOBAL, NULL, 0) &&
|
|
|
|
wine_dlopen(SONAME_LIBXEXT, RTLD_NOW|RTLD_GLOBAL, NULL, 0) &&
|
|
|
|
(xrender_handle = wine_dlopen(SONAME_LIBXRENDER, RTLD_NOW, NULL, 0)))
|
|
|
|
{
|
2002-04-24 00:06:41 +02:00
|
|
|
|
|
|
|
#define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(xrender_handle, #f, NULL, 0)) == NULL) goto sym_not_found;
|
|
|
|
LOAD_FUNCPTR(XRenderAddGlyphs)
|
2004-08-02 20:54:54 +02:00
|
|
|
LOAD_FUNCPTR(XRenderComposite)
|
2002-04-24 00:06:41 +02:00
|
|
|
LOAD_FUNCPTR(XRenderCompositeString8)
|
|
|
|
LOAD_FUNCPTR(XRenderCompositeString16)
|
|
|
|
LOAD_FUNCPTR(XRenderCompositeString32)
|
|
|
|
LOAD_FUNCPTR(XRenderCreateGlyphSet)
|
|
|
|
LOAD_FUNCPTR(XRenderCreatePicture)
|
|
|
|
LOAD_FUNCPTR(XRenderFillRectangle)
|
|
|
|
LOAD_FUNCPTR(XRenderFindFormat)
|
2004-08-02 20:54:54 +02:00
|
|
|
LOAD_FUNCPTR(XRenderFindStandardFormat)
|
2002-04-24 00:06:41 +02:00
|
|
|
LOAD_FUNCPTR(XRenderFindVisualFormat)
|
|
|
|
LOAD_FUNCPTR(XRenderFreeGlyphSet)
|
|
|
|
LOAD_FUNCPTR(XRenderFreePicture)
|
|
|
|
LOAD_FUNCPTR(XRenderSetPictureClipRectangles)
|
|
|
|
LOAD_FUNCPTR(XRenderQueryExtension)
|
|
|
|
#undef LOAD_FUNCPTR
|
2004-10-27 02:43:50 +02:00
|
|
|
#ifdef HAVE_XRENDERSETPICTURETRANSFORM
|
|
|
|
#define LOAD_OPTIONAL_FUNCPTR(f) p##f = wine_dlsym(xrender_handle, #f, NULL, 0);
|
|
|
|
LOAD_OPTIONAL_FUNCPTR(XRenderSetPictureTransform)
|
|
|
|
#undef LOAD_OPTIONAL_FUNCPTR
|
|
|
|
#endif
|
|
|
|
|
2002-04-24 00:06:41 +02:00
|
|
|
|
2002-11-14 23:31:34 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
if(pXRenderQueryExtension(gdi_display, &event_base, &error_base)) {
|
|
|
|
X11DRV_XRender_Installed = TRUE;
|
|
|
|
TRACE("Xrender is up and running error_base = %d\n", error_base);
|
|
|
|
screen_format = pXRenderFindVisualFormat(gdi_display, visual);
|
2005-03-24 22:04:10 +01:00
|
|
|
if(!screen_format)
|
|
|
|
{
|
|
|
|
/* Xrender doesn't like DirectColor visuals, try to find a TrueColor one instead */
|
|
|
|
if (visual->class == DirectColor)
|
|
|
|
{
|
|
|
|
XVisualInfo info;
|
|
|
|
if (XMatchVisualInfo( gdi_display, DefaultScreen(gdi_display),
|
|
|
|
screen_depth, TrueColor, &info ))
|
|
|
|
{
|
|
|
|
screen_format = pXRenderFindVisualFormat(gdi_display, info.visual);
|
|
|
|
if (screen_format) visual = info.visual;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!screen_format) /* This fails in buggy versions of libXrender.so */
|
|
|
|
{
|
2002-11-14 23:31:34 +01:00
|
|
|
wine_tsx11_unlock();
|
|
|
|
WINE_MESSAGE(
|
|
|
|
"Wine has detected that you probably have a buggy version\n"
|
|
|
|
"of libXrender.so . Because of this client side font rendering\n"
|
|
|
|
"will be disabled. Please upgrade this library.\n");
|
|
|
|
X11DRV_XRender_Installed = FALSE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pf.type = PictTypeDirect;
|
|
|
|
pf.depth = 1;
|
|
|
|
pf.direct.alpha = 0;
|
|
|
|
pf.direct.alphaMask = 1;
|
|
|
|
mono_format = pXRenderFindFormat(gdi_display, PictFormatType |
|
|
|
|
PictFormatDepth | PictFormatAlpha |
|
|
|
|
PictFormatAlphaMask, &pf, 0);
|
|
|
|
if(!mono_format) {
|
|
|
|
ERR("mono_format == NULL?\n");
|
|
|
|
X11DRV_XRender_Installed = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
sym_not_found:
|
|
|
|
if(X11DRV_XRender_Installed || client_side_with_core)
|
|
|
|
{
|
2002-01-29 04:07:21 +01:00
|
|
|
glyphsetCache = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(*glyphsetCache) * INIT_CACHE_SIZE);
|
|
|
|
|
|
|
|
glyphsetCacheSize = INIT_CACHE_SIZE;
|
|
|
|
lastfree = 0;
|
|
|
|
for(i = 0; i < INIT_CACHE_SIZE; i++) {
|
|
|
|
glyphsetCache[i].next = i + 1;
|
|
|
|
glyphsetCache[i].count = -1;
|
|
|
|
}
|
|
|
|
glyphsetCache[i-1].next = -1;
|
2002-11-14 23:31:34 +01:00
|
|
|
using_client_side_fonts = 1;
|
2002-04-24 00:06:41 +02:00
|
|
|
|
2002-11-14 23:31:34 +01:00
|
|
|
if(!X11DRV_XRender_Installed) {
|
|
|
|
TRACE("Xrender is not available on your XServer, client side rendering with the core protocol instead.\n");
|
|
|
|
if(screen_depth <= 8 || !client_side_antialias_with_core)
|
|
|
|
antialias = 0;
|
|
|
|
} else {
|
|
|
|
if(screen_depth <= 8 || !client_side_antialias_with_render)
|
|
|
|
antialias = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else TRACE("Using X11 core fonts\n");
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL fontcmp(LFANDSIZE *p1, LFANDSIZE *p2)
|
|
|
|
{
|
|
|
|
if(p1->hash != p2->hash) return TRUE;
|
2004-03-04 04:55:52 +01:00
|
|
|
if(memcmp(&p1->devsize, &p2->devsize, sizeof(p1->devsize))) return TRUE;
|
2002-01-29 04:07:21 +01:00
|
|
|
if(memcmp(&p1->lf, &p2->lf, offsetof(LOGFONTW, lfFaceName))) return TRUE;
|
|
|
|
return strcmpW(p1->lf.lfFaceName, p2->lf.lfFaceName);
|
|
|
|
}
|
|
|
|
|
2002-04-01 23:08:16 +02:00
|
|
|
#if 0
|
2002-01-29 04:07:21 +01:00
|
|
|
static void walk_cache(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2002-06-22 03:01:34 +02:00
|
|
|
EnterCriticalSection(&xrender_cs);
|
2002-01-29 04:07:21 +01:00
|
|
|
for(i=mru; i >= 0; i = glyphsetCache[i].next)
|
|
|
|
TRACE("item %d\n", i);
|
2002-06-22 03:01:34 +02:00
|
|
|
LeaveCriticalSection(&xrender_cs);
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
2002-04-01 23:08:16 +02:00
|
|
|
#endif
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2002-06-22 03:01:34 +02:00
|
|
|
static int LookupEntry(LFANDSIZE *plfsz)
|
2002-01-29 04:07:21 +01:00
|
|
|
{
|
|
|
|
int i, prev_i = -1;
|
|
|
|
|
|
|
|
for(i = mru; i >= 0; i = glyphsetCache[i].next) {
|
|
|
|
TRACE("%d\n", i);
|
|
|
|
if(glyphsetCache[i].count == -1) { /* reached free list so stop */
|
|
|
|
i = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!fontcmp(&glyphsetCache[i].lfsz, plfsz)) {
|
|
|
|
glyphsetCache[i].count++;
|
|
|
|
if(prev_i >= 0) {
|
|
|
|
glyphsetCache[prev_i].next = glyphsetCache[i].next;
|
|
|
|
glyphsetCache[i].next = mru;
|
|
|
|
mru = i;
|
|
|
|
}
|
|
|
|
TRACE("found font in cache %d\n", i);
|
2002-06-22 03:01:34 +02:00
|
|
|
return i;
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
prev_i = i;
|
|
|
|
}
|
|
|
|
TRACE("font not in cache\n");
|
2002-06-22 03:01:34 +02:00
|
|
|
return -1;
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
2002-11-14 23:31:34 +01:00
|
|
|
static void FreeEntry(int entry)
|
|
|
|
{
|
2005-01-24 20:08:02 +01:00
|
|
|
int i, format;
|
|
|
|
|
|
|
|
for(format = 0; format < AA_MAXVALUE; format++) {
|
|
|
|
gsCacheEntryFormat * formatEntry;
|
2002-11-14 23:31:34 +01:00
|
|
|
|
2005-01-24 20:08:02 +01:00
|
|
|
if( !glyphsetCache[entry].format[format] )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
formatEntry = glyphsetCache[entry].format[format];
|
|
|
|
|
|
|
|
if(formatEntry->glyphset) {
|
|
|
|
wine_tsx11_lock();
|
|
|
|
pXRenderFreeGlyphSet(gdi_display, formatEntry->glyphset);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
formatEntry->glyphset = 0;
|
|
|
|
}
|
|
|
|
if(formatEntry->nrealized) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, formatEntry->realized);
|
|
|
|
formatEntry->realized = NULL;
|
|
|
|
if(formatEntry->bitmaps) {
|
|
|
|
for(i = 0; i < formatEntry->nrealized; i++)
|
|
|
|
if(formatEntry->bitmaps[i])
|
|
|
|
HeapFree(GetProcessHeap(), 0, formatEntry->bitmaps[i]);
|
|
|
|
HeapFree(GetProcessHeap(), 0, formatEntry->bitmaps);
|
|
|
|
formatEntry->bitmaps = NULL;
|
|
|
|
HeapFree(GetProcessHeap(), 0, formatEntry->gis);
|
|
|
|
formatEntry->gis = NULL;
|
|
|
|
}
|
|
|
|
formatEntry->nrealized = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, formatEntry);
|
|
|
|
glyphsetCache[entry].format[format] = NULL;
|
2002-11-14 23:31:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-22 03:01:34 +02:00
|
|
|
static int AllocEntry(void)
|
2002-01-29 04:07:21 +01:00
|
|
|
{
|
|
|
|
int best = -1, prev_best = -1, i, prev_i = -1;
|
|
|
|
|
|
|
|
if(lastfree >= 0) {
|
|
|
|
assert(glyphsetCache[lastfree].count == -1);
|
|
|
|
glyphsetCache[lastfree].count = 1;
|
|
|
|
best = lastfree;
|
2002-06-01 01:06:46 +02:00
|
|
|
lastfree = glyphsetCache[lastfree].next;
|
2002-01-29 04:07:21 +01:00
|
|
|
assert(best != mru);
|
|
|
|
glyphsetCache[best].next = mru;
|
|
|
|
mru = best;
|
|
|
|
|
|
|
|
TRACE("empty space at %d, next lastfree = %d\n", mru, lastfree);
|
2002-06-22 03:01:34 +02:00
|
|
|
return mru;
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for(i = mru; i >= 0; i = glyphsetCache[i].next) {
|
|
|
|
if(glyphsetCache[i].count == 0) {
|
|
|
|
best = i;
|
|
|
|
prev_best = prev_i;
|
|
|
|
}
|
|
|
|
prev_i = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(best >= 0) {
|
|
|
|
TRACE("freeing unused glyphset at cache %d\n", best);
|
2002-11-14 23:31:34 +01:00
|
|
|
FreeEntry(best);
|
2002-01-29 04:07:21 +01:00
|
|
|
glyphsetCache[best].count = 1;
|
|
|
|
if(prev_best >= 0) {
|
|
|
|
glyphsetCache[prev_best].next = glyphsetCache[best].next;
|
|
|
|
glyphsetCache[best].next = mru;
|
|
|
|
mru = best;
|
|
|
|
} else {
|
|
|
|
assert(mru == best);
|
|
|
|
}
|
2002-06-22 03:01:34 +02:00
|
|
|
return mru;
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Growing cache\n");
|
2003-10-24 02:29:43 +02:00
|
|
|
|
|
|
|
if (glyphsetCache)
|
|
|
|
glyphsetCache = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
2002-01-29 04:07:21 +01:00
|
|
|
glyphsetCache,
|
|
|
|
(glyphsetCacheSize + INIT_CACHE_SIZE)
|
|
|
|
* sizeof(*glyphsetCache));
|
2003-10-24 02:29:43 +02:00
|
|
|
else
|
|
|
|
glyphsetCache = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
(glyphsetCacheSize + INIT_CACHE_SIZE)
|
|
|
|
* sizeof(*glyphsetCache));
|
|
|
|
|
2002-01-29 04:07:21 +01:00
|
|
|
for(best = i = glyphsetCacheSize; i < glyphsetCacheSize + INIT_CACHE_SIZE;
|
|
|
|
i++) {
|
|
|
|
glyphsetCache[i].next = i + 1;
|
|
|
|
glyphsetCache[i].count = -1;
|
|
|
|
}
|
|
|
|
glyphsetCache[i-1].next = -1;
|
|
|
|
glyphsetCacheSize += INIT_CACHE_SIZE;
|
|
|
|
|
|
|
|
lastfree = glyphsetCache[best].next;
|
|
|
|
glyphsetCache[best].count = 1;
|
|
|
|
glyphsetCache[best].next = mru;
|
|
|
|
mru = best;
|
|
|
|
TRACE("new free cache slot at %d\n", mru);
|
2002-06-22 03:01:34 +02:00
|
|
|
return mru;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2002-06-22 03:01:34 +02:00
|
|
|
static int GetCacheEntry(LFANDSIZE *plfsz)
|
2002-01-29 04:07:21 +01:00
|
|
|
{
|
2002-11-14 23:31:34 +01:00
|
|
|
int ret;
|
2005-01-24 20:08:02 +01:00
|
|
|
int format;
|
2002-11-14 23:31:34 +01:00
|
|
|
gsCacheEntry *entry;
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2002-11-14 23:31:34 +01:00
|
|
|
if((ret = LookupEntry(plfsz)) != -1) return ret;
|
|
|
|
|
|
|
|
ret = AllocEntry();
|
|
|
|
entry = glyphsetCache + ret;
|
|
|
|
entry->lfsz = *plfsz;
|
2005-01-24 20:08:02 +01:00
|
|
|
for( format = 0; format < AA_MAXVALUE; format++ ) {
|
|
|
|
assert( !entry->format[format] );
|
|
|
|
}
|
2002-11-14 23:31:34 +01:00
|
|
|
|
2005-01-24 20:32:54 +01:00
|
|
|
if(antialias && plfsz->lf.lfQuality != NONANTIALIASED_QUALITY)
|
2005-01-24 20:08:02 +01:00
|
|
|
entry->aa_default = AA_Grey;
|
2002-11-14 23:31:34 +01:00
|
|
|
else
|
2005-01-24 20:08:02 +01:00
|
|
|
entry->aa_default = AA_None;
|
2002-11-14 23:31:34 +01:00
|
|
|
|
|
|
|
return ret;
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
2002-06-22 03:01:34 +02:00
|
|
|
static void dec_ref_cache(int index)
|
2002-01-29 04:07:21 +01:00
|
|
|
{
|
2002-11-14 23:31:34 +01:00
|
|
|
assert(index >= 0);
|
|
|
|
TRACE("dec'ing entry %d to %d\n", index, glyphsetCache[index].count - 1);
|
|
|
|
assert(glyphsetCache[index].count > 0);
|
|
|
|
glyphsetCache[index].count--;
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void lfsz_calc_hash(LFANDSIZE *plfsz)
|
|
|
|
{
|
|
|
|
DWORD hash = 0, *ptr;
|
|
|
|
int i;
|
|
|
|
|
2004-03-04 04:55:52 +01:00
|
|
|
hash ^= plfsz->devsize.cx;
|
|
|
|
hash ^= plfsz->devsize.cy;
|
2002-01-29 04:07:21 +01:00
|
|
|
for(i = 0, ptr = (DWORD*)&plfsz->lf; i < 7; i++, ptr++)
|
|
|
|
hash ^= *ptr;
|
|
|
|
for(i = 0, ptr = (DWORD*)&plfsz->lf.lfFaceName; i < LF_FACESIZE/2; i++, ptr++) {
|
|
|
|
WCHAR *pwc = (WCHAR *)ptr;
|
|
|
|
if(!*pwc) break;
|
|
|
|
hash ^= *ptr;
|
|
|
|
pwc++;
|
|
|
|
if(!*pwc) break;
|
|
|
|
}
|
|
|
|
plfsz->hash = hash;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_XRender_Finalize
|
|
|
|
*/
|
|
|
|
void X11DRV_XRender_Finalize(void)
|
|
|
|
{
|
2002-11-14 23:31:34 +01:00
|
|
|
int i;
|
|
|
|
|
|
|
|
EnterCriticalSection(&xrender_cs);
|
|
|
|
for(i = mru; i >= 0; i = glyphsetCache[i].next)
|
|
|
|
FreeEntry(i);
|
|
|
|
LeaveCriticalSection(&xrender_cs);
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_XRender_SelectFont
|
|
|
|
*/
|
2002-03-28 23:22:05 +01:00
|
|
|
BOOL X11DRV_XRender_SelectFont(X11DRV_PDEVICE *physDev, HFONT hfont)
|
2002-01-29 04:07:21 +01:00
|
|
|
{
|
|
|
|
LFANDSIZE lfsz;
|
|
|
|
|
|
|
|
GetObjectW(hfont, sizeof(lfsz.lf), &lfsz.lf);
|
|
|
|
TRACE("h=%ld w=%ld weight=%ld it=%d charset=%d name=%s\n",
|
|
|
|
lfsz.lf.lfHeight, lfsz.lf.lfWidth, lfsz.lf.lfWeight,
|
|
|
|
lfsz.lf.lfItalic, lfsz.lf.lfCharSet, debugstr_w(lfsz.lf.lfFaceName));
|
2004-03-04 04:55:52 +01:00
|
|
|
lfsz.devsize.cx = X11DRV_XWStoDS( physDev, lfsz.lf.lfWidth );
|
|
|
|
lfsz.devsize.cy = X11DRV_YWStoDS( physDev, lfsz.lf.lfHeight );
|
2002-01-29 04:07:21 +01:00
|
|
|
lfsz_calc_hash(&lfsz);
|
|
|
|
|
2002-06-22 03:01:34 +02:00
|
|
|
EnterCriticalSection(&xrender_cs);
|
|
|
|
if(!physDev->xrender) {
|
2002-01-29 04:07:21 +01:00
|
|
|
physDev->xrender = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(*physDev->xrender));
|
2002-06-22 03:01:34 +02:00
|
|
|
physDev->xrender->cache_index = -1;
|
|
|
|
}
|
|
|
|
else if(physDev->xrender->cache_index != -1)
|
|
|
|
dec_ref_cache(physDev->xrender->cache_index);
|
|
|
|
physDev->xrender->cache_index = GetCacheEntry(&lfsz);
|
|
|
|
LeaveCriticalSection(&xrender_cs);
|
2002-01-29 04:07:21 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_XRender_DeleteDC
|
|
|
|
*/
|
2002-03-28 23:22:05 +01:00
|
|
|
void X11DRV_XRender_DeleteDC(X11DRV_PDEVICE *physDev)
|
2002-01-29 04:07:21 +01:00
|
|
|
{
|
2002-04-24 00:06:41 +02:00
|
|
|
wine_tsx11_lock();
|
2002-01-29 04:07:21 +01:00
|
|
|
if(physDev->xrender->tile_pict)
|
2002-04-24 00:06:41 +02:00
|
|
|
pXRenderFreePicture(gdi_display, physDev->xrender->tile_pict);
|
2002-01-29 04:07:21 +01:00
|
|
|
|
|
|
|
if(physDev->xrender->tile_xpm)
|
2002-04-24 00:06:41 +02:00
|
|
|
XFreePixmap(gdi_display, physDev->xrender->tile_xpm);
|
2002-01-29 04:07:21 +01:00
|
|
|
|
|
|
|
if(physDev->xrender->pict) {
|
2004-01-20 23:04:00 +01:00
|
|
|
TRACE("freeing pict = %lx dc = %p\n", physDev->xrender->pict, physDev->hdc);
|
2002-04-24 00:06:41 +02:00
|
|
|
pXRenderFreePicture(gdi_display, physDev->xrender->pict);
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
2002-04-24 00:06:41 +02:00
|
|
|
wine_tsx11_unlock();
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2002-06-22 03:01:34 +02:00
|
|
|
EnterCriticalSection(&xrender_cs);
|
|
|
|
if(physDev->xrender->cache_index != -1)
|
|
|
|
dec_ref_cache(physDev->xrender->cache_index);
|
|
|
|
LeaveCriticalSection(&xrender_cs);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-29 04:07:21 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, physDev->xrender);
|
|
|
|
physDev->xrender = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_XRender_UpdateDrawable
|
|
|
|
*
|
2002-11-14 23:31:34 +01:00
|
|
|
* This gets called from X11DRV_SetDrawable and X11DRV_SelectBitmap.
|
|
|
|
* It deletes the pict when the drawable changes.
|
2002-01-29 04:07:21 +01:00
|
|
|
*/
|
2002-03-28 23:22:05 +01:00
|
|
|
void X11DRV_XRender_UpdateDrawable(X11DRV_PDEVICE *physDev)
|
2002-01-29 04:07:21 +01:00
|
|
|
{
|
|
|
|
if(physDev->xrender->pict) {
|
2002-11-14 23:31:34 +01:00
|
|
|
TRACE("freeing pict %08lx from dc %p drawable %08lx\n", physDev->xrender->pict,
|
2004-01-20 23:04:00 +01:00
|
|
|
physDev->hdc, physDev->drawable);
|
2002-04-24 00:06:41 +02:00
|
|
|
wine_tsx11_lock();
|
2002-11-14 23:31:34 +01:00
|
|
|
XFlush(gdi_display);
|
2002-04-24 00:06:41 +02:00
|
|
|
pXRenderFreePicture(gdi_display, physDev->xrender->pict);
|
|
|
|
wine_tsx11_unlock();
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
physDev->xrender->pict = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-22 03:01:34 +02:00
|
|
|
/************************************************************************
|
|
|
|
* UploadGlyph
|
|
|
|
*
|
|
|
|
* Helper to ExtTextOut. Must be called inside xrender_cs
|
|
|
|
*/
|
2005-01-24 20:08:02 +01:00
|
|
|
static BOOL UploadGlyph(X11DRV_PDEVICE *physDev, int glyph, AA_Type format)
|
2002-01-29 04:07:21 +01:00
|
|
|
{
|
2004-08-12 01:45:34 +02:00
|
|
|
unsigned int buflen;
|
2002-01-29 04:07:21 +01:00
|
|
|
char *buf;
|
|
|
|
Glyph gid;
|
|
|
|
GLYPHMETRICS gm;
|
|
|
|
XGlyphInfo gi;
|
2002-06-22 03:01:34 +02:00
|
|
|
gsCacheEntry *entry = glyphsetCache + physDev->xrender->cache_index;
|
2005-01-24 20:08:02 +01:00
|
|
|
gsCacheEntryFormat *formatEntry;
|
2002-04-04 00:08:27 +02:00
|
|
|
UINT ggo_format = GGO_GLYPH_INDEX;
|
2004-06-15 19:01:52 +02:00
|
|
|
XRenderPictFormat pf;
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2005-01-24 20:08:02 +01:00
|
|
|
/* If there is nothing for the current type, we create the entry. */
|
|
|
|
if( !entry->format[format] ) {
|
|
|
|
entry->format[format] = HeapAlloc(GetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(gsCacheEntryFormat));
|
|
|
|
}
|
|
|
|
formatEntry = entry->format[format];
|
2003-10-24 02:29:43 +02:00
|
|
|
|
2005-01-24 20:08:02 +01:00
|
|
|
if(formatEntry->nrealized <= glyph) {
|
|
|
|
formatEntry->nrealized = (glyph / 128 + 1) * 128;
|
|
|
|
|
|
|
|
if (formatEntry->realized)
|
|
|
|
formatEntry->realized = HeapReAlloc(GetProcessHeap(),
|
2002-01-29 04:07:21 +01:00
|
|
|
HEAP_ZERO_MEMORY,
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->realized,
|
|
|
|
formatEntry->nrealized * sizeof(BOOL));
|
2003-10-24 02:29:43 +02:00
|
|
|
else
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->realized = HeapAlloc(GetProcessHeap(),
|
2003-10-24 02:29:43 +02:00
|
|
|
HEAP_ZERO_MEMORY,
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->nrealized * sizeof(BOOL));
|
2003-10-24 02:29:43 +02:00
|
|
|
|
2004-06-15 19:01:52 +02:00
|
|
|
if(!X11DRV_XRender_Installed) {
|
2005-01-24 20:08:02 +01:00
|
|
|
if (formatEntry->bitmaps)
|
|
|
|
formatEntry->bitmaps = HeapReAlloc(GetProcessHeap(),
|
2002-11-14 23:31:34 +01:00
|
|
|
HEAP_ZERO_MEMORY,
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->bitmaps,
|
|
|
|
formatEntry->nrealized * sizeof(formatEntry->bitmaps[0]));
|
2003-10-24 02:29:43 +02:00
|
|
|
else
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->bitmaps = HeapAlloc(GetProcessHeap(),
|
2003-10-24 02:29:43 +02:00
|
|
|
HEAP_ZERO_MEMORY,
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->nrealized * sizeof(formatEntry->bitmaps[0]));
|
2003-10-24 02:29:43 +02:00
|
|
|
|
2005-01-24 20:08:02 +01:00
|
|
|
if (formatEntry->gis)
|
|
|
|
formatEntry->gis = HeapReAlloc(GetProcessHeap(),
|
2002-11-14 23:31:34 +01:00
|
|
|
HEAP_ZERO_MEMORY,
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->gis,
|
|
|
|
formatEntry->nrealized * sizeof(formatEntry->gis[0]));
|
2003-10-24 02:29:43 +02:00
|
|
|
else
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->gis = HeapAlloc(GetProcessHeap(),
|
2003-10-24 02:29:43 +02:00
|
|
|
HEAP_ZERO_MEMORY,
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->nrealized * sizeof(formatEntry->gis[0]));
|
2002-11-14 23:31:34 +01:00
|
|
|
}
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
2005-01-24 20:08:02 +01:00
|
|
|
switch(format) {
|
2002-11-14 23:31:34 +01:00
|
|
|
case AA_Grey:
|
2002-04-04 00:08:27 +02:00
|
|
|
ggo_format |= WINE_GGO_GRAY16_BITMAP;
|
2002-11-14 23:31:34 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2005-01-24 20:08:02 +01:00
|
|
|
ERR("aa = %d - not implemented\n", format);
|
2002-11-14 23:31:34 +01:00
|
|
|
case AA_None:
|
|
|
|
ggo_format |= GGO_BITMAP;
|
|
|
|
break;
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
buflen = GetGlyphOutlineW(physDev->hdc, glyph, ggo_format, &gm, 0, NULL,
|
2002-01-29 04:07:21 +01:00
|
|
|
NULL);
|
2002-06-22 03:01:34 +02:00
|
|
|
if(buflen == GDI_ERROR) {
|
2005-01-24 20:08:02 +01:00
|
|
|
if(format != AA_None) {
|
|
|
|
format = AA_None;
|
|
|
|
entry->aa_default = AA_None;
|
2004-06-15 19:01:52 +02:00
|
|
|
ggo_format &= ~WINE_GGO_GRAY16_BITMAP;
|
|
|
|
ggo_format |= GGO_BITMAP;
|
|
|
|
buflen = GetGlyphOutlineW(physDev->hdc, glyph, ggo_format, &gm, 0, NULL,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
if(buflen == GDI_ERROR) {
|
2004-06-16 21:02:25 +02:00
|
|
|
ERR("GetGlyphOutlineW failed\n");
|
2004-06-15 19:01:52 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
TRACE("Turning off antialiasing for this monochrome font\n");
|
|
|
|
}
|
|
|
|
|
2005-01-24 20:08:02 +01:00
|
|
|
if(formatEntry->glyphset == 0 && X11DRV_XRender_Installed) {
|
|
|
|
switch(format) {
|
2004-06-15 19:01:52 +02:00
|
|
|
case AA_Grey:
|
|
|
|
pf.depth = 8;
|
|
|
|
pf.direct.alphaMask = 0xff;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2005-01-24 20:08:02 +01:00
|
|
|
ERR("aa = %d - not implemented\n", format);
|
2004-06-15 19:01:52 +02:00
|
|
|
case AA_None:
|
|
|
|
pf.depth = 1;
|
|
|
|
pf.direct.alphaMask = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pf.type = PictTypeDirect;
|
|
|
|
pf.direct.alpha = 0;
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->font_format = pXRenderFindFormat(gdi_display,
|
2004-06-15 19:01:52 +02:00
|
|
|
PictFormatType |
|
|
|
|
PictFormatDepth |
|
|
|
|
PictFormatAlpha |
|
|
|
|
PictFormatAlphaMask,
|
|
|
|
&pf, 0);
|
|
|
|
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->glyphset = pXRenderCreateGlyphSet(gdi_display, formatEntry->font_format);
|
2004-06-15 19:01:52 +02:00
|
|
|
wine_tsx11_unlock();
|
2002-06-22 03:01:34 +02:00
|
|
|
}
|
|
|
|
|
2002-01-29 04:07:21 +01:00
|
|
|
|
|
|
|
buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buflen);
|
2002-03-28 23:22:05 +01:00
|
|
|
GetGlyphOutlineW(physDev->hdc, glyph, ggo_format, &gm, buflen, buf, NULL);
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->realized[glyph] = TRUE;
|
2002-01-29 04:07:21 +01:00
|
|
|
|
|
|
|
TRACE("buflen = %d. Got metrics: %dx%d adv=%d,%d origin=%ld,%ld\n",
|
|
|
|
buflen,
|
|
|
|
gm.gmBlackBoxX, gm.gmBlackBoxY, gm.gmCellIncX, gm.gmCellIncY,
|
|
|
|
gm.gmptGlyphOrigin.x, gm.gmptGlyphOrigin.y);
|
|
|
|
|
|
|
|
gi.width = gm.gmBlackBoxX;
|
|
|
|
gi.height = gm.gmBlackBoxY;
|
|
|
|
gi.x = -gm.gmptGlyphOrigin.x;
|
|
|
|
gi.y = gm.gmptGlyphOrigin.y;
|
|
|
|
gi.xOff = gm.gmCellIncX;
|
|
|
|
gi.yOff = gm.gmCellIncY;
|
|
|
|
|
|
|
|
if(TRACE_ON(xrender)) {
|
|
|
|
int pitch, i, j;
|
|
|
|
char output[300];
|
|
|
|
unsigned char *line;
|
|
|
|
|
2005-01-24 20:08:02 +01:00
|
|
|
if(format == AA_None) {
|
2002-01-29 04:07:21 +01:00
|
|
|
pitch = ((gi.width + 31) / 32) * 4;
|
|
|
|
for(i = 0; i < gi.height; i++) {
|
|
|
|
line = buf + i * pitch;
|
|
|
|
output[0] = '\0';
|
|
|
|
for(j = 0; j < pitch * 8; j++) {
|
|
|
|
strcat(output, (line[j / 8] & (1 << (7 - (j % 8)))) ? "#" : " ");
|
|
|
|
}
|
|
|
|
strcat(output, "\n");
|
|
|
|
TRACE(output);
|
|
|
|
}
|
|
|
|
} else {
|
2004-05-04 06:13:05 +02:00
|
|
|
static const char blks[] = " .:;!o*#";
|
2002-01-29 04:07:21 +01:00
|
|
|
char str[2];
|
|
|
|
|
|
|
|
str[1] = '\0';
|
|
|
|
pitch = ((gi.width + 3) / 4) * 4;
|
|
|
|
for(i = 0; i < gi.height; i++) {
|
|
|
|
line = buf + i * pitch;
|
|
|
|
output[0] = '\0';
|
|
|
|
for(j = 0; j < pitch; j++) {
|
|
|
|
str[0] = blks[line[j] >> 5];
|
|
|
|
strcat(output, str);
|
|
|
|
}
|
|
|
|
strcat(output, "\n");
|
|
|
|
TRACE(output);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-24 20:08:02 +01:00
|
|
|
if(formatEntry->glyphset) {
|
|
|
|
if(format == AA_None && BitmapBitOrder(gdi_display) != MSBFirst) {
|
2002-11-14 23:31:34 +01:00
|
|
|
unsigned char *byte = buf, c;
|
|
|
|
int i = buflen;
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2002-11-14 23:31:34 +01:00
|
|
|
while(i--) {
|
|
|
|
c = *byte;
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2002-11-14 23:31:34 +01:00
|
|
|
/* magic to flip bit order */
|
|
|
|
c = ((c << 1) & 0xaa) | ((c >> 1) & 0x55);
|
|
|
|
c = ((c << 2) & 0xcc) | ((c >> 2) & 0x33);
|
|
|
|
c = ((c << 4) & 0xf0) | ((c >> 4) & 0x0f);
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2002-11-14 23:31:34 +01:00
|
|
|
*byte++ = c;
|
|
|
|
}
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
2002-11-14 23:31:34 +01:00
|
|
|
gid = glyph;
|
|
|
|
wine_tsx11_lock();
|
2005-01-24 20:08:02 +01:00
|
|
|
pXRenderAddGlyphs(gdi_display, formatEntry->glyphset, &gid, &gi, 1,
|
2002-11-14 23:31:34 +01:00
|
|
|
buf, buflen);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
} else {
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->bitmaps[glyph] = buf;
|
|
|
|
memcpy(&formatEntry->gis[glyph], &gi, sizeof(gi));
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-11-14 23:31:34 +01:00
|
|
|
static void SharpGlyphMono(X11DRV_PDEVICE *physDev, INT x, INT y,
|
|
|
|
void *bitmap, XGlyphInfo *gi)
|
|
|
|
{
|
|
|
|
unsigned char *srcLine = bitmap, *src;
|
|
|
|
unsigned char bits, bitsMask;
|
|
|
|
int width = gi->width;
|
|
|
|
int stride = ((width + 31) & ~31) >> 3;
|
|
|
|
int height = gi->height;
|
|
|
|
int w;
|
|
|
|
int xspan, lenspan;
|
|
|
|
|
|
|
|
TRACE("%d, %d\n", x, y);
|
|
|
|
x -= gi->x;
|
|
|
|
y -= gi->y;
|
|
|
|
while (height--)
|
|
|
|
{
|
|
|
|
src = srcLine;
|
|
|
|
srcLine += stride;
|
|
|
|
w = width;
|
|
|
|
|
|
|
|
bitsMask = 0x80; /* FreeType is always MSB first */
|
|
|
|
bits = *src++;
|
|
|
|
|
|
|
|
xspan = x;
|
|
|
|
while (w)
|
|
|
|
{
|
|
|
|
if (bits & bitsMask)
|
|
|
|
{
|
|
|
|
lenspan = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
lenspan++;
|
|
|
|
if (lenspan == w)
|
|
|
|
break;
|
|
|
|
bitsMask = bitsMask >> 1;
|
|
|
|
if (!bitsMask)
|
|
|
|
{
|
|
|
|
bits = *src++;
|
|
|
|
bitsMask = 0x80;
|
|
|
|
}
|
|
|
|
} while (bits & bitsMask);
|
|
|
|
XFillRectangle (gdi_display, physDev->drawable,
|
|
|
|
physDev->gc, xspan, y, lenspan, 1);
|
|
|
|
xspan += lenspan;
|
|
|
|
w -= lenspan;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
w--;
|
|
|
|
xspan++;
|
|
|
|
if (!w)
|
|
|
|
break;
|
|
|
|
bitsMask = bitsMask >> 1;
|
|
|
|
if (!bitsMask)
|
|
|
|
{
|
|
|
|
bits = *src++;
|
|
|
|
bitsMask = 0x80;
|
|
|
|
}
|
|
|
|
} while (!(bits & bitsMask));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
y++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SharpGlyphGray(X11DRV_PDEVICE *physDev, INT x, INT y,
|
|
|
|
void *bitmap, XGlyphInfo *gi)
|
|
|
|
{
|
|
|
|
unsigned char *srcLine = bitmap, *src, bits;
|
|
|
|
int width = gi->width;
|
|
|
|
int stride = ((width + 3) & ~3);
|
|
|
|
int height = gi->height;
|
|
|
|
int w;
|
|
|
|
int xspan, lenspan;
|
|
|
|
|
|
|
|
x -= gi->x;
|
|
|
|
y -= gi->y;
|
|
|
|
while (height--)
|
|
|
|
{
|
|
|
|
src = srcLine;
|
|
|
|
srcLine += stride;
|
|
|
|
w = width;
|
|
|
|
|
|
|
|
bits = *src++;
|
|
|
|
xspan = x;
|
|
|
|
while (w)
|
|
|
|
{
|
|
|
|
if (bits >= 0x80)
|
|
|
|
{
|
|
|
|
lenspan = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
lenspan++;
|
|
|
|
if (lenspan == w)
|
|
|
|
break;
|
|
|
|
bits = *src++;
|
|
|
|
} while (bits >= 0x80);
|
|
|
|
XFillRectangle (gdi_display, physDev->drawable,
|
|
|
|
physDev->gc, xspan, y, lenspan, 1);
|
|
|
|
xspan += lenspan;
|
|
|
|
w -= lenspan;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
w--;
|
|
|
|
xspan++;
|
|
|
|
if (!w)
|
|
|
|
break;
|
|
|
|
bits = *src++;
|
|
|
|
} while (bits < 0x80);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
y++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void ExamineBitfield (DWORD mask, int *shift, int *len)
|
|
|
|
{
|
|
|
|
int s, l;
|
|
|
|
|
|
|
|
s = 0;
|
|
|
|
while ((mask & 1) == 0)
|
|
|
|
{
|
|
|
|
mask >>= 1;
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
l = 0;
|
|
|
|
while ((mask & 1) == 1)
|
|
|
|
{
|
|
|
|
mask >>= 1;
|
|
|
|
l++;
|
|
|
|
}
|
|
|
|
*shift = s;
|
|
|
|
*len = l;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD GetField (DWORD pixel, int shift, int len)
|
|
|
|
{
|
|
|
|
pixel = pixel & (((1 << (len)) - 1) << shift);
|
|
|
|
pixel = pixel << (32 - (shift + len)) >> 24;
|
|
|
|
while (len < 8)
|
|
|
|
{
|
|
|
|
pixel |= (pixel >> len);
|
|
|
|
len <<= 1;
|
|
|
|
}
|
|
|
|
return pixel;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static DWORD PutField (DWORD pixel, int shift, int len)
|
|
|
|
{
|
|
|
|
shift = shift - (8 - len);
|
|
|
|
if (len <= 8)
|
|
|
|
pixel &= (((1 << len) - 1) << (8 - len));
|
|
|
|
if (shift < 0)
|
|
|
|
pixel >>= -shift;
|
|
|
|
else
|
|
|
|
pixel <<= shift;
|
|
|
|
return pixel;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SmoothGlyphGray(XImage *image, int x, int y, void *bitmap, XGlyphInfo *gi,
|
2004-11-22 19:10:16 +01:00
|
|
|
int color)
|
2002-11-14 23:31:34 +01:00
|
|
|
{
|
|
|
|
int r_shift, r_len;
|
|
|
|
int g_shift, g_len;
|
|
|
|
int b_shift, b_len;
|
|
|
|
BYTE *maskLine, *mask, m;
|
|
|
|
int maskStride;
|
|
|
|
DWORD pixel;
|
|
|
|
int width, height;
|
|
|
|
int w, tx;
|
|
|
|
BYTE src_r, src_g, src_b;
|
|
|
|
|
|
|
|
x -= gi->x;
|
|
|
|
y -= gi->y;
|
|
|
|
width = gi->width;
|
|
|
|
height = gi->height;
|
|
|
|
|
|
|
|
maskLine = (unsigned char *) bitmap;
|
|
|
|
maskStride = (width + 3) & ~3;
|
|
|
|
|
|
|
|
ExamineBitfield (image->red_mask, &r_shift, &r_len);
|
|
|
|
ExamineBitfield (image->green_mask, &g_shift, &g_len);
|
|
|
|
ExamineBitfield (image->blue_mask, &b_shift, &b_len);
|
2004-11-22 19:10:16 +01:00
|
|
|
|
|
|
|
src_r = GetField(color, r_shift, r_len);
|
|
|
|
src_g = GetField(color, g_shift, g_len);
|
|
|
|
src_b = GetField(color, b_shift, b_len);
|
|
|
|
|
2002-11-14 23:31:34 +01:00
|
|
|
for(; height--; y++)
|
|
|
|
{
|
|
|
|
mask = maskLine;
|
|
|
|
maskLine += maskStride;
|
|
|
|
w = width;
|
|
|
|
tx = x;
|
|
|
|
|
|
|
|
if(y < 0) continue;
|
|
|
|
if(y >= image->height) break;
|
|
|
|
|
|
|
|
for(; w--; tx++)
|
|
|
|
{
|
|
|
|
if(tx >= image->width) break;
|
|
|
|
|
|
|
|
m = *mask++;
|
|
|
|
if(tx < 0) continue;
|
|
|
|
|
|
|
|
if (m == 0xff)
|
2004-11-22 19:10:16 +01:00
|
|
|
XPutPixel (image, tx, y, color);
|
2002-11-14 23:31:34 +01:00
|
|
|
else if (m)
|
|
|
|
{
|
|
|
|
BYTE r, g, b;
|
|
|
|
|
|
|
|
pixel = XGetPixel (image, tx, y);
|
|
|
|
|
|
|
|
r = GetField(pixel, r_shift, r_len);
|
|
|
|
r = ((BYTE)~m * (WORD)r + (BYTE)m * (WORD)src_r) >> 8;
|
|
|
|
g = GetField(pixel, g_shift, g_len);
|
|
|
|
g = ((BYTE)~m * (WORD)g + (BYTE)m * (WORD)src_g) >> 8;
|
|
|
|
b = GetField(pixel, b_shift, b_len);
|
|
|
|
b = ((BYTE)~m * (WORD)b + (BYTE)m * (WORD)src_b) >> 8;
|
|
|
|
|
|
|
|
pixel = (PutField (r, r_shift, r_len) |
|
|
|
|
PutField (g, g_shift, g_len) |
|
|
|
|
PutField (b, b_shift, b_len));
|
|
|
|
XPutPixel (image, tx, y, pixel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int XRenderErrorHandler(Display *dpy, XErrorEvent *event, void *arg)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-01-29 04:07:21 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_XRender_ExtTextOut
|
|
|
|
*/
|
2002-03-28 23:22:05 +01:00
|
|
|
BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
|
2002-01-29 04:07:21 +01:00
|
|
|
const RECT *lprect, LPCWSTR wstr, UINT count,
|
2004-03-04 02:42:57 +01:00
|
|
|
const INT *lpDx, INT breakExtra )
|
2002-01-29 04:07:21 +01:00
|
|
|
{
|
|
|
|
XRenderColor col;
|
2004-08-12 01:45:34 +02:00
|
|
|
unsigned int idx;
|
2002-01-29 04:07:21 +01:00
|
|
|
TEXTMETRICW tm;
|
2002-05-26 00:16:12 +02:00
|
|
|
RGNDATA *data;
|
2002-01-29 04:07:21 +01:00
|
|
|
SIZE sz;
|
|
|
|
RECT rc;
|
|
|
|
BOOL done_extents = FALSE;
|
|
|
|
INT width, xwidth, ywidth;
|
|
|
|
double cosEsc, sinEsc;
|
|
|
|
XGCValues xgcval;
|
|
|
|
LOGFONTW lf;
|
|
|
|
int render_op = PictOpOver;
|
2004-11-30 22:38:57 +01:00
|
|
|
const WORD *glyphs;
|
2002-06-22 03:01:34 +02:00
|
|
|
POINT pt;
|
|
|
|
gsCacheEntry *entry;
|
2005-01-24 20:08:02 +01:00
|
|
|
gsCacheEntryFormat *formatEntry;
|
2002-06-22 03:01:34 +02:00
|
|
|
BOOL retv = FALSE;
|
2002-03-28 23:22:05 +01:00
|
|
|
HDC hdc = physDev->hdc;
|
2002-11-14 23:31:34 +01:00
|
|
|
int textPixel, backgroundPixel;
|
2004-11-30 22:38:57 +01:00
|
|
|
INT *deltas = NULL, char_extra;
|
2004-02-13 21:26:27 +01:00
|
|
|
HRGN saved_region = 0;
|
2004-01-20 23:04:00 +01:00
|
|
|
UINT align = GetTextAlign( hdc );
|
2005-01-26 20:43:42 +01:00
|
|
|
BOOL disable_antialias = FALSE;
|
|
|
|
AA_Type antialias = AA_None;
|
|
|
|
DIBSECTION bmp;
|
|
|
|
|
|
|
|
/* Do we need to disable antialiasing because of palette mode? */
|
2005-04-12 13:59:48 +02:00
|
|
|
if( !physDev->bitmap || GetObjectW( physDev->bitmap->hbitmap, sizeof(bmp), &bmp ) != sizeof(bmp) ) {
|
2005-01-26 20:43:42 +01:00
|
|
|
TRACE("bitmap is not a DIB\n");
|
|
|
|
}
|
|
|
|
else if (bmp.dsBmih.biBitCount <= 8) {
|
|
|
|
TRACE("Disabling antialiasing\n");
|
|
|
|
disable_antialias = TRUE;
|
|
|
|
}
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2002-10-31 03:38:20 +01:00
|
|
|
TRACE("%p, %d, %d, %08x, %p, %s, %d, %p)\n", hdc, x, y, flags,
|
2002-01-29 04:07:21 +01:00
|
|
|
lprect, debugstr_wn(wstr, count), count, lpDx);
|
2002-04-04 00:08:27 +02:00
|
|
|
|
|
|
|
if(flags & ETO_GLYPH_INDEX)
|
2004-11-30 22:38:57 +01:00
|
|
|
glyphs = (const WORD*)wstr;
|
2002-04-04 00:08:27 +02:00
|
|
|
else {
|
|
|
|
glyphs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR));
|
2004-11-30 22:38:57 +01:00
|
|
|
GetGlyphIndicesW(hdc, wstr, count, (WORD*)glyphs, 0);
|
2002-04-04 00:08:27 +02:00
|
|
|
}
|
|
|
|
|
2002-01-29 04:07:21 +01:00
|
|
|
if(lprect)
|
2003-01-08 22:09:25 +01:00
|
|
|
TRACE("rect: %ld,%ld - %ld,%ld\n", lprect->left, lprect->top, lprect->right,
|
2002-01-29 04:07:21 +01:00
|
|
|
lprect->bottom);
|
2004-02-13 05:00:29 +01:00
|
|
|
TRACE("align = %x bkmode = %x mapmode = %x\n", align, GetBkMode(hdc), GetMapMode(hdc));
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2004-01-20 23:04:00 +01:00
|
|
|
if(align & TA_UPDATECP)
|
|
|
|
{
|
|
|
|
GetCurrentPositionEx( hdc, &pt );
|
|
|
|
x = pt.x;
|
|
|
|
y = pt.y;
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
2004-08-11 21:34:20 +02:00
|
|
|
GetTextMetricsW(hdc, &tm);
|
2002-03-28 23:22:05 +01:00
|
|
|
GetObjectW(GetCurrentObject(hdc, OBJ_FONT), sizeof(lf), &lf);
|
2004-08-11 21:34:20 +02:00
|
|
|
|
|
|
|
if(!(tm.tmPitchAndFamily & TMPF_VECTOR)) /* Non-scalable fonts shouldn't be rotated */
|
|
|
|
lf.lfEscapement = 0;
|
|
|
|
|
2002-01-29 04:07:21 +01:00
|
|
|
if(lf.lfEscapement != 0) {
|
|
|
|
cosEsc = cos(lf.lfEscapement * M_PI / 1800);
|
|
|
|
sinEsc = sin(lf.lfEscapement * M_PI / 1800);
|
|
|
|
} else {
|
|
|
|
cosEsc = 1;
|
|
|
|
sinEsc = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(flags & (ETO_CLIPPED | ETO_OPAQUE)) {
|
|
|
|
if(!lprect) {
|
2005-03-14 11:03:39 +01:00
|
|
|
if(flags & ETO_CLIPPED) goto done;
|
|
|
|
GetTextExtentPointI(hdc, glyphs, count, &sz);
|
|
|
|
done_extents = TRUE;
|
|
|
|
rc.left = x;
|
|
|
|
rc.top = y;
|
|
|
|
rc.right = x + sz.cx;
|
|
|
|
rc.bottom = y + sz.cy;
|
2002-01-29 04:07:21 +01:00
|
|
|
} else {
|
|
|
|
rc = *lprect;
|
|
|
|
}
|
|
|
|
|
2004-01-20 23:04:00 +01:00
|
|
|
LPtoDP(hdc, (POINT*)&rc, 2);
|
2002-01-29 04:07:21 +01:00
|
|
|
|
|
|
|
if(rc.left > rc.right) {INT tmp = rc.left; rc.left = rc.right; rc.right = tmp;}
|
|
|
|
if(rc.top > rc.bottom) {INT tmp = rc.top; rc.top = rc.bottom; rc.bottom = tmp;}
|
|
|
|
}
|
|
|
|
|
|
|
|
xgcval.function = GXcopy;
|
|
|
|
xgcval.background = physDev->backgroundPixel;
|
|
|
|
xgcval.fill_style = FillSolid;
|
2003-11-21 06:41:56 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XChangeGC( gdi_display, physDev->gc, GCFunction | GCBackground | GCFillStyle, &xgcval );
|
|
|
|
wine_tsx11_unlock();
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
X11DRV_LockDIBSection( physDev, DIB_Status_GdiMod, FALSE );
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2004-01-18 23:20:17 +01:00
|
|
|
if(physDev->depth == 1) {
|
2004-11-22 19:10:16 +01:00
|
|
|
if((physDev->textPixel & 0xffffff) == 0) {
|
2002-11-14 23:31:34 +01:00
|
|
|
textPixel = 0;
|
|
|
|
backgroundPixel = 1;
|
|
|
|
} else {
|
|
|
|
textPixel = 1;
|
|
|
|
backgroundPixel = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
textPixel = physDev->textPixel;
|
|
|
|
backgroundPixel = physDev->backgroundPixel;
|
|
|
|
}
|
|
|
|
|
2002-01-29 04:07:21 +01:00
|
|
|
if(flags & ETO_OPAQUE) {
|
2003-11-21 06:41:56 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XSetForeground( gdi_display, physDev->gc, backgroundPixel );
|
|
|
|
XFillRectangle( gdi_display, physDev->drawable, physDev->gc,
|
|
|
|
physDev->org.x + rc.left, physDev->org.y + rc.top,
|
|
|
|
rc.right - rc.left, rc.bottom - rc.top );
|
|
|
|
wine_tsx11_unlock();
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(count == 0) {
|
2002-06-22 03:01:34 +02:00
|
|
|
retv = TRUE;
|
2005-03-14 11:03:39 +01:00
|
|
|
goto done_unlock;
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
2002-06-22 03:01:34 +02:00
|
|
|
pt.x = x;
|
|
|
|
pt.y = y;
|
2004-01-20 23:04:00 +01:00
|
|
|
LPtoDP(hdc, &pt, 1);
|
2002-06-22 03:01:34 +02:00
|
|
|
x = pt.x;
|
|
|
|
y = pt.y;
|
2002-01-29 04:07:21 +01:00
|
|
|
|
|
|
|
TRACE("real x,y %d,%d\n", x, y);
|
|
|
|
|
2005-02-23 13:42:17 +01:00
|
|
|
char_extra = GetTextCharacterExtra(hdc);
|
|
|
|
if(char_extra || breakExtra) {
|
2004-08-12 01:45:34 +02:00
|
|
|
UINT i;
|
2002-11-14 23:31:34 +01:00
|
|
|
SIZE tmpsz;
|
|
|
|
deltas = HeapAlloc(GetProcessHeap(), 0, count * sizeof(INT));
|
|
|
|
for(i = 0; i < count; i++) {
|
|
|
|
if(lpDx)
|
2003-11-11 01:28:19 +01:00
|
|
|
deltas[i] = lpDx[i] + char_extra;
|
2002-11-14 23:31:34 +01:00
|
|
|
else {
|
|
|
|
GetTextExtentPointI(hdc, glyphs + i, 1, &tmpsz);
|
2003-11-11 01:28:19 +01:00
|
|
|
deltas[i] = tmpsz.cx;
|
2002-11-14 23:31:34 +01:00
|
|
|
}
|
2005-02-23 13:42:17 +01:00
|
|
|
|
|
|
|
if (breakExtra && wstr[i] == tm.tmBreakChar) {
|
|
|
|
deltas[i] = deltas[i] + breakExtra;
|
|
|
|
}
|
2002-11-14 23:31:34 +01:00
|
|
|
}
|
|
|
|
} else if(lpDx)
|
|
|
|
deltas = (INT*)lpDx;
|
|
|
|
|
|
|
|
if(deltas) {
|
2002-01-29 04:07:21 +01:00
|
|
|
width = 0;
|
|
|
|
for(idx = 0; idx < count; idx++)
|
2002-11-14 23:31:34 +01:00
|
|
|
width += deltas[idx];
|
2002-01-29 04:07:21 +01:00
|
|
|
} else {
|
|
|
|
if(!done_extents) {
|
2002-04-04 00:08:27 +02:00
|
|
|
GetTextExtentPointI(hdc, glyphs, count, &sz);
|
2002-01-29 04:07:21 +01:00
|
|
|
done_extents = TRUE;
|
|
|
|
}
|
|
|
|
width = sz.cx;
|
|
|
|
}
|
2004-01-15 07:19:35 +01:00
|
|
|
width = X11DRV_XWStoDS(physDev, width);
|
2002-01-29 04:07:21 +01:00
|
|
|
xwidth = width * cosEsc;
|
|
|
|
ywidth = width * sinEsc;
|
|
|
|
|
2004-04-29 22:01:23 +02:00
|
|
|
tm.tmAscent = abs(X11DRV_YWStoDS(physDev, tm.tmAscent));
|
|
|
|
tm.tmDescent = abs(X11DRV_YWStoDS(physDev, tm.tmDescent));
|
2004-02-13 05:00:29 +01:00
|
|
|
switch( align & (TA_LEFT | TA_RIGHT | TA_CENTER) ) {
|
2002-01-29 04:07:21 +01:00
|
|
|
case TA_LEFT:
|
2004-01-20 23:04:00 +01:00
|
|
|
if (align & TA_UPDATECP) {
|
2002-06-22 03:01:34 +02:00
|
|
|
pt.x = x + xwidth;
|
|
|
|
pt.y = y - ywidth;
|
2004-01-20 23:04:00 +01:00
|
|
|
DPtoLP(hdc, &pt, 1);
|
|
|
|
MoveToEx(hdc, pt.x, pt.y, NULL);
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-29 04:07:21 +01:00
|
|
|
case TA_CENTER:
|
|
|
|
x -= xwidth / 2;
|
|
|
|
y += ywidth / 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TA_RIGHT:
|
|
|
|
x -= xwidth;
|
|
|
|
y += ywidth;
|
2004-01-20 23:04:00 +01:00
|
|
|
if (align & TA_UPDATECP) {
|
2002-06-22 03:01:34 +02:00
|
|
|
pt.x = x;
|
|
|
|
pt.y = y;
|
2004-01-20 23:04:00 +01:00
|
|
|
DPtoLP(hdc, &pt, 1);
|
|
|
|
MoveToEx(hdc, pt.x, pt.y, NULL);
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-01-20 23:04:00 +01:00
|
|
|
switch( align & (TA_TOP | TA_BOTTOM | TA_BASELINE) ) {
|
2002-01-29 04:07:21 +01:00
|
|
|
case TA_TOP:
|
|
|
|
y += tm.tmAscent * cosEsc;
|
|
|
|
x += tm.tmAscent * sinEsc;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TA_BOTTOM:
|
|
|
|
y -= tm.tmDescent * cosEsc;
|
|
|
|
x -= tm.tmDescent * sinEsc;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TA_BASELINE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & ETO_CLIPPED)
|
|
|
|
{
|
2004-02-16 21:35:52 +01:00
|
|
|
HRGN clip_region;
|
|
|
|
RECT clip_rect = *lprect;
|
|
|
|
|
|
|
|
LPtoDP( hdc, (POINT *)&clip_rect, 2 );
|
|
|
|
clip_region = CreateRectRgnIndirect( &clip_rect );
|
2004-02-13 21:26:27 +01:00
|
|
|
/* make a copy of the current device region */
|
|
|
|
saved_region = CreateRectRgn( 0, 0, 0, 0 );
|
|
|
|
CombineRgn( saved_region, physDev->region, 0, RGN_COPY );
|
|
|
|
X11DRV_SetDeviceClipping( physDev, saved_region, clip_region );
|
|
|
|
DeleteObject( clip_region );
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
2002-11-14 23:31:34 +01:00
|
|
|
if(X11DRV_XRender_Installed) {
|
|
|
|
if(!physDev->xrender->pict) {
|
|
|
|
XRenderPictureAttributes pa;
|
|
|
|
pa.subwindow_mode = IncludeInferiors;
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2002-11-14 23:31:34 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
physDev->xrender->pict = pXRenderCreatePicture(gdi_display,
|
|
|
|
physDev->drawable,
|
2004-01-18 23:20:17 +01:00
|
|
|
(physDev->depth == 1) ?
|
2002-11-14 23:31:34 +01:00
|
|
|
mono_format : screen_format,
|
|
|
|
CPSubwindowMode, &pa);
|
|
|
|
wine_tsx11_unlock();
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2004-02-13 05:00:29 +01:00
|
|
|
TRACE("allocing pict = %lx dc = %p drawable = %08lx\n",
|
|
|
|
physDev->xrender->pict, hdc, physDev->drawable);
|
2002-11-14 23:31:34 +01:00
|
|
|
} else {
|
2004-02-13 05:00:29 +01:00
|
|
|
TRACE("using existing pict = %lx dc = %p drawable = %08lx\n",
|
|
|
|
physDev->xrender->pict, hdc, physDev->drawable);
|
2002-11-14 23:31:34 +01:00
|
|
|
}
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2004-02-13 21:26:27 +01:00
|
|
|
if ((data = X11DRV_GetRegionData( physDev->region, 0 )))
|
2002-11-14 23:31:34 +01:00
|
|
|
{
|
|
|
|
wine_tsx11_lock();
|
|
|
|
pXRenderSetPictureClipRectangles( gdi_display, physDev->xrender->pict,
|
|
|
|
physDev->org.x, physDev->org.y,
|
|
|
|
(XRectangle *)data->Buffer, data->rdh.nCount );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
HeapFree( GetProcessHeap(), 0, data );
|
|
|
|
}
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
if(GetBkMode(hdc) != TRANSPARENT) {
|
2002-01-29 04:07:21 +01:00
|
|
|
if(!((flags & ETO_CLIPPED) && (flags & ETO_OPAQUE))) {
|
|
|
|
if(!(flags & ETO_OPAQUE) || x < rc.left || x + width >= rc.right ||
|
|
|
|
y - tm.tmAscent < rc.top || y + tm.tmDescent >= rc.bottom) {
|
2003-11-21 06:41:56 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XSetForeground( gdi_display, physDev->gc, backgroundPixel );
|
|
|
|
XFillRectangle( gdi_display, physDev->drawable, physDev->gc,
|
|
|
|
physDev->org.x + x, physDev->org.y + y - tm.tmAscent,
|
|
|
|
width, tm.tmAscent + tm.tmDescent );
|
|
|
|
wine_tsx11_unlock();
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-14 23:31:34 +01:00
|
|
|
if(X11DRV_XRender_Installed) {
|
|
|
|
/* Create a 1x1 pixmap to tile over the font mask */
|
|
|
|
if(!physDev->xrender->tile_xpm) {
|
|
|
|
XRenderPictureAttributes pa;
|
|
|
|
|
2004-01-18 23:20:17 +01:00
|
|
|
XRenderPictFormat *format = (physDev->depth == 1) ? mono_format : screen_format;
|
2002-11-14 23:31:34 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
physDev->xrender->tile_xpm = XCreatePixmap(gdi_display,
|
|
|
|
physDev->drawable,
|
|
|
|
1, 1,
|
|
|
|
format->depth);
|
|
|
|
pa.repeat = True;
|
|
|
|
physDev->xrender->tile_pict = pXRenderCreatePicture(gdi_display,
|
|
|
|
physDev->xrender->tile_xpm,
|
|
|
|
format,
|
|
|
|
CPRepeat, &pa);
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
TRACE("Created pixmap of depth %d\n", format->depth);
|
2004-11-22 19:10:16 +01:00
|
|
|
/* init lastTextColor to something different from textPixel */
|
|
|
|
physDev->xrender->lastTextColor = ~physDev->textPixel;
|
2002-01-29 04:07:21 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-11-22 19:10:16 +01:00
|
|
|
if(physDev->textPixel != physDev->xrender->lastTextColor) {
|
2004-01-18 23:20:17 +01:00
|
|
|
if(physDev->depth != 1) {
|
2004-11-22 19:10:16 +01:00
|
|
|
/* Map 0 -- 0xff onto 0 -- 0xffff */
|
|
|
|
int r_shift, r_len;
|
|
|
|
int g_shift, g_len;
|
|
|
|
int b_shift, b_len;
|
|
|
|
|
|
|
|
ExamineBitfield (visual->red_mask, &r_shift, &r_len );
|
|
|
|
ExamineBitfield (visual->green_mask, &g_shift, &g_len);
|
|
|
|
ExamineBitfield (visual->blue_mask, &b_shift, &b_len);
|
|
|
|
|
|
|
|
col.red = GetField(physDev->textPixel, r_shift, r_len);
|
2002-11-14 23:31:34 +01:00
|
|
|
col.red |= col.red << 8;
|
2004-11-22 19:10:16 +01:00
|
|
|
col.green = GetField(physDev->textPixel, g_shift, g_len);
|
2002-11-14 23:31:34 +01:00
|
|
|
col.green |= col.green << 8;
|
2004-11-22 19:10:16 +01:00
|
|
|
col.blue = GetField(physDev->textPixel, b_shift, b_len);
|
2002-11-14 23:31:34 +01:00
|
|
|
col.blue |= col.blue << 8;
|
|
|
|
col.alpha = 0x0;
|
|
|
|
} else { /* for a 1bpp bitmap we always need a 1 in the tile */
|
|
|
|
col.red = col.green = col.blue = 0;
|
|
|
|
col.alpha = 0xffff;
|
|
|
|
}
|
|
|
|
wine_tsx11_lock();
|
|
|
|
pXRenderFillRectangle(gdi_display, PictOpSrc,
|
|
|
|
physDev->xrender->tile_pict,
|
|
|
|
&col, 0, 0, 1, 1);
|
|
|
|
wine_tsx11_unlock();
|
2004-11-22 19:10:16 +01:00
|
|
|
physDev->xrender->lastTextColor = physDev->textPixel;
|
2002-11-14 23:31:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME the mapping of Text/BkColor onto 1 or 0 needs investigation.
|
|
|
|
*/
|
2004-01-18 23:20:17 +01:00
|
|
|
if((physDev->depth == 1) && (textPixel == 0))
|
2002-11-14 23:31:34 +01:00
|
|
|
render_op = PictOpOutReverse; /* This gives us 'black' text */
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-06-22 03:01:34 +02:00
|
|
|
EnterCriticalSection(&xrender_cs);
|
|
|
|
entry = glyphsetCache + physDev->xrender->cache_index;
|
2005-01-26 20:43:42 +01:00
|
|
|
if( disable_antialias == FALSE )
|
|
|
|
antialias = entry->aa_default;
|
|
|
|
formatEntry = entry->format[antialias];
|
2002-06-22 03:01:34 +02:00
|
|
|
|
2002-01-29 04:07:21 +01:00
|
|
|
for(idx = 0; idx < count; idx++) {
|
2005-01-24 20:08:02 +01:00
|
|
|
if( !formatEntry ) {
|
2005-01-26 20:43:42 +01:00
|
|
|
UploadGlyph(physDev, glyphs[idx], antialias);
|
|
|
|
formatEntry = entry->format[antialias];
|
2005-01-24 20:08:02 +01:00
|
|
|
} else if( glyphs[idx] >= formatEntry->nrealized || formatEntry->realized[glyphs[idx]] == FALSE) {
|
2005-01-26 20:43:42 +01:00
|
|
|
UploadGlyph(physDev, glyphs[idx], antialias);
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
}
|
2005-01-24 20:08:02 +01:00
|
|
|
assert(formatEntry);
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2002-06-11 00:52:47 +02:00
|
|
|
TRACE("Writing %s at %ld,%ld\n", debugstr_wn(wstr,count),
|
|
|
|
physDev->org.x + x, physDev->org.y + y);
|
2002-04-24 00:06:41 +02:00
|
|
|
|
2002-11-14 23:31:34 +01:00
|
|
|
if(X11DRV_XRender_Installed) {
|
|
|
|
wine_tsx11_lock();
|
|
|
|
if(!deltas)
|
|
|
|
pXRenderCompositeString16(gdi_display, render_op,
|
|
|
|
physDev->xrender->tile_pict,
|
|
|
|
physDev->xrender->pict,
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->font_format, formatEntry->glyphset,
|
2002-11-14 23:31:34 +01:00
|
|
|
0, 0, physDev->org.x + x, physDev->org.y + y,
|
|
|
|
glyphs, count);
|
|
|
|
|
|
|
|
else {
|
|
|
|
INT offset = 0, xoff = 0, yoff = 0;
|
|
|
|
for(idx = 0; idx < count; idx++) {
|
|
|
|
pXRenderCompositeString16(gdi_display, render_op,
|
|
|
|
physDev->xrender->tile_pict,
|
|
|
|
physDev->xrender->pict,
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->font_format, formatEntry->glyphset,
|
2002-11-14 23:31:34 +01:00
|
|
|
0, 0, physDev->org.x + x + xoff,
|
|
|
|
physDev->org.y + y + yoff,
|
|
|
|
glyphs + idx, 1);
|
2004-01-15 07:19:35 +01:00
|
|
|
offset += X11DRV_XWStoDS(physDev, deltas[idx]);
|
2002-11-14 23:31:34 +01:00
|
|
|
xoff = offset * cosEsc;
|
|
|
|
yoff = offset * -sinEsc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wine_tsx11_unlock();
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2002-11-14 23:31:34 +01:00
|
|
|
} else {
|
2002-01-29 04:07:21 +01:00
|
|
|
INT offset = 0, xoff = 0, yoff = 0;
|
2002-11-14 23:31:34 +01:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XSetForeground( gdi_display, physDev->gc, textPixel );
|
|
|
|
|
2005-01-26 20:43:42 +01:00
|
|
|
if(antialias == AA_None) {
|
2002-11-14 23:31:34 +01:00
|
|
|
for(idx = 0; idx < count; idx++) {
|
|
|
|
SharpGlyphMono(physDev, physDev->org.x + x + xoff,
|
|
|
|
physDev->org.y + y + yoff,
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->bitmaps[glyphs[idx]],
|
|
|
|
&formatEntry->gis[glyphs[idx]]);
|
2002-11-14 23:31:34 +01:00
|
|
|
if(deltas) {
|
2004-01-15 07:19:35 +01:00
|
|
|
offset += X11DRV_XWStoDS(physDev, deltas[idx]);
|
2002-11-14 23:31:34 +01:00
|
|
|
xoff = offset * cosEsc;
|
|
|
|
yoff = offset * -sinEsc;
|
|
|
|
|
|
|
|
} else {
|
2005-01-24 20:08:02 +01:00
|
|
|
xoff += formatEntry->gis[glyphs[idx]].xOff;
|
|
|
|
yoff += formatEntry->gis[glyphs[idx]].yOff;
|
2002-11-14 23:31:34 +01:00
|
|
|
}
|
|
|
|
}
|
2004-01-18 23:20:17 +01:00
|
|
|
} else if(physDev->depth == 1) {
|
2002-11-14 23:31:34 +01:00
|
|
|
for(idx = 0; idx < count; idx++) {
|
|
|
|
SharpGlyphGray(physDev, physDev->org.x + x + xoff,
|
|
|
|
physDev->org.y + y + yoff,
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->bitmaps[glyphs[idx]],
|
|
|
|
&formatEntry->gis[glyphs[idx]]);
|
2002-11-14 23:31:34 +01:00
|
|
|
if(deltas) {
|
2004-01-15 07:19:35 +01:00
|
|
|
offset += X11DRV_XWStoDS(physDev, deltas[idx]);
|
2002-11-14 23:31:34 +01:00
|
|
|
xoff = offset * cosEsc;
|
|
|
|
yoff = offset * -sinEsc;
|
|
|
|
|
|
|
|
} else {
|
2005-01-24 20:08:02 +01:00
|
|
|
xoff += formatEntry->gis[glyphs[idx]].xOff;
|
|
|
|
yoff += formatEntry->gis[glyphs[idx]].yOff;
|
2002-11-14 23:31:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
XImage *image;
|
|
|
|
unsigned int w, h, dummy_uint;
|
|
|
|
Window dummy_window;
|
|
|
|
int dummy_int;
|
|
|
|
int image_x, image_y, image_off_x, image_off_y, image_w, image_h;
|
|
|
|
RECT extents = {0, 0, 0, 0};
|
|
|
|
POINT cur = {0, 0};
|
|
|
|
|
|
|
|
|
|
|
|
XGetGeometry(gdi_display, physDev->drawable, &dummy_window, &dummy_int, &dummy_int,
|
|
|
|
&w, &h, &dummy_uint, &dummy_uint);
|
|
|
|
TRACE("drawable %dx%d\n", w, h);
|
|
|
|
|
|
|
|
for(idx = 0; idx < count; idx++) {
|
2005-01-24 20:08:02 +01:00
|
|
|
if(extents.left > cur.x - formatEntry->gis[glyphs[idx]].x)
|
|
|
|
extents.left = cur.x - formatEntry->gis[glyphs[idx]].x;
|
|
|
|
if(extents.top > cur.y - formatEntry->gis[glyphs[idx]].y)
|
|
|
|
extents.top = cur.y - formatEntry->gis[glyphs[idx]].y;
|
|
|
|
if(extents.right < cur.x - formatEntry->gis[glyphs[idx]].x + formatEntry->gis[glyphs[idx]].width)
|
|
|
|
extents.right = cur.x - formatEntry->gis[glyphs[idx]].x + formatEntry->gis[glyphs[idx]].width;
|
|
|
|
if(extents.bottom < cur.y - formatEntry->gis[glyphs[idx]].y + formatEntry->gis[glyphs[idx]].height)
|
|
|
|
extents.bottom = cur.y - formatEntry->gis[glyphs[idx]].y + formatEntry->gis[glyphs[idx]].height;
|
2002-11-14 23:31:34 +01:00
|
|
|
if(deltas) {
|
2004-01-15 07:19:35 +01:00
|
|
|
offset += X11DRV_XWStoDS(physDev, deltas[idx]);
|
2002-11-14 23:31:34 +01:00
|
|
|
cur.x = offset * cosEsc;
|
|
|
|
cur.y = offset * -sinEsc;
|
|
|
|
} else {
|
2005-01-24 20:08:02 +01:00
|
|
|
cur.x += formatEntry->gis[glyphs[idx]].xOff;
|
|
|
|
cur.y += formatEntry->gis[glyphs[idx]].yOff;
|
2002-11-14 23:31:34 +01:00
|
|
|
}
|
|
|
|
}
|
2003-01-08 22:09:25 +01:00
|
|
|
TRACE("glyph extents %ld,%ld - %ld,%ld drawable x,y %ld,%ld\n", extents.left, extents.top,
|
2002-11-14 23:31:34 +01:00
|
|
|
extents.right, extents.bottom, physDev->org.x + x, physDev->org.y + y);
|
|
|
|
|
|
|
|
if(physDev->org.x + x + extents.left >= 0) {
|
|
|
|
image_x = physDev->org.x + x + extents.left;
|
|
|
|
image_off_x = 0;
|
|
|
|
} else {
|
|
|
|
image_x = 0;
|
|
|
|
image_off_x = physDev->org.x + x + extents.left;
|
|
|
|
}
|
|
|
|
if(physDev->org.y + y + extents.top >= 0) {
|
|
|
|
image_y = physDev->org.y + y + extents.top;
|
|
|
|
image_off_y = 0;
|
|
|
|
} else {
|
|
|
|
image_y = 0;
|
|
|
|
image_off_y = physDev->org.y + y + extents.top;
|
|
|
|
}
|
|
|
|
if(physDev->org.x + x + extents.right < w)
|
|
|
|
image_w = physDev->org.x + x + extents.right - image_x;
|
|
|
|
else
|
|
|
|
image_w = w - image_x;
|
|
|
|
if(physDev->org.y + y + extents.bottom < h)
|
|
|
|
image_h = physDev->org.y + y + extents.bottom - image_y;
|
|
|
|
else
|
|
|
|
image_h = h - image_y;
|
|
|
|
|
|
|
|
if(image_w <= 0 || image_h <= 0) goto no_image;
|
|
|
|
|
|
|
|
X11DRV_expect_error(gdi_display, XRenderErrorHandler, NULL);
|
|
|
|
image = XGetImage(gdi_display, physDev->drawable,
|
|
|
|
image_x, image_y, image_w, image_h,
|
|
|
|
AllPlanes, ZPixmap);
|
|
|
|
X11DRV_check_error();
|
|
|
|
|
|
|
|
TRACE("XGetImage(%p, %x, %d, %d, %d, %d, %lx, %x) depth = %d rets %p\n",
|
|
|
|
gdi_display, (int)physDev->drawable, image_x, image_y,
|
|
|
|
image_w, image_h, AllPlanes, ZPixmap,
|
2004-01-18 23:20:17 +01:00
|
|
|
physDev->depth, image);
|
2002-11-14 23:31:34 +01:00
|
|
|
if(!image) {
|
|
|
|
Pixmap xpm = XCreatePixmap(gdi_display, physDev->drawable, image_w, image_h,
|
2004-01-18 23:20:17 +01:00
|
|
|
physDev->depth);
|
2002-11-14 23:31:34 +01:00
|
|
|
GC gc;
|
|
|
|
XGCValues gcv;
|
|
|
|
|
|
|
|
gcv.graphics_exposures = False;
|
|
|
|
gc = XCreateGC(gdi_display, xpm, GCGraphicsExposures, &gcv);
|
|
|
|
XCopyArea(gdi_display, physDev->drawable, xpm, gc, image_x, image_y,
|
|
|
|
image_w, image_h, 0, 0);
|
|
|
|
XFreeGC(gdi_display, gc);
|
|
|
|
X11DRV_expect_error(gdi_display, XRenderErrorHandler, NULL);
|
|
|
|
image = XGetImage(gdi_display, xpm, 0, 0, image_w, image_h, AllPlanes,
|
|
|
|
ZPixmap);
|
|
|
|
X11DRV_check_error();
|
|
|
|
XFreePixmap(gdi_display, xpm);
|
|
|
|
}
|
|
|
|
if(!image) goto no_image;
|
|
|
|
|
|
|
|
image->red_mask = visual->red_mask;
|
|
|
|
image->green_mask = visual->green_mask;
|
|
|
|
image->blue_mask = visual->blue_mask;
|
|
|
|
|
|
|
|
offset = xoff = yoff = 0;
|
|
|
|
for(idx = 0; idx < count; idx++) {
|
|
|
|
SmoothGlyphGray(image, xoff + image_off_x - extents.left,
|
|
|
|
yoff + image_off_y - extents.top,
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->bitmaps[glyphs[idx]],
|
|
|
|
&formatEntry->gis[glyphs[idx]],
|
2004-11-22 19:10:16 +01:00
|
|
|
physDev->textPixel);
|
2002-11-14 23:31:34 +01:00
|
|
|
if(deltas) {
|
2004-01-15 07:19:35 +01:00
|
|
|
offset += X11DRV_XWStoDS(physDev, deltas[idx]);
|
2002-11-14 23:31:34 +01:00
|
|
|
xoff = offset * cosEsc;
|
|
|
|
yoff = offset * -sinEsc;
|
|
|
|
} else {
|
2005-01-24 20:08:02 +01:00
|
|
|
xoff += formatEntry->gis[glyphs[idx]].xOff;
|
|
|
|
yoff += formatEntry->gis[glyphs[idx]].yOff;
|
2002-11-14 23:31:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
XPutImage(gdi_display, physDev->drawable, physDev->gc, image, 0, 0,
|
|
|
|
image_x, image_y, image_w, image_h);
|
|
|
|
XDestroyImage(image);
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
2002-11-27 21:14:32 +01:00
|
|
|
no_image:
|
2002-11-14 23:31:34 +01:00
|
|
|
wine_tsx11_unlock();
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
2002-06-22 03:01:34 +02:00
|
|
|
LeaveCriticalSection(&xrender_cs);
|
|
|
|
|
2004-07-22 21:44:10 +02:00
|
|
|
if (lf.lfUnderline || lf.lfStrikeOut) {
|
2004-11-19 19:10:47 +01:00
|
|
|
int underlinePos, strikeoutPos;
|
|
|
|
int underlineWidth, strikeoutWidth;
|
2004-07-22 21:44:10 +02:00
|
|
|
UINT nMetricsSize = GetOutlineTextMetricsW(hdc, 0, NULL);
|
2004-11-19 19:10:47 +01:00
|
|
|
OUTLINETEXTMETRICW* otm = NULL;
|
|
|
|
|
|
|
|
if(!nMetricsSize) {
|
|
|
|
underlinePos = 0;
|
|
|
|
underlineWidth = tm.tmAscent / 20 + 1;
|
|
|
|
strikeoutPos = tm.tmAscent / 2;
|
|
|
|
strikeoutWidth = underlineWidth;
|
|
|
|
} else {
|
|
|
|
otm = HeapAlloc(GetProcessHeap(), 0, nMetricsSize);
|
2005-03-14 11:03:39 +01:00
|
|
|
if (!otm) goto done_unlock;
|
2004-11-19 19:10:47 +01:00
|
|
|
|
|
|
|
GetOutlineTextMetricsW(hdc, nMetricsSize, otm);
|
|
|
|
underlinePos = otm->otmsUnderscorePosition;
|
|
|
|
underlineWidth = otm->otmsUnderscoreSize;
|
|
|
|
strikeoutPos = otm->otmsStrikeoutPosition;
|
|
|
|
strikeoutWidth = otm->otmsStrikeoutSize;
|
|
|
|
}
|
2004-07-22 21:44:10 +02:00
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XSetForeground( gdi_display, physDev->gc, physDev->textPixel );
|
|
|
|
|
|
|
|
if (lf.lfUnderline) {
|
2004-11-19 19:10:47 +01:00
|
|
|
underlinePos = X11DRV_YWStoDS(physDev, underlinePos);
|
|
|
|
underlineWidth = X11DRV_YWStoDS(physDev, underlineWidth);
|
2004-07-22 21:44:10 +02:00
|
|
|
|
2004-11-19 19:10:47 +01:00
|
|
|
XSetLineAttributes( gdi_display, physDev->gc, underlineWidth,
|
2004-07-22 21:44:10 +02:00
|
|
|
LineSolid, CapProjecting, JoinBevel );
|
|
|
|
XDrawLine( gdi_display, physDev->drawable, physDev->gc,
|
2004-11-19 19:10:47 +01:00
|
|
|
physDev->org.x + x - underlinePos * sinEsc,
|
|
|
|
physDev->org.y + y - underlinePos * cosEsc,
|
|
|
|
physDev->org.x + x + width * cosEsc - underlinePos * sinEsc,
|
|
|
|
physDev->org.y + y - width * sinEsc - underlinePos * cosEsc );
|
2004-07-22 21:44:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (lf.lfStrikeOut) {
|
2004-11-19 19:10:47 +01:00
|
|
|
strikeoutPos = X11DRV_YWStoDS(physDev, strikeoutPos);
|
|
|
|
strikeoutWidth = X11DRV_YWStoDS(physDev, strikeoutWidth);
|
2004-07-22 21:44:10 +02:00
|
|
|
|
2004-11-19 19:10:47 +01:00
|
|
|
XSetLineAttributes( gdi_display, physDev->gc, strikeoutWidth,
|
2004-07-22 21:44:10 +02:00
|
|
|
LineSolid, CapProjecting, JoinBevel );
|
|
|
|
XDrawLine( gdi_display, physDev->drawable, physDev->gc,
|
2004-11-19 19:10:47 +01:00
|
|
|
physDev->org.x + x - strikeoutPos * sinEsc,
|
|
|
|
physDev->org.y + y - strikeoutPos * cosEsc,
|
|
|
|
physDev->org.x + x + width * cosEsc - strikeoutPos * sinEsc,
|
|
|
|
physDev->org.y + y - width * sinEsc - strikeoutPos * cosEsc);
|
2004-07-22 21:44:10 +02:00
|
|
|
}
|
|
|
|
wine_tsx11_unlock();
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, otm);
|
2004-07-22 21:44:10 +02:00
|
|
|
}
|
|
|
|
|
2002-11-14 23:31:34 +01:00
|
|
|
if(deltas && deltas != lpDx)
|
|
|
|
HeapFree(GetProcessHeap(), 0, deltas);
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if (flags & ETO_CLIPPED)
|
2004-02-13 21:26:27 +01:00
|
|
|
{
|
|
|
|
/* restore the device region */
|
|
|
|
X11DRV_SetDeviceClipping( physDev, saved_region, 0 );
|
|
|
|
DeleteObject( saved_region );
|
|
|
|
}
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2002-06-22 03:01:34 +02:00
|
|
|
retv = TRUE;
|
|
|
|
|
2005-03-14 11:03:39 +01:00
|
|
|
done_unlock:
|
2002-03-28 23:22:05 +01:00
|
|
|
X11DRV_UnlockDIBSection( physDev, TRUE );
|
2005-03-14 11:03:39 +01:00
|
|
|
done:
|
2004-11-30 22:38:57 +01:00
|
|
|
if(glyphs != wstr) HeapFree(GetProcessHeap(), 0, (WORD*)glyphs);
|
2002-06-22 03:01:34 +02:00
|
|
|
return retv;
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
2005-04-20 17:18:42 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* AlphaBlend (x11drv.@)
|
|
|
|
*/
|
2004-08-02 20:54:54 +02:00
|
|
|
BOOL X11DRV_AlphaBlend(X11DRV_PDEVICE *devDst, INT xDst, INT yDst, INT widthDst, INT heightDst,
|
|
|
|
X11DRV_PDEVICE *devSrc, INT xSrc, INT ySrc, INT widthSrc, INT heightSrc,
|
2004-08-06 20:59:31 +02:00
|
|
|
BLENDFUNCTION blendfn)
|
2004-08-02 20:54:54 +02:00
|
|
|
{
|
|
|
|
XRenderPictureAttributes pa;
|
|
|
|
XRenderPictFormat *src_format;
|
|
|
|
Picture dst_pict, src_pict;
|
|
|
|
Pixmap xpm;
|
2005-03-31 21:05:48 +02:00
|
|
|
DIBSECTION dib;
|
2004-08-02 20:54:54 +02:00
|
|
|
XImage *image;
|
|
|
|
GC gc;
|
|
|
|
XGCValues gcv;
|
|
|
|
char *dstbits, *data;
|
|
|
|
int y;
|
|
|
|
POINT pts[2];
|
2004-08-04 20:15:42 +02:00
|
|
|
BOOL top_down = FALSE;
|
2004-08-02 20:54:54 +02:00
|
|
|
|
|
|
|
if(!X11DRV_XRender_Installed) {
|
|
|
|
FIXME("Unable to AlphaBlend without Xrender\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
pts[0].x = xDst;
|
|
|
|
pts[0].y = yDst;
|
|
|
|
pts[1].x = xDst + widthDst;
|
|
|
|
pts[1].y = yDst + heightDst;
|
|
|
|
LPtoDP(devDst->hdc, pts, 2);
|
|
|
|
xDst = pts[0].x;
|
|
|
|
yDst = pts[0].y;
|
|
|
|
widthDst = pts[1].x - pts[0].x;
|
|
|
|
heightDst = pts[1].y - pts[0].y;
|
|
|
|
|
|
|
|
pts[0].x = xSrc;
|
|
|
|
pts[0].y = ySrc;
|
|
|
|
pts[1].x = xSrc + widthSrc;
|
|
|
|
pts[1].y = ySrc + heightSrc;
|
|
|
|
LPtoDP(devSrc->hdc, pts, 2);
|
|
|
|
xSrc = pts[0].x;
|
|
|
|
ySrc = pts[0].y;
|
|
|
|
widthSrc = pts[1].x - pts[0].x;
|
|
|
|
heightSrc = pts[1].y - pts[0].y;
|
|
|
|
|
2004-10-27 02:43:50 +02:00
|
|
|
#ifndef HAVE_XRENDERSETPICTURETRANSFORM
|
|
|
|
if(widthDst != widthSrc || heightDst != heightSrc)
|
|
|
|
#else
|
|
|
|
if(!pXRenderSetPictureTransform)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
FIXME("Unable to Stretch, XRenderSetPictureTransform is currently required\n");
|
2004-08-02 20:54:54 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-04-12 13:59:48 +02:00
|
|
|
if (!devSrc->bitmap || GetObjectW( devSrc->bitmap->hbitmap, sizeof(dib), &dib ) != sizeof(dib))
|
2005-03-31 21:05:48 +02:00
|
|
|
{
|
2004-08-02 20:54:54 +02:00
|
|
|
FIXME("not a dibsection\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-03-31 21:05:48 +02:00
|
|
|
if(dib.dsBm.bmBitsPixel != 32) {
|
2004-08-02 20:54:54 +02:00
|
|
|
FIXME("not a 32 bpp dibsection\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
dstbits = data = HeapAlloc(GetProcessHeap(), 0, heightSrc * widthSrc * 4);
|
2004-08-04 20:15:42 +02:00
|
|
|
|
2005-03-31 21:05:48 +02:00
|
|
|
if(dib.dsBmih.biHeight < 0) { /* top-down dib */
|
2004-08-04 20:15:42 +02:00
|
|
|
top_down = TRUE;
|
|
|
|
dstbits += widthSrc * (heightSrc - 1) * 4;
|
|
|
|
}
|
2004-08-02 20:54:54 +02:00
|
|
|
for(y = ySrc + heightSrc - 1; y >= ySrc; y--) {
|
2005-03-31 21:05:48 +02:00
|
|
|
memcpy(dstbits, (char *)dib.dsBm.bmBits + y * dib.dsBm.bmWidthBytes + xSrc * 4,
|
2004-08-02 20:54:54 +02:00
|
|
|
widthSrc * 4);
|
2004-08-04 20:15:42 +02:00
|
|
|
dstbits += (top_down ? -1 : 1) * widthSrc * 4;
|
2004-08-02 20:54:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wine_tsx11_lock();
|
|
|
|
image = XCreateImage(gdi_display, visual, 32, ZPixmap, 0,
|
|
|
|
data, widthSrc, heightSrc, 32, widthSrc * 4);
|
|
|
|
|
|
|
|
src_format = pXRenderFindStandardFormat(gdi_display, PictStandardARGB32);
|
|
|
|
|
|
|
|
|
|
|
|
TRACE("src_format %p\n", src_format);
|
|
|
|
|
|
|
|
pa.subwindow_mode = IncludeInferiors;
|
|
|
|
|
|
|
|
/* FIXME use devDst->xrender->pict ? */
|
|
|
|
dst_pict = pXRenderCreatePicture(gdi_display,
|
|
|
|
devDst->drawable,
|
|
|
|
(devDst->depth == 1) ?
|
|
|
|
mono_format : screen_format,
|
|
|
|
CPSubwindowMode, &pa);
|
|
|
|
TRACE("dst_pict %08lx\n", dst_pict);
|
|
|
|
TRACE("src_drawable = %08lx\n", devSrc->drawable);
|
|
|
|
xpm = XCreatePixmap(gdi_display,
|
|
|
|
devSrc->drawable,
|
|
|
|
widthSrc, heightSrc, 32);
|
|
|
|
gcv.graphics_exposures = False;
|
|
|
|
gc = XCreateGC(gdi_display, xpm, GCGraphicsExposures, &gcv);
|
|
|
|
TRACE("xpm = %08lx\n", xpm);
|
|
|
|
XPutImage(gdi_display, xpm, gc, image, 0, 0, 0, 0, widthSrc, heightSrc);
|
|
|
|
|
|
|
|
src_pict = pXRenderCreatePicture(gdi_display,
|
|
|
|
xpm, src_format,
|
|
|
|
CPSubwindowMode, &pa);
|
|
|
|
TRACE("src_pict %08lx\n", src_pict);
|
|
|
|
|
2004-10-27 02:43:50 +02:00
|
|
|
#ifdef HAVE_XRENDERSETPICTURETRANSFORM
|
|
|
|
if(widthDst != widthSrc || heightDst != heightSrc) {
|
|
|
|
double xscale = widthSrc/(double)widthDst;
|
|
|
|
double yscale = heightSrc/(double)heightDst;
|
|
|
|
XTransform xform = {{
|
|
|
|
{ XDoubleToFixed(xscale), XDoubleToFixed(0), XDoubleToFixed(0) },
|
|
|
|
{ XDoubleToFixed(0), XDoubleToFixed(yscale), XDoubleToFixed(0) },
|
|
|
|
{ XDoubleToFixed(0), XDoubleToFixed(0), XDoubleToFixed(1) }
|
|
|
|
}};
|
|
|
|
pXRenderSetPictureTransform(gdi_display, src_pict, &xform);
|
|
|
|
}
|
|
|
|
#endif
|
2004-08-02 20:54:54 +02:00
|
|
|
pXRenderComposite(gdi_display, PictOpOver, src_pict, 0, dst_pict,
|
|
|
|
xSrc, ySrc, 0, 0,
|
2004-11-09 21:02:57 +01:00
|
|
|
xDst + devDst->org.x, yDst + devDst->org.y, widthDst, heightDst);
|
2004-08-02 20:54:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
pXRenderFreePicture(gdi_display, src_pict);
|
|
|
|
XFreePixmap(gdi_display, xpm);
|
|
|
|
XFreeGC(gdi_display, gc);
|
|
|
|
pXRenderFreePicture(gdi_display, dst_pict);
|
|
|
|
image->data = NULL;
|
|
|
|
XDestroyImage(image);
|
|
|
|
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-04-24 00:06:41 +02:00
|
|
|
#else /* HAVE_X11_EXTENSIONS_XRENDER_H */
|
2002-01-29 04:07:21 +01:00
|
|
|
|
|
|
|
void X11DRV_XRender_Init(void)
|
|
|
|
{
|
|
|
|
TRACE("XRender support not compiled in.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void X11DRV_XRender_Finalize(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
BOOL X11DRV_XRender_SelectFont(X11DRV_PDEVICE *physDev, HFONT hfont)
|
2002-01-29 04:07:21 +01:00
|
|
|
{
|
|
|
|
assert(0);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
void X11DRV_XRender_DeleteDC(X11DRV_PDEVICE *physDev)
|
2002-01-29 04:07:21 +01:00
|
|
|
{
|
|
|
|
assert(0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
|
2002-01-29 04:07:21 +01:00
|
|
|
const RECT *lprect, LPCWSTR wstr, UINT count,
|
2004-03-04 02:42:57 +01:00
|
|
|
const INT *lpDx, INT breakExtra )
|
2002-01-29 04:07:21 +01:00
|
|
|
{
|
|
|
|
assert(0);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
void X11DRV_XRender_UpdateDrawable(X11DRV_PDEVICE *physDev)
|
2002-01-29 04:07:21 +01:00
|
|
|
{
|
|
|
|
assert(0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-04-20 17:18:42 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* AlphaBlend (x11drv.@)
|
|
|
|
*/
|
2004-08-02 20:54:54 +02:00
|
|
|
BOOL X11DRV_AlphaBlend(X11DRV_PDEVICE *devDst, INT xDst, INT yDst, INT widthDst, INT heightDst,
|
|
|
|
X11DRV_PDEVICE *devSrc, INT xSrc, INT ySrc, INT widthSrc, INT heightSrc,
|
2004-08-06 20:59:31 +02:00
|
|
|
BLENDFUNCTION blendfn)
|
2004-08-02 20:54:54 +02:00
|
|
|
{
|
|
|
|
FIXME("not supported - XRENDER headers were missing at compile time\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-04-24 00:06:41 +02:00
|
|
|
#endif /* HAVE_X11_EXTENSIONS_XRENDER_H */
|