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
|
2009-09-26 14:52:46 +02:00
|
|
|
* Copyright 2009 Roderick Colenbrander
|
2011-09-19 17:46:33 +02:00
|
|
|
* Copyright 2011 Alexandre Julliard
|
2002-11-14 23:31:34 +01:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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-01-29 04:07:21 +01:00
|
|
|
#include "x11drv.h"
|
2005-09-12 13:11:30 +02:00
|
|
|
#include "winternl.h"
|
2004-01-20 23:04:00 +01:00
|
|
|
#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-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(xrender);
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2007-07-04 12:47:57 +02:00
|
|
|
#ifdef SONAME_LIBXRENDER
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2011-11-17 20:44:26 +01:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(winediag);
|
|
|
|
|
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
|
|
|
|
2009-05-20 18:22:41 +02:00
|
|
|
#ifndef RepeatNone /* added in 0.10 */
|
|
|
|
#define RepeatNone 0
|
|
|
|
#define RepeatNormal 1
|
|
|
|
#define RepeatPad 2
|
|
|
|
#define RepeatReflect 3
|
|
|
|
#endif
|
2007-07-03 16:18:55 +02:00
|
|
|
|
2011-09-15 15:35:32 +02:00
|
|
|
enum wxr_format
|
2009-07-05 20:35:01 +02:00
|
|
|
{
|
|
|
|
WXR_FORMAT_MONO,
|
2009-07-05 21:03:48 +02:00
|
|
|
WXR_FORMAT_GRAY,
|
2009-07-05 20:35:01 +02:00
|
|
|
WXR_FORMAT_X1R5G5B5,
|
|
|
|
WXR_FORMAT_X1B5G5R5,
|
|
|
|
WXR_FORMAT_R5G6B5,
|
|
|
|
WXR_FORMAT_B5G6R5,
|
|
|
|
WXR_FORMAT_R8G8B8,
|
|
|
|
WXR_FORMAT_B8G8R8,
|
|
|
|
WXR_FORMAT_A8R8G8B8,
|
2010-04-15 15:55:40 +02:00
|
|
|
WXR_FORMAT_B8G8R8A8,
|
2009-07-05 20:35:01 +02:00
|
|
|
WXR_FORMAT_X8R8G8B8,
|
2010-04-15 15:55:40 +02:00
|
|
|
WXR_FORMAT_B8G8R8X8,
|
2011-09-15 15:26:44 +02:00
|
|
|
WXR_NB_FORMATS,
|
|
|
|
WXR_INVALID_FORMAT = WXR_NB_FORMATS
|
2011-09-15 15:35:32 +02:00
|
|
|
};
|
2009-07-05 20:35:01 +02:00
|
|
|
|
|
|
|
typedef struct wine_xrender_format_template
|
|
|
|
{
|
|
|
|
unsigned int depth;
|
|
|
|
unsigned int alpha;
|
|
|
|
unsigned int alphaMask;
|
|
|
|
unsigned int red;
|
|
|
|
unsigned int redMask;
|
|
|
|
unsigned int green;
|
|
|
|
unsigned int greenMask;
|
|
|
|
unsigned int blue;
|
|
|
|
unsigned int blueMask;
|
|
|
|
} WineXRenderFormatTemplate;
|
|
|
|
|
2010-04-15 15:55:40 +02:00
|
|
|
static const WineXRenderFormatTemplate wxr_formats_template[WXR_NB_FORMATS] =
|
2009-07-05 20:35:01 +02:00
|
|
|
{
|
|
|
|
/* Format depth alpha mask red mask green mask blue mask*/
|
2011-09-15 15:33:59 +02:00
|
|
|
/* WXR_FORMAT_MONO */ { 1, 0, 0x01, 0, 0, 0, 0, 0, 0 },
|
|
|
|
/* WXR_FORMAT_GRAY */ { 8, 0, 0xff, 0, 0, 0, 0, 0, 0 },
|
|
|
|
/* WXR_FORMAT_X1R5G5B5 */ { 16, 0, 0, 10, 0x1f, 5, 0x1f, 0, 0x1f },
|
|
|
|
/* WXR_FORMAT_X1B5G5R5 */ { 16, 0, 0, 0, 0x1f, 5, 0x1f, 10, 0x1f },
|
|
|
|
/* WXR_FORMAT_R5G6B5 */ { 16, 0, 0, 11, 0x1f, 5, 0x3f, 0, 0x1f },
|
|
|
|
/* WXR_FORMAT_B5G6R5 */ { 16, 0, 0, 0, 0x1f, 5, 0x3f, 11, 0x1f },
|
|
|
|
/* WXR_FORMAT_R8G8B8 */ { 24, 0, 0, 16, 0xff, 8, 0xff, 0, 0xff },
|
|
|
|
/* WXR_FORMAT_B8G8R8 */ { 24, 0, 0, 0, 0xff, 8, 0xff, 16, 0xff },
|
|
|
|
/* WXR_FORMAT_A8R8G8B8 */ { 32, 24, 0xff, 16, 0xff, 8, 0xff, 0, 0xff },
|
|
|
|
/* WXR_FORMAT_B8G8R8A8 */ { 32, 0, 0xff, 8, 0xff, 16, 0xff, 24, 0xff },
|
|
|
|
/* WXR_FORMAT_X8R8G8B8 */ { 32, 0, 0, 16, 0xff, 8, 0xff, 0, 0xff },
|
|
|
|
/* WXR_FORMAT_B8G8R8X8 */ { 32, 0, 0, 8, 0xff, 16, 0xff, 24, 0xff },
|
2009-07-05 20:35:01 +02:00
|
|
|
};
|
|
|
|
|
2011-09-26 16:56:55 +02:00
|
|
|
static const ColorShifts wxr_color_shifts[WXR_NB_FORMATS] =
|
|
|
|
{
|
|
|
|
/* format phys red phys green phys blue log red log green log blue */
|
|
|
|
/* WXR_FORMAT_MONO */ { { 0,0,0 }, { 0,0,0 }, { 0,0,0 }, { 0,0,0 }, { 0,0,0 }, { 0,0,0 } },
|
|
|
|
/* WXR_FORMAT_GRAY */ { { 0,0,0 }, { 0,0,0 }, { 0,0,0 }, { 0,0,0 }, { 0,0,0 }, { 0,0,0 } },
|
|
|
|
/* WXR_FORMAT_X1R5G5B5 */ { {10,5,31}, { 5,5,31}, { 0,5,31}, {10,5,31}, { 5,5,31}, { 0,5,31} },
|
|
|
|
/* WXR_FORMAT_X1B5G5R5 */ { { 0,5,31}, { 5,5,31}, {10,5,31}, { 0,5,31}, { 5,5,31}, {10,5,31} },
|
|
|
|
/* WXR_FORMAT_R5G6B5 */ { {11,5,31}, { 5,6,63}, { 0,5,31}, {11,5,31}, { 5,6,63}, { 0,5,31} },
|
|
|
|
/* WXR_FORMAT_B5G6R5 */ { { 0,5,31}, { 5,6,63}, {11,5,31}, { 0,5,31}, { 5,6,63}, {11,5,31} },
|
|
|
|
/* WXR_FORMAT_R8G8B8 */ { {16,8,255}, { 8,8,255}, { 0,8,255}, {16,8,255}, { 8,8,255}, { 0,8,255} },
|
|
|
|
/* WXR_FORMAT_B8G8R8 */ { { 0,8,255}, { 8,8,255}, {16,8,255}, { 0,8,255}, { 8,8,255}, {16,8,255} },
|
|
|
|
/* WXR_FORMAT_A8R8G8B8 */ { {16,8,255}, { 8,8,255}, { 0,8,255}, {16,8,255}, { 8,8,255}, { 0,8,255} },
|
|
|
|
/* WXR_FORMAT_B8G8R8A8 */ { { 8,8,255}, {16,8,255}, {24,8,255}, { 8,8,255}, {16,8,255}, {24,8,255} },
|
|
|
|
/* WXR_FORMAT_X8R8G8B8 */ { {16,8,255}, { 8,8,255}, { 0,8,255}, {16,8,255}, { 8,8,255}, { 0,8,255} },
|
|
|
|
/* WXR_FORMAT_B8G8R8X8 */ { { 8,8,255}, {16,8,255}, {24,8,255}, { 8,8,255}, {16,8,255}, {24,8,255} },
|
|
|
|
};
|
|
|
|
|
2011-09-26 15:25:35 +02:00
|
|
|
static enum wxr_format default_format = WXR_INVALID_FORMAT;
|
2011-09-15 15:26:44 +02:00
|
|
|
static XRenderPictFormat *pict_formats[WXR_NB_FORMATS + 1 /* invalid format */];
|
2011-09-15 15:10:17 +02:00
|
|
|
|
2002-01-29 04:07:21 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2002-11-14 23:31:34 +01:00
|
|
|
LOGFONTW lf;
|
2009-03-02 10:22:59 +01:00
|
|
|
XFORM xform;
|
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;
|
2011-09-15 15:10:17 +02:00
|
|
|
XRenderPictFormat *font_format;
|
2002-11-14 23:31:34 +01:00
|
|
|
int nrealized;
|
|
|
|
BOOL *realized;
|
|
|
|
XGlyphInfo *gis;
|
2005-01-24 20:08:02 +01:00
|
|
|
} gsCacheEntryFormat;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
LFANDSIZE lfsz;
|
|
|
|
AA_Type aa_default;
|
|
|
|
gsCacheEntryFormat * format[AA_MAXVALUE];
|
2005-07-15 18:34:04 +02:00
|
|
|
INT count;
|
2002-11-14 23:31:34 +01:00
|
|
|
INT next;
|
2002-01-29 04:07:21 +01:00
|
|
|
} gsCacheEntry;
|
|
|
|
|
2011-09-15 13:21:45 +02:00
|
|
|
struct xrender_physdev
|
2002-01-29 04:07:21 +01:00
|
|
|
{
|
2011-09-15 13:21:45 +02:00
|
|
|
struct gdi_physdev dev;
|
|
|
|
X11DRV_PDEVICE *x11dev;
|
2012-01-10 20:26:26 +01:00
|
|
|
HRGN region;
|
2011-09-15 15:26:44 +02:00
|
|
|
enum wxr_format format;
|
2002-06-22 03:01:34 +02:00
|
|
|
int cache_index;
|
2011-09-20 11:51:43 +02:00
|
|
|
BOOL update_clip;
|
2002-01-29 04:07:21 +01:00
|
|
|
Picture pict;
|
2009-10-14 13:15:01 +02:00
|
|
|
Picture pict_src;
|
2011-09-15 15:10:17 +02:00
|
|
|
XRenderPictFormat *pict_format;
|
2002-01-29 04:07:21 +01:00
|
|
|
};
|
|
|
|
|
2011-09-12 11:39:17 +02:00
|
|
|
static inline struct xrender_physdev *get_xrender_dev( PHYSDEV dev )
|
|
|
|
{
|
|
|
|
return (struct xrender_physdev *)dev;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct gdi_dc_funcs xrender_funcs;
|
|
|
|
|
2002-01-29 04:07:21 +01:00
|
|
|
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-04-24 00:06:41 +02:00
|
|
|
static void *xrender_handle;
|
|
|
|
|
|
|
|
#define MAKE_FUNCPTR(f) static typeof(f) * p##f;
|
|
|
|
MAKE_FUNCPTR(XRenderAddGlyphs)
|
2011-12-06 14:00:14 +01:00
|
|
|
MAKE_FUNCPTR(XRenderChangePicture)
|
2004-08-02 20:54:54 +02:00
|
|
|
MAKE_FUNCPTR(XRenderComposite)
|
2007-05-24 16:06:44 +02:00
|
|
|
MAKE_FUNCPTR(XRenderCompositeText16)
|
2002-04-24 00:06:41 +02:00
|
|
|
MAKE_FUNCPTR(XRenderCreateGlyphSet)
|
|
|
|
MAKE_FUNCPTR(XRenderCreatePicture)
|
|
|
|
MAKE_FUNCPTR(XRenderFillRectangle)
|
|
|
|
MAKE_FUNCPTR(XRenderFindFormat)
|
|
|
|
MAKE_FUNCPTR(XRenderFindVisualFormat)
|
|
|
|
MAKE_FUNCPTR(XRenderFreeGlyphSet)
|
|
|
|
MAKE_FUNCPTR(XRenderFreePicture)
|
|
|
|
MAKE_FUNCPTR(XRenderSetPictureClipRectangles)
|
2011-11-30 13:22:21 +01:00
|
|
|
#ifdef HAVE_XRENDERCREATELINEARGRADIENT
|
|
|
|
MAKE_FUNCPTR(XRenderCreateLinearGradient)
|
|
|
|
#endif
|
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)
|
2010-05-17 11:48:12 +02:00
|
|
|
|
|
|
|
#ifdef SONAME_LIBFONTCONFIG
|
|
|
|
#include <fontconfig/fontconfig.h>
|
|
|
|
MAKE_FUNCPTR(FcConfigSubstitute)
|
|
|
|
MAKE_FUNCPTR(FcDefaultSubstitute)
|
|
|
|
MAKE_FUNCPTR(FcFontMatch)
|
|
|
|
MAKE_FUNCPTR(FcInit)
|
|
|
|
MAKE_FUNCPTR(FcPatternCreate)
|
|
|
|
MAKE_FUNCPTR(FcPatternDestroy)
|
|
|
|
MAKE_FUNCPTR(FcPatternAddInteger)
|
|
|
|
MAKE_FUNCPTR(FcPatternAddString)
|
2010-05-24 12:34:28 +02:00
|
|
|
MAKE_FUNCPTR(FcPatternGetBool)
|
2010-05-17 11:48:12 +02:00
|
|
|
MAKE_FUNCPTR(FcPatternGetInteger)
|
2010-05-19 19:49:15 +02:00
|
|
|
MAKE_FUNCPTR(FcPatternGetString)
|
2010-05-19 11:26:44 +02:00
|
|
|
static void *fontconfig_handle;
|
2010-05-17 11:48:12 +02:00
|
|
|
static BOOL fontconfig_installed;
|
|
|
|
#endif
|
|
|
|
|
2002-04-24 00:06:41 +02:00
|
|
|
#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 },
|
2005-09-09 12:19:44 +02:00
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": xrender_cs") }
|
2003-08-13 01:50:54 +02:00
|
|
|
};
|
|
|
|
static CRITICAL_SECTION xrender_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
|
2002-06-22 03:01:34 +02:00
|
|
|
|
2005-09-12 13:11:30 +02:00
|
|
|
#define MS_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
|
|
|
|
( ( (ULONG)_x4 << 24 ) | \
|
|
|
|
( (ULONG)_x3 << 16 ) | \
|
|
|
|
( (ULONG)_x2 << 8 ) | \
|
|
|
|
(ULONG)_x1 )
|
|
|
|
|
|
|
|
#define MS_GASP_TAG MS_MAKE_TAG('g', 'a', 's', 'p')
|
|
|
|
|
|
|
|
#define GASP_GRIDFIT 0x01
|
|
|
|
#define GASP_DOGRAY 0x02
|
|
|
|
|
|
|
|
#ifdef WORDS_BIGENDIAN
|
|
|
|
#define get_be_word(x) (x)
|
2008-12-10 15:50:44 +01:00
|
|
|
#define NATIVE_BYTE_ORDER MSBFirst
|
2005-09-12 13:11:30 +02:00
|
|
|
#else
|
|
|
|
#define get_be_word(x) RtlUshortByteSwap(x)
|
2008-12-10 15:50:44 +01:00
|
|
|
#define NATIVE_BYTE_ORDER LSBFirst
|
2005-09-12 13:11:30 +02:00
|
|
|
#endif
|
2002-06-22 03:01:34 +02:00
|
|
|
|
2011-10-03 23:47:31 +02:00
|
|
|
static BOOL has_alpha( enum wxr_format format )
|
|
|
|
{
|
|
|
|
return (format == WXR_FORMAT_A8R8G8B8 || format == WXR_FORMAT_B8G8R8A8);
|
|
|
|
}
|
|
|
|
|
2011-09-15 15:35:32 +02:00
|
|
|
static enum wxr_format get_format_without_alpha( enum wxr_format format )
|
2010-04-15 15:55:40 +02:00
|
|
|
{
|
|
|
|
switch (format)
|
|
|
|
{
|
|
|
|
case WXR_FORMAT_A8R8G8B8: return WXR_FORMAT_X8R8G8B8;
|
|
|
|
case WXR_FORMAT_B8G8R8A8: return WXR_FORMAT_B8G8R8X8;
|
|
|
|
default: return format;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-05 20:35:01 +02:00
|
|
|
static BOOL get_xrender_template(const WineXRenderFormatTemplate *fmt, XRenderPictFormat *templ, unsigned long *mask)
|
|
|
|
{
|
|
|
|
templ->id = 0;
|
|
|
|
templ->type = PictTypeDirect;
|
|
|
|
templ->depth = fmt->depth;
|
|
|
|
templ->direct.alpha = fmt->alpha;
|
|
|
|
templ->direct.alphaMask = fmt->alphaMask;
|
|
|
|
templ->direct.red = fmt->red;
|
|
|
|
templ->direct.redMask = fmt->redMask;
|
|
|
|
templ->direct.green = fmt->green;
|
|
|
|
templ->direct.greenMask = fmt->greenMask;
|
|
|
|
templ->direct.blue = fmt->blue;
|
|
|
|
templ->direct.blueMask = fmt->blueMask;
|
|
|
|
templ->colormap = 0;
|
|
|
|
|
|
|
|
*mask = PictFormatType | PictFormatDepth | PictFormatAlpha | PictFormatAlphaMask | PictFormatRed | PictFormatRedMask | PictFormatGreen | PictFormatGreenMask | PictFormatBlue | PictFormatBlueMask;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL is_wxrformat_compatible_with_default_visual(const WineXRenderFormatTemplate *fmt)
|
|
|
|
{
|
2012-09-25 15:51:03 +02:00
|
|
|
if(fmt->depth != default_visual.depth) return FALSE;
|
|
|
|
if( (fmt->redMask << fmt->red) != default_visual.red_mask) return FALSE;
|
|
|
|
if( (fmt->greenMask << fmt->green) != default_visual.green_mask) return FALSE;
|
|
|
|
if( (fmt->blueMask << fmt->blue) != default_visual.blue_mask) return FALSE;
|
2009-07-05 20:35:01 +02:00
|
|
|
|
|
|
|
/* We never select a default ARGB visual */
|
2012-09-25 15:51:03 +02:00
|
|
|
if(fmt->alphaMask) return FALSE;
|
2009-07-05 20:35:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int load_xrender_formats(void)
|
|
|
|
{
|
2011-09-15 15:26:44 +02:00
|
|
|
int count = 0;
|
2009-07-05 20:35:01 +02:00
|
|
|
unsigned int i;
|
2011-09-15 15:26:44 +02:00
|
|
|
|
2011-09-15 15:33:59 +02:00
|
|
|
for (i = 0; i < WXR_NB_FORMATS; i++)
|
2009-07-05 20:35:01 +02:00
|
|
|
{
|
2011-09-15 15:33:59 +02:00
|
|
|
XRenderPictFormat templ;
|
2009-07-05 20:35:01 +02:00
|
|
|
|
|
|
|
if(is_wxrformat_compatible_with_default_visual(&wxr_formats_template[i]))
|
|
|
|
{
|
2012-09-25 15:51:03 +02:00
|
|
|
pict_formats[i] = pXRenderFindVisualFormat(gdi_display, default_visual.visual);
|
2011-09-15 15:33:59 +02:00
|
|
|
if (!pict_formats[i])
|
2009-07-05 20:35:01 +02:00
|
|
|
{
|
|
|
|
/* Xrender doesn't like DirectColor visuals, try to find a TrueColor one instead */
|
2012-09-25 15:51:03 +02:00
|
|
|
if (default_visual.class == DirectColor)
|
2009-07-05 20:35:01 +02:00
|
|
|
{
|
|
|
|
XVisualInfo info;
|
2012-09-25 15:51:03 +02:00
|
|
|
if (XMatchVisualInfo( gdi_display, default_visual.screen,
|
|
|
|
default_visual.depth, TrueColor, &info ))
|
2009-07-05 20:35:01 +02:00
|
|
|
{
|
2011-09-15 15:33:59 +02:00
|
|
|
pict_formats[i] = pXRenderFindVisualFormat(gdi_display, info.visual);
|
2012-09-25 15:51:03 +02:00
|
|
|
if (pict_formats[i]) default_visual = info;
|
2009-07-05 20:35:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-09-15 15:33:59 +02:00
|
|
|
if (pict_formats[i]) default_format = i;
|
2009-07-05 20:35:01 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned long mask = 0;
|
|
|
|
get_xrender_template(&wxr_formats_template[i], &templ, &mask);
|
2011-09-15 15:33:59 +02:00
|
|
|
pict_formats[i] = pXRenderFindFormat(gdi_display, mask, &templ, 0);
|
|
|
|
}
|
|
|
|
if (pict_formats[i])
|
|
|
|
{
|
|
|
|
count++;
|
|
|
|
TRACE("Loaded pict_format with id=%#lx for wxr_format=%#x\n", pict_formats[i]->id, i);
|
2009-07-05 20:35:01 +02:00
|
|
|
}
|
|
|
|
}
|
2011-09-15 15:26:44 +02:00
|
|
|
return count;
|
2009-07-05 20:35:01 +02:00
|
|
|
}
|
|
|
|
|
2002-01-29 04:07:21 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_XRender_Init
|
|
|
|
*
|
|
|
|
* Let's see if our XServer has the extension available
|
|
|
|
*
|
|
|
|
*/
|
2011-09-12 11:39:17 +02:00
|
|
|
const struct gdi_dc_funcs *X11DRV_XRender_Init(void)
|
2002-01-29 04:07:21 +01:00
|
|
|
{
|
2006-04-01 14:21:31 +02:00
|
|
|
int event_base, i;
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2011-11-17 20:44:26 +01:00
|
|
|
if (!client_side_with_render) return NULL;
|
|
|
|
if (!(xrender_handle = wine_dlopen(SONAME_LIBXRENDER, RTLD_NOW, NULL, 0))) return NULL;
|
|
|
|
|
|
|
|
#define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(xrender_handle, #f, NULL, 0)) == NULL) return NULL
|
2011-11-30 13:22:21 +01:00
|
|
|
#define LOAD_OPTIONAL_FUNCPTR(f) p##f = wine_dlsym(xrender_handle, #f, NULL, 0)
|
2011-11-17 20:44:26 +01:00
|
|
|
LOAD_FUNCPTR(XRenderAddGlyphs);
|
2011-12-06 14:00:14 +01:00
|
|
|
LOAD_FUNCPTR(XRenderChangePicture);
|
2011-11-17 20:44:26 +01:00
|
|
|
LOAD_FUNCPTR(XRenderComposite);
|
|
|
|
LOAD_FUNCPTR(XRenderCompositeText16);
|
|
|
|
LOAD_FUNCPTR(XRenderCreateGlyphSet);
|
|
|
|
LOAD_FUNCPTR(XRenderCreatePicture);
|
|
|
|
LOAD_FUNCPTR(XRenderFillRectangle);
|
|
|
|
LOAD_FUNCPTR(XRenderFindFormat);
|
|
|
|
LOAD_FUNCPTR(XRenderFindVisualFormat);
|
|
|
|
LOAD_FUNCPTR(XRenderFreeGlyphSet);
|
|
|
|
LOAD_FUNCPTR(XRenderFreePicture);
|
|
|
|
LOAD_FUNCPTR(XRenderSetPictureClipRectangles);
|
|
|
|
LOAD_FUNCPTR(XRenderQueryExtension);
|
2011-11-30 13:22:21 +01:00
|
|
|
#ifdef HAVE_XRENDERCREATELINEARGRADIENT
|
|
|
|
LOAD_OPTIONAL_FUNCPTR(XRenderCreateLinearGradient);
|
|
|
|
#endif
|
2004-10-27 02:43:50 +02:00
|
|
|
#ifdef HAVE_XRENDERSETPICTURETRANSFORM
|
2011-11-17 20:44:26 +01:00
|
|
|
LOAD_OPTIONAL_FUNCPTR(XRenderSetPictureTransform);
|
2004-10-27 02:43:50 +02:00
|
|
|
#endif
|
2011-11-30 13:22:21 +01:00
|
|
|
#undef LOAD_OPTIONAL_FUNCPTR
|
|
|
|
#undef LOAD_FUNCPTR
|
2004-10-27 02:43:50 +02:00
|
|
|
|
2012-08-14 13:38:03 +02:00
|
|
|
if (!pXRenderQueryExtension(gdi_display, &event_base, &xrender_error_base)) return NULL;
|
2009-07-05 20:35:01 +02:00
|
|
|
|
2011-11-17 20:44:26 +01:00
|
|
|
TRACE("Xrender is up and running error_base = %d\n", xrender_error_base);
|
|
|
|
if(!load_xrender_formats()) /* This fails in buggy versions of libXrender.so */
|
|
|
|
{
|
|
|
|
ERR_(winediag)("Wine has detected that you probably have a buggy version "
|
|
|
|
"of libXrender. Because of this client side font rendering "
|
|
|
|
"will be disabled. Please upgrade this library.\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-09-25 15:51:03 +02:00
|
|
|
if (!default_visual.red_mask || !default_visual.green_mask || !default_visual.blue_mask)
|
2011-11-17 20:44:26 +01:00
|
|
|
{
|
|
|
|
WARN("one or more of the colour masks are 0, disabling XRENDER. Try running in 16-bit mode or higher.\n");
|
|
|
|
return NULL;
|
2002-11-14 23:31:34 +01:00
|
|
|
}
|
|
|
|
|
2010-05-19 11:26:44 +02:00
|
|
|
#ifdef SONAME_LIBFONTCONFIG
|
2010-05-17 11:48:12 +02:00
|
|
|
if ((fontconfig_handle = wine_dlopen(SONAME_LIBFONTCONFIG, RTLD_NOW, NULL, 0)))
|
|
|
|
{
|
|
|
|
#define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(fontconfig_handle, #f, NULL, 0)) == NULL){WARN("Can't find symbol %s\n", #f); goto sym_not_found;}
|
|
|
|
LOAD_FUNCPTR(FcConfigSubstitute);
|
|
|
|
LOAD_FUNCPTR(FcDefaultSubstitute);
|
|
|
|
LOAD_FUNCPTR(FcFontMatch);
|
|
|
|
LOAD_FUNCPTR(FcInit);
|
|
|
|
LOAD_FUNCPTR(FcPatternCreate);
|
|
|
|
LOAD_FUNCPTR(FcPatternDestroy);
|
|
|
|
LOAD_FUNCPTR(FcPatternAddInteger);
|
|
|
|
LOAD_FUNCPTR(FcPatternAddString);
|
2010-05-24 12:34:28 +02:00
|
|
|
LOAD_FUNCPTR(FcPatternGetBool);
|
2010-05-17 11:48:12 +02:00
|
|
|
LOAD_FUNCPTR(FcPatternGetInteger);
|
2010-05-19 19:49:15 +02:00
|
|
|
LOAD_FUNCPTR(FcPatternGetString);
|
2010-05-17 11:48:12 +02:00
|
|
|
#undef LOAD_FUNCPTR
|
|
|
|
fontconfig_installed = pFcInit();
|
|
|
|
}
|
|
|
|
else TRACE( "cannot find the fontconfig library " SONAME_LIBFONTCONFIG "\n" );
|
|
|
|
|
2002-11-14 23:31:34 +01:00
|
|
|
sym_not_found:
|
2011-11-26 23:34:52 +01:00
|
|
|
#endif
|
|
|
|
|
2011-11-17 20:44:26 +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;
|
2002-11-14 23:31:34 +01:00
|
|
|
}
|
2011-11-17 20:44:26 +01:00
|
|
|
glyphsetCache[i-1].next = -1;
|
|
|
|
|
2012-09-25 15:51:03 +02:00
|
|
|
if(default_visual.depth <= 8 || !client_side_antialias_with_render) antialias = 0;
|
2011-11-17 20:44:26 +01:00
|
|
|
|
|
|
|
return &xrender_funcs;
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
2009-07-06 23:01:07 +02:00
|
|
|
/* Helper function to convert from a color packed in a 32-bit integer to a XRenderColor */
|
2012-01-10 20:54:40 +01:00
|
|
|
static void get_xrender_color( struct xrender_physdev *physdev, COLORREF src_color, XRenderColor *dst_color )
|
2009-07-06 23:01:07 +02:00
|
|
|
{
|
2012-01-10 20:54:40 +01:00
|
|
|
if (src_color & (1 << 24)) /* PALETTEINDEX */
|
|
|
|
{
|
|
|
|
HPALETTE pal = GetCurrentObject( physdev->dev.hdc, OBJ_PAL );
|
|
|
|
PALETTEENTRY pal_ent;
|
|
|
|
|
|
|
|
if (!GetPaletteEntries( pal, LOWORD(src_color), 1, &pal_ent ))
|
|
|
|
GetPaletteEntries( pal, 0, 1, &pal_ent );
|
|
|
|
dst_color->red = pal_ent.peRed * 257;
|
|
|
|
dst_color->green = pal_ent.peGreen * 257;
|
|
|
|
dst_color->blue = pal_ent.peBlue * 257;
|
|
|
|
}
|
2009-07-06 23:01:07 +02:00
|
|
|
else
|
2012-01-10 20:54:40 +01:00
|
|
|
{
|
|
|
|
if (src_color >> 16 == 0x10ff) src_color = 0; /* DIBINDEX */
|
2009-07-06 23:01:07 +02:00
|
|
|
|
2012-01-10 20:54:40 +01:00
|
|
|
dst_color->red = GetRValue( src_color ) * 257;
|
|
|
|
dst_color->green = GetGValue( src_color ) * 257;
|
|
|
|
dst_color->blue = GetBValue( src_color ) * 257;
|
|
|
|
}
|
2009-07-06 23:01:07 +02:00
|
|
|
|
2012-01-10 20:54:40 +01:00
|
|
|
if (physdev->format == WXR_FORMAT_MONO && !dst_color->red && !dst_color->green && !dst_color->blue)
|
|
|
|
dst_color->alpha = 0;
|
2009-07-06 23:01:07 +02:00
|
|
|
else
|
2012-01-10 20:54:40 +01:00
|
|
|
dst_color->alpha = 0xffff;
|
2009-07-06 23:01:07 +02:00
|
|
|
}
|
|
|
|
|
2011-10-11 11:53:02 +02:00
|
|
|
static enum wxr_format get_xrender_format_from_bitmapinfo( const BITMAPINFO *info )
|
2011-09-19 17:46:33 +02:00
|
|
|
{
|
|
|
|
if (info->bmiHeader.biPlanes != 1) return WXR_INVALID_FORMAT;
|
|
|
|
|
|
|
|
switch (info->bmiHeader.biBitCount)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
return WXR_FORMAT_MONO;
|
|
|
|
case 4:
|
|
|
|
case 8:
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
if (info->bmiHeader.biCompression != BI_RGB) break;
|
|
|
|
return WXR_FORMAT_R8G8B8;
|
|
|
|
case 16:
|
|
|
|
case 32:
|
|
|
|
if (info->bmiHeader.biCompression == BI_BITFIELDS)
|
|
|
|
{
|
|
|
|
DWORD *colors = (DWORD *)((char *)info + info->bmiHeader.biSize);
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < WXR_NB_FORMATS; i++)
|
|
|
|
{
|
|
|
|
if (info->bmiHeader.biBitCount == wxr_formats_template[i].depth &&
|
|
|
|
colors[0] == (wxr_formats_template[i].redMask << wxr_formats_template[i].red) &&
|
|
|
|
colors[1] == (wxr_formats_template[i].greenMask << wxr_formats_template[i].green) &&
|
|
|
|
colors[2] == (wxr_formats_template[i].blueMask << wxr_formats_template[i].blue))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (info->bmiHeader.biCompression != BI_RGB) break;
|
2011-10-11 11:53:02 +02:00
|
|
|
return (info->bmiHeader.biBitCount == 16) ? WXR_FORMAT_X1R5G5B5 : WXR_FORMAT_A8R8G8B8;
|
2011-09-19 17:46:33 +02:00
|
|
|
}
|
|
|
|
return WXR_INVALID_FORMAT;
|
|
|
|
}
|
|
|
|
|
2009-10-08 17:24:46 +02:00
|
|
|
/* Set the x/y scaling and x/y offsets in the transformation matrix of the source picture */
|
2010-04-15 12:13:16 +02:00
|
|
|
static void set_xrender_transformation(Picture src_pict, double xscale, double yscale, int xoffset, int yoffset)
|
2009-10-08 17:24:46 +02:00
|
|
|
{
|
|
|
|
#ifdef HAVE_XRENDERSETPICTURETRANSFORM
|
|
|
|
XTransform xform = {{
|
|
|
|
{ XDoubleToFixed(xscale), XDoubleToFixed(0), XDoubleToFixed(xoffset) },
|
|
|
|
{ XDoubleToFixed(0), XDoubleToFixed(yscale), XDoubleToFixed(yoffset) },
|
|
|
|
{ XDoubleToFixed(0), XDoubleToFixed(0), XDoubleToFixed(1) }
|
|
|
|
}};
|
|
|
|
|
|
|
|
pXRenderSetPictureTransform(gdi_display, src_pict, &xform);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-12-06 14:00:14 +01:00
|
|
|
static void update_xrender_clipping( struct xrender_physdev *dev, HRGN rgn )
|
|
|
|
{
|
|
|
|
XRenderPictureAttributes pa;
|
|
|
|
RGNDATA *data;
|
|
|
|
|
|
|
|
if (!rgn)
|
|
|
|
{
|
|
|
|
pa.clip_mask = None;
|
|
|
|
pXRenderChangePicture( gdi_display, dev->pict, CPClipMask, &pa );
|
|
|
|
}
|
|
|
|
else if ((data = X11DRV_GetRegionData( rgn, 0 )))
|
|
|
|
{
|
|
|
|
pXRenderSetPictureClipRectangles( gdi_display, dev->pict,
|
|
|
|
dev->x11dev->dc_rect.left, dev->x11dev->dc_rect.top,
|
|
|
|
(XRectangle *)data->Buffer, data->rdh.nCount );
|
|
|
|
HeapFree( GetProcessHeap(), 0, data );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-20 11:51:43 +02:00
|
|
|
static Picture get_xrender_picture( struct xrender_physdev *dev, HRGN clip_rgn, const RECT *clip_rect )
|
2009-10-08 17:24:46 +02:00
|
|
|
{
|
2011-09-15 15:10:17 +02:00
|
|
|
if (!dev->pict && dev->pict_format)
|
2009-10-08 17:24:46 +02:00
|
|
|
{
|
2009-10-13 12:21:53 +02:00
|
|
|
XRenderPictureAttributes pa;
|
|
|
|
|
|
|
|
pa.subwindow_mode = IncludeInferiors;
|
2011-09-15 13:21:45 +02:00
|
|
|
dev->pict = pXRenderCreatePicture( gdi_display, dev->x11dev->drawable,
|
2011-09-15 15:10:17 +02:00
|
|
|
dev->pict_format, CPSubwindowMode, &pa );
|
2011-09-15 13:21:45 +02:00
|
|
|
TRACE( "Allocing pict=%lx dc=%p drawable=%08lx\n",
|
|
|
|
dev->pict, dev->dev.hdc, dev->x11dev->drawable );
|
2012-01-10 20:26:26 +01:00
|
|
|
dev->update_clip = (dev->region != 0);
|
2009-10-08 17:24:46 +02:00
|
|
|
}
|
|
|
|
|
2011-12-06 14:00:14 +01:00
|
|
|
if (clip_rect)
|
2011-09-20 11:51:43 +02:00
|
|
|
{
|
2011-12-06 14:00:14 +01:00
|
|
|
HRGN rgn = CreateRectRgnIndirect( clip_rect );
|
|
|
|
if (clip_rgn) CombineRgn( rgn, rgn, clip_rgn, RGN_AND );
|
2012-01-10 20:26:26 +01:00
|
|
|
if (dev->region) CombineRgn( rgn, rgn, dev->region, RGN_AND );
|
2011-12-06 14:00:14 +01:00
|
|
|
update_xrender_clipping( dev, rgn );
|
|
|
|
DeleteObject( rgn );
|
|
|
|
}
|
|
|
|
else if (clip_rgn)
|
|
|
|
{
|
2012-01-10 20:26:26 +01:00
|
|
|
if (dev->region)
|
2011-09-20 11:51:43 +02:00
|
|
|
{
|
2011-12-06 14:00:14 +01:00
|
|
|
HRGN rgn = CreateRectRgn( 0, 0, 0, 0 );
|
2012-01-10 20:26:26 +01:00
|
|
|
CombineRgn( rgn, clip_rgn, dev->region, RGN_AND );
|
2011-12-06 14:00:14 +01:00
|
|
|
update_xrender_clipping( dev, rgn );
|
|
|
|
DeleteObject( rgn );
|
2011-09-20 11:51:43 +02:00
|
|
|
}
|
2011-12-06 14:00:14 +01:00
|
|
|
else update_xrender_clipping( dev, clip_rgn );
|
2011-09-20 11:51:43 +02:00
|
|
|
}
|
2012-01-10 20:26:26 +01:00
|
|
|
else if (dev->update_clip) update_xrender_clipping( dev, dev->region );
|
2011-12-06 14:00:14 +01:00
|
|
|
|
|
|
|
dev->update_clip = (clip_rect || clip_rgn); /* have to update again if we are using a custom region */
|
2011-09-15 13:21:45 +02:00
|
|
|
return dev->pict;
|
2009-10-08 17:24:46 +02:00
|
|
|
}
|
|
|
|
|
2011-09-15 13:21:45 +02:00
|
|
|
static Picture get_xrender_picture_source( struct xrender_physdev *dev, BOOL repeat )
|
2009-10-14 13:15:01 +02:00
|
|
|
{
|
2011-09-15 15:10:17 +02:00
|
|
|
if (!dev->pict_src && dev->pict_format)
|
2009-10-14 13:15:01 +02:00
|
|
|
{
|
|
|
|
XRenderPictureAttributes pa;
|
|
|
|
|
|
|
|
pa.subwindow_mode = IncludeInferiors;
|
2010-04-15 13:47:28 +02:00
|
|
|
pa.repeat = repeat ? RepeatNormal : RepeatNone;
|
2011-09-15 13:21:45 +02:00
|
|
|
dev->pict_src = pXRenderCreatePicture( gdi_display, dev->x11dev->drawable,
|
2011-09-15 15:10:17 +02:00
|
|
|
dev->pict_format, CPSubwindowMode|CPRepeat, &pa );
|
2009-10-14 13:15:01 +02:00
|
|
|
|
2010-04-15 13:47:28 +02:00
|
|
|
TRACE("Allocing pict_src=%lx dc=%p drawable=%08lx repeat=%u\n",
|
2011-09-15 13:21:45 +02:00
|
|
|
dev->pict_src, dev->dev.hdc, dev->x11dev->drawable, pa.repeat);
|
2009-10-14 13:15:01 +02:00
|
|
|
}
|
|
|
|
|
2011-09-15 13:21:45 +02:00
|
|
|
return dev->pict_src;
|
2009-10-14 13:15:01 +02:00
|
|
|
}
|
|
|
|
|
2011-09-12 11:39:56 +02:00
|
|
|
static void free_xrender_picture( struct xrender_physdev *dev )
|
|
|
|
{
|
2011-09-15 13:21:45 +02:00
|
|
|
if (dev->pict || dev->pict_src)
|
2011-09-12 11:39:56 +02:00
|
|
|
{
|
|
|
|
XFlush( gdi_display );
|
2011-09-15 13:21:45 +02:00
|
|
|
if (dev->pict)
|
2011-09-12 11:39:56 +02:00
|
|
|
{
|
2011-09-15 13:21:45 +02:00
|
|
|
TRACE("freeing pict = %lx dc = %p\n", dev->pict, dev->dev.hdc);
|
|
|
|
pXRenderFreePicture(gdi_display, dev->pict);
|
|
|
|
dev->pict = 0;
|
2011-09-12 11:39:56 +02:00
|
|
|
}
|
2011-09-15 13:21:45 +02:00
|
|
|
if(dev->pict_src)
|
2011-09-12 11:39:56 +02:00
|
|
|
{
|
2011-09-15 13:21:45 +02:00
|
|
|
TRACE("freeing pict = %lx dc = %p\n", dev->pict_src, dev->dev.hdc);
|
|
|
|
pXRenderFreePicture(gdi_display, dev->pict_src);
|
|
|
|
dev->pict_src = 0;
|
2011-09-12 11:39:56 +02:00
|
|
|
}
|
|
|
|
}
|
2011-09-12 12:04:41 +02:00
|
|
|
}
|
|
|
|
|
2010-05-18 14:11:51 +02:00
|
|
|
/* return a mask picture used to force alpha to 0 */
|
|
|
|
static Picture get_no_alpha_mask(void)
|
|
|
|
{
|
|
|
|
static Pixmap pixmap;
|
|
|
|
static Picture pict;
|
|
|
|
|
2012-08-14 14:43:28 +02:00
|
|
|
EnterCriticalSection( &xrender_cs );
|
2010-05-18 14:11:51 +02:00
|
|
|
if (!pict)
|
|
|
|
{
|
|
|
|
XRenderPictureAttributes pa;
|
|
|
|
XRenderColor col;
|
|
|
|
|
|
|
|
pixmap = XCreatePixmap( gdi_display, root_window, 1, 1, 32 );
|
|
|
|
pa.repeat = RepeatNormal;
|
|
|
|
pa.component_alpha = True;
|
2011-09-15 15:10:17 +02:00
|
|
|
pict = pXRenderCreatePicture( gdi_display, pixmap, pict_formats[WXR_FORMAT_A8R8G8B8],
|
2010-05-18 14:11:51 +02:00
|
|
|
CPRepeat|CPComponentAlpha, &pa );
|
|
|
|
col.red = col.green = col.blue = 0xffff;
|
|
|
|
col.alpha = 0;
|
|
|
|
pXRenderFillRectangle( gdi_display, PictOpSrc, pict, &col, 0, 0, 1, 1 );
|
|
|
|
}
|
2012-08-14 14:43:28 +02:00
|
|
|
LeaveCriticalSection( &xrender_cs );
|
2010-05-18 14:11:51 +02:00
|
|
|
return pict;
|
|
|
|
}
|
|
|
|
|
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;
|
2009-03-02 10:22:59 +01:00
|
|
|
if(memcmp(&p1->xform, &p2->xform, sizeof(p1->xform))) return TRUE;
|
2002-01-29 04:07:21 +01:00
|
|
|
if(memcmp(&p1->lf, &p2->lf, offsetof(LOGFONTW, lfFaceName))) return TRUE;
|
2009-03-02 10:22:59 +01:00
|
|
|
return strcmpiW(p1->lf.lfFaceName, p2->lf.lfFaceName);
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
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);
|
2011-07-06 10:34:44 +02:00
|
|
|
if(glyphsetCache[i].count == -1) break; /* reached free list so stop */
|
2002-01-29 04:07:21 +01:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2011-11-17 20:26:23 +01:00
|
|
|
int format;
|
|
|
|
|
2005-01-24 20:08:02 +01:00
|
|
|
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) {
|
|
|
|
pXRenderFreeGlyphSet(gdi_display, formatEntry->glyphset);
|
|
|
|
formatEntry->glyphset = 0;
|
|
|
|
}
|
|
|
|
if(formatEntry->nrealized) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, formatEntry->realized);
|
|
|
|
formatEntry->realized = NULL;
|
2007-05-24 16:06:44 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, formatEntry->gis);
|
|
|
|
formatEntry->gis = NULL;
|
2005-01-24 20:08:02 +01:00
|
|
|
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
|
|
|
|
2011-09-12 13:27:31 +02:00
|
|
|
static BOOL get_gasp_flags(HDC hdc, WORD *flags)
|
2005-09-12 13:11:30 +02:00
|
|
|
{
|
|
|
|
DWORD size;
|
2005-09-19 16:40:18 +02:00
|
|
|
WORD *gasp, *buffer;
|
2005-09-12 13:11:30 +02:00
|
|
|
WORD num_recs;
|
|
|
|
DWORD ppem;
|
|
|
|
TEXTMETRICW tm;
|
|
|
|
|
|
|
|
*flags = 0;
|
|
|
|
|
2011-09-12 13:27:31 +02:00
|
|
|
size = GetFontData(hdc, MS_GASP_TAG, 0, NULL, 0);
|
2005-09-12 13:11:30 +02:00
|
|
|
if(size == GDI_ERROR)
|
|
|
|
return FALSE;
|
|
|
|
|
2005-09-19 16:40:18 +02:00
|
|
|
gasp = buffer = HeapAlloc(GetProcessHeap(), 0, size);
|
2011-09-12 13:27:31 +02:00
|
|
|
GetFontData(hdc, MS_GASP_TAG, 0, gasp, size);
|
2005-09-12 13:11:30 +02:00
|
|
|
|
2011-09-12 13:27:31 +02:00
|
|
|
GetTextMetricsW(hdc, &tm);
|
|
|
|
ppem = abs(X11DRV_YWStoDS(hdc, tm.tmAscent + tm.tmDescent - tm.tmInternalLeading));
|
2005-09-12 13:11:30 +02:00
|
|
|
|
|
|
|
gasp++;
|
|
|
|
num_recs = get_be_word(*gasp);
|
|
|
|
gasp++;
|
|
|
|
while(num_recs--)
|
|
|
|
{
|
|
|
|
*flags = get_be_word(*(gasp + 1));
|
|
|
|
if(ppem <= get_be_word(*gasp))
|
|
|
|
break;
|
|
|
|
gasp += 2;
|
|
|
|
}
|
2006-10-08 01:34:01 +02:00
|
|
|
TRACE("got flags %04x for ppem %d\n", *flags, ppem);
|
2005-09-12 13:11:30 +02:00
|
|
|
|
2005-09-19 16:40:18 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
2005-09-12 13:11:30 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-09-12 13:27:31 +02:00
|
|
|
static AA_Type get_antialias_type( HDC hdc, BOOL subpixel, BOOL hinter )
|
2008-12-31 03:43:42 +01:00
|
|
|
{
|
|
|
|
AA_Type ret;
|
|
|
|
WORD flags;
|
|
|
|
UINT font_smoothing_type, font_smoothing_orientation;
|
|
|
|
|
2012-01-10 17:49:39 +01:00
|
|
|
if (subpixel &&
|
2008-12-31 03:43:42 +01:00
|
|
|
SystemParametersInfoW( SPI_GETFONTSMOOTHINGTYPE, 0, &font_smoothing_type, 0) &&
|
|
|
|
font_smoothing_type == FE_FONTSMOOTHINGCLEARTYPE)
|
|
|
|
{
|
|
|
|
if ( SystemParametersInfoW( SPI_GETFONTSMOOTHINGORIENTATION, 0,
|
|
|
|
&font_smoothing_orientation, 0) &&
|
|
|
|
font_smoothing_orientation == FE_FONTSMOOTHINGORIENTATIONBGR)
|
|
|
|
{
|
|
|
|
ret = AA_BGR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = AA_RGB;
|
|
|
|
/*FIXME
|
|
|
|
If the monitor is in portrait mode, ClearType is disabled in the MS Windows (MSDN).
|
|
|
|
But, Wine's subpixel rendering can support the portrait mode.
|
|
|
|
*/
|
|
|
|
}
|
2011-09-12 13:27:31 +02:00
|
|
|
else if (!hinter || !get_gasp_flags(hdc, &flags) || flags & GASP_DOGRAY)
|
2008-12-31 03:43:42 +01:00
|
|
|
ret = AA_Grey;
|
|
|
|
else
|
|
|
|
ret = AA_None;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-09-12 13:27:31 +02:00
|
|
|
static int GetCacheEntry( HDC hdc, 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;
|
2005-10-06 14:28:19 +02:00
|
|
|
static int hinter = -1;
|
2008-12-10 15:50:44 +01:00
|
|
|
static int subpixel = -1;
|
2008-12-31 03:43:42 +01:00
|
|
|
BOOL font_smoothing;
|
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-09-12 13:11:30 +02:00
|
|
|
{
|
2008-12-10 15:50:44 +01:00
|
|
|
if(hinter == -1 || subpixel == -1)
|
2005-10-06 14:28:19 +02:00
|
|
|
{
|
|
|
|
RASTERIZER_STATUS status;
|
|
|
|
GetRasterizerCaps(&status, sizeof(status));
|
|
|
|
hinter = status.wFlags & WINE_TT_HINTER_ENABLED;
|
2008-12-10 15:50:44 +01:00
|
|
|
subpixel = status.wFlags & WINE_TT_SUBPIXEL_RENDERING_ENABLED;
|
2005-10-06 14:28:19 +02:00
|
|
|
}
|
2008-12-10 15:50:44 +01:00
|
|
|
|
2008-12-31 03:43:42 +01:00
|
|
|
switch (plfsz->lf.lfQuality)
|
|
|
|
{
|
|
|
|
case ANTIALIASED_QUALITY:
|
2011-09-12 13:27:31 +02:00
|
|
|
entry->aa_default = get_antialias_type( hdc, FALSE, hinter );
|
2010-06-02 10:55:19 +02:00
|
|
|
return ret; /* ignore further configuration */
|
2008-12-31 03:43:42 +01:00
|
|
|
case CLEARTYPE_QUALITY:
|
|
|
|
case CLEARTYPE_NATURAL_QUALITY:
|
2011-09-12 13:27:31 +02:00
|
|
|
entry->aa_default = get_antialias_type( hdc, subpixel, hinter );
|
2008-12-31 03:43:42 +01:00
|
|
|
break;
|
|
|
|
case DEFAULT_QUALITY:
|
|
|
|
case DRAFT_QUALITY:
|
|
|
|
case PROOF_QUALITY:
|
|
|
|
default:
|
|
|
|
if ( SystemParametersInfoW( SPI_GETFONTSMOOTHING, 0, &font_smoothing, 0) &&
|
|
|
|
font_smoothing)
|
|
|
|
{
|
2011-09-12 13:27:31 +02:00
|
|
|
entry->aa_default = get_antialias_type( hdc, subpixel, hinter );
|
2008-12-31 03:43:42 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
entry->aa_default = AA_None;
|
|
|
|
break;
|
|
|
|
}
|
2010-05-17 11:48:12 +02:00
|
|
|
|
2010-06-29 14:58:31 +02:00
|
|
|
font_smoothing = TRUE; /* default to enabled */
|
2010-05-17 11:48:12 +02:00
|
|
|
#ifdef SONAME_LIBFONTCONFIG
|
|
|
|
if (fontconfig_installed)
|
|
|
|
{
|
2011-10-28 12:41:14 +02:00
|
|
|
FcPattern *match, *pattern;
|
2010-05-17 11:48:12 +02:00
|
|
|
FcResult result;
|
|
|
|
char family[LF_FACESIZE * 4];
|
|
|
|
|
2011-10-28 12:41:14 +02:00
|
|
|
#if defined(__i386__) && defined(__GNUC__)
|
|
|
|
/* fontconfig generates floating point exceptions, mask them */
|
|
|
|
WORD cw, default_cw = 0x37f;
|
|
|
|
__asm__ __volatile__("fnstcw %0; fldcw %1" : "=m" (cw) : "m" (default_cw));
|
|
|
|
#endif
|
|
|
|
|
2010-05-17 11:48:12 +02:00
|
|
|
WideCharToMultiByte( CP_UTF8, 0, plfsz->lf.lfFaceName, -1, family, sizeof(family), NULL, NULL );
|
2011-10-28 12:41:14 +02:00
|
|
|
pattern = pFcPatternCreate();
|
2010-05-17 11:48:12 +02:00
|
|
|
pFcPatternAddString( pattern, FC_FAMILY, (FcChar8 *)family );
|
|
|
|
if (plfsz->lf.lfWeight != FW_DONTCARE)
|
|
|
|
{
|
|
|
|
int weight;
|
|
|
|
switch (plfsz->lf.lfWeight)
|
|
|
|
{
|
|
|
|
case FW_THIN: weight = FC_WEIGHT_THIN; break;
|
|
|
|
case FW_EXTRALIGHT: weight = FC_WEIGHT_EXTRALIGHT; break;
|
|
|
|
case FW_LIGHT: weight = FC_WEIGHT_LIGHT; break;
|
|
|
|
case FW_NORMAL: weight = FC_WEIGHT_NORMAL; break;
|
|
|
|
case FW_MEDIUM: weight = FC_WEIGHT_MEDIUM; break;
|
|
|
|
case FW_SEMIBOLD: weight = FC_WEIGHT_SEMIBOLD; break;
|
|
|
|
case FW_BOLD: weight = FC_WEIGHT_BOLD; break;
|
|
|
|
case FW_EXTRABOLD: weight = FC_WEIGHT_EXTRABOLD; break;
|
|
|
|
case FW_HEAVY: weight = FC_WEIGHT_HEAVY; break;
|
|
|
|
default: weight = (plfsz->lf.lfWeight - 80) / 4; break;
|
|
|
|
}
|
|
|
|
pFcPatternAddInteger( pattern, FC_WEIGHT, weight );
|
|
|
|
}
|
|
|
|
pFcPatternAddInteger( pattern, FC_SLANT, plfsz->lf.lfItalic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN );
|
|
|
|
pFcConfigSubstitute( NULL, pattern, FcMatchPattern );
|
|
|
|
pFcDefaultSubstitute( pattern );
|
|
|
|
if ((match = pFcFontMatch( NULL, pattern, &result )))
|
|
|
|
{
|
|
|
|
int rgba;
|
2010-05-24 12:34:28 +02:00
|
|
|
FcBool antialias;
|
2010-05-17 11:48:12 +02:00
|
|
|
|
2010-05-24 12:34:28 +02:00
|
|
|
if (pFcPatternGetBool( match, FC_ANTIALIAS, 0, &antialias ) != FcResultMatch)
|
|
|
|
antialias = TRUE;
|
2010-05-17 11:48:12 +02:00
|
|
|
if (pFcPatternGetInteger( match, FC_RGBA, 0, &rgba ) == FcResultMatch)
|
|
|
|
{
|
2010-05-19 19:49:15 +02:00
|
|
|
FcChar8 *file;
|
|
|
|
if (pFcPatternGetString( match, FC_FILE, 0, &file ) != FcResultMatch) file = NULL;
|
|
|
|
|
2010-05-24 12:34:28 +02:00
|
|
|
TRACE( "fontconfig returned rgba %u antialias %u for font %s file %s\n",
|
|
|
|
rgba, antialias, debugstr_w(plfsz->lf.lfFaceName), debugstr_a((char *)file) );
|
2010-05-19 19:49:15 +02:00
|
|
|
|
2010-05-17 11:48:12 +02:00
|
|
|
switch (rgba)
|
|
|
|
{
|
|
|
|
case FC_RGBA_RGB: entry->aa_default = AA_RGB; break;
|
|
|
|
case FC_RGBA_BGR: entry->aa_default = AA_BGR; break;
|
|
|
|
case FC_RGBA_VRGB: entry->aa_default = AA_VRGB; break;
|
|
|
|
case FC_RGBA_VBGR: entry->aa_default = AA_VBGR; break;
|
2010-06-29 14:58:31 +02:00
|
|
|
case FC_RGBA_NONE: entry->aa_default = AA_Grey; break;
|
2010-05-17 11:48:12 +02:00
|
|
|
}
|
|
|
|
}
|
2010-06-29 14:58:31 +02:00
|
|
|
if (!antialias) font_smoothing = FALSE;
|
2010-05-17 11:48:12 +02:00
|
|
|
pFcPatternDestroy( match );
|
|
|
|
}
|
|
|
|
pFcPatternDestroy( pattern );
|
2011-10-28 12:41:14 +02:00
|
|
|
|
|
|
|
#if defined(__i386__) && defined(__GNUC__)
|
|
|
|
__asm__ __volatile__("fnclex; fldcw %0" : : "m" (cw));
|
|
|
|
#endif
|
2010-05-17 11:48:12 +02:00
|
|
|
}
|
|
|
|
#endif /* SONAME_LIBFONTCONFIG */
|
2010-05-24 12:34:55 +02:00
|
|
|
|
|
|
|
/* now check Xft resources */
|
|
|
|
{
|
|
|
|
char *value;
|
|
|
|
BOOL antialias = TRUE;
|
|
|
|
|
|
|
|
if ((value = XGetDefault( gdi_display, "Xft", "antialias" )))
|
|
|
|
{
|
|
|
|
if (tolower(value[0]) == 'f' || tolower(value[0]) == 'n' ||
|
|
|
|
value[0] == '0' || !strcasecmp( value, "off" ))
|
|
|
|
antialias = FALSE;
|
|
|
|
}
|
|
|
|
if ((value = XGetDefault( gdi_display, "Xft", "rgba" )))
|
|
|
|
{
|
|
|
|
TRACE( "Xft resource returned rgba '%s' antialias %u\n", value, antialias );
|
|
|
|
if (!strcmp( value, "rgb" )) entry->aa_default = AA_RGB;
|
|
|
|
else if (!strcmp( value, "bgr" )) entry->aa_default = AA_BGR;
|
|
|
|
else if (!strcmp( value, "vrgb" )) entry->aa_default = AA_VRGB;
|
|
|
|
else if (!strcmp( value, "vbgr" )) entry->aa_default = AA_VBGR;
|
2010-06-29 14:58:31 +02:00
|
|
|
else if (!strcmp( value, "none" )) entry->aa_default = AA_Grey;
|
2010-05-24 12:34:55 +02:00
|
|
|
}
|
2010-06-29 14:58:31 +02:00
|
|
|
if (!antialias) font_smoothing = FALSE;
|
2010-05-24 12:34:55 +02:00
|
|
|
}
|
2010-05-29 10:42:29 +02:00
|
|
|
|
2010-06-29 14:58:31 +02:00
|
|
|
if (!font_smoothing) entry->aa_default = AA_None;
|
2005-09-12 13:11:30 +02:00
|
|
|
}
|
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)
|
|
|
|
{
|
2009-03-02 10:22:59 +01:00
|
|
|
DWORD hash = 0, *ptr, two_chars;
|
|
|
|
WORD *pwc;
|
2002-01-29 04:07:21 +01:00
|
|
|
int i;
|
|
|
|
|
2004-03-04 04:55:52 +01:00
|
|
|
hash ^= plfsz->devsize.cx;
|
|
|
|
hash ^= plfsz->devsize.cy;
|
2009-03-02 10:22:59 +01:00
|
|
|
for(i = 0, ptr = (DWORD*)&plfsz->xform; i < sizeof(XFORM)/sizeof(DWORD); i++, ptr++)
|
|
|
|
hash ^= *ptr;
|
2002-01-29 04:07:21 +01:00
|
|
|
for(i = 0, ptr = (DWORD*)&plfsz->lf; i < 7; i++, ptr++)
|
|
|
|
hash ^= *ptr;
|
2008-07-12 21:37:27 +02:00
|
|
|
for(i = 0, ptr = (DWORD*)plfsz->lf.lfFaceName; i < LF_FACESIZE/2; i++, ptr++) {
|
2009-03-02 10:22:59 +01:00
|
|
|
two_chars = *ptr;
|
|
|
|
pwc = (WCHAR *)&two_chars;
|
2002-01-29 04:07:21 +01:00
|
|
|
if(!*pwc) break;
|
2009-03-02 10:22:59 +01:00
|
|
|
*pwc = toupperW(*pwc);
|
2002-01-29 04:07:21 +01:00
|
|
|
pwc++;
|
2009-03-02 10:22:59 +01:00
|
|
|
*pwc = toupperW(*pwc);
|
|
|
|
hash ^= two_chars;
|
2002-01-29 04:07:21 +01:00
|
|
|
if(!*pwc) break;
|
|
|
|
}
|
|
|
|
plfsz->hash = hash;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-09-12 11:50:42 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* xrenderdrv_SelectFont
|
2002-01-29 04:07:21 +01:00
|
|
|
*/
|
2011-10-18 13:10:58 +02:00
|
|
|
static HFONT xrenderdrv_SelectFont( PHYSDEV dev, HFONT hfont )
|
2002-01-29 04:07:21 +01:00
|
|
|
{
|
2012-04-18 13:07:17 +02:00
|
|
|
LFANDSIZE lfsz;
|
2011-09-12 11:50:42 +02:00
|
|
|
struct xrender_physdev *physdev = get_xrender_dev( dev );
|
2011-10-18 13:10:58 +02:00
|
|
|
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSelectFont );
|
|
|
|
HFONT ret = next->funcs->pSelectFont( next, hfont );
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2011-10-18 13:10:58 +02:00
|
|
|
if (!ret) return 0;
|
2011-09-12 11:50:42 +02:00
|
|
|
|
2012-04-18 13:07:17 +02:00
|
|
|
GetObjectW( hfont, sizeof(lfsz.lf), &lfsz.lf );
|
2011-09-12 11:50:42 +02:00
|
|
|
|
2012-04-18 13:07:17 +02:00
|
|
|
TRACE("h=%d w=%d weight=%d 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));
|
|
|
|
lfsz.lf.lfWidth = abs( lfsz.lf.lfWidth );
|
|
|
|
lfsz.devsize.cx = X11DRV_XWStoDS( dev->hdc, lfsz.lf.lfWidth );
|
|
|
|
lfsz.devsize.cy = X11DRV_YWStoDS( dev->hdc, lfsz.lf.lfHeight );
|
2011-01-24 11:40:13 +01:00
|
|
|
|
2012-04-18 13:07:17 +02:00
|
|
|
GetTransform( dev->hdc, 0x204, &lfsz.xform );
|
|
|
|
TRACE("font transform %f %f %f %f\n", lfsz.xform.eM11, lfsz.xform.eM12,
|
|
|
|
lfsz.xform.eM21, lfsz.xform.eM22);
|
2011-01-24 11:40:13 +01:00
|
|
|
|
2012-04-18 13:07:17 +02:00
|
|
|
if (GetGraphicsMode( dev->hdc ) == GM_COMPATIBLE && lfsz.xform.eM11 * lfsz.xform.eM22 < 0)
|
|
|
|
lfsz.lf.lfOrientation = -lfsz.lf.lfOrientation;
|
2010-11-29 10:17:26 +01:00
|
|
|
|
2012-04-18 13:07:17 +02:00
|
|
|
/* Not used fields, would break hashing */
|
|
|
|
lfsz.xform.eDx = lfsz.xform.eDy = 0;
|
2012-02-16 13:22:02 +01:00
|
|
|
|
2012-04-18 13:07:17 +02:00
|
|
|
lfsz_calc_hash(&lfsz);
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2012-04-18 13:07:17 +02:00
|
|
|
EnterCriticalSection(&xrender_cs);
|
|
|
|
if (physdev->cache_index != -1)
|
|
|
|
dec_ref_cache( physdev->cache_index );
|
|
|
|
physdev->cache_index = GetCacheEntry( dev->hdc, &lfsz );
|
|
|
|
LeaveCriticalSection(&xrender_cs);
|
2011-10-18 13:10:58 +02:00
|
|
|
return ret;
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
2011-09-26 15:25:35 +02:00
|
|
|
static BOOL create_xrender_dc( PHYSDEV *pdev, enum wxr_format format )
|
2011-09-12 11:39:56 +02:00
|
|
|
{
|
|
|
|
X11DRV_PDEVICE *x11dev = get_x11drv_dev( *pdev );
|
|
|
|
struct xrender_physdev *physdev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physdev) );
|
|
|
|
|
|
|
|
if (!physdev) return FALSE;
|
|
|
|
physdev->x11dev = x11dev;
|
2011-09-15 13:21:45 +02:00
|
|
|
physdev->cache_index = -1;
|
2011-09-26 15:25:35 +02:00
|
|
|
physdev->format = format;
|
|
|
|
physdev->pict_format = pict_formats[format];
|
2011-09-12 11:39:56 +02:00
|
|
|
push_dc_driver( pdev, &physdev->dev, &xrender_funcs );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-09-19 17:46:33 +02:00
|
|
|
/* store the color mask data in the bitmap info structure */
|
|
|
|
static void set_color_info( XRenderPictFormat *format, BITMAPINFO *info )
|
|
|
|
{
|
|
|
|
DWORD *colors = (DWORD *)((char *)info + info->bmiHeader.biSize);
|
|
|
|
|
|
|
|
info->bmiHeader.biPlanes = 1;
|
|
|
|
info->bmiHeader.biBitCount = pixmap_formats[format->depth]->bits_per_pixel;
|
|
|
|
info->bmiHeader.biCompression = BI_RGB;
|
|
|
|
info->bmiHeader.biClrUsed = 0;
|
|
|
|
|
|
|
|
switch (info->bmiHeader.biBitCount)
|
|
|
|
{
|
|
|
|
case 16:
|
|
|
|
colors[0] = format->direct.redMask << format->direct.red;
|
|
|
|
colors[1] = format->direct.greenMask << format->direct.green;
|
|
|
|
colors[2] = format->direct.blueMask << format->direct.blue;
|
|
|
|
info->bmiHeader.biCompression = BI_BITFIELDS;
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
colors[0] = format->direct.redMask << format->direct.red;
|
|
|
|
colors[1] = format->direct.greenMask << format->direct.green;
|
|
|
|
colors[2] = format->direct.blueMask << format->direct.blue;
|
|
|
|
if (colors[0] != 0xff0000 || colors[1] != 0x00ff00 || colors[2] != 0x0000ff)
|
|
|
|
info->bmiHeader.biCompression = BI_BITFIELDS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-12 11:39:17 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* xrenderdrv_CreateDC
|
|
|
|
*/
|
|
|
|
static BOOL xrenderdrv_CreateDC( PHYSDEV *pdev, LPCWSTR driver, LPCWSTR device,
|
|
|
|
LPCWSTR output, const DEVMODEW* initData )
|
|
|
|
{
|
2011-09-26 15:25:35 +02:00
|
|
|
return create_xrender_dc( pdev, default_format );
|
2011-09-12 11:39:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* xrenderdrv_CreateCompatibleDC
|
|
|
|
*/
|
|
|
|
static BOOL xrenderdrv_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev )
|
|
|
|
{
|
|
|
|
if (orig) /* chain to x11drv first */
|
|
|
|
{
|
|
|
|
orig = GET_NEXT_PHYSDEV( orig, pCreateCompatibleDC );
|
|
|
|
if (!orig->funcs->pCreateCompatibleDC( orig, pdev )) return FALSE;
|
|
|
|
}
|
|
|
|
/* otherwise we have been called by x11drv */
|
|
|
|
|
2011-09-26 15:25:35 +02:00
|
|
|
return create_xrender_dc( pdev, WXR_FORMAT_MONO );
|
2011-09-12 11:39:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* xrenderdrv_DeleteDC
|
|
|
|
*/
|
|
|
|
static BOOL xrenderdrv_DeleteDC( PHYSDEV dev )
|
|
|
|
{
|
|
|
|
struct xrender_physdev *physdev = get_xrender_dev( dev );
|
|
|
|
|
2011-09-12 11:39:56 +02:00
|
|
|
free_xrender_picture( physdev );
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2011-09-12 11:39:56 +02:00
|
|
|
EnterCriticalSection( &xrender_cs );
|
2011-09-15 13:21:45 +02:00
|
|
|
if (physdev->cache_index != -1) dec_ref_cache( physdev->cache_index );
|
2011-09-12 11:39:56 +02:00
|
|
|
LeaveCriticalSection( &xrender_cs );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2011-09-12 11:39:56 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, physdev );
|
|
|
|
return TRUE;
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
2011-09-12 12:04:41 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* xrenderdrv_ExtEscape
|
|
|
|
*/
|
|
|
|
static INT xrenderdrv_ExtEscape( PHYSDEV dev, INT escape, INT in_count, LPCVOID in_data,
|
|
|
|
INT out_count, LPVOID out_data )
|
|
|
|
{
|
|
|
|
struct xrender_physdev *physdev = get_xrender_dev( dev );
|
|
|
|
|
|
|
|
dev = GET_NEXT_PHYSDEV( dev, pExtEscape );
|
|
|
|
|
|
|
|
if (escape == X11DRV_ESCAPE && in_data && in_count >= sizeof(enum x11drv_escape_codes))
|
|
|
|
{
|
|
|
|
if (*(const enum x11drv_escape_codes *)in_data == X11DRV_SET_DRAWABLE)
|
|
|
|
{
|
|
|
|
BOOL ret = dev->funcs->pExtEscape( dev, escape, in_count, in_data, out_count, out_data );
|
2011-09-26 15:25:35 +02:00
|
|
|
if (ret) free_xrender_picture( physdev ); /* pict format doesn't change, only drawable */
|
2011-09-12 12:04:41 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dev->funcs->pExtEscape( dev, escape, in_count, in_data, out_count, out_data );
|
|
|
|
}
|
|
|
|
|
2011-09-13 15:47:19 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* xrenderdrv_SetDeviceClipping
|
|
|
|
*/
|
2011-12-06 13:15:35 +01:00
|
|
|
static void xrenderdrv_SetDeviceClipping( PHYSDEV dev, HRGN rgn )
|
2011-09-13 15:47:19 +02:00
|
|
|
{
|
|
|
|
struct xrender_physdev *physdev = get_xrender_dev( dev );
|
|
|
|
|
2012-01-10 20:26:26 +01:00
|
|
|
physdev->region = rgn;
|
2011-09-20 11:51:43 +02:00
|
|
|
physdev->update_clip = TRUE;
|
2011-09-13 15:47:19 +02:00
|
|
|
|
2011-09-20 11:51:43 +02:00
|
|
|
dev = GET_NEXT_PHYSDEV( dev, pSetDeviceClipping );
|
2011-12-06 13:15:35 +01:00
|
|
|
dev->funcs->pSetDeviceClipping( dev, rgn );
|
2011-09-13 15:47:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-22 03:01:34 +02:00
|
|
|
/************************************************************************
|
|
|
|
* UploadGlyph
|
|
|
|
*
|
|
|
|
* Helper to ExtTextOut. Must be called inside xrender_cs
|
|
|
|
*/
|
2011-09-12 11:57:22 +02:00
|
|
|
static void UploadGlyph(struct xrender_physdev *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;
|
2011-09-15 13:21:45 +02:00
|
|
|
gsCacheEntry *entry = glyphsetCache + physDev->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;
|
2011-09-15 15:35:32 +02:00
|
|
|
enum wxr_format wxr_format;
|
2007-06-12 16:51:31 +02:00
|
|
|
static const char zero[4];
|
2009-02-03 10:54:48 +01:00
|
|
|
static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} };
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2006-08-21 11:50:59 +02:00
|
|
|
switch(format) {
|
|
|
|
case AA_Grey:
|
|
|
|
ggo_format |= WINE_GGO_GRAY16_BITMAP;
|
|
|
|
break;
|
2008-12-10 15:50:44 +01:00
|
|
|
case AA_RGB:
|
|
|
|
ggo_format |= WINE_GGO_HRGB_BITMAP;
|
|
|
|
break;
|
|
|
|
case AA_BGR:
|
|
|
|
ggo_format |= WINE_GGO_HBGR_BITMAP;
|
|
|
|
break;
|
|
|
|
case AA_VRGB:
|
|
|
|
ggo_format |= WINE_GGO_VRGB_BITMAP;
|
|
|
|
break;
|
|
|
|
case AA_VBGR:
|
|
|
|
ggo_format |= WINE_GGO_VBGR_BITMAP;
|
|
|
|
break;
|
2006-08-21 11:50:59 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
ERR("aa = %d - not implemented\n", format);
|
|
|
|
case AA_None:
|
|
|
|
ggo_format |= GGO_BITMAP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-07-08 16:03:59 +02:00
|
|
|
buflen = GetGlyphOutlineW(physDev->dev.hdc, glyph, ggo_format, &gm, 0, NULL, &identity);
|
2006-08-21 11:50:59 +02:00
|
|
|
if(buflen == GDI_ERROR) {
|
|
|
|
if(format != AA_None) {
|
|
|
|
format = AA_None;
|
|
|
|
entry->aa_default = AA_None;
|
2008-12-10 15:50:44 +01:00
|
|
|
ggo_format = GGO_GLYPH_INDEX | GGO_BITMAP;
|
2011-07-08 16:03:59 +02:00
|
|
|
buflen = GetGlyphOutlineW(physDev->dev.hdc, glyph, ggo_format, &gm, 0, NULL, &identity);
|
2006-08-21 11:50:59 +02:00
|
|
|
}
|
|
|
|
if(buflen == GDI_ERROR) {
|
2010-06-22 14:50:21 +02:00
|
|
|
WARN("GetGlyphOutlineW failed using default glyph\n");
|
2011-07-08 16:03:59 +02:00
|
|
|
buflen = GetGlyphOutlineW(physDev->dev.hdc, 0, ggo_format, &gm, 0, NULL, &identity);
|
2010-06-22 14:50:21 +02:00
|
|
|
if(buflen == GDI_ERROR) {
|
|
|
|
WARN("GetGlyphOutlineW failed for default glyph trying for space\n");
|
2011-07-08 16:03:59 +02:00
|
|
|
buflen = GetGlyphOutlineW(physDev->dev.hdc, 0x20, ggo_format, &gm, 0, NULL, &identity);
|
2010-06-22 14:50:21 +02:00
|
|
|
if(buflen == GDI_ERROR) {
|
|
|
|
ERR("GetGlyphOutlineW for all attempts unable to upload a glyph\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2006-08-21 11:50:59 +02:00
|
|
|
}
|
|
|
|
TRACE("Turning off antialiasing for this monochrome font\n");
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2007-05-24 16:06:44 +02:00
|
|
|
if (formatEntry->gis)
|
2005-01-24 20:08:02 +01:00
|
|
|
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]));
|
2007-05-24 16:06:44 +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,
|
2007-05-24 16:06:44 +02:00
|
|
|
formatEntry->nrealized * sizeof(formatEntry->gis[0]));
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
2004-06-15 19:01:52 +02:00
|
|
|
|
2011-11-17 20:26:23 +01:00
|
|
|
if(formatEntry->glyphset == 0) {
|
2005-01-24 20:08:02 +01:00
|
|
|
switch(format) {
|
2009-07-05 21:03:48 +02:00
|
|
|
case AA_Grey:
|
|
|
|
wxr_format = WXR_FORMAT_GRAY;
|
|
|
|
break;
|
2008-12-10 15:50:44 +01:00
|
|
|
|
2009-07-05 21:03:48 +02:00
|
|
|
case AA_RGB:
|
|
|
|
case AA_BGR:
|
|
|
|
case AA_VRGB:
|
|
|
|
case AA_VBGR:
|
|
|
|
wxr_format = WXR_FORMAT_A8R8G8B8;
|
|
|
|
break;
|
2004-06-15 19:01:52 +02:00
|
|
|
|
2009-07-05 21:03:48 +02:00
|
|
|
default:
|
|
|
|
ERR("aa = %d - not implemented\n", format);
|
|
|
|
case AA_None:
|
|
|
|
wxr_format = WXR_FORMAT_MONO;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-09-15 15:26:44 +02:00
|
|
|
formatEntry->font_format = pict_formats[wxr_format];
|
2011-09-15 15:10:17 +02:00
|
|
|
formatEntry->glyphset = pXRenderCreateGlyphSet(gdi_display, formatEntry->font_format);
|
2002-06-22 03:01:34 +02:00
|
|
|
}
|
|
|
|
|
2002-01-29 04:07:21 +01:00
|
|
|
|
|
|
|
buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buflen);
|
2011-07-08 16:03:59 +02:00
|
|
|
GetGlyphOutlineW(physDev->dev.hdc, glyph, ggo_format, &gm, buflen, buf, &identity);
|
2005-01-24 20:08:02 +01:00
|
|
|
formatEntry->realized[glyph] = TRUE;
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2006-10-08 01:34:01 +02:00
|
|
|
TRACE("buflen = %d. Got metrics: %dx%d adv=%d,%d origin=%d,%d\n",
|
2002-01-29 04:07:21 +01:00
|
|
|
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++) {
|
2005-08-12 12:35:46 +02:00
|
|
|
line = (unsigned char*) buf + i * pitch;
|
2002-01-29 04:07:21 +01:00
|
|
|
output[0] = '\0';
|
|
|
|
for(j = 0; j < pitch * 8; j++) {
|
|
|
|
strcat(output, (line[j / 8] & (1 << (7 - (j % 8)))) ? "#" : " ");
|
|
|
|
}
|
2008-12-05 04:18:52 +01:00
|
|
|
TRACE("%s\n", output);
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
} 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++) {
|
2005-08-12 12:35:46 +02:00
|
|
|
line = (unsigned char*) buf + i * pitch;
|
2002-01-29 04:07:21 +01:00
|
|
|
output[0] = '\0';
|
|
|
|
for(j = 0; j < pitch; j++) {
|
|
|
|
str[0] = blks[line[j] >> 5];
|
|
|
|
strcat(output, str);
|
|
|
|
}
|
2008-12-05 04:18:52 +01:00
|
|
|
TRACE("%s\n", output);
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-24 16:06:44 +02:00
|
|
|
|
2005-01-24 20:08:02 +01:00
|
|
|
if(formatEntry->glyphset) {
|
|
|
|
if(format == AA_None && BitmapBitOrder(gdi_display) != MSBFirst) {
|
2005-08-12 12:35:46 +02:00
|
|
|
unsigned char *byte = (unsigned char*) buf, c;
|
2002-11-14 23:31:34 +01:00
|
|
|
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
|
|
|
}
|
2008-12-10 15:50:44 +01:00
|
|
|
else if ( format != AA_Grey &&
|
|
|
|
ImageByteOrder (gdi_display) != NATIVE_BYTE_ORDER)
|
|
|
|
{
|
|
|
|
unsigned int i, *data = (unsigned int *)buf;
|
|
|
|
for (i = buflen / sizeof(int); i; i--, data++) *data = RtlUlongByteSwap(*data);
|
|
|
|
}
|
2002-11-14 23:31:34 +01:00
|
|
|
gid = glyph;
|
2007-06-06 16:20:16 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
XRenderCompositeText seems to ignore 0x0 glyphs when
|
|
|
|
AA_None, which means we lose the advance width of glyphs
|
|
|
|
like the space. We'll pretend that such glyphs are 1x1
|
|
|
|
bitmaps.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if(buflen == 0)
|
|
|
|
gi.width = gi.height = 1;
|
|
|
|
|
2005-01-24 20:08:02 +01:00
|
|
|
pXRenderAddGlyphs(gdi_display, formatEntry->glyphset, &gid, &gi, 1,
|
2007-06-12 16:51:31 +02:00
|
|
|
buflen ? buf : zero, buflen ? buflen : sizeof(zero));
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
2007-06-06 16:20:16 +02:00
|
|
|
|
2012-10-30 20:07:22 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
2008-03-22 18:10:01 +01:00
|
|
|
formatEntry->gis[glyph] = gi;
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
2007-07-03 16:21:32 +02:00
|
|
|
/*************************************************************
|
|
|
|
* get_tile_pict
|
|
|
|
*
|
2008-01-04 20:37:14 +01:00
|
|
|
* Returns an appropriate Picture for tiling the text colour.
|
2007-07-03 16:21:32 +02:00
|
|
|
* Call and use result within the xrender_cs
|
|
|
|
*/
|
2011-09-15 15:26:44 +02:00
|
|
|
static Picture get_tile_pict( enum wxr_format wxr_format, const XRenderColor *color)
|
2007-07-03 16:21:32 +02:00
|
|
|
{
|
|
|
|
static struct
|
|
|
|
{
|
|
|
|
Pixmap xpm;
|
|
|
|
Picture pict;
|
2011-09-15 12:51:08 +02:00
|
|
|
XRenderColor current_color;
|
2010-04-15 15:55:40 +02:00
|
|
|
} tiles[WXR_NB_FORMATS], *tile;
|
2007-07-03 16:21:32 +02:00
|
|
|
|
2011-09-15 15:26:44 +02:00
|
|
|
tile = &tiles[wxr_format];
|
2007-07-03 16:21:32 +02:00
|
|
|
|
|
|
|
if(!tile->xpm)
|
|
|
|
{
|
|
|
|
XRenderPictureAttributes pa;
|
2011-09-15 15:26:44 +02:00
|
|
|
XRenderPictFormat *pict_format = pict_formats[wxr_format];
|
2007-07-03 16:21:32 +02:00
|
|
|
|
2011-09-15 15:10:17 +02:00
|
|
|
tile->xpm = XCreatePixmap(gdi_display, root_window, 1, 1, pict_format->depth);
|
2007-07-03 16:21:32 +02:00
|
|
|
|
2009-05-20 18:22:41 +02:00
|
|
|
pa.repeat = RepeatNormal;
|
2011-09-15 15:10:17 +02:00
|
|
|
tile->pict = pXRenderCreatePicture(gdi_display, tile->xpm, pict_format, CPRepeat, &pa);
|
2007-07-03 16:21:32 +02:00
|
|
|
|
|
|
|
/* init current_color to something different from text_pixel */
|
2011-09-15 12:51:08 +02:00
|
|
|
tile->current_color = *color;
|
|
|
|
tile->current_color.red ^= 0xffff;
|
2007-07-03 16:21:32 +02:00
|
|
|
|
2011-09-15 15:26:44 +02:00
|
|
|
if (wxr_format == WXR_FORMAT_MONO)
|
2007-07-03 16:21:32 +02:00
|
|
|
{
|
|
|
|
/* for a 1bpp bitmap we always need a 1 in the tile */
|
2011-09-15 12:51:08 +02:00
|
|
|
XRenderColor col;
|
2007-07-03 16:21:32 +02:00
|
|
|
col.red = col.green = col.blue = 0;
|
|
|
|
col.alpha = 0xffff;
|
|
|
|
pXRenderFillRectangle(gdi_display, PictOpSrc, tile->pict, &col, 0, 0, 1, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-15 15:26:44 +02:00
|
|
|
if (memcmp( color, &tile->current_color, sizeof(*color) ) && wxr_format != WXR_FORMAT_MONO)
|
2007-07-03 16:21:32 +02:00
|
|
|
{
|
2011-09-15 12:51:08 +02:00
|
|
|
pXRenderFillRectangle(gdi_display, PictOpSrc, tile->pict, color, 0, 0, 1, 1);
|
|
|
|
tile->current_color = *color;
|
2007-07-03 16:21:32 +02:00
|
|
|
}
|
|
|
|
return tile->pict;
|
|
|
|
}
|
|
|
|
|
2010-04-15 11:39:41 +02:00
|
|
|
/*************************************************************
|
|
|
|
* get_mask_pict
|
|
|
|
*
|
|
|
|
* Returns an appropriate Picture for masking with the specified alpha.
|
|
|
|
* Call and use result within the xrender_cs
|
|
|
|
*/
|
|
|
|
static Picture get_mask_pict( int alpha )
|
|
|
|
{
|
|
|
|
static Pixmap pixmap;
|
|
|
|
static Picture pict;
|
|
|
|
static int current_alpha;
|
|
|
|
|
|
|
|
if (alpha == 0xffff) return 0; /* don't need a mask for alpha==1.0 */
|
|
|
|
|
|
|
|
if (!pixmap)
|
|
|
|
{
|
|
|
|
XRenderPictureAttributes pa;
|
|
|
|
|
2010-04-22 20:48:30 +02:00
|
|
|
pixmap = XCreatePixmap( gdi_display, root_window, 1, 1, 32 );
|
2010-04-15 11:39:41 +02:00
|
|
|
pa.repeat = RepeatNormal;
|
2011-09-15 15:10:17 +02:00
|
|
|
pict = pXRenderCreatePicture( gdi_display, pixmap,
|
|
|
|
pict_formats[WXR_FORMAT_A8R8G8B8], CPRepeat, &pa );
|
2010-04-15 11:39:41 +02:00
|
|
|
current_alpha = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (alpha != current_alpha)
|
|
|
|
{
|
|
|
|
XRenderColor col;
|
|
|
|
col.red = col.green = col.blue = 0;
|
|
|
|
col.alpha = current_alpha = alpha;
|
|
|
|
pXRenderFillRectangle( gdi_display, PictOpSrc, pict, &col, 0, 0, 1, 1 );
|
|
|
|
}
|
|
|
|
return pict;
|
|
|
|
}
|
|
|
|
|
2002-01-29 04:07:21 +01:00
|
|
|
/***********************************************************************
|
2011-09-12 11:57:22 +02:00
|
|
|
* xrenderdrv_ExtTextOut
|
2002-01-29 04:07:21 +01:00
|
|
|
*/
|
2011-10-03 13:28:56 +02:00
|
|
|
static BOOL xrenderdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
|
|
|
|
const RECT *lprect, LPCWSTR wstr, UINT count, const INT *lpDx )
|
2002-01-29 04:07:21 +01:00
|
|
|
{
|
2011-09-12 11:57:22 +02:00
|
|
|
struct xrender_physdev *physdev = get_xrender_dev( dev );
|
2002-06-22 03:01:34 +02:00
|
|
|
gsCacheEntry *entry;
|
2005-01-24 20:08:02 +01:00
|
|
|
gsCacheEntryFormat *formatEntry;
|
2007-03-29 12:55:59 +02:00
|
|
|
AA_Type aa_type = AA_None;
|
2005-08-23 11:38:58 +02:00
|
|
|
unsigned int idx;
|
2011-11-17 20:26:23 +01:00
|
|
|
Picture pict, tile_pict = 0;
|
|
|
|
XGlyphElt16 *elts;
|
|
|
|
POINT offset, desired, current;
|
|
|
|
int render_op = PictOpOver;
|
|
|
|
XRenderColor col;
|
2012-04-16 17:49:05 +02:00
|
|
|
RECT rect, bounds;
|
2005-01-26 20:43:42 +01:00
|
|
|
|
2012-01-10 20:54:40 +01:00
|
|
|
get_xrender_color( physdev, GetTextColor( physdev->dev.hdc ), &col );
|
|
|
|
pict = get_xrender_picture( physdev, 0, (flags & ETO_CLIPPED) ? lprect : NULL );
|
2002-11-14 23:31:34 +01:00
|
|
|
|
2005-08-23 11:38:58 +02:00
|
|
|
if(flags & ETO_OPAQUE)
|
|
|
|
{
|
2012-01-10 20:54:40 +01:00
|
|
|
XRenderColor bg;
|
|
|
|
|
|
|
|
if (physdev->format == WXR_FORMAT_MONO)
|
|
|
|
/* use the inverse of the text color */
|
|
|
|
bg.red = bg.green = bg.blue = bg.alpha = ~col.alpha;
|
|
|
|
else
|
|
|
|
get_xrender_color( physdev, GetBkColor( physdev->dev.hdc ), &bg );
|
|
|
|
|
|
|
|
set_xrender_transformation( pict, 1, 1, 0, 0 );
|
|
|
|
pXRenderFillRectangle( gdi_display, PictOpSrc, pict, &bg,
|
|
|
|
physdev->x11dev->dc_rect.left + lprect->left,
|
|
|
|
physdev->x11dev->dc_rect.top + lprect->top,
|
|
|
|
lprect->right - lprect->left,
|
|
|
|
lprect->bottom - lprect->top );
|
2012-04-16 17:49:05 +02:00
|
|
|
add_device_bounds( physdev->x11dev, lprect );
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
2012-01-06 17:54:41 +01:00
|
|
|
if(count == 0) return TRUE;
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2007-09-21 10:47:45 +02:00
|
|
|
EnterCriticalSection(&xrender_cs);
|
|
|
|
|
2011-09-15 13:21:45 +02:00
|
|
|
entry = glyphsetCache + physdev->cache_index;
|
2011-11-14 21:25:47 +01:00
|
|
|
aa_type = entry->aa_default;
|
2007-03-29 12:55:59 +02:00
|
|
|
formatEntry = entry->format[aa_type];
|
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 ) {
|
2011-09-12 11:57:22 +02:00
|
|
|
UploadGlyph(physdev, wstr[idx], aa_type);
|
2006-08-21 11:50:59 +02:00
|
|
|
/* re-evaluate antialias since aa_default may have changed */
|
2011-11-14 21:25:47 +01:00
|
|
|
aa_type = entry->aa_default;
|
2007-03-29 12:55:59 +02:00
|
|
|
formatEntry = entry->format[aa_type];
|
2005-08-23 11:38:58 +02:00
|
|
|
} else if( wstr[idx] >= formatEntry->nrealized || formatEntry->realized[wstr[idx]] == FALSE) {
|
2011-09-12 11:57:22 +02:00
|
|
|
UploadGlyph(physdev, wstr[idx], aa_type);
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
}
|
2007-03-18 15:09:34 +01:00
|
|
|
if (!formatEntry)
|
|
|
|
{
|
|
|
|
WARN("could not upload requested glyphs\n");
|
|
|
|
LeaveCriticalSection(&xrender_cs);
|
2011-11-17 20:26:23 +01:00
|
|
|
return FALSE;
|
2007-03-18 15:09:34 +01:00
|
|
|
}
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2006-10-08 01:34:01 +02:00
|
|
|
TRACE("Writing %s at %d,%d\n", debugstr_wn(wstr,count),
|
2011-09-12 11:57:22 +02:00
|
|
|
physdev->x11dev->dc_rect.left + x, physdev->x11dev->dc_rect.top + y);
|
2002-04-24 00:06:41 +02:00
|
|
|
|
2011-11-17 20:26:23 +01:00
|
|
|
elts = HeapAlloc(GetProcessHeap(), 0, sizeof(XGlyphElt16) * count);
|
2009-10-08 17:24:46 +02:00
|
|
|
|
2011-11-17 20:26:23 +01:00
|
|
|
/* There's a bug in XRenderCompositeText that ignores the xDst and yDst parameters.
|
|
|
|
So we pass zeros to the function and move to our starting position using the first
|
|
|
|
element of the elts array. */
|
2007-05-24 16:06:44 +02:00
|
|
|
|
2011-11-17 20:26:23 +01:00
|
|
|
desired.x = physdev->x11dev->dc_rect.left + x;
|
|
|
|
desired.y = physdev->x11dev->dc_rect.top + y;
|
|
|
|
offset.x = offset.y = 0;
|
|
|
|
current.x = current.y = 0;
|
2007-05-24 16:06:44 +02:00
|
|
|
|
2011-11-17 20:26:23 +01:00
|
|
|
tile_pict = get_tile_pict(physdev->format, &col);
|
2007-09-21 10:47:45 +02:00
|
|
|
|
2011-11-17 20:26:23 +01:00
|
|
|
/* FIXME the mapping of Text/BkColor onto 1 or 0 needs investigation.
|
|
|
|
*/
|
2012-01-10 20:54:40 +01:00
|
|
|
if (physdev->format == WXR_FORMAT_MONO && col.red == 0 && col.green == 0 && col.blue == 0)
|
2011-11-17 20:26:23 +01:00
|
|
|
render_op = PictOpOutReverse; /* This gives us 'black' text */
|
2007-09-21 10:47:45 +02:00
|
|
|
|
2012-04-16 17:49:05 +02:00
|
|
|
reset_bounds( &bounds );
|
2011-11-17 20:26:23 +01:00
|
|
|
for(idx = 0; idx < count; idx++)
|
|
|
|
{
|
|
|
|
elts[idx].glyphset = formatEntry->glyphset;
|
|
|
|
elts[idx].chars = wstr + idx;
|
|
|
|
elts[idx].nchars = 1;
|
|
|
|
elts[idx].xOff = desired.x - current.x;
|
|
|
|
elts[idx].yOff = desired.y - current.y;
|
2007-05-24 16:06:44 +02:00
|
|
|
|
2011-11-17 20:26:23 +01:00
|
|
|
current.x += (elts[idx].xOff + formatEntry->gis[wstr[idx]].xOff);
|
|
|
|
current.y += (elts[idx].yOff + formatEntry->gis[wstr[idx]].yOff);
|
2007-05-24 16:06:44 +02:00
|
|
|
|
2012-04-16 17:49:05 +02:00
|
|
|
rect.left = desired.x - physdev->x11dev->dc_rect.left - formatEntry->gis[wstr[idx]].x;
|
|
|
|
rect.top = desired.y - physdev->x11dev->dc_rect.top - formatEntry->gis[wstr[idx]].y;
|
|
|
|
rect.right = rect.left + formatEntry->gis[wstr[idx]].width;
|
|
|
|
rect.bottom = rect.top + formatEntry->gis[wstr[idx]].height;
|
|
|
|
add_bounds_rect( &bounds, &rect );
|
|
|
|
|
2011-11-17 20:26:23 +01:00
|
|
|
if(!lpDx)
|
|
|
|
{
|
|
|
|
desired.x += formatEntry->gis[wstr[idx]].xOff;
|
|
|
|
desired.y += formatEntry->gis[wstr[idx]].yOff;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(flags & ETO_PDY)
|
2007-05-24 16:06:44 +02:00
|
|
|
{
|
2011-11-17 20:26:23 +01:00
|
|
|
offset.x += lpDx[idx * 2];
|
|
|
|
offset.y += lpDx[idx * 2 + 1];
|
2007-05-24 16:06:44 +02:00
|
|
|
}
|
|
|
|
else
|
2011-11-17 20:26:23 +01:00
|
|
|
offset.x += lpDx[idx];
|
|
|
|
desired.x = physdev->x11dev->dc_rect.left + x + offset.x;
|
|
|
|
desired.y = physdev->x11dev->dc_rect.top + y + offset.y;
|
2007-05-24 16:06:44 +02:00
|
|
|
}
|
2011-11-17 20:26:23 +01:00
|
|
|
}
|
2011-09-13 15:47:19 +02:00
|
|
|
|
2011-11-17 20:26:23 +01:00
|
|
|
/* Make sure we don't have any transforms set from a previous call */
|
|
|
|
set_xrender_transformation(pict, 1, 1, 0, 0);
|
|
|
|
pXRenderCompositeText16(gdi_display, render_op,
|
|
|
|
tile_pict,
|
|
|
|
pict,
|
|
|
|
formatEntry->font_format,
|
|
|
|
0, 0, 0, 0, elts, count);
|
|
|
|
HeapFree(GetProcessHeap(), 0, elts);
|
2007-05-24 17:32:06 +02:00
|
|
|
|
2002-06-22 03:01:34 +02:00
|
|
|
LeaveCriticalSection(&xrender_cs);
|
2012-04-16 17:49:05 +02:00
|
|
|
add_device_bounds( physdev->x11dev, &bounds );
|
2011-11-17 20:26:23 +01:00
|
|
|
return TRUE;
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
2011-09-26 15:25:05 +02:00
|
|
|
/* multiply the alpha channel of a picture */
|
|
|
|
static void multiply_alpha( Picture pict, XRenderPictFormat *format, int alpha,
|
|
|
|
int x, int y, int width, int height )
|
|
|
|
{
|
|
|
|
XRenderPictureAttributes pa;
|
|
|
|
Pixmap src_pixmap, mask_pixmap;
|
|
|
|
Picture src_pict, mask_pict;
|
|
|
|
XRenderColor color;
|
|
|
|
|
|
|
|
src_pixmap = XCreatePixmap( gdi_display, root_window, 1, 1, format->depth );
|
|
|
|
mask_pixmap = XCreatePixmap( gdi_display, root_window, 1, 1, format->depth );
|
|
|
|
pa.repeat = RepeatNormal;
|
|
|
|
src_pict = pXRenderCreatePicture( gdi_display, src_pixmap, format, CPRepeat, &pa );
|
|
|
|
pa.component_alpha = True;
|
|
|
|
mask_pict = pXRenderCreatePicture( gdi_display, mask_pixmap, format, CPRepeat|CPComponentAlpha, &pa );
|
|
|
|
color.red = color.green = color.blue = color.alpha = 0xffff;
|
|
|
|
pXRenderFillRectangle( gdi_display, PictOpSrc, src_pict, &color, 0, 0, 1, 1 );
|
|
|
|
color.alpha = alpha;
|
|
|
|
pXRenderFillRectangle( gdi_display, PictOpSrc, mask_pict, &color, 0, 0, 1, 1 );
|
|
|
|
pXRenderComposite( gdi_display, PictOpInReverse, src_pict, mask_pict, pict,
|
|
|
|
0, 0, 0, 0, x, y, width, height );
|
|
|
|
pXRenderFreePicture( gdi_display, src_pict );
|
|
|
|
pXRenderFreePicture( gdi_display, mask_pict );
|
|
|
|
XFreePixmap( gdi_display, src_pixmap );
|
|
|
|
XFreePixmap( gdi_display, mask_pixmap );
|
|
|
|
}
|
|
|
|
|
2009-07-22 17:42:14 +02:00
|
|
|
/* Helper function for (stretched) blitting using xrender */
|
2010-04-15 11:39:41 +02:00
|
|
|
static void xrender_blit( int op, Picture src_pict, Picture mask_pict, Picture dst_pict,
|
2012-01-18 14:39:18 +01:00
|
|
|
int x_src, int y_src, int width_src, int height_src,
|
|
|
|
int x_dst, int y_dst, int width_dst, int height_dst,
|
|
|
|
double xscale, double yscale )
|
2009-07-22 17:42:14 +02:00
|
|
|
{
|
2010-04-15 12:13:16 +02:00
|
|
|
int x_offset, y_offset;
|
2010-02-17 12:43:46 +01:00
|
|
|
|
2012-01-18 14:39:18 +01:00
|
|
|
if (width_src < 0)
|
|
|
|
{
|
|
|
|
x_src += width_src + 1;
|
|
|
|
width_src = -width_src;
|
|
|
|
}
|
|
|
|
if (height_src < 0)
|
|
|
|
{
|
|
|
|
y_src += height_src + 1;
|
|
|
|
height_src = -height_src;
|
|
|
|
}
|
|
|
|
if (width_dst < 0)
|
|
|
|
{
|
|
|
|
x_dst += width_dst + 1;
|
|
|
|
width_dst = -width_dst;
|
|
|
|
}
|
|
|
|
if (height_dst < 0)
|
|
|
|
{
|
|
|
|
y_dst += height_dst + 1;
|
|
|
|
height_dst = -height_dst;
|
|
|
|
}
|
|
|
|
|
2009-07-22 17:42:14 +02:00
|
|
|
/* When we need to scale we perform scaling and source_x / source_y translation using a transformation matrix.
|
|
|
|
* This is needed because XRender is inaccurate in combination with scaled source coordinates passed to XRenderComposite.
|
|
|
|
* In all other cases we do use XRenderComposite for translation as it is faster than using a transformation matrix. */
|
|
|
|
if(xscale != 1.0 || yscale != 1.0)
|
|
|
|
{
|
2010-04-15 12:13:16 +02:00
|
|
|
/* In case of mirroring we need a source x- and y-offset because without the pixels will be
|
|
|
|
* in the wrong quadrant of the x-y plane.
|
|
|
|
*/
|
2012-01-18 14:39:18 +01:00
|
|
|
x_offset = (xscale < 0) ? -width_dst : 0;
|
|
|
|
y_offset = (yscale < 0) ? -height_dst : 0;
|
2010-04-15 12:13:16 +02:00
|
|
|
set_xrender_transformation(src_pict, xscale, yscale, x_src, y_src);
|
2009-07-22 17:42:14 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-04-15 12:13:16 +02:00
|
|
|
x_offset = x_src;
|
|
|
|
y_offset = y_src;
|
|
|
|
set_xrender_transformation(src_pict, 1, 1, 0, 0);
|
|
|
|
}
|
2010-04-15 11:39:41 +02:00
|
|
|
pXRenderComposite( gdi_display, op, src_pict, mask_pict, dst_pict,
|
2012-01-18 14:39:18 +01:00
|
|
|
x_offset, y_offset, 0, 0, x_dst, y_dst, width_dst, height_dst );
|
2010-04-15 12:13:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper function for (stretched) mono->color blitting using xrender */
|
2011-09-20 20:22:34 +02:00
|
|
|
static void xrender_mono_blit( Picture src_pict, Picture dst_pict,
|
|
|
|
enum wxr_format dst_format, XRenderColor *fg, XRenderColor *bg,
|
2012-01-18 14:39:18 +01:00
|
|
|
int x_src, int y_src, int width_src, int height_src,
|
|
|
|
int x_dst, int y_dst, int width_dst, int height_dst,
|
|
|
|
double xscale, double yscale )
|
2010-04-15 12:13:16 +02:00
|
|
|
{
|
2011-09-20 20:22:34 +02:00
|
|
|
Picture tile_pict;
|
2010-04-15 12:13:16 +02:00
|
|
|
int x_offset, y_offset;
|
2011-09-26 15:25:05 +02:00
|
|
|
XRenderColor color;
|
2010-04-15 12:13:16 +02:00
|
|
|
|
2012-01-18 14:39:18 +01:00
|
|
|
if (width_src < 0)
|
|
|
|
{
|
|
|
|
x_src += width_src + 1;
|
|
|
|
width_src = -width_src;
|
|
|
|
}
|
|
|
|
if (height_src < 0)
|
|
|
|
{
|
|
|
|
y_src += height_src + 1;
|
|
|
|
height_src = -height_src;
|
|
|
|
}
|
|
|
|
if (width_dst < 0)
|
|
|
|
{
|
|
|
|
x_dst += width_dst + 1;
|
|
|
|
width_dst = -width_dst;
|
|
|
|
}
|
|
|
|
if (height_dst < 0)
|
|
|
|
{
|
|
|
|
y_dst += height_dst + 1;
|
|
|
|
height_dst = -height_dst;
|
|
|
|
}
|
|
|
|
|
2011-09-20 20:22:34 +02:00
|
|
|
/* When doing a mono->color blit, the source data is used as mask, and the source picture
|
|
|
|
* contains a 1x1 picture for tiling. The source data effectively acts as an alpha channel to
|
|
|
|
* the tile data.
|
2010-04-15 12:13:16 +02:00
|
|
|
*/
|
2011-09-20 20:22:34 +02:00
|
|
|
EnterCriticalSection( &xrender_cs );
|
2011-09-26 15:25:05 +02:00
|
|
|
color = *bg;
|
|
|
|
color.alpha = 0xffff; /* tile pict needs 100% alpha */
|
|
|
|
tile_pict = get_tile_pict( dst_format, &color );
|
2011-09-20 20:22:34 +02:00
|
|
|
|
2012-01-18 14:39:18 +01:00
|
|
|
pXRenderFillRectangle( gdi_display, PictOpSrc, dst_pict, fg, x_dst, y_dst, width_dst, height_dst );
|
2011-09-20 20:22:34 +02:00
|
|
|
|
2010-04-15 12:13:16 +02:00
|
|
|
if (xscale != 1.0 || yscale != 1.0)
|
|
|
|
{
|
|
|
|
/* In case of mirroring we need a source x- and y-offset because without the pixels will be
|
|
|
|
* in the wrong quadrant of the x-y plane.
|
|
|
|
*/
|
2012-01-18 14:39:18 +01:00
|
|
|
x_offset = (xscale < 0) ? -width_dst : 0;
|
|
|
|
y_offset = (yscale < 0) ? -height_dst : 0;
|
2011-09-20 20:22:34 +02:00
|
|
|
set_xrender_transformation(src_pict, xscale, yscale, x_src, y_src);
|
2010-04-15 12:13:16 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x_offset = x_src;
|
|
|
|
y_offset = y_src;
|
2011-09-20 20:22:34 +02:00
|
|
|
set_xrender_transformation(src_pict, 1, 1, 0, 0);
|
2009-07-22 17:42:14 +02:00
|
|
|
}
|
2011-09-20 20:22:34 +02:00
|
|
|
pXRenderComposite(gdi_display, PictOpOver, tile_pict, src_pict, dst_pict,
|
2012-01-18 14:39:18 +01:00
|
|
|
0, 0, x_offset, y_offset, x_dst, y_dst, width_dst, height_dst );
|
2011-09-20 20:22:34 +02:00
|
|
|
LeaveCriticalSection( &xrender_cs );
|
2011-09-26 15:25:05 +02:00
|
|
|
|
|
|
|
/* force the alpha channel for background pixels, it has been set to 100% by the tile */
|
|
|
|
if (bg->alpha != 0xffff && (dst_format == WXR_FORMAT_A8R8G8B8 || dst_format == WXR_FORMAT_B8G8R8A8))
|
2012-01-18 14:39:18 +01:00
|
|
|
multiply_alpha( dst_pict, pict_formats[dst_format], bg->alpha,
|
|
|
|
x_dst, y_dst, width_dst, height_dst );
|
2009-07-22 17:42:14 +02:00
|
|
|
}
|
|
|
|
|
2011-09-20 11:21:00 +02:00
|
|
|
/* create a pixmap and render picture for an image */
|
|
|
|
static DWORD create_image_pixmap( BITMAPINFO *info, const struct gdi_image_bits *bits,
|
|
|
|
struct bitblt_coords *src, enum wxr_format format,
|
|
|
|
Pixmap *pixmap, Picture *pict, BOOL *use_repeat )
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
int width = src->visrect.right - src->visrect.left;
|
|
|
|
int height = src->visrect.bottom - src->visrect.top;
|
|
|
|
int depth = pict_formats[format]->depth;
|
|
|
|
struct gdi_image_bits dst_bits;
|
|
|
|
XRenderPictureAttributes pa;
|
2012-05-29 21:12:15 +02:00
|
|
|
GC gc;
|
2011-09-20 11:21:00 +02:00
|
|
|
XImage *image;
|
|
|
|
|
2012-09-25 15:51:03 +02:00
|
|
|
image = XCreateImage( gdi_display, default_visual.visual, depth, ZPixmap, 0, NULL,
|
2011-09-20 11:21:00 +02:00
|
|
|
info->bmiHeader.biWidth, height, 32, 0 );
|
|
|
|
if (!image) return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
ret = copy_image_bits( info, (format == WXR_FORMAT_R8G8B8), image, bits, &dst_bits, src, NULL, ~0u );
|
|
|
|
if (ret) return ret;
|
|
|
|
|
|
|
|
image->data = dst_bits.ptr;
|
|
|
|
|
|
|
|
*use_repeat = (width == 1 && height == 1);
|
|
|
|
pa.repeat = *use_repeat ? RepeatNormal : RepeatNone;
|
|
|
|
|
|
|
|
*pixmap = XCreatePixmap( gdi_display, root_window, width, height, depth );
|
2012-05-29 21:12:15 +02:00
|
|
|
gc = XCreateGC( gdi_display, *pixmap, 0, NULL );
|
|
|
|
XPutImage( gdi_display, *pixmap, gc, image, src->visrect.left, 0, 0, 0, width, height );
|
2011-09-20 11:21:00 +02:00
|
|
|
*pict = pXRenderCreatePicture( gdi_display, *pixmap, pict_formats[format], CPRepeat, &pa );
|
2012-05-29 21:12:15 +02:00
|
|
|
XFreeGC( gdi_display, gc );
|
2011-09-20 11:21:00 +02:00
|
|
|
|
|
|
|
/* make coordinates relative to the pixmap */
|
|
|
|
src->x -= src->visrect.left;
|
|
|
|
src->y -= src->visrect.top;
|
|
|
|
OffsetRect( &src->visrect, -src->visrect.left, -src->visrect.top );
|
|
|
|
|
|
|
|
image->data = NULL;
|
|
|
|
XDestroyImage( image );
|
|
|
|
if (dst_bits.free) dst_bits.free( &dst_bits );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-09-15 12:49:08 +02:00
|
|
|
static void xrender_stretch_blit( struct xrender_physdev *physdev_src, struct xrender_physdev *physdev_dst,
|
2011-09-20 11:51:43 +02:00
|
|
|
Drawable drawable, const struct bitblt_coords *src,
|
2011-09-15 12:49:08 +02:00
|
|
|
const struct bitblt_coords *dst )
|
|
|
|
{
|
2011-09-15 23:13:01 +02:00
|
|
|
int x_dst, y_dst;
|
|
|
|
Picture src_pict = 0, dst_pict, mask_pict = 0;
|
2012-05-25 11:28:37 +02:00
|
|
|
double xscale = src->width / (double)dst->width;
|
|
|
|
double yscale = src->height / (double)dst->height;
|
2011-09-15 12:49:08 +02:00
|
|
|
|
2011-09-15 23:13:01 +02:00
|
|
|
if (drawable) /* using an intermediate pixmap */
|
|
|
|
{
|
2011-09-16 17:10:41 +02:00
|
|
|
x_dst = dst->x;
|
|
|
|
y_dst = dst->y;
|
2012-05-25 11:28:37 +02:00
|
|
|
dst_pict = pXRenderCreatePicture( gdi_display, drawable, physdev_dst->pict_format, 0, NULL );
|
2011-09-15 23:13:01 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-16 17:10:41 +02:00
|
|
|
x_dst = physdev_dst->x11dev->dc_rect.left + dst->x;
|
|
|
|
y_dst = physdev_dst->x11dev->dc_rect.top + dst->y;
|
2011-09-20 11:51:43 +02:00
|
|
|
dst_pict = get_xrender_picture( physdev_dst, 0, &dst->visrect );
|
2011-09-15 23:13:01 +02:00
|
|
|
}
|
2011-09-15 13:12:54 +02:00
|
|
|
|
2012-05-25 11:28:37 +02:00
|
|
|
src_pict = get_xrender_picture_source( physdev_src, FALSE );
|
2011-09-20 20:22:34 +02:00
|
|
|
|
2011-09-15 12:49:08 +02:00
|
|
|
/* mono -> color */
|
2011-09-15 15:26:44 +02:00
|
|
|
if (physdev_src->format == WXR_FORMAT_MONO && physdev_dst->format != WXR_FORMAT_MONO)
|
2011-09-15 12:49:08 +02:00
|
|
|
{
|
|
|
|
XRenderColor fg, bg;
|
|
|
|
|
2012-01-10 20:54:40 +01:00
|
|
|
get_xrender_color( physdev_dst, GetTextColor( physdev_dst->dev.hdc ), &fg );
|
|
|
|
get_xrender_color( physdev_dst, GetBkColor( physdev_dst->dev.hdc ), &bg );
|
2011-09-15 12:49:08 +02:00
|
|
|
fg.alpha = bg.alpha = 0;
|
|
|
|
|
2011-09-20 20:22:34 +02:00
|
|
|
xrender_mono_blit( src_pict, dst_pict, physdev_dst->format, &fg, &bg,
|
2012-01-18 14:39:18 +01:00
|
|
|
physdev_src->x11dev->dc_rect.left + src->x,
|
|
|
|
physdev_src->x11dev->dc_rect.top + src->y,
|
|
|
|
src->width, src->height, x_dst, y_dst, dst->width, dst->height, xscale, yscale );
|
2011-09-15 12:49:08 +02:00
|
|
|
}
|
|
|
|
else /* color -> color (can be at different depths) or mono -> mono */
|
|
|
|
{
|
2012-01-10 20:26:26 +01:00
|
|
|
if (physdev_dst->pict_format->depth == 32 && physdev_src->pict_format->depth < 32)
|
2011-09-15 12:49:08 +02:00
|
|
|
mask_pict = get_no_alpha_mask();
|
|
|
|
|
|
|
|
xrender_blit( PictOpSrc, src_pict, mask_pict, dst_pict,
|
2012-01-18 14:39:18 +01:00
|
|
|
physdev_src->x11dev->dc_rect.left + src->x,
|
|
|
|
physdev_src->x11dev->dc_rect.top + src->y,
|
|
|
|
src->width, src->height, x_dst, y_dst, dst->width, dst->height, xscale, yscale );
|
2011-09-15 23:13:01 +02:00
|
|
|
}
|
|
|
|
|
2012-08-14 13:38:03 +02:00
|
|
|
if (drawable) pXRenderFreePicture( gdi_display, dst_pict );
|
2011-09-15 12:49:08 +02:00
|
|
|
}
|
|
|
|
|
2011-09-20 11:21:00 +02:00
|
|
|
|
2011-10-03 23:47:31 +02:00
|
|
|
static void xrender_put_image( Pixmap src_pixmap, Picture src_pict, Picture mask_pict, HRGN clip,
|
2011-09-19 17:46:33 +02:00
|
|
|
XRenderPictFormat *dst_format, struct xrender_physdev *physdev,
|
2011-09-20 11:21:00 +02:00
|
|
|
Drawable drawable, struct bitblt_coords *src,
|
|
|
|
struct bitblt_coords *dst, BOOL use_repeat )
|
2011-09-19 17:46:33 +02:00
|
|
|
{
|
2012-01-18 14:39:18 +01:00
|
|
|
int x_dst, y_dst;
|
2011-09-20 11:21:00 +02:00
|
|
|
Picture dst_pict;
|
2011-09-19 17:46:33 +02:00
|
|
|
double xscale, yscale;
|
|
|
|
|
|
|
|
if (drawable) /* using an intermediate pixmap */
|
|
|
|
{
|
2011-09-20 11:51:43 +02:00
|
|
|
RGNDATA *clip_data = NULL;
|
|
|
|
|
2011-09-19 17:46:33 +02:00
|
|
|
if (clip) clip_data = X11DRV_GetRegionData( clip, 0 );
|
|
|
|
x_dst = dst->x;
|
|
|
|
y_dst = dst->y;
|
2012-05-25 11:28:37 +02:00
|
|
|
dst_pict = pXRenderCreatePicture( gdi_display, drawable, dst_format, 0, NULL );
|
2011-09-19 17:46:33 +02:00
|
|
|
if (clip_data)
|
|
|
|
pXRenderSetPictureClipRectangles( gdi_display, dst_pict, 0, 0,
|
|
|
|
(XRectangle *)clip_data->Buffer, clip_data->rdh.nCount );
|
2011-09-20 11:51:43 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, clip_data );
|
2011-09-19 17:46:33 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x_dst = physdev->x11dev->dc_rect.left + dst->x;
|
|
|
|
y_dst = physdev->x11dev->dc_rect.top + dst->y;
|
2011-09-20 11:51:43 +02:00
|
|
|
dst_pict = get_xrender_picture( physdev, clip, &dst->visrect );
|
2011-09-19 17:46:33 +02:00
|
|
|
}
|
|
|
|
|
2011-09-20 11:21:00 +02:00
|
|
|
if (!use_repeat)
|
2011-09-19 17:46:33 +02:00
|
|
|
{
|
|
|
|
xscale = src->width / (double)dst->width;
|
|
|
|
yscale = src->height / (double)dst->height;
|
|
|
|
}
|
2011-09-20 11:21:00 +02:00
|
|
|
else xscale = yscale = 1; /* no scaling needed with a repeating source */
|
2011-09-19 17:46:33 +02:00
|
|
|
|
2012-01-18 14:39:18 +01:00
|
|
|
xrender_blit( PictOpSrc, src_pict, mask_pict, dst_pict, src->x, src->y, src->width, src->height,
|
|
|
|
x_dst, y_dst, dst->width, dst->height, xscale, yscale );
|
2011-09-19 17:46:33 +02:00
|
|
|
|
2012-08-14 13:38:03 +02:00
|
|
|
if (drawable) pXRenderFreePicture( gdi_display, dst_pict );
|
2011-09-19 17:46:33 +02:00
|
|
|
}
|
|
|
|
|
2011-09-15 12:49:08 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* xrenderdrv_StretchBlt
|
|
|
|
*/
|
|
|
|
static BOOL xrenderdrv_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst,
|
|
|
|
PHYSDEV src_dev, struct bitblt_coords *src, DWORD rop )
|
|
|
|
{
|
|
|
|
struct xrender_physdev *physdev_dst = get_xrender_dev( dst_dev );
|
|
|
|
struct xrender_physdev *physdev_src = get_xrender_dev( src_dev );
|
|
|
|
BOOL stretch = (src->width != dst->width) || (src->height != dst->height);
|
|
|
|
|
|
|
|
if (src_dev->funcs != dst_dev->funcs)
|
|
|
|
{
|
|
|
|
dst_dev = GET_NEXT_PHYSDEV( dst_dev, pStretchBlt );
|
|
|
|
return dst_dev->funcs->pStretchBlt( dst_dev, dst, src_dev, src, rop );
|
|
|
|
}
|
|
|
|
|
2011-09-15 15:26:44 +02:00
|
|
|
/* XRender is of no use for color -> mono */
|
|
|
|
if (physdev_dst->format == WXR_FORMAT_MONO && physdev_src->format != WXR_FORMAT_MONO)
|
2011-09-16 11:36:59 +02:00
|
|
|
goto x11drv_fallback;
|
2011-09-15 12:49:08 +02:00
|
|
|
|
|
|
|
/* if not stretching, we only need to handle format conversion */
|
2011-09-16 11:36:59 +02:00
|
|
|
if (!stretch && physdev_dst->format == physdev_src->format) goto x11drv_fallback;
|
2011-09-15 12:49:08 +02:00
|
|
|
|
2011-09-15 13:12:54 +02:00
|
|
|
if (rop != SRCCOPY)
|
|
|
|
{
|
|
|
|
GC tmpGC;
|
|
|
|
Pixmap tmp_pixmap;
|
2011-09-16 17:10:41 +02:00
|
|
|
struct bitblt_coords tmp;
|
|
|
|
|
|
|
|
/* make coordinates relative to tmp pixmap */
|
|
|
|
tmp = *dst;
|
|
|
|
tmp.x -= tmp.visrect.left;
|
|
|
|
tmp.y -= tmp.visrect.top;
|
|
|
|
OffsetRect( &tmp.visrect, -tmp.visrect.left, -tmp.visrect.top );
|
2011-09-15 12:49:08 +02:00
|
|
|
|
2011-09-15 13:12:54 +02:00
|
|
|
tmpGC = XCreateGC( gdi_display, physdev_dst->x11dev->drawable, 0, NULL );
|
|
|
|
XSetSubwindowMode( gdi_display, tmpGC, IncludeInferiors );
|
|
|
|
XSetGraphicsExposures( gdi_display, tmpGC, False );
|
2011-09-16 17:10:41 +02:00
|
|
|
tmp_pixmap = XCreatePixmap( gdi_display, root_window, tmp.visrect.right - tmp.visrect.left,
|
2012-01-10 20:26:26 +01:00
|
|
|
tmp.visrect.bottom - tmp.visrect.top, physdev_dst->pict_format->depth );
|
2011-09-15 12:49:08 +02:00
|
|
|
|
2011-09-20 11:51:43 +02:00
|
|
|
xrender_stretch_blit( physdev_src, physdev_dst, tmp_pixmap, src, &tmp );
|
2011-09-15 13:12:54 +02:00
|
|
|
execute_rop( physdev_dst->x11dev, tmp_pixmap, tmpGC, &dst->visrect, rop );
|
2011-09-15 12:49:08 +02:00
|
|
|
|
2011-09-15 13:12:54 +02:00
|
|
|
XFreePixmap( gdi_display, tmp_pixmap );
|
|
|
|
XFreeGC( gdi_display, tmpGC );
|
|
|
|
}
|
2011-09-20 11:51:43 +02:00
|
|
|
else xrender_stretch_blit( physdev_src, physdev_dst, 0, src, dst );
|
2011-09-15 12:49:08 +02:00
|
|
|
|
2012-04-16 17:49:05 +02:00
|
|
|
add_device_bounds( physdev_dst->x11dev, &dst->visrect );
|
2011-09-15 12:49:08 +02:00
|
|
|
return TRUE;
|
2011-09-16 11:36:59 +02:00
|
|
|
|
|
|
|
x11drv_fallback:
|
|
|
|
return X11DRV_StretchBlt( &physdev_dst->x11dev->dev, dst, &physdev_src->x11dev->dev, src, rop );
|
2011-09-15 12:49:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-19 17:46:33 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* xrenderdrv_PutImage
|
|
|
|
*/
|
2012-05-23 23:36:20 +02:00
|
|
|
static DWORD xrenderdrv_PutImage( PHYSDEV dev, HRGN clip, BITMAPINFO *info,
|
2011-09-19 17:46:33 +02:00
|
|
|
const struct gdi_image_bits *bits, struct bitblt_coords *src,
|
|
|
|
struct bitblt_coords *dst, DWORD rop )
|
|
|
|
{
|
2012-05-23 23:36:20 +02:00
|
|
|
struct xrender_physdev *physdev = get_xrender_dev( dev );
|
2011-09-19 17:46:33 +02:00
|
|
|
DWORD ret;
|
|
|
|
Pixmap tmp_pixmap;
|
|
|
|
GC gc;
|
|
|
|
enum wxr_format src_format, dst_format;
|
|
|
|
XRenderPictFormat *pict_format;
|
2011-09-20 11:21:00 +02:00
|
|
|
Pixmap src_pixmap;
|
2011-10-03 23:47:31 +02:00
|
|
|
Picture src_pict, mask_pict = 0;
|
2011-09-20 11:21:00 +02:00
|
|
|
BOOL use_repeat;
|
2011-09-19 17:46:33 +02:00
|
|
|
|
2012-05-23 23:36:20 +02:00
|
|
|
dst_format = physdev->format;
|
2011-10-11 11:53:02 +02:00
|
|
|
src_format = get_xrender_format_from_bitmapinfo( info );
|
2011-09-19 17:46:33 +02:00
|
|
|
if (!(pict_format = pict_formats[src_format])) goto update_format;
|
|
|
|
|
|
|
|
/* make sure we can create an image with the same bpp */
|
|
|
|
if (info->bmiHeader.biBitCount != pixmap_formats[pict_format->depth]->bits_per_pixel)
|
|
|
|
goto update_format;
|
|
|
|
|
|
|
|
/* mono <-> color conversions not supported */
|
|
|
|
if ((src_format != dst_format) && (src_format == WXR_FORMAT_MONO || dst_format == WXR_FORMAT_MONO))
|
|
|
|
goto x11drv_fallback;
|
|
|
|
|
|
|
|
if (!bits) return ERROR_SUCCESS; /* just querying the format */
|
|
|
|
|
2011-10-03 23:47:31 +02:00
|
|
|
if (!has_alpha( src_format ) && has_alpha( dst_format )) mask_pict = get_no_alpha_mask();
|
|
|
|
|
2011-09-20 11:21:00 +02:00
|
|
|
ret = create_image_pixmap( info, bits, src, src_format, &src_pixmap, &src_pict, &use_repeat );
|
2011-09-19 17:46:33 +02:00
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
struct bitblt_coords tmp;
|
|
|
|
|
2012-05-23 23:36:20 +02:00
|
|
|
if (rop != SRCCOPY)
|
2011-09-19 17:46:33 +02:00
|
|
|
{
|
2012-05-23 23:36:20 +02:00
|
|
|
BOOL restore_region = add_extra_clipping_region( physdev->x11dev, clip );
|
2011-09-19 17:46:33 +02:00
|
|
|
|
2012-05-23 23:36:20 +02:00
|
|
|
/* make coordinates relative to tmp pixmap */
|
|
|
|
tmp = *dst;
|
|
|
|
tmp.x -= tmp.visrect.left;
|
|
|
|
tmp.y -= tmp.visrect.top;
|
|
|
|
OffsetRect( &tmp.visrect, -tmp.visrect.left, -tmp.visrect.top );
|
|
|
|
|
|
|
|
gc = XCreateGC( gdi_display, physdev->x11dev->drawable, 0, NULL );
|
|
|
|
XSetSubwindowMode( gdi_display, gc, IncludeInferiors );
|
|
|
|
XSetGraphicsExposures( gdi_display, gc, False );
|
|
|
|
tmp_pixmap = XCreatePixmap( gdi_display, root_window,
|
|
|
|
tmp.visrect.right - tmp.visrect.left,
|
|
|
|
tmp.visrect.bottom - tmp.visrect.top,
|
|
|
|
physdev->pict_format->depth );
|
2012-04-16 17:49:05 +02:00
|
|
|
|
2012-05-23 23:36:20 +02:00
|
|
|
xrender_put_image( src_pixmap, src_pict, mask_pict, NULL, physdev->pict_format,
|
|
|
|
NULL, tmp_pixmap, src, &tmp, use_repeat );
|
|
|
|
execute_rop( physdev->x11dev, tmp_pixmap, gc, &dst->visrect, rop );
|
|
|
|
|
|
|
|
XFreePixmap( gdi_display, tmp_pixmap );
|
|
|
|
XFreeGC( gdi_display, gc );
|
|
|
|
if (restore_region) restore_clipping_region( physdev->x11dev );
|
2011-09-19 17:46:33 +02:00
|
|
|
}
|
2012-05-23 23:36:20 +02:00
|
|
|
else xrender_put_image( src_pixmap, src_pict, mask_pict, clip,
|
|
|
|
physdev->pict_format, physdev, 0, src, dst, use_repeat );
|
|
|
|
|
|
|
|
add_device_bounds( physdev->x11dev, &dst->visrect );
|
2011-09-19 17:46:33 +02:00
|
|
|
|
2011-09-20 11:21:00 +02:00
|
|
|
pXRenderFreePicture( gdi_display, src_pict );
|
|
|
|
XFreePixmap( gdi_display, src_pixmap );
|
2011-09-19 17:46:33 +02:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
update_format:
|
|
|
|
if (info->bmiHeader.biHeight > 0) info->bmiHeader.biHeight = -info->bmiHeader.biHeight;
|
|
|
|
set_color_info( pict_formats[dst_format], info );
|
|
|
|
return ERROR_BAD_FORMAT;
|
|
|
|
|
|
|
|
x11drv_fallback:
|
|
|
|
dev = GET_NEXT_PHYSDEV( dev, pPutImage );
|
2012-05-23 23:36:20 +02:00
|
|
|
return dev->funcs->pPutImage( dev, clip, info, bits, src, dst, rop );
|
2011-09-19 17:46:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-20 12:00:00 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* xrenderdrv_BlendImage
|
|
|
|
*/
|
|
|
|
static DWORD xrenderdrv_BlendImage( PHYSDEV dev, BITMAPINFO *info, const struct gdi_image_bits *bits,
|
|
|
|
struct bitblt_coords *src, struct bitblt_coords *dst,
|
|
|
|
BLENDFUNCTION func )
|
|
|
|
{
|
|
|
|
struct xrender_physdev *physdev = get_xrender_dev( dev );
|
|
|
|
DWORD ret;
|
|
|
|
enum wxr_format format;
|
|
|
|
XRenderPictFormat *pict_format;
|
|
|
|
Picture dst_pict, src_pict, mask_pict;
|
|
|
|
Pixmap src_pixmap;
|
|
|
|
BOOL use_repeat;
|
|
|
|
|
2011-10-11 11:53:02 +02:00
|
|
|
format = get_xrender_format_from_bitmapinfo( info );
|
|
|
|
if (!(func.AlphaFormat & AC_SRC_ALPHA))
|
|
|
|
format = get_format_without_alpha( format );
|
2012-10-10 17:08:05 +02:00
|
|
|
else if (format != WXR_FORMAT_A8R8G8B8 || info->bmiHeader.biCompression != BI_RGB)
|
2011-10-11 11:53:02 +02:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2011-09-20 12:00:00 +02:00
|
|
|
if (!(pict_format = pict_formats[format])) goto update_format;
|
|
|
|
|
|
|
|
/* make sure we can create an image with the same bpp */
|
|
|
|
if (info->bmiHeader.biBitCount != pixmap_formats[pict_format->depth]->bits_per_pixel)
|
|
|
|
goto update_format;
|
|
|
|
|
|
|
|
if (format == WXR_FORMAT_MONO && physdev->format != WXR_FORMAT_MONO)
|
|
|
|
goto update_format;
|
|
|
|
|
|
|
|
if (!bits) return ERROR_SUCCESS; /* just querying the format */
|
|
|
|
|
|
|
|
ret = create_image_pixmap( info, bits, src, format, &src_pixmap, &src_pict, &use_repeat );
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
double xscale, yscale;
|
|
|
|
|
|
|
|
if (!use_repeat)
|
|
|
|
{
|
|
|
|
xscale = src->width / (double)dst->width;
|
|
|
|
yscale = src->height / (double)dst->height;
|
|
|
|
}
|
|
|
|
else xscale = yscale = 1; /* no scaling needed with a repeating source */
|
|
|
|
|
|
|
|
dst_pict = get_xrender_picture( physdev, 0, &dst->visrect );
|
|
|
|
|
|
|
|
EnterCriticalSection( &xrender_cs );
|
|
|
|
mask_pict = get_mask_pict( func.SourceConstantAlpha * 257 );
|
|
|
|
|
2012-01-18 14:39:18 +01:00
|
|
|
xrender_blit( PictOpOver, src_pict, mask_pict, dst_pict,
|
|
|
|
src->x, src->y, src->width, src->height,
|
2011-09-20 12:00:00 +02:00
|
|
|
physdev->x11dev->dc_rect.left + dst->x,
|
|
|
|
physdev->x11dev->dc_rect.top + dst->y,
|
2012-01-18 14:39:18 +01:00
|
|
|
dst->width, dst->height, xscale, yscale );
|
2011-09-20 20:22:34 +02:00
|
|
|
|
2011-09-20 12:00:00 +02:00
|
|
|
pXRenderFreePicture( gdi_display, src_pict );
|
|
|
|
XFreePixmap( gdi_display, src_pixmap );
|
|
|
|
|
|
|
|
LeaveCriticalSection( &xrender_cs );
|
2012-04-16 17:49:05 +02:00
|
|
|
add_device_bounds( physdev->x11dev, &dst->visrect );
|
2011-09-20 12:00:00 +02:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
update_format:
|
|
|
|
if (info->bmiHeader.biHeight > 0) info->bmiHeader.biHeight = -info->bmiHeader.biHeight;
|
|
|
|
set_color_info( physdev->pict_format, info );
|
|
|
|
return ERROR_BAD_FORMAT;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-12 12:20:01 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* xrenderdrv_AlphaBlend
|
2005-04-20 17:18:42 +02:00
|
|
|
*/
|
2011-09-12 12:20:01 +02:00
|
|
|
static BOOL xrenderdrv_AlphaBlend( PHYSDEV dst_dev, struct bitblt_coords *dst,
|
|
|
|
PHYSDEV src_dev, struct bitblt_coords *src, BLENDFUNCTION blendfn )
|
2004-08-02 20:54:54 +02:00
|
|
|
{
|
2011-09-12 12:20:01 +02:00
|
|
|
struct xrender_physdev *physdev_dst = get_xrender_dev( dst_dev );
|
|
|
|
struct xrender_physdev *physdev_src = get_xrender_dev( src_dev );
|
2010-04-15 15:55:40 +02:00
|
|
|
Picture dst_pict, src_pict = 0, mask_pict = 0, tmp_pict = 0;
|
2011-09-20 20:23:18 +02:00
|
|
|
XRenderPictureAttributes pa;
|
|
|
|
Pixmap tmp_pixmap = 0;
|
2010-04-15 11:39:41 +02:00
|
|
|
double xscale, yscale;
|
2004-08-02 20:54:54 +02:00
|
|
|
|
2012-01-10 17:49:39 +01:00
|
|
|
if (src_dev->funcs != dst_dev->funcs)
|
2011-09-12 12:20:01 +02:00
|
|
|
{
|
|
|
|
dst_dev = GET_NEXT_PHYSDEV( dst_dev, pAlphaBlend );
|
|
|
|
return dst_dev->funcs->pAlphaBlend( dst_dev, dst, src_dev, src, blendfn );
|
|
|
|
}
|
|
|
|
|
2011-10-11 11:53:02 +02:00
|
|
|
if ((blendfn.AlphaFormat & AC_SRC_ALPHA) && physdev_src->format != WXR_FORMAT_A8R8G8B8)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-09-20 11:51:43 +02:00
|
|
|
dst_pict = get_xrender_picture( physdev_dst, 0, &dst->visrect );
|
2009-09-22 20:30:24 +02:00
|
|
|
|
2012-05-25 11:28:37 +02:00
|
|
|
xscale = src->width / (double)dst->width;
|
|
|
|
yscale = src->height / (double)dst->height;
|
2007-08-30 19:43:20 +02:00
|
|
|
|
2012-05-25 11:28:37 +02:00
|
|
|
src_pict = get_xrender_picture_source( physdev_src, FALSE );
|
2011-09-20 20:23:18 +02:00
|
|
|
|
|
|
|
if (physdev_src->format == WXR_FORMAT_MONO && physdev_dst->format != WXR_FORMAT_MONO)
|
|
|
|
{
|
|
|
|
/* mono -> color blending needs an intermediate color pixmap */
|
|
|
|
XRenderColor fg, bg;
|
|
|
|
int width = src->visrect.right - src->visrect.left;
|
|
|
|
int height = src->visrect.bottom - src->visrect.top;
|
|
|
|
|
|
|
|
/* blending doesn't use the destination DC colors */
|
|
|
|
fg.red = fg.green = fg.blue = 0;
|
|
|
|
bg.red = bg.green = bg.blue = 0xffff;
|
|
|
|
fg.alpha = bg.alpha = 0xffff;
|
|
|
|
|
|
|
|
tmp_pixmap = XCreatePixmap( gdi_display, root_window, width, height,
|
|
|
|
physdev_dst->pict_format->depth );
|
2012-05-25 11:28:37 +02:00
|
|
|
tmp_pict = pXRenderCreatePicture( gdi_display, tmp_pixmap, physdev_dst->pict_format, 0, NULL );
|
2011-09-20 20:23:18 +02:00
|
|
|
|
|
|
|
xrender_mono_blit( src_pict, tmp_pict, physdev_dst->format, &fg, &bg,
|
2012-01-18 14:39:18 +01:00
|
|
|
src->visrect.left, src->visrect.top, width, height, 0, 0, width, height, 1, 1 );
|
2011-09-20 20:23:18 +02:00
|
|
|
}
|
|
|
|
else if (!(blendfn.AlphaFormat & AC_SRC_ALPHA) && physdev_src->pict_format)
|
2007-08-30 19:43:20 +02:00
|
|
|
{
|
2010-04-15 11:39:41 +02:00
|
|
|
/* we need a source picture with no alpha */
|
2011-09-15 15:26:44 +02:00
|
|
|
enum wxr_format format = get_format_without_alpha( physdev_src->format );
|
|
|
|
if (format != physdev_src->format)
|
2010-04-15 15:55:40 +02:00
|
|
|
{
|
|
|
|
pa.subwindow_mode = IncludeInferiors;
|
2011-09-15 15:10:17 +02:00
|
|
|
tmp_pict = pXRenderCreatePicture( gdi_display, physdev_src->x11dev->drawable,
|
2012-05-25 11:28:37 +02:00
|
|
|
pict_formats[format], CPSubwindowMode, &pa );
|
2010-04-15 15:55:40 +02:00
|
|
|
}
|
2009-07-05 20:52:19 +02:00
|
|
|
}
|
2010-04-15 15:55:40 +02:00
|
|
|
|
2011-09-20 20:23:18 +02:00
|
|
|
if (tmp_pict) src_pict = tmp_pict;
|
2004-08-02 20:54:54 +02:00
|
|
|
|
2010-04-15 11:39:41 +02:00
|
|
|
EnterCriticalSection( &xrender_cs );
|
|
|
|
mask_pict = get_mask_pict( blendfn.SourceConstantAlpha * 257 );
|
2004-08-02 20:54:54 +02:00
|
|
|
|
2010-04-15 11:39:41 +02:00
|
|
|
xrender_blit( PictOpOver, src_pict, mask_pict, dst_pict,
|
2011-09-16 17:10:41 +02:00
|
|
|
physdev_src->x11dev->dc_rect.left + src->x,
|
|
|
|
physdev_src->x11dev->dc_rect.top + src->y,
|
2012-01-18 14:39:18 +01:00
|
|
|
src->width, src->height,
|
2011-09-16 17:10:41 +02:00
|
|
|
physdev_dst->x11dev->dc_rect.left + dst->x,
|
|
|
|
physdev_dst->x11dev->dc_rect.top + dst->y,
|
2012-01-18 14:39:18 +01:00
|
|
|
dst->width, dst->height, xscale, yscale );
|
2011-09-20 20:22:34 +02:00
|
|
|
|
2010-04-15 11:39:41 +02:00
|
|
|
if (tmp_pict) pXRenderFreePicture( gdi_display, tmp_pict );
|
2011-09-20 20:23:18 +02:00
|
|
|
if (tmp_pixmap) XFreePixmap( gdi_display, tmp_pixmap );
|
2010-04-15 11:39:41 +02:00
|
|
|
|
|
|
|
LeaveCriticalSection( &xrender_cs );
|
2012-04-16 17:49:05 +02:00
|
|
|
add_device_bounds( physdev_dst->x11dev, &dst->visrect );
|
2004-08-02 20:54:54 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-11-30 13:22:21 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* xrenderdrv_GradientFill
|
|
|
|
*/
|
|
|
|
static BOOL xrenderdrv_GradientFill( PHYSDEV dev, TRIVERTEX *vert_array, ULONG nvert,
|
|
|
|
void * grad_array, ULONG ngrad, ULONG mode )
|
|
|
|
{
|
|
|
|
#ifdef HAVE_XRENDERCREATELINEARGRADIENT
|
|
|
|
static const XFixed stops[2] = { 0, 1 << 16 };
|
|
|
|
struct xrender_physdev *physdev = get_xrender_dev( dev );
|
|
|
|
XLinearGradient gradient;
|
|
|
|
XRenderColor colors[2];
|
|
|
|
Picture src_pict, dst_pict;
|
|
|
|
unsigned int i;
|
|
|
|
const GRADIENT_RECT *rect = grad_array;
|
2012-04-16 17:49:05 +02:00
|
|
|
RECT rc;
|
2011-11-30 13:22:21 +01:00
|
|
|
POINT pt[2];
|
|
|
|
|
|
|
|
if (!pXRenderCreateLinearGradient) goto fallback;
|
|
|
|
|
2011-12-05 13:46:23 +01:00
|
|
|
/* <= 16-bpp uses dithering */
|
|
|
|
if (!physdev->pict_format || physdev->pict_format->depth <= 16) goto fallback;
|
2011-11-30 13:22:21 +01:00
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case GRADIENT_FILL_RECT_H:
|
|
|
|
case GRADIENT_FILL_RECT_V:
|
|
|
|
for (i = 0; i < ngrad; i++, rect++)
|
|
|
|
{
|
|
|
|
const TRIVERTEX *v1 = vert_array + rect->UpperLeft;
|
|
|
|
const TRIVERTEX *v2 = vert_array + rect->LowerRight;
|
|
|
|
|
|
|
|
colors[0].red = v1->Red * 257 / 256;
|
|
|
|
colors[0].green = v1->Green * 257 / 256;
|
|
|
|
colors[0].blue = v1->Blue * 257 / 256;
|
|
|
|
colors[1].red = v2->Red * 257 / 256;
|
|
|
|
colors[1].green = v2->Green * 257 / 256;
|
|
|
|
colors[1].blue = v2->Blue * 257 / 256;
|
2011-12-02 14:12:07 +01:00
|
|
|
/* always ignore alpha since otherwise xrender will want to pre-multiply the colors */
|
|
|
|
colors[0].alpha = colors[1].alpha = 65535;
|
2011-11-30 13:22:21 +01:00
|
|
|
|
|
|
|
pt[0].x = v1->x;
|
|
|
|
pt[0].y = v1->y;
|
|
|
|
pt[1].x = v2->x;
|
|
|
|
pt[1].y = v2->y;
|
|
|
|
LPtoDP( dev->hdc, pt, 2 );
|
|
|
|
if (mode == GRADIENT_FILL_RECT_H)
|
|
|
|
{
|
|
|
|
gradient.p1.y = gradient.p2.y = 0;
|
|
|
|
if (pt[1].x > pt[0].x)
|
|
|
|
{
|
|
|
|
gradient.p1.x = 0;
|
|
|
|
gradient.p2.x = (pt[1].x - pt[0].x) << 16;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gradient.p1.x = (pt[0].x - pt[1].x) << 16;
|
|
|
|
gradient.p2.x = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gradient.p1.x = gradient.p2.x = 0;
|
|
|
|
if (pt[1].y > pt[0].y)
|
|
|
|
{
|
|
|
|
gradient.p1.y = 0;
|
|
|
|
gradient.p2.y = (pt[1].y - pt[0].y) << 16;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gradient.p1.y = (pt[0].y - pt[1].y) << 16;
|
|
|
|
gradient.p2.y = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-16 17:49:05 +02:00
|
|
|
rc.left = min( pt[0].x, pt[1].x );
|
|
|
|
rc.top = min( pt[0].y, pt[1].y );
|
|
|
|
rc.right = max( pt[0].x, pt[1].x );
|
|
|
|
rc.bottom = max( pt[0].y, pt[1].y );
|
|
|
|
|
|
|
|
TRACE( "%u gradient %s colors %04x,%04x,%04x,%04x -> %04x,%04x,%04x,%04x\n",
|
|
|
|
mode, wine_dbgstr_rect( &rc ),
|
2011-11-30 13:22:21 +01:00
|
|
|
colors[0].red, colors[0].green, colors[0].blue, colors[0].alpha,
|
|
|
|
colors[1].red, colors[1].green, colors[1].blue, colors[1].alpha );
|
|
|
|
|
2011-12-07 17:57:32 +01:00
|
|
|
dst_pict = get_xrender_picture( physdev, 0, NULL );
|
|
|
|
|
2011-11-30 13:22:21 +01:00
|
|
|
src_pict = pXRenderCreateLinearGradient( gdi_display, &gradient, stops, colors, 2 );
|
2012-01-18 14:39:18 +01:00
|
|
|
xrender_blit( PictOpSrc, src_pict, 0, dst_pict,
|
2012-04-16 17:49:05 +02:00
|
|
|
0, 0, rc.right - rc.left, rc.bottom - rc.top,
|
|
|
|
physdev->x11dev->dc_rect.left + rc.left,
|
|
|
|
physdev->x11dev->dc_rect.top + rc.top,
|
|
|
|
rc.right - rc.left, rc.bottom - rc.top, 1, 1 );
|
2011-11-30 13:22:21 +01:00
|
|
|
pXRenderFreePicture( gdi_display, src_pict );
|
2012-04-16 17:49:05 +02:00
|
|
|
add_device_bounds( physdev->x11dev, &rc );
|
2011-11-30 13:22:21 +01:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
fallback:
|
|
|
|
#endif
|
|
|
|
dev = GET_NEXT_PHYSDEV( dev, pGradientFill );
|
|
|
|
return dev->funcs->pGradientFill( dev, vert_array, nvert, grad_array, ngrad, mode );
|
|
|
|
}
|
|
|
|
|
2011-11-03 17:40:47 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* xrenderdrv_SelectBrush
|
|
|
|
*/
|
2011-12-29 19:49:41 +01:00
|
|
|
static HBRUSH xrenderdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern )
|
2009-09-10 10:41:51 +02:00
|
|
|
{
|
2011-11-03 17:40:47 +01:00
|
|
|
struct xrender_physdev *physdev = get_xrender_dev( dev );
|
|
|
|
Pixmap pixmap;
|
2012-09-25 15:51:03 +02:00
|
|
|
XVisualInfo vis = default_visual;
|
2012-05-23 21:44:59 +02:00
|
|
|
XRenderPictFormat *format = physdev->pict_format;
|
2009-09-10 10:41:51 +02:00
|
|
|
|
2011-12-29 19:49:41 +01:00
|
|
|
if (!pattern) goto x11drv_fallback;
|
2012-05-23 21:44:59 +02:00
|
|
|
if (pattern->info->bmiHeader.biBitCount == 1) goto x11drv_fallback;
|
2011-11-03 17:40:47 +01:00
|
|
|
if (physdev->format == WXR_FORMAT_MONO) goto x11drv_fallback;
|
2009-09-10 10:41:51 +02:00
|
|
|
|
2012-05-23 21:44:59 +02:00
|
|
|
vis.depth = format->depth;
|
|
|
|
vis.red_mask = format->direct.redMask << format->direct.red;
|
|
|
|
vis.green_mask = format->direct.greenMask << format->direct.green;
|
|
|
|
vis.blue_mask = format->direct.blueMask << format->direct.blue;
|
2009-09-10 10:41:51 +02:00
|
|
|
|
2012-05-23 21:44:59 +02:00
|
|
|
pixmap = create_pixmap_from_image( physdev->dev.hdc, &vis, pattern->info,
|
|
|
|
&pattern->bits, pattern->usage );
|
|
|
|
if (!pixmap) return 0;
|
2009-09-10 10:41:51 +02:00
|
|
|
|
2011-11-03 17:40:47 +01:00
|
|
|
if (physdev->x11dev->brush.pixmap) XFreePixmap( gdi_display, physdev->x11dev->brush.pixmap );
|
|
|
|
physdev->x11dev->brush.pixmap = pixmap;
|
|
|
|
physdev->x11dev->brush.fillStyle = FillTiled;
|
|
|
|
physdev->x11dev->brush.pixel = 0; /* ignored */
|
2011-12-14 17:35:21 +01:00
|
|
|
physdev->x11dev->brush.style = BS_PATTERN;
|
2011-11-03 17:40:47 +01:00
|
|
|
return hbrush;
|
|
|
|
|
|
|
|
x11drv_fallback:
|
|
|
|
dev = GET_NEXT_PHYSDEV( dev, pSelectBrush );
|
2011-12-29 19:49:41 +01:00
|
|
|
return dev->funcs->pSelectBrush( dev, hbrush, pattern );
|
2009-09-10 10:41:51 +02:00
|
|
|
}
|
|
|
|
|
2011-11-03 17:40:47 +01:00
|
|
|
|
2011-09-12 11:39:17 +02:00
|
|
|
static const struct gdi_dc_funcs xrender_funcs =
|
|
|
|
{
|
|
|
|
NULL, /* pAbortDoc */
|
|
|
|
NULL, /* pAbortPath */
|
2011-09-12 12:20:01 +02:00
|
|
|
xrenderdrv_AlphaBlend, /* pAlphaBlend */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pAngleArc */
|
|
|
|
NULL, /* pArc */
|
|
|
|
NULL, /* pArcTo */
|
|
|
|
NULL, /* pBeginPath */
|
2011-09-20 12:00:00 +02:00
|
|
|
xrenderdrv_BlendImage, /* pBlendImage */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pChord */
|
|
|
|
NULL, /* pCloseFigure */
|
|
|
|
xrenderdrv_CreateCompatibleDC, /* pCreateCompatibleDC */
|
|
|
|
xrenderdrv_CreateDC, /* pCreateDC */
|
|
|
|
xrenderdrv_DeleteDC, /* pDeleteDC */
|
|
|
|
NULL, /* pDeleteObject */
|
|
|
|
NULL, /* pDeviceCapabilities */
|
|
|
|
NULL, /* pEllipse */
|
|
|
|
NULL, /* pEndDoc */
|
|
|
|
NULL, /* pEndPage */
|
|
|
|
NULL, /* pEndPath */
|
2011-10-19 15:37:10 +02:00
|
|
|
NULL, /* pEnumFonts */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pEnumICMProfiles */
|
|
|
|
NULL, /* pExcludeClipRect */
|
|
|
|
NULL, /* pExtDeviceMode */
|
2011-09-12 12:04:41 +02:00
|
|
|
xrenderdrv_ExtEscape, /* pExtEscape */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pExtFloodFill */
|
|
|
|
NULL, /* pExtSelectClipRgn */
|
2011-09-12 11:57:22 +02:00
|
|
|
xrenderdrv_ExtTextOut, /* pExtTextOut */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pFillPath */
|
|
|
|
NULL, /* pFillRgn */
|
|
|
|
NULL, /* pFlattenPath */
|
2011-10-19 21:51:39 +02:00
|
|
|
NULL, /* pFontIsLinked */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pFrameRgn */
|
|
|
|
NULL, /* pGdiComment */
|
2011-10-19 21:51:39 +02:00
|
|
|
NULL, /* pGdiRealizationInfo */
|
2012-04-10 16:17:14 +02:00
|
|
|
NULL, /* pGetBoundsRect */
|
2011-10-19 21:51:39 +02:00
|
|
|
NULL, /* pGetCharABCWidths */
|
|
|
|
NULL, /* pGetCharABCWidthsI */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pGetCharWidth */
|
|
|
|
NULL, /* pGetDeviceCaps */
|
|
|
|
NULL, /* pGetDeviceGammaRamp */
|
2011-10-19 21:51:39 +02:00
|
|
|
NULL, /* pGetFontData */
|
|
|
|
NULL, /* pGetFontUnicodeRanges */
|
|
|
|
NULL, /* pGetGlyphIndices */
|
|
|
|
NULL, /* pGetGlyphOutline */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pGetICMProfile */
|
2012-05-23 23:36:20 +02:00
|
|
|
NULL, /* pGetImage */
|
2011-10-19 21:51:39 +02:00
|
|
|
NULL, /* pGetKerningPairs */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pGetNearestColor */
|
2011-10-19 21:51:39 +02:00
|
|
|
NULL, /* pGetOutlineTextMetrics */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pGetPixel */
|
|
|
|
NULL, /* pGetSystemPaletteEntries */
|
2011-10-19 21:51:39 +02:00
|
|
|
NULL, /* pGetTextCharsetInfo */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pGetTextExtentExPoint */
|
2011-10-19 21:51:39 +02:00
|
|
|
NULL, /* pGetTextExtentExPointI */
|
|
|
|
NULL, /* pGetTextFace */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pGetTextMetrics */
|
2011-11-30 13:22:21 +01:00
|
|
|
xrenderdrv_GradientFill, /* pGradientFill */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pIntersectClipRect */
|
|
|
|
NULL, /* pInvertRgn */
|
|
|
|
NULL, /* pLineTo */
|
|
|
|
NULL, /* pModifyWorldTransform */
|
|
|
|
NULL, /* pMoveTo */
|
|
|
|
NULL, /* pOffsetClipRgn */
|
|
|
|
NULL, /* pOffsetViewportOrg */
|
|
|
|
NULL, /* pOffsetWindowOrg */
|
|
|
|
NULL, /* pPaintRgn */
|
|
|
|
NULL, /* pPatBlt */
|
|
|
|
NULL, /* pPie */
|
|
|
|
NULL, /* pPolyBezier */
|
|
|
|
NULL, /* pPolyBezierTo */
|
|
|
|
NULL, /* pPolyDraw */
|
|
|
|
NULL, /* pPolyPolygon */
|
|
|
|
NULL, /* pPolyPolyline */
|
|
|
|
NULL, /* pPolygon */
|
|
|
|
NULL, /* pPolyline */
|
|
|
|
NULL, /* pPolylineTo */
|
2011-09-12 12:12:15 +02:00
|
|
|
xrenderdrv_PutImage, /* pPutImage */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pRealizeDefaultPalette */
|
|
|
|
NULL, /* pRealizePalette */
|
|
|
|
NULL, /* pRectangle */
|
|
|
|
NULL, /* pResetDC */
|
|
|
|
NULL, /* pRestoreDC */
|
|
|
|
NULL, /* pRoundRect */
|
|
|
|
NULL, /* pSaveDC */
|
|
|
|
NULL, /* pScaleViewportExt */
|
|
|
|
NULL, /* pScaleWindowExt */
|
2012-05-23 23:55:17 +02:00
|
|
|
NULL, /* pSelectBitmap */
|
2011-11-03 17:40:47 +01:00
|
|
|
xrenderdrv_SelectBrush, /* pSelectBrush */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pSelectClipPath */
|
2011-09-12 11:50:42 +02:00
|
|
|
xrenderdrv_SelectFont, /* pSelectFont */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pSelectPalette */
|
|
|
|
NULL, /* pSelectPen */
|
|
|
|
NULL, /* pSetArcDirection */
|
|
|
|
NULL, /* pSetBkColor */
|
|
|
|
NULL, /* pSetBkMode */
|
2012-04-25 12:26:44 +02:00
|
|
|
NULL, /* pSetBoundsRect */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pSetDCBrushColor */
|
|
|
|
NULL, /* pSetDCPenColor */
|
|
|
|
NULL, /* pSetDIBitsToDevice */
|
2011-09-13 15:47:19 +02:00
|
|
|
xrenderdrv_SetDeviceClipping, /* pSetDeviceClipping */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pSetDeviceGammaRamp */
|
|
|
|
NULL, /* pSetLayout */
|
|
|
|
NULL, /* pSetMapMode */
|
|
|
|
NULL, /* pSetMapperFlags */
|
|
|
|
NULL, /* pSetPixel */
|
|
|
|
NULL, /* pSetPolyFillMode */
|
|
|
|
NULL, /* pSetROP2 */
|
|
|
|
NULL, /* pSetRelAbs */
|
|
|
|
NULL, /* pSetStretchBltMode */
|
|
|
|
NULL, /* pSetTextAlign */
|
|
|
|
NULL, /* pSetTextCharacterExtra */
|
|
|
|
NULL, /* pSetTextColor */
|
|
|
|
NULL, /* pSetTextJustification */
|
|
|
|
NULL, /* pSetViewportExt */
|
|
|
|
NULL, /* pSetViewportOrg */
|
|
|
|
NULL, /* pSetWindowExt */
|
|
|
|
NULL, /* pSetWindowOrg */
|
|
|
|
NULL, /* pSetWorldTransform */
|
|
|
|
NULL, /* pStartDoc */
|
|
|
|
NULL, /* pStartPage */
|
2011-09-15 12:49:08 +02:00
|
|
|
xrenderdrv_StretchBlt, /* pStretchBlt */
|
2011-09-12 11:39:17 +02:00
|
|
|
NULL, /* pStretchDIBits */
|
|
|
|
NULL, /* pStrokeAndFillPath */
|
|
|
|
NULL, /* pStrokePath */
|
|
|
|
NULL, /* pUnrealizePalette */
|
|
|
|
NULL, /* pWidenPath */
|
2012-06-28 14:13:24 +02:00
|
|
|
NULL, /* wine_get_wgl_driver */
|
2012-05-08 12:16:05 +02:00
|
|
|
GDI_PRIORITY_GRAPHICS_DRV + 10 /* priority */
|
2011-09-12 11:39:17 +02:00
|
|
|
};
|
|
|
|
|
2007-07-04 12:47:57 +02:00
|
|
|
#else /* SONAME_LIBXRENDER */
|
2002-01-29 04:07:21 +01:00
|
|
|
|
2011-09-12 11:39:17 +02:00
|
|
|
const struct gdi_dc_funcs *X11DRV_XRender_Init(void)
|
2002-01-29 04:07:21 +01:00
|
|
|
{
|
|
|
|
TRACE("XRender support not compiled in.\n");
|
2011-09-12 11:39:17 +02:00
|
|
|
return NULL;
|
2002-01-29 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
2007-07-04 12:47:57 +02:00
|
|
|
#endif /* SONAME_LIBXRENDER */
|