2003-11-14 17:48:57 +01:00
|
|
|
/*
|
|
|
|
*
|
2004-12-04 01:43:13 +01:00
|
|
|
* Copyright © 2000 SuSE, Inc.
|
2007-05-18 03:31:08 +02:00
|
|
|
* Copyright © 2007 Red Hat, Inc.
|
2003-11-14 17:48:57 +01:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
* the above copyright notice appear in all copies and that both that
|
|
|
|
* copyright notice and this permission notice appear in supporting
|
|
|
|
* documentation, and that the name of SuSE not be used in advertising or
|
|
|
|
* publicity pertaining to distribution of the software without specific,
|
|
|
|
* written prior permission. SuSE makes no representations about the
|
|
|
|
* suitability of this software for any purpose. It is provided "as is"
|
|
|
|
* without express or implied warranty.
|
|
|
|
*
|
|
|
|
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
|
|
|
|
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
2005-06-13 16:40:25 +02:00
|
|
|
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
2003-11-14 17:48:57 +01:00
|
|
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* Author: Keith Packard, SuSE, Inc.
|
|
|
|
*/
|
|
|
|
|
2005-07-03 09:02:09 +02:00
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
2006-02-10 23:00:30 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
2003-11-14 17:48:57 +01:00
|
|
|
#include "fb.h"
|
|
|
|
|
|
|
|
#include "picturestr.h"
|
|
|
|
#include "mipict.h"
|
|
|
|
#include "fbpict.h"
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
fbComposite(CARD8 op,
|
|
|
|
PicturePtr pSrc,
|
|
|
|
PicturePtr pMask,
|
|
|
|
PicturePtr pDst,
|
|
|
|
INT16 xSrc,
|
|
|
|
INT16 ySrc,
|
|
|
|
INT16 xMask,
|
|
|
|
INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2007-05-22 02:00:25 +02:00
|
|
|
pixman_image_t *src, *mask, *dest;
|
2009-12-02 17:37:20 +01:00
|
|
|
int src_xoff, src_yoff;
|
|
|
|
int msk_xoff, msk_yoff;
|
|
|
|
int dst_xoff, dst_yoff;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
miCompositeSourceValidate(pSrc);
|
2007-06-11 15:16:46 +02:00
|
|
|
if (pMask)
|
2012-03-21 20:55:09 +01:00
|
|
|
miCompositeSourceValidate(pMask);
|
|
|
|
|
|
|
|
src = image_from_pict(pSrc, FALSE, &src_xoff, &src_yoff);
|
|
|
|
mask = image_from_pict(pMask, FALSE, &msk_xoff, &msk_yoff);
|
|
|
|
dest = image_from_pict(pDst, TRUE, &dst_xoff, &dst_yoff);
|
|
|
|
|
|
|
|
if (src && dest && !(pMask && !mask)) {
|
|
|
|
pixman_image_composite(op, src, mask, dest,
|
|
|
|
xSrc + src_xoff, ySrc + src_yoff,
|
|
|
|
xMask + msk_xoff, yMask + msk_yoff,
|
|
|
|
xDst + dst_xoff, yDst + dst_yoff, width, height);
|
2005-05-09 01:34:15 +02:00
|
|
|
}
|
2007-08-01 23:30:03 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
free_pixman_pict(pSrc, src);
|
|
|
|
free_pixman_pict(pMask, mask);
|
|
|
|
free_pixman_pict(pDst, dest);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2012-05-30 11:19:08 +02:00
|
|
|
static pixman_glyph_cache_t *glyphCache;
|
|
|
|
|
|
|
|
void
|
|
|
|
fbDestroyGlyphCache(void)
|
|
|
|
{
|
|
|
|
if (glyphCache)
|
|
|
|
{
|
|
|
|
pixman_glyph_cache_destroy (glyphCache);
|
|
|
|
glyphCache = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-08 18:13:13 +02:00
|
|
|
static void
|
2012-05-30 11:19:08 +02:00
|
|
|
fbUnrealizeGlyph(ScreenPtr pScreen,
|
|
|
|
GlyphPtr pGlyph)
|
|
|
|
{
|
|
|
|
if (glyphCache)
|
|
|
|
pixman_glyph_cache_remove (glyphCache, pGlyph, NULL);
|
|
|
|
}
|
|
|
|
|
2014-04-02 06:15:41 +02:00
|
|
|
void
|
2012-05-30 11:19:08 +02:00
|
|
|
fbGlyphs(CARD8 op,
|
|
|
|
PicturePtr pSrc,
|
|
|
|
PicturePtr pDst,
|
|
|
|
PictFormatPtr maskFormat,
|
|
|
|
INT16 xSrc,
|
|
|
|
INT16 ySrc, int nlist,
|
|
|
|
GlyphListPtr list,
|
|
|
|
GlyphPtr *glyphs)
|
|
|
|
{
|
|
|
|
#define N_STACK_GLYPHS 512
|
|
|
|
ScreenPtr pScreen = pDst->pDrawable->pScreen;
|
|
|
|
pixman_glyph_t stack_glyphs[N_STACK_GLYPHS];
|
|
|
|
pixman_glyph_t *pglyphs = stack_glyphs;
|
|
|
|
pixman_image_t *srcImage, *dstImage;
|
|
|
|
int srcXoff, srcYoff, dstXoff, dstYoff;
|
|
|
|
GlyphPtr glyph;
|
|
|
|
int n_glyphs;
|
|
|
|
int x, y;
|
|
|
|
int i, n;
|
|
|
|
int xDst = list->xOff, yDst = list->yOff;
|
|
|
|
|
|
|
|
miCompositeSourceValidate(pSrc);
|
2014-10-31 00:45:12 +01:00
|
|
|
|
2012-05-30 11:19:08 +02:00
|
|
|
n_glyphs = 0;
|
|
|
|
for (i = 0; i < nlist; ++i)
|
|
|
|
n_glyphs += list[i].len;
|
|
|
|
|
|
|
|
if (!glyphCache)
|
|
|
|
glyphCache = pixman_glyph_cache_create();
|
|
|
|
|
|
|
|
pixman_glyph_cache_freeze (glyphCache);
|
2014-10-31 00:45:12 +01:00
|
|
|
|
2012-05-30 11:19:08 +02:00
|
|
|
if (n_glyphs > N_STACK_GLYPHS) {
|
|
|
|
if (!(pglyphs = malloc (n_glyphs * sizeof (pixman_glyph_t))))
|
|
|
|
goto out;
|
|
|
|
}
|
2014-10-31 00:45:12 +01:00
|
|
|
|
2012-05-30 11:19:08 +02:00
|
|
|
i = 0;
|
|
|
|
x = y = 0;
|
|
|
|
while (nlist--) {
|
|
|
|
x += list->xOff;
|
|
|
|
y += list->yOff;
|
|
|
|
n = list->len;
|
|
|
|
while (n--) {
|
|
|
|
const void *g;
|
|
|
|
|
|
|
|
glyph = *glyphs++;
|
|
|
|
|
|
|
|
if (!(g = pixman_glyph_cache_lookup (glyphCache, glyph, NULL))) {
|
|
|
|
pixman_image_t *glyphImage;
|
|
|
|
PicturePtr pPicture;
|
|
|
|
int xoff, yoff;
|
|
|
|
|
|
|
|
pPicture = GetGlyphPicture(glyph, pScreen);
|
|
|
|
if (!pPicture) {
|
|
|
|
n_glyphs--;
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(glyphImage = image_from_pict(pPicture, FALSE, &xoff, &yoff)))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
g = pixman_glyph_cache_insert(glyphCache, glyph, NULL,
|
|
|
|
glyph->info.x,
|
|
|
|
glyph->info.y,
|
|
|
|
glyphImage);
|
|
|
|
|
|
|
|
free_pixman_pict(pPicture, glyphImage);
|
|
|
|
|
|
|
|
if (!g)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
pglyphs[i].x = x;
|
|
|
|
pglyphs[i].y = y;
|
|
|
|
pglyphs[i].glyph = g;
|
|
|
|
i++;
|
|
|
|
|
|
|
|
next:
|
|
|
|
x += glyph->info.xOff;
|
|
|
|
y += glyph->info.yOff;
|
|
|
|
}
|
|
|
|
list++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(srcImage = image_from_pict(pSrc, FALSE, &srcXoff, &srcYoff)))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (!(dstImage = image_from_pict(pDst, TRUE, &dstXoff, &dstYoff)))
|
|
|
|
goto out_free_src;
|
|
|
|
|
|
|
|
if (maskFormat) {
|
|
|
|
pixman_format_code_t format;
|
|
|
|
pixman_box32_t extents;
|
|
|
|
|
|
|
|
format = maskFormat->format | (maskFormat->depth << 24);
|
|
|
|
|
|
|
|
pixman_glyph_get_extents(glyphCache, n_glyphs, pglyphs, &extents);
|
|
|
|
|
|
|
|
pixman_composite_glyphs(op, srcImage, dstImage, format,
|
fb: Fix origin of source picture in fbGlyphs
If a source picture doesn't repeat and a mask format is specified, the
incorrect calulation of the origin of the glyphs caused the glyphs to
not be drawn at all.
Noticed when running gtk-demo from RHEL 6.5 and selecting "Rotated
Text".
Signed-off-by: Peter Harris <pharris@opentext.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
/* Test for this bug
cc -std=c99 -o glyph glyph.c `pkg-config --cflags --libs xcb-render`
*/
// 16 x 16 pictfmt_a8 "glyph"
static const char glyph[] = {
0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff,
0, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0,
0, 0, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0, 0,
0, 0, 0, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0, 0, 0,
0, 0, 0, 0, 0xff, 0, 0, 0, 0, 0, 0, 0xff, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0xff, 0, 0, 0, 0, 0xff, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0xff, 0, 0, 0xff, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0xff, 0, 0, 0xff, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0xff, 0, 0, 0, 0, 0xff, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0xff, 0, 0, 0, 0, 0, 0, 0xff, 0, 0, 0, 0,
0, 0, 0, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0, 0, 0,
0, 0, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0, 0,
0, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0,
0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff,
};
static struct {
uint8_t len;
uint8_t pad[3];
uint16_t deltax, deltay;
uint8_t glyph;
uint8_t pad2[3];
} elt = { len:1, glyph:1, deltax:WIN_SIZE/2 - GLYPH_SIZE/2, deltay:WIN_SIZE/2 - GLYPH_SIZE/2 };
int main(int argc, char *argv[])
{
int screen;
xcb_connection_t *c = xcb_connect(NULL, &screen);
if (!c || xcb_connection_has_error(c)) {
fprintf(stderr, "Cannot open default display \"%s\"\n", getenv("DISPLAY"));
return EXIT_FAILURE;
}
// Find root window and depth
const xcb_setup_t *setup = xcb_get_setup(c);
if (screen >= setup->roots_len)
screen = 0;
xcb_screen_iterator_t si = xcb_setup_roots_iterator(setup);
for (int i=0; i < screen; i++)
xcb_screen_next(&si);
xcb_window_t root = si.data->root;
uint8_t depth = si.data->root_depth;
xcb_visualid_t visual = si.data->root_visual;
// Find picture formats
xcb_render_query_pict_formats_reply_t *qpf;
qpf = xcb_render_query_pict_formats_reply(c, xcb_render_query_pict_formats(c), NULL);
if (!qpf) {
fprintf(stderr, "Cannot query RENDER picture formats\n");
return EXIT_FAILURE;
}
xcb_render_pictformat_t fmt_a8 = 0;
xcb_render_pictforminfo_iterator_t pfi =
xcb_render_query_pict_formats_formats_iterator(qpf);
for (int i = 0; i < xcb_render_query_pict_formats_formats_length(qpf); i++) {
if (pfi.data->depth == 8 &&
pfi.data->type == XCB_RENDER_PICT_TYPE_DIRECT &&
pfi.data->direct.alpha_mask == 0xFF) {
fmt_a8 = pfi.data->id;
break;
}
xcb_render_pictforminfo_next(&pfi);
}
if (!fmt_a8) {
fprintf(stderr, "Cannot find a8 RENDER picture format\n");
return EXIT_FAILURE;
}
xcb_render_pictformat_t fmt_visual = 0;
xcb_render_pictscreen_iterator_t psi =
xcb_render_query_pict_formats_screens_iterator(qpf);
for (int i = 0; i < xcb_render_query_pict_formats_screens_length(qpf); i++) {
xcb_render_pictdepth_iterator_t pdi =
xcb_render_pictscreen_depths_iterator(psi.data);
for (int j = 0; i < xcb_render_pictscreen_depths_length(psi.data); i++) {
xcb_render_pictvisual_iterator_t pvi =
xcb_render_pictdepth_visuals_iterator(pdi.data);
for (int k = 0; k < xcb_render_pictdepth_visuals_length(pdi.data); i++) {
if (pvi.data->visual == visual) {
fmt_visual = pvi.data->format;
goto found_visual;
}
xcb_render_pictvisual_next(&pvi);
}
xcb_render_pictdepth_next(&pdi);
}
xcb_render_pictscreen_next(&psi);
}
found_visual:
if (!fmt_visual) {
fprintf(stderr, "Cannot find visual RENDER picture format\n");
return EXIT_FAILURE;
}
xcb_render_glyphset_t glyphset = xcb_generate_id(c);
xcb_render_create_glyph_set(c, glyphset, fmt_a8);
uint32_t glyph_ids[] = {1};
xcb_render_add_glyphs(c, glyphset, 1, glyph_ids,
&(xcb_render_glyphinfo_t){width:GLYPH_SIZE, height:GLYPH_SIZE}, sizeof(glyph), glyph);
// Create window, pixmap, and gc
xcb_window_t window = xcb_generate_id(c);
uint32_t list[] = { si.data->black_pixel, XCB_EVENT_MASK_EXPOSURE };
xcb_create_window(c, XCB_COPY_FROM_PARENT, window, root, 0, 0, WIN_SIZE, WIN_SIZE,
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT,
XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK, list);
xcb_map_window(c, window);
xcb_render_picture_t winpic = xcb_generate_id(c);
xcb_render_create_picture(c, winpic, window, fmt_visual, 0, NULL);
xcb_pixmap_t pixmap = xcb_generate_id(c);
xcb_create_pixmap(c, depth, pixmap, window, GLYPH_SIZE, GLYPH_SIZE);
xcb_render_picture_t pixpic = xcb_generate_id(c);
xcb_render_create_picture(c, pixpic, pixmap, fmt_visual, 0, NULL);
xcb_render_fill_rectangles(c, XCB_RENDER_PICT_OP_SRC, pixpic,
(xcb_render_color_t){green:0xFFFF, alpha:0xFFFF}, 1,
&(xcb_rectangle_t){width:GLYPH_SIZE, height:GLYPH_SIZE} );
xcb_flush(c);
for (xcb_generic_event_t *ev = xcb_wait_for_event(c); ev; ev = xcb_wait_for_event(c)) {
int type = ev->response_type;
free(ev);
if (type == XCB_EXPOSE) {
xcb_clear_area(c, 0, window, 0, 0, 0, 0);
xcb_render_composite_glyphs_8(c, XCB_RENDER_PICT_OP_SRC, pixpic, winpic, fmt_a8,
glyphset, 0, 0, sizeof(elt), (uint8_t *)&elt);
xcb_flush(c);
}
}
return EXIT_SUCCESS;
}
2014-04-11 23:44:59 +02:00
|
|
|
xSrc + srcXoff + extents.x1 - xDst, ySrc + srcYoff + extents.y1 - yDst,
|
2013-02-14 01:06:55 +01:00
|
|
|
extents.x1, extents.y1,
|
|
|
|
extents.x1 + dstXoff, extents.y1 + dstYoff,
|
2012-05-30 11:19:08 +02:00
|
|
|
extents.x2 - extents.x1,
|
|
|
|
extents.y2 - extents.y1,
|
|
|
|
glyphCache, n_glyphs, pglyphs);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pixman_composite_glyphs_no_mask(op, srcImage, dstImage,
|
|
|
|
xSrc + srcXoff - xDst, ySrc + srcYoff - yDst,
|
|
|
|
dstXoff, dstYoff,
|
|
|
|
glyphCache, n_glyphs, pglyphs);
|
|
|
|
}
|
|
|
|
|
|
|
|
free_pixman_pict(pDst, dstImage);
|
|
|
|
|
|
|
|
out_free_src:
|
|
|
|
free_pixman_pict(pSrc, srcImage);
|
|
|
|
|
|
|
|
out:
|
|
|
|
pixman_glyph_cache_thaw(glyphCache);
|
|
|
|
if (pglyphs != stack_glyphs)
|
|
|
|
free(pglyphs);
|
|
|
|
}
|
|
|
|
|
2007-06-11 15:16:46 +02:00
|
|
|
static pixman_image_t *
|
2012-03-21 20:55:09 +01:00
|
|
|
create_solid_fill_image(PicturePtr pict)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2007-06-11 15:16:46 +02:00
|
|
|
PictSolidFill *solid = &pict->pSourcePict->solidFill;
|
|
|
|
pixman_color_t color;
|
|
|
|
CARD32 a, r, g, b;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2007-06-11 15:16:46 +02:00
|
|
|
a = (solid->color & 0xff000000) >> 24;
|
|
|
|
r = (solid->color & 0x00ff0000) >> 16;
|
2012-03-21 20:55:09 +01:00
|
|
|
g = (solid->color & 0x0000ff00) >> 8;
|
|
|
|
b = (solid->color & 0x000000ff) >> 0;
|
|
|
|
|
2007-06-11 15:16:46 +02:00
|
|
|
color.alpha = (a << 8) | a;
|
2012-03-21 20:55:09 +01:00
|
|
|
color.red = (r << 8) | r;
|
2007-06-11 15:16:46 +02:00
|
|
|
color.green = (g << 8) | g;
|
2012-03-21 20:55:09 +01:00
|
|
|
color.blue = (b << 8) | b;
|
|
|
|
|
|
|
|
return pixman_image_create_solid_fill(&color);
|
2007-06-11 15:16:46 +02:00
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2007-06-11 15:16:46 +02:00
|
|
|
static pixman_image_t *
|
2012-03-21 20:55:09 +01:00
|
|
|
create_linear_gradient_image(PictGradient * gradient)
|
2007-06-11 15:16:46 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
PictLinearGradient *linear = (PictLinearGradient *) gradient;
|
2007-06-11 15:16:46 +02:00
|
|
|
pixman_point_fixed_t p1;
|
|
|
|
pixman_point_fixed_t p2;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2007-06-11 15:16:46 +02:00
|
|
|
p1.x = linear->p1.x;
|
|
|
|
p1.y = linear->p1.y;
|
|
|
|
p2.x = linear->p2.x;
|
|
|
|
p2.y = linear->p2.y;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
return pixman_image_create_linear_gradient(&p1, &p2,
|
|
|
|
(pixman_gradient_stop_t *)
|
|
|
|
gradient->stops,
|
|
|
|
gradient->nstops);
|
2007-06-11 15:16:46 +02:00
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2007-06-11 15:16:46 +02:00
|
|
|
static pixman_image_t *
|
2012-03-21 20:55:09 +01:00
|
|
|
create_radial_gradient_image(PictGradient * gradient)
|
2007-06-11 15:16:46 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
PictRadialGradient *radial = (PictRadialGradient *) gradient;
|
2007-06-11 15:16:46 +02:00
|
|
|
pixman_point_fixed_t c1;
|
|
|
|
pixman_point_fixed_t c2;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2007-06-11 15:16:46 +02:00
|
|
|
c1.x = radial->c1.x;
|
|
|
|
c1.y = radial->c1.y;
|
|
|
|
c2.x = radial->c2.x;
|
|
|
|
c2.y = radial->c2.y;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
return pixman_image_create_radial_gradient(&c1, &c2, radial->c1.radius,
|
|
|
|
radial->c2.radius,
|
|
|
|
(pixman_gradient_stop_t *)
|
|
|
|
gradient->stops,
|
|
|
|
gradient->nstops);
|
2007-06-11 15:16:46 +02:00
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2007-06-11 15:16:46 +02:00
|
|
|
static pixman_image_t *
|
2012-03-21 20:55:09 +01:00
|
|
|
create_conical_gradient_image(PictGradient * gradient)
|
2007-06-11 15:16:46 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
PictConicalGradient *conical = (PictConicalGradient *) gradient;
|
2007-06-11 15:16:46 +02:00
|
|
|
pixman_point_fixed_t center;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2007-06-11 15:16:46 +02:00
|
|
|
center.x = conical->center.x;
|
|
|
|
center.y = conical->center.y;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
return pixman_image_create_conical_gradient(¢er, conical->angle,
|
|
|
|
(pixman_gradient_stop_t *)
|
|
|
|
gradient->stops,
|
|
|
|
gradient->nstops);
|
2007-06-11 15:16:46 +02:00
|
|
|
}
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2007-06-11 15:16:46 +02:00
|
|
|
static pixman_image_t *
|
2012-03-21 20:55:09 +01:00
|
|
|
create_bits_picture(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
|
2007-06-11 15:16:46 +02:00
|
|
|
{
|
2009-12-02 17:37:20 +01:00
|
|
|
PixmapPtr pixmap;
|
2007-06-11 15:16:46 +02:00
|
|
|
FbBits *bits;
|
|
|
|
FbStride stride;
|
2009-12-02 17:37:20 +01:00
|
|
|
int bpp;
|
2007-06-11 15:16:46 +02:00
|
|
|
pixman_image_t *image;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
fbGetDrawablePixmap(pict->pDrawable, pixmap, *xoff, *yoff);
|
2009-12-02 17:37:20 +01:00
|
|
|
fbGetPixmapBitsData(pixmap, bits, stride, bpp);
|
2007-08-17 02:43:29 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
image = pixman_image_create_bits((pixman_format_code_t) pict->format,
|
|
|
|
pixmap->drawable.width,
|
|
|
|
pixmap->drawable.height, (uint32_t *) bits,
|
|
|
|
stride * sizeof(FbStride));
|
2011-10-04 21:02:20 +02:00
|
|
|
|
|
|
|
if (!image)
|
2012-03-21 20:55:09 +01:00
|
|
|
return NULL;
|
|
|
|
|
2007-06-11 15:16:46 +02:00
|
|
|
#ifdef FB_ACCESS_WRAPPER
|
2012-03-21 20:55:09 +01:00
|
|
|
pixman_image_set_accessors(image,
|
|
|
|
(pixman_read_memory_func_t) wfbReadMemory,
|
|
|
|
(pixman_write_memory_func_t) wfbWriteMemory);
|
2007-06-11 15:16:46 +02:00
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2009-12-01 20:09:32 +01:00
|
|
|
/* pCompositeClip is undefined for source pictures, so
|
|
|
|
* only set the clip region for pictures with drawables
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
if (has_clip) {
|
2014-10-08 17:20:33 +02:00
|
|
|
if (pict->clientClip)
|
2012-03-21 20:55:09 +01:00
|
|
|
pixman_image_set_has_client_clip(image, TRUE);
|
2009-05-11 05:27:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (*xoff || *yoff)
|
|
|
|
pixman_region_translate(pict->pCompositeClip, *xoff, *yoff);
|
2009-05-11 05:27:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
pixman_image_set_clip_region(image, pict->pCompositeClip);
|
2009-06-13 16:28:21 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (*xoff || *yoff)
|
|
|
|
pixman_region_translate(pict->pCompositeClip, -*xoff, -*yoff);
|
2007-06-11 15:16:46 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2007-06-11 15:16:46 +02:00
|
|
|
/* Indexed table */
|
|
|
|
if (pict->pFormat->index.devPrivate)
|
2012-03-21 20:55:09 +01:00
|
|
|
pixman_image_set_indexed(image, pict->pFormat->index.devPrivate);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2009-12-02 17:37:20 +01:00
|
|
|
/* Add in drawable origin to position within the image */
|
|
|
|
*xoff += pict->pDrawable->x;
|
|
|
|
*yoff += pict->pDrawable->y;
|
|
|
|
|
2007-06-11 15:16:46 +02:00
|
|
|
return image;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
2005-11-30 03:36:25 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
static pixman_image_t *image_from_pict_internal(PicturePtr pict, Bool has_clip,
|
|
|
|
int *xoff, int *yoff,
|
|
|
|
Bool is_alpha_map);
|
2010-05-21 18:01:43 +02:00
|
|
|
|
2007-05-23 21:50:25 +02:00
|
|
|
static void
|
2012-03-21 20:55:09 +01:00
|
|
|
set_image_properties(pixman_image_t * image, PicturePtr pict, Bool has_clip,
|
|
|
|
int *xoff, int *yoff, Bool is_alpha_map)
|
2007-05-23 21:50:25 +02:00
|
|
|
{
|
|
|
|
pixman_repeat_t repeat;
|
|
|
|
pixman_filter_t filter;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
if (pict->transform) {
|
|
|
|
/* For source images, adjust the transform to account
|
|
|
|
* for the drawable offset within the pixman image,
|
|
|
|
* then set the offset to 0 as it will be used
|
|
|
|
* to compute positions within the transformed image.
|
|
|
|
*/
|
|
|
|
if (!has_clip) {
|
|
|
|
struct pixman_transform adjusted;
|
|
|
|
|
|
|
|
adjusted = *pict->transform;
|
|
|
|
pixman_transform_translate(&adjusted,
|
|
|
|
NULL,
|
|
|
|
pixman_int_to_fixed(*xoff),
|
|
|
|
pixman_int_to_fixed(*yoff));
|
|
|
|
pixman_image_set_transform(image, &adjusted);
|
|
|
|
*xoff = 0;
|
|
|
|
*yoff = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pixman_image_set_transform(image, pict->transform);
|
2007-05-23 21:50:25 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
switch (pict->repeatType) {
|
2007-05-23 21:50:25 +02:00
|
|
|
default:
|
|
|
|
case RepeatNone:
|
2012-03-21 20:55:09 +01:00
|
|
|
repeat = PIXMAN_REPEAT_NONE;
|
|
|
|
break;
|
|
|
|
|
2007-05-23 21:50:25 +02:00
|
|
|
case RepeatPad:
|
2012-03-21 20:55:09 +01:00
|
|
|
repeat = PIXMAN_REPEAT_PAD;
|
|
|
|
break;
|
|
|
|
|
2007-05-23 21:50:25 +02:00
|
|
|
case RepeatNormal:
|
2012-03-21 20:55:09 +01:00
|
|
|
repeat = PIXMAN_REPEAT_NORMAL;
|
|
|
|
break;
|
|
|
|
|
2007-05-23 21:50:25 +02:00
|
|
|
case RepeatReflect:
|
2012-03-21 20:55:09 +01:00
|
|
|
repeat = PIXMAN_REPEAT_REFLECT;
|
|
|
|
break;
|
2007-05-23 21:50:25 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
pixman_image_set_repeat(image, repeat);
|
|
|
|
|
2010-05-21 18:01:43 +02:00
|
|
|
/* Fetch alpha map unless 'pict' is being used
|
|
|
|
* as the alpha map for this operation
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pict->alphaMap && !is_alpha_map) {
|
|
|
|
int alpha_xoff, alpha_yoff;
|
|
|
|
pixman_image_t *alpha_map =
|
|
|
|
image_from_pict_internal(pict->alphaMap, FALSE, &alpha_xoff,
|
|
|
|
&alpha_yoff, TRUE);
|
|
|
|
|
|
|
|
pixman_image_set_alpha_map(image, alpha_map, pict->alphaOrigin.x,
|
|
|
|
pict->alphaOrigin.y);
|
|
|
|
|
|
|
|
free_pixman_pict(pict->alphaMap, alpha_map);
|
2007-05-23 21:50:25 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
pixman_image_set_component_alpha(image, pict->componentAlpha);
|
|
|
|
|
|
|
|
switch (pict->filter) {
|
2007-05-23 21:50:25 +02:00
|
|
|
default:
|
|
|
|
case PictFilterNearest:
|
|
|
|
case PictFilterFast:
|
2012-03-21 20:55:09 +01:00
|
|
|
filter = PIXMAN_FILTER_NEAREST;
|
|
|
|
break;
|
|
|
|
|
2007-05-23 21:50:25 +02:00
|
|
|
case PictFilterBilinear:
|
|
|
|
case PictFilterGood:
|
2012-03-21 20:55:09 +01:00
|
|
|
filter = PIXMAN_FILTER_BILINEAR;
|
|
|
|
break;
|
|
|
|
|
2007-05-23 21:50:25 +02:00
|
|
|
case PictFilterConvolution:
|
2012-03-21 20:55:09 +01:00
|
|
|
filter = PIXMAN_FILTER_CONVOLUTION;
|
|
|
|
break;
|
2007-05-23 21:50:25 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
pixman_image_set_filter(image, filter,
|
|
|
|
(pixman_fixed_t *) pict->filter_params,
|
|
|
|
pict->filter_nparams);
|
|
|
|
pixman_image_set_source_clipping(image, TRUE);
|
2007-05-23 21:50:25 +02:00
|
|
|
}
|
|
|
|
|
2010-05-21 18:01:43 +02:00
|
|
|
static pixman_image_t *
|
2012-03-21 20:55:09 +01:00
|
|
|
image_from_pict_internal(PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
|
|
|
|
Bool is_alpha_map)
|
2007-05-23 21:50:25 +02:00
|
|
|
{
|
|
|
|
pixman_image_t *image = NULL;
|
|
|
|
|
|
|
|
if (!pict)
|
2012-03-21 20:55:09 +01:00
|
|
|
return NULL;
|
2007-05-23 21:50:25 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pict->pDrawable) {
|
|
|
|
image = create_bits_picture(pict, has_clip, xoff, yoff);
|
2007-05-23 21:50:25 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (pict->pSourcePict) {
|
|
|
|
SourcePict *sp = pict->pSourcePict;
|
|
|
|
|
|
|
|
if (sp->type == SourcePictTypeSolidFill) {
|
|
|
|
image = create_solid_fill_image(pict);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PictGradient *gradient = &pict->pSourcePict->gradient;
|
|
|
|
|
|
|
|
if (sp->type == SourcePictTypeLinear)
|
|
|
|
image = create_linear_gradient_image(gradient);
|
|
|
|
else if (sp->type == SourcePictTypeRadial)
|
|
|
|
image = create_radial_gradient_image(gradient);
|
|
|
|
else if (sp->type == SourcePictTypeConical)
|
|
|
|
image = create_conical_gradient_image(gradient);
|
|
|
|
}
|
|
|
|
*xoff = *yoff = 0;
|
2007-05-23 21:50:25 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2007-05-23 21:50:25 +02:00
|
|
|
if (image)
|
2012-03-21 20:55:09 +01:00
|
|
|
set_image_properties(image, pict, has_clip, xoff, yoff, is_alpha_map);
|
|
|
|
|
2007-05-23 21:50:25 +02:00
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
2010-05-21 18:01:43 +02:00
|
|
|
pixman_image_t *
|
2012-03-21 20:55:09 +01:00
|
|
|
image_from_pict(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
|
2010-05-21 18:01:43 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
return image_from_pict_internal(pict, has_clip, xoff, yoff, FALSE);
|
2010-05-21 18:01:43 +02:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
free_pixman_pict(PicturePtr pict, pixman_image_t * image)
|
2007-08-01 23:30:03 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
if (image && pixman_image_unref(image) && pict->pDrawable)
|
|
|
|
fbFinishAccess(pict->pDrawable);
|
2007-08-01 23:30:03 +02:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
fbPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
|
2007-06-11 15:16:46 +02:00
|
|
|
{
|
2007-05-23 21:50:25 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
PictureScreenPtr ps;
|
2007-06-11 15:16:46 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!miPictureInit(pScreen, formats, nformats))
|
|
|
|
return FALSE;
|
2007-06-11 15:16:46 +02:00
|
|
|
ps = GetPictureScreen(pScreen);
|
|
|
|
ps->Composite = fbComposite;
|
2012-05-30 11:19:08 +02:00
|
|
|
ps->Glyphs = fbGlyphs;
|
|
|
|
ps->UnrealizeGlyph = fbUnrealizeGlyph;
|
2007-06-11 15:16:46 +02:00
|
|
|
ps->CompositeRects = miCompositeRects;
|
|
|
|
ps->RasterizeTrapezoid = fbRasterizeTrapezoid;
|
2011-01-11 15:46:46 +01:00
|
|
|
ps->Trapezoids = fbTrapezoids;
|
2007-06-11 15:16:46 +02:00
|
|
|
ps->AddTraps = fbAddTraps;
|
|
|
|
ps->AddTriangles = fbAddTriangles;
|
2011-01-11 16:33:57 +01:00
|
|
|
ps->Triangles = fbTriangles;
|
2007-06-11 15:16:46 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|