aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/glamor
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2014-04-13 14:24:56 +0200
committermarha <marha@users.sourceforge.net>2014-04-13 14:24:56 +0200
commitd2ad10d03be8e6d4b150bbdf2a28ea3d5a18a2ed (patch)
tree2a860c9d687826b3cb48facfa21c616e14e69347 /xorg-server/glamor
parentedb5b380994125bf33929ef7dc5a3c456dfbe93b (diff)
downloadvcxsrv-d2ad10d03be8e6d4b150bbdf2a28ea3d5a18a2ed.tar.gz
vcxsrv-d2ad10d03be8e6d4b150bbdf2a28ea3d5a18a2ed.tar.bz2
vcxsrv-d2ad10d03be8e6d4b150bbdf2a28ea3d5a18a2ed.zip
fontconfig libxcb mesa xserver xcb-proto git update 13 Apr 2014
xserver commit 3028ae6c9aa37168e249e0d847b29f8e3efb05b2 libxcb commit 29e419c5840a1eeda3336a0802686ee723dcaab3 libxcb/xcb-proto commit 70fea02b7d90d86e9d3b0dc5b61406bf4c910999 pixman commit 4b76bbfda670f9ede67d0449f3640605e1fc4df0 fontconfig commit f44157c809d280e2a0ce87fb078fc4b278d24a67 mesa commit 936dda08ee6d7b2be2b016bc06780e401088ec13
Diffstat (limited to 'xorg-server/glamor')
-rw-r--r--xorg-server/glamor/Makefile.am10
-rw-r--r--xorg-server/glamor/glamor.c34
-rw-r--r--xorg-server/glamor/glamor.h21
-rw-r--r--xorg-server/glamor/glamor_core.c14
-rw-r--r--xorg-server/glamor/glamor_egl.c11
-rw-r--r--xorg-server/glamor/glamor_egl_stubs.c4
-rw-r--r--xorg-server/glamor/glamor_fillspans.c107
-rw-r--r--xorg-server/glamor/glamor_font.c186
-rw-r--r--xorg-server/glamor/glamor_font.h49
-rw-r--r--xorg-server/glamor/glamor_getspans.c92
-rw-r--r--xorg-server/glamor/glamor_glyphblt.c261
-rw-r--r--xorg-server/glamor/glamor_pixmap.c4
-rw-r--r--xorg-server/glamor/glamor_points.c21
-rw-r--r--xorg-server/glamor/glamor_polyfillrect.c123
-rw-r--r--xorg-server/glamor/glamor_priv.h73
-rw-r--r--xorg-server/glamor/glamor_program.c18
-rw-r--r--xorg-server/glamor/glamor_rects.c189
-rw-r--r--xorg-server/glamor/glamor_setspans.c118
-rw-r--r--xorg-server/glamor/glamor_spans.c438
-rw-r--r--xorg-server/glamor/glamor_text.c526
-rw-r--r--xorg-server/glamor/glamor_transfer.c264
-rw-r--r--xorg-server/glamor/glamor_transfer.h55
-rw-r--r--xorg-server/glamor/glamor_xv.c14
23 files changed, 1954 insertions, 678 deletions
diff --git a/xorg-server/glamor/Makefile.am b/xorg-server/glamor/Makefile.am
index 8555e4087..4d0cc8138 100644
--- a/xorg-server/glamor/Makefile.am
+++ b/xorg-server/glamor/Makefile.am
@@ -12,18 +12,20 @@ libglamor_la_SOURCES = \
glamor_core.c \
glamor_debug.h \
glamor_fill.c \
- glamor_fillspans.c \
- glamor_getspans.c \
+ glamor_font.c \
glamor_glx.c \
glamor_glyphs.c \
- glamor_polyfillrect.c \
glamor_polylines.c \
glamor_putimage.c \
- glamor_setspans.c \
glamor_segment.c \
glamor_render.c \
glamor_gradient.c \
glamor_program.c \
+ glamor_rects.c \
+ glamor_spans.c \
+ glamor_text.c \
+ glamor_transfer.c \
+ glamor_transfer.h \
glamor_transform.c \
glamor_trapezoid.c \
glamor_tile.c \
diff --git a/xorg-server/glamor/glamor.c b/xorg-server/glamor/glamor.c
index 30944326b..2c2d9760c 100644
--- a/xorg-server/glamor/glamor.c
+++ b/xorg-server/glamor/glamor.c
@@ -182,7 +182,15 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3;
screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, pitch, NULL);
- if (type == GLAMOR_MEMORY_MAP || usage == GLAMOR_CREATE_NO_LARGE ||
+ if (usage == GLAMOR_CREATE_PIXMAP_NO_TEXTURE) {
+ pixmap_priv->type = GLAMOR_TEXTURE_ONLY;
+ pixmap_priv->base.box.x1 = 0;
+ pixmap_priv->base.box.y1 = 0;
+ pixmap_priv->base.box.x2 = w;
+ pixmap_priv->base.box.y2 = h;
+ return pixmap;
+ }
+ else if (type == GLAMOR_MEMORY_MAP || usage == GLAMOR_CREATE_NO_LARGE ||
glamor_check_fbo_size(glamor_priv, w, h))
{
pixmap_priv->type = type;
@@ -353,6 +361,15 @@ glamor_init(ScreenPtr screen, unsigned int flags)
gl_version = epoxy_gl_version();
+ /* Would be nice to have a cleaner test for GLSL 1.30 support,
+ * but for now this should suffice
+ */
+ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP && gl_version >= 30)
+ glamor_priv->glsl_version = 130;
+ else
+ glamor_priv->glsl_version = 120;
+
+
/* We'd like to require GL_ARB_map_buffer_range or
* GL_OES_map_buffer_range, since it offers more information to
* the driver than plain old glMapBuffer() or glBufferSubData().
@@ -415,6 +432,9 @@ glamor_init(ScreenPtr screen, unsigned int flags)
screen->CreateScreenResources;
screen->CreateScreenResources = glamor_create_screen_resources;
+ if (!glamor_font_init(screen))
+ goto fail;
+
if (flags & GLAMOR_USE_SCREEN) {
if (!RegisterBlockAndWakeupHandlers(_glamor_block_handler,
_glamor_wakeup_handler,
@@ -475,13 +495,13 @@ glamor_init(ScreenPtr screen, unsigned int flags)
glamor_priv->saved_procs.create_picture = ps->CreatePicture;
ps->CreatePicture = glamor_create_picture;
- glamor_priv->saved_procs.set_window_pixmap = screen->SetWindowPixmap;
- screen->SetWindowPixmap = glamor_set_window_pixmap;
-
glamor_priv->saved_procs.destroy_picture = ps->DestroyPicture;
ps->DestroyPicture = glamor_destroy_picture;
glamor_init_composite_shaders(screen);
#endif
+ glamor_priv->saved_procs.set_window_pixmap = screen->SetWindowPixmap;
+ screen->SetWindowPixmap = glamor_set_window_pixmap;
+
glamor_init_vbo(screen);
glamor_init_pixmap_fbo(screen);
glamor_init_solid_shader(screen);
@@ -494,9 +514,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
#ifdef GLAMOR_GRADIENT_SHADER
glamor_init_gradient_shader(screen);
#endif
-#ifdef GLAMOR_XV
- glamor_init_xv_shader(screen);
-#endif
glamor_pixmap_init(screen);
glamor_glyphs_init(screen);
@@ -516,9 +533,6 @@ glamor_release_screen_priv(ScreenPtr screen)
glamor_screen_private *glamor_priv;
glamor_priv = glamor_get_screen_private(screen);
-#ifdef GLAMOR_XV
- glamor_fini_xv_shader(screen);
-#endif
#ifdef RENDER
glamor_fini_composite_shaders(screen);
#endif
diff --git a/xorg-server/glamor/glamor.h b/xorg-server/glamor/glamor.h
index 11ec49361..e63762b44 100644
--- a/xorg-server/glamor/glamor.h
+++ b/xorg-server/glamor/glamor.h
@@ -143,12 +143,14 @@ extern _X_EXPORT void glamor_block_handler(ScreenPtr screen);
extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h,
int depth, unsigned int usage);
+extern _X_EXPORT Bool glamor_destroy_pixmap(PixmapPtr pixmap);
#define GLAMOR_CREATE_PIXMAP_CPU 0x100
#define GLAMOR_CREATE_PIXMAP_FIXUP 0x101
#define GLAMOR_CREATE_FBO_NO_FBO 0x103
#define GLAMOR_CREATE_PIXMAP_MAP 0x104
#define GLAMOR_CREATE_NO_LARGE 0x105
+#define GLAMOR_CREATE_PIXMAP_NO_TEXTURE 0x106
/* @glamor_egl_exchange_buffers: Exchange the underlying buffers(KHR image,fbo).
*
@@ -310,6 +312,8 @@ extern _X_EXPORT Bool
#endif
+extern _X_EXPORT void glamor_egl_screen_init(ScreenPtr screen,
+ struct glamor_context *glamor_ctx);
extern _X_EXPORT void glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap);
extern _X_EXPORT int glamor_create_gc(GCPtr gc);
@@ -431,12 +435,23 @@ extern _X_EXPORT Bool glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC,
extern _X_EXPORT Bool glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC,
int nseg, xSegment *pSeg);
-extern _X_EXPORT Bool glamor_poly_line_nf(DrawablePtr pDrawable, GCPtr pGC,
- int mode, int npt, DDXPointPtr ppt);
-
extern _X_EXPORT Bool glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc,
int mode, int n, DDXPointPtr points);
+extern _X_EXPORT Bool glamor_poly_text8_nf(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, char *chars, int *final_pos);
+
+extern _X_EXPORT Bool glamor_poly_text16_nf(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, unsigned short *chars, int *final_pos);
+
+extern _X_EXPORT Bool glamor_image_text8_nf(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, char *chars);
+
+extern _X_EXPORT Bool glamor_image_text16_nf(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, unsigned short *chars);
+
+#define HAS_GLAMOR_TEXT 1
+
#ifdef GLAMOR_FOR_XORG
extern _X_EXPORT XF86VideoAdaptorPtr glamor_xv_init(ScreenPtr pScreen,
int num_texture_ports);
diff --git a/xorg-server/glamor/glamor_core.c b/xorg-server/glamor/glamor_core.c
index 5711be72f..7b1615d2d 100644
--- a/xorg-server/glamor/glamor_core.c
+++ b/xorg-server/glamor/glamor_core.c
@@ -426,13 +426,13 @@ GCOps glamor_gc_ops = {
.FillPolygon = miFillPolygon,
.PolyFillRect = glamor_poly_fill_rect,
.PolyFillArc = miPolyFillArc,
- .PolyText8 = miPolyText8,
- .PolyText16 = miPolyText16,
- .ImageText8 = miImageText8,
- .ImageText16 = miImageText16,
- .ImageGlyphBlt = glamor_image_glyph_blt, //miImageGlyphBlt,
- .PolyGlyphBlt = glamor_poly_glyph_blt, //miPolyGlyphBlt,
- .PushPixels = glamor_push_pixels, //miPushPixels,
+ .PolyText8 = glamor_poly_text8,
+ .PolyText16 = glamor_poly_text16,
+ .ImageText8 = glamor_image_text8,
+ .ImageText16 = glamor_image_text16,
+ .ImageGlyphBlt = miImageGlyphBlt,
+ .PolyGlyphBlt = glamor_poly_glyph_blt,
+ .PushPixels = glamor_push_pixels,
};
/**
diff --git a/xorg-server/glamor/glamor_egl.c b/xorg-server/glamor/glamor_egl.c
index 812342129..d37de9b95 100644
--- a/xorg-server/glamor/glamor_egl.c
+++ b/xorg-server/glamor/glamor_egl.c
@@ -608,9 +608,10 @@ glamor_egl_close_screen(ScreenPtr screen)
}
static int
-glamor_dri3_open(ScreenPtr screen,
- RRProviderPtr provider,
- int *fdp)
+glamor_dri3_open_client(ClientPtr client,
+ ScreenPtr screen,
+ RRProviderPtr provider,
+ int *fdp)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
struct glamor_egl_screen_private *glamor_egl =
@@ -657,8 +658,8 @@ glamor_dri3_open(ScreenPtr screen,
}
static dri3_screen_info_rec glamor_dri3_info = {
- .version = 0,
- .open = glamor_dri3_open,
+ .version = 1,
+ .open_client = glamor_dri3_open_client,
.pixmap_from_fd = glamor_pixmap_from_fd,
.fd_from_pixmap = glamor_fd_from_pixmap,
};
diff --git a/xorg-server/glamor/glamor_egl_stubs.c b/xorg-server/glamor/glamor_egl_stubs.c
index 4fd9e8016..028d1cc05 100644
--- a/xorg-server/glamor/glamor_egl_stubs.c
+++ b/xorg-server/glamor/glamor_egl_stubs.c
@@ -26,7 +26,9 @@
* Stubbed out glamor_egl.c functions for servers other than Xorg.
*/
-#include "glamor_priv.h"
+#include "dix-config.h"
+
+#include "glamor.h"
void
glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
diff --git a/xorg-server/glamor/glamor_fillspans.c b/xorg-server/glamor/glamor_fillspans.c
deleted file mode 100644
index 8cbd79f6d..000000000
--- a/xorg-server/glamor/glamor_fillspans.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright © 1998 Keith Packard
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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 OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-/** @file glamor_fillspans.c
- *
- * FillSpans implementation, taken from fb_fillsp.c
- */
-#include "glamor_priv.h"
-
-static Bool
-_glamor_fill_spans(DrawablePtr drawable,
- GCPtr gc,
- int n, DDXPointPtr points, int *widths, int sorted,
- Bool fallback)
-{
- DDXPointPtr ppt;
- int nbox;
- BoxPtr pbox;
- int x1, x2, y;
- RegionPtr pClip = fbGetCompositeClip(gc);
- Bool ret = FALSE;
-
- if (gc->fillStyle != FillSolid && gc->fillStyle != FillTiled)
- goto fail;
-
- ppt = points;
- while (n--) {
- x1 = ppt->x;
- y = ppt->y;
- x2 = x1 + (int) *widths;
- ppt++;
- widths++;
-
- nbox = REGION_NUM_RECTS(pClip);
- pbox = REGION_RECTS(pClip);
- while (nbox--) {
- int real_x1 = x1, real_x2 = x2;
-
- if (real_x1 < pbox->x1)
- real_x1 = pbox->x1;
-
- if (real_x2 > pbox->x2)
- real_x2 = pbox->x2;
-
- if (real_x2 > real_x1 && pbox->y1 <= y && pbox->y2 > y) {
- if (!glamor_fill(drawable, gc, real_x1, y,
- real_x2 - real_x1, 1, fallback))
- goto fail;
- }
- pbox++;
- }
- }
- ret = TRUE;
- goto done;
-
- fail:
- if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
- && glamor_ddx_fallback_check_gc(gc)) {
- goto done;
- }
- glamor_fallback("to %p (%c)\n", drawable,
- glamor_get_drawable_location(drawable));
- if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
- glamor_prepare_access_gc(gc)) {
- fbFillSpans(drawable, gc, n, points, widths, sorted);
- }
- glamor_finish_access_gc(gc);
- glamor_finish_access(drawable);
- ret = TRUE;
-
- done:
- return ret;
-}
-
-void
-glamor_fill_spans(DrawablePtr drawable,
- GCPtr gc, int n, DDXPointPtr points, int *widths, int sorted)
-{
- _glamor_fill_spans(drawable, gc, n, points, widths, sorted, TRUE);
-}
-
-Bool
-glamor_fill_spans_nf(DrawablePtr drawable,
- GCPtr gc,
- int n, DDXPointPtr points, int *widths, int sorted)
-{
- return _glamor_fill_spans(drawable, gc, n, points, widths, sorted, FALSE);
-}
diff --git a/xorg-server/glamor/glamor_font.c b/xorg-server/glamor/glamor_font.c
new file mode 100644
index 000000000..47dfe2a69
--- /dev/null
+++ b/xorg-server/glamor/glamor_font.c
@@ -0,0 +1,186 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * 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 the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS 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 OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include "glamor_priv.h"
+#include "glamor_font.h"
+#include <dixfontstr.h>
+
+static int glamor_font_generation;
+static int glamor_font_private_index;
+static int glamor_font_screen_count;
+
+glamor_font_t *
+glamor_font_get(ScreenPtr screen, FontPtr font)
+{
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+
+ glamor_font_t *privates;
+ glamor_font_t *glamor_font;
+ int overall_width, overall_height;
+ int num_rows;
+ int num_cols;
+ int glyph_width_pixels;
+ int glyph_width_bytes;
+ int glyph_height;
+ int row, col;
+ unsigned char c[2];
+ CharInfoPtr glyph;
+ unsigned long count;
+
+
+ privates = FontGetPrivate(font, glamor_font_private_index);
+ if (!privates) {
+ privates = calloc(glamor_font_screen_count, sizeof (glamor_font_t));
+ if (!privates)
+ return NULL;
+ FontSetPrivate(font, glamor_font_private_index, privates);
+ }
+
+ glamor_font = &privates[screen->myNum];
+
+ if (glamor_font->realized)
+ return glamor_font;
+
+ glamor_font->realized = TRUE;
+
+ /* Figure out how many glyphs are in the font */
+ num_cols = font->info.lastCol - font->info.firstCol + 1;
+ num_rows = font->info.lastRow - font->info.firstRow + 1;
+
+ /* Figure out the size of each glyph */
+ glyph_width_pixels = font->info.maxbounds.rightSideBearing - font->info.minbounds.leftSideBearing;
+ glyph_height = font->info.maxbounds.ascent + font->info.maxbounds.descent;
+
+ glyph_width_bytes = (glyph_width_pixels + 7) >> 3;
+
+ glamor_font->glyph_width_pixels = glyph_width_pixels;
+ glamor_font->glyph_width_bytes = glyph_width_bytes;
+ glamor_font->glyph_height = glyph_height;
+
+ overall_width = glyph_width_bytes * num_cols;
+ overall_height = glyph_height * num_rows;
+
+ /* Check whether the font has a default character */
+ c[0] = font->info.lastRow + 1;
+ c[1] = font->info.lastCol + 1;
+ (*font->get_glyphs)(font, 1, c, TwoD16Bit, &count, &glyph);
+
+ glamor_font->default_char = count ? glyph : NULL;
+ glamor_font->default_row = font->info.defaultCh >> 8;
+ glamor_font->default_col = font->info.defaultCh;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ glamor_get_context(glamor_priv);
+
+ glGenTextures(1, &glamor_font->texture_id);
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, glamor_font->texture_id);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ /* Allocate storage */
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_R8UI, overall_width, overall_height,
+ 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, NULL);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+
+ /* Paint all of the glyphs */
+ for (row = 0; row < num_rows; row++) {
+ for (col = 0; col < num_cols; col++) {
+ c[0] = row + font->info.firstRow;
+ c[1] = col + font->info.firstCol;
+
+ (*font->get_glyphs)(font, 1, c, TwoD16Bit, &count, &glyph);
+
+ if (count)
+ glTexSubImage2D(GL_TEXTURE_2D, 0, col * glyph_width_bytes, row * glyph_height,
+ GLYPHWIDTHBYTES(glyph), GLYPHHEIGHTPIXELS(glyph),
+ GL_RED_INTEGER, GL_UNSIGNED_BYTE, glyph->bits);
+ }
+ }
+
+ glamor_put_context(glamor_priv);
+
+ return glamor_font;
+}
+
+static Bool
+glamor_realize_font(ScreenPtr screen, FontPtr font)
+{
+ return TRUE;
+}
+
+static Bool
+glamor_unrealize_font(ScreenPtr screen, FontPtr font)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_font_t *privates = FontGetPrivate(font, glamor_font_private_index);
+ glamor_font_t *glamor_font;
+ int s;
+
+ if (!privates)
+ return TRUE;
+
+ glamor_font = &privates[screen->myNum];
+
+ if (!glamor_font->realized)
+ return TRUE;
+
+ /* Unrealize the font, freeing the allocated texture */
+ glamor_font->realized = FALSE;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ glamor_get_context(glamor_priv);
+ glDeleteTextures(1, &glamor_font->texture_id);
+ glamor_put_context(glamor_priv);
+
+ /* Check to see if all of the screens are done with this font
+ * and free the private when that happens
+ */
+ for (s = 0; s < glamor_font_screen_count; s++)
+ if (privates[s].realized)
+ return TRUE;
+
+ free(privates);
+ FontSetPrivate(font, glamor_font_private_index, NULL);
+ return TRUE;
+}
+
+Bool
+glamor_font_init(ScreenPtr screen)
+{
+ if (glamor_font_generation != serverGeneration) {
+ glamor_font_private_index = AllocateFontPrivateIndex();
+ if (glamor_font_private_index == -1)
+ return FALSE;
+ glamor_font_screen_count = 0;
+ glamor_font_generation = serverGeneration;
+ }
+
+ if (screen->myNum >= glamor_font_screen_count)
+ glamor_font_screen_count = screen->myNum + 1;
+
+ screen->RealizeFont = glamor_realize_font;
+ screen->UnrealizeFont = glamor_unrealize_font;
+ return TRUE;
+}
diff --git a/xorg-server/glamor/glamor_font.h b/xorg-server/glamor/glamor_font.h
new file mode 100644
index 000000000..36d20624d
--- /dev/null
+++ b/xorg-server/glamor/glamor_font.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * 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 the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS 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 OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef _GLAMOR_FONT_H_
+#define _GLAMOR_FONT_H_
+
+typedef struct {
+ Bool realized;
+ CharInfoPtr default_char;
+ CARD8 default_row;
+ CARD8 default_col;
+
+ GLuint texture_id;
+
+ CARD16 glyph_width_bytes;
+ CARD16 glyph_width_pixels;
+ CARD16 glyph_height;
+
+} glamor_font_t;
+
+glamor_font_t *
+glamor_font_get(ScreenPtr screen, FontPtr font);
+
+Bool
+glamor_font_init(ScreenPtr screen);
+
+void
+glamor_fini_glyph_shader(ScreenPtr screen);
+
+#endif /* _GLAMOR_FONT_H_ */
diff --git a/xorg-server/glamor/glamor_getspans.c b/xorg-server/glamor/glamor_getspans.c
deleted file mode 100644
index 42df87f3d..000000000
--- a/xorg-server/glamor/glamor_getspans.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright © 2009 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- *
- * Authors:
- * Eric Anholt <eric@anholt.net>
- * Zhigang Gong <zhigang.gong@linux.intel.com>
- *
- */
-
-#include "glamor_priv.h"
-
-static Bool
-_glamor_get_spans(DrawablePtr drawable,
- int wmax,
- DDXPointPtr points, int *widths, int count, char *dst,
- Bool fallback)
-{
- PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
- glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
- int i;
- uint8_t *readpixels_dst = (uint8_t *) dst;
- void *data;
- int x_off, y_off;
- Bool ret = FALSE;
-
- if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
- goto fail;
-
- glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
- for (i = 0; i < count; i++) {
- data = glamor_download_sub_pixmap_to_cpu(pixmap, points[i].x + x_off,
- points[i].y + y_off, widths[i],
- 1, PixmapBytePad(widths[i],
- drawable->
- depth),
- readpixels_dst, 0,
- GLAMOR_ACCESS_RO);
- (void)data;
- assert(data == readpixels_dst);
- readpixels_dst += PixmapBytePad(widths[i], drawable->depth);
- }
-
- ret = TRUE;
- goto done;
- fail:
-
- if (!fallback && glamor_ddx_fallback_check_pixmap(drawable))
- goto done;
-
- ret = TRUE;
- if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RO)) {
- fbGetSpans(drawable, wmax, points, widths, count, dst);
- }
- glamor_finish_access(drawable);
- done:
- return ret;
-}
-
-void
-glamor_get_spans(DrawablePtr drawable,
- int wmax,
- DDXPointPtr points, int *widths, int count, char *dst)
-{
- _glamor_get_spans(drawable, wmax, points, widths, count, dst, TRUE);
-}
-
-Bool
-glamor_get_spans_nf(DrawablePtr drawable,
- int wmax,
- DDXPointPtr points, int *widths, int count, char *dst)
-{
- return _glamor_get_spans(drawable, wmax, points, widths, count, dst, FALSE);
-}
diff --git a/xorg-server/glamor/glamor_glyphblt.c b/xorg-server/glamor/glamor_glyphblt.c
index a58cef907..c031747f7 100644
--- a/xorg-server/glamor/glamor_glyphblt.c
+++ b/xorg-server/glamor/glamor_glyphblt.c
@@ -28,203 +28,156 @@
#include "glamor_priv.h"
#include <dixfontstr.h>
+#include "glamor_transform.h"
+
+static const glamor_facet glamor_facet_poly_glyph_blt = {
+ .name = "poly_glyph_blt",
+ .vs_vars = "attribute vec2 primitive;\n",
+ .vs_exec = (" vec2 pos = vec2(0,0);\n"
+ GLAMOR_POS(gl_Position, primitive)),
+};
static Bool
-glamor_poly_glyph_blt_pixels(DrawablePtr drawable, GCPtr gc,
- int x, int y, unsigned int nglyph,
- CharInfoPtr *ppci)
+glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc,
+ int start_x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, void *pglyph_base)
{
ScreenPtr screen = drawable->pScreen;
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
glamor_pixmap_private *pixmap_priv;
- int off_x, off_y;
- GLfloat xscale, yscale;
- float color[4];
- unsigned long fg_pixel = gc->fgPixel;
- char *vbo_offset;
- RegionPtr clip;
- int num_points, max_points;
- float *points = NULL;
-
- x += drawable->x;
- y += drawable->y;
-
- if (gc->fillStyle != FillSolid) {
- glamor_fallback("gc fillstyle not solid\n");
- return FALSE;
- }
+ glamor_program *prog;
+ RegionPtr clip = gc->pCompositeClip;
+ int box_x, box_y;
pixmap_priv = glamor_get_pixmap_private(pixmap);
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
- return FALSE;
+ goto bail;
glamor_get_context(glamor_priv);
- if (!glamor_set_alu(screen, gc->alu)) {
- if (gc->alu == GXclear)
- fg_pixel = 0;
- else {
- glamor_fallback("unsupported alu %x\n", gc->alu);
- glamor_put_context(glamor_priv);
- return FALSE;
- }
- }
-
- if (!glamor_set_planemask(pixmap, gc->planemask)) {
- glamor_fallback("Failed to set planemask in %s.\n", __FUNCTION__);
- glamor_put_context(glamor_priv);
- return FALSE;
- }
-
- glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
-
- glamor_set_destination_pixmap_priv_nc(pixmap_priv);
- pixmap_priv_get_dest_scale(pixmap_priv, &xscale, &yscale);
-
- glUseProgram(glamor_priv->solid_prog);
- glamor_get_rgba_from_pixel(fg_pixel,
- &color[0], &color[1], &color[2], &color[3],
- format_for_pixmap(pixmap));
- glUniform4fv(glamor_priv->solid_color_uniform_location, 1, color);
-
- clip = fbGetCompositeClip(gc);
+ prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->poly_glyph_blt_progs,
+ &glamor_facet_poly_glyph_blt);
+ if (!prog)
+ goto bail_ctx;
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
- max_points = 500;
- num_points = 0;
- while (nglyph--) {
- CharInfoPtr charinfo = *ppci++;
- int w = GLYPHWIDTHPIXELS(charinfo);
- int h = GLYPHHEIGHTPIXELS(charinfo);
- uint8_t *glyphbits = FONTGLYPHBITS(NULL, charinfo);
-
- if (w && h) {
- int glyph_x = x + charinfo->metrics.leftSideBearing;
- int glyph_y = y - charinfo->metrics.ascent;
- int glyph_stride = GLYPHWIDTHBYTESPADDED(charinfo);
- int xx, yy;
-
- for (yy = 0; yy < h; yy++) {
- uint8_t *glyph_row = glyphbits + glyph_stride * yy;
- for (xx = 0; xx < w; xx++) {
- int pt_x_i = glyph_x + xx;
- int pt_y_i = glyph_y + yy;
- float pt_x_f, pt_y_f;
- if (!(glyph_row[xx / 8] & (1 << xx % 8)))
- continue;
-
- if (!RegionContainsPoint(clip, pt_x_i, pt_y_i, NULL))
- continue;
-
- if (!num_points) {
- points = glamor_get_vbo_space(screen,
- max_points * 2 * sizeof(float),
- &vbo_offset);
-
- glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
- GL_FALSE, 2 * sizeof(float),
- vbo_offset);
- }
-
- pt_x_f = v_from_x_coord_x(xscale, pt_x_i + off_x + 0.5);
- if (glamor_priv->yInverted)
- pt_y_f = v_from_x_coord_y_inverted(yscale, pt_y_i + off_y + 0.5);
- else
- pt_y_f = v_from_x_coord_y(yscale, pt_y_i + off_y + 0.5);
-
- points[num_points * 2 + 0] = pt_x_f;
- points[num_points * 2 + 1] = pt_y_f;
- num_points++;
+ start_x += drawable->x;
+ y += drawable->y;
- if (num_points == max_points) {
- glamor_put_vbo_space(screen);
- glDrawArrays(GL_POINTS, 0, num_points);
- num_points = 0;
+ glamor_pixmap_loop(pixmap_priv, box_x, box_y) {
+ int x;
+ int n;
+ int num_points, max_points;
+ INT16 *points = NULL;
+ int off_x, off_y;
+ char *vbo_offset;
+
+ glamor_set_destination_drawable(drawable, box_x, box_y, FALSE, TRUE, prog->matrix_uniform, &off_x, &off_y);
+
+ max_points = 500;
+ num_points = 0;
+ x = start_x;
+ for (n = 0; n < nglyph; n++) {
+ CharInfoPtr charinfo = ppci[n];
+ int w = GLYPHWIDTHPIXELS(charinfo);
+ int h = GLYPHHEIGHTPIXELS(charinfo);
+ uint8_t *glyphbits = FONTGLYPHBITS(NULL, charinfo);
+
+ if (w && h) {
+ int glyph_x = x + charinfo->metrics.leftSideBearing;
+ int glyph_y = y - charinfo->metrics.ascent;
+ int glyph_stride = GLYPHWIDTHBYTESPADDED(charinfo);
+ int xx, yy;
+
+ for (yy = 0; yy < h; yy++) {
+ uint8_t *glyph = glyphbits;
+ for (xx = 0; xx < w; glyph += ((xx&7) == 7), xx++) {
+ int pt_x_i = glyph_x + xx;
+ int pt_y_i = glyph_y + yy;
+
+ if (!(*glyph & (1 << (xx & 7))))
+ continue;
+
+ if (!RegionContainsPoint(clip, pt_x_i, pt_y_i, NULL))
+ continue;
+
+ if (!num_points) {
+ points = glamor_get_vbo_space(screen,
+ max_points * (2 * sizeof (INT16)),
+ &vbo_offset);
+
+ glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_SHORT,
+ GL_FALSE, 0, vbo_offset);
+ }
+
+ *points++ = pt_x_i;
+ *points++ = pt_y_i;
+ num_points++;
+
+ if (num_points == max_points) {
+ glamor_put_vbo_space(screen);
+ glDrawArrays(GL_POINTS, 0, num_points);
+ num_points = 0;
+ }
}
+ glyphbits += glyph_stride;
}
}
+ x += charinfo->metrics.characterWidth;
}
- x += charinfo->metrics.characterWidth;
- }
-
- if (num_points) {
- glamor_put_vbo_space(screen);
- glDrawArrays(GL_POINTS, 0, num_points);
+ if (num_points) {
+ glamor_put_vbo_space(screen);
+ glDrawArrays(GL_POINTS, 0, num_points);
+ }
}
+ glDisable(GL_COLOR_LOGIC_OP);
glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
glamor_put_context(glamor_priv);
-
- return TRUE;
-}
-
-static Bool
-_glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
- int x, int y, unsigned int nglyph,
- CharInfoPtr *ppci, void *pglyphBase, Bool fallback)
-{
- if (!fallback && glamor_ddx_fallback_check_pixmap(pDrawable)
- && glamor_ddx_fallback_check_gc(pGC))
- return FALSE;
-
- miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
return TRUE;
+bail_ctx:
+ glDisable(GL_COLOR_LOGIC_OP);
+ glamor_put_context(glamor_priv);
+bail:
+ return FALSE;
}
void
-glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
- int x, int y, unsigned int nglyph,
- CharInfoPtr *ppci, void *pglyphBase)
+glamor_poly_glyph_blt(DrawablePtr drawable, GCPtr gc,
+ int start_x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, void *pglyph_base)
{
- _glamor_image_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase,
- TRUE);
+ if (glamor_poly_glyph_blt_gl(drawable, gc, start_x, y, nglyph, ppci, pglyph_base))
+ return;
+ miPolyGlyphBlt(drawable, gc, start_x, y, nglyph,
+ ppci, pglyph_base);
}
Bool
-glamor_image_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
- int x, int y, unsigned int nglyph,
- CharInfoPtr *ppci, void *pglyphBase)
-{
- return _glamor_image_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci,
- pglyphBase, FALSE);
-}
-
-static Bool
-_glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
- int x, int y, unsigned int nglyph,
- CharInfoPtr *ppci, void *pglyphBase, Bool fallback)
+glamor_poly_glyph_blt_nf(DrawablePtr drawable, GCPtr gc,
+ int start_x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, void *pglyph_base)
{
- if (glamor_poly_glyph_blt_pixels(pDrawable, pGC, x, y, nglyph, ppci))
+ if (glamor_poly_glyph_blt_gl(drawable, gc, start_x, y, nglyph, ppci, pglyph_base))
return TRUE;
-
- if (!fallback && glamor_ddx_fallback_check_pixmap(pDrawable)
- && glamor_ddx_fallback_check_gc(pGC))
+ if (glamor_ddx_fallback_check_pixmap(drawable) && glamor_ddx_fallback_check_gc(gc))
return FALSE;
-
- miPolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ miPolyGlyphBlt(drawable, gc, start_x, y, nglyph,
+ ppci, pglyph_base);
return TRUE;
}
-void
-glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
- int x, int y, unsigned int nglyph,
- CharInfoPtr *ppci, void *pglyphBase)
-{
- _glamor_poly_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase,
- TRUE);
-}
-
Bool
-glamor_poly_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
- int x, int y, unsigned int nglyph,
- CharInfoPtr *ppci, void *pglyphBase)
+glamor_image_glyph_blt_nf(DrawablePtr drawable, GCPtr gc,
+ int start_x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, void *pglyph_base)
{
- return _glamor_poly_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci,
- pglyphBase, FALSE);
+ miImageGlyphBlt(drawable, gc, start_x, y, nglyph, ppci, pglyph_base);
+ return TRUE;
}
static Bool
diff --git a/xorg-server/glamor/glamor_pixmap.c b/xorg-server/glamor/glamor_pixmap.c
index 891ecdd37..a811f6015 100644
--- a/xorg-server/glamor/glamor_pixmap.c
+++ b/xorg-server/glamor/glamor_pixmap.c
@@ -283,8 +283,6 @@ glamor_get_tex_format_type_from_pictformat_gl(PictFormatShort format,
break;
default:
- LogMessageVerb(X_INFO, 0,
- "fail to get matched format for %x \n", format);
return -1;
}
return 0;
@@ -980,7 +978,7 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w,
&no_alpha,
&revert, &swap_rb, 1)) {
glamor_fallback("Unknown pixmap depth %d.\n", pixmap->drawable.depth);
- return TRUE;
+ return FALSE;
}
if (glamor_pixmap_upload_prepare(pixmap, format, no_alpha, revert, swap_rb))
return FALSE;
diff --git a/xorg-server/glamor/glamor_points.c b/xorg-server/glamor/glamor_points.c
index 5399f96e8..0d58e555f 100644
--- a/xorg-server/glamor/glamor_points.c
+++ b/xorg-server/glamor/glamor_points.c
@@ -35,8 +35,8 @@ static const glamor_facet glamor_facet_point = {
.vs_exec = GLAMOR_POS(gl_Position, primitive),
};
-Bool
-glamor_poly_point_nf(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPointPtr ppt)
+static Bool
+glamor_poly_point_gl(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPointPtr ppt)
{
ScreenPtr screen = drawable->pScreen;
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
@@ -123,7 +123,22 @@ void
glamor_poly_point(DrawablePtr drawable, GCPtr gc, int mode, int npt,
DDXPointPtr ppt)
{
- if (glamor_poly_point_nf(drawable, gc, mode, npt, ppt))
+ if (glamor_poly_point_gl(drawable, gc, mode, npt, ppt))
return;
miPolyPoint(drawable, gc, mode, npt, ppt);
}
+
+Bool
+glamor_poly_point_nf(DrawablePtr drawable, GCPtr gc, int mode, int npt,
+ DDXPointPtr ppt)
+{
+ if (glamor_poly_point_gl(drawable, gc, mode, npt, ppt))
+ return TRUE;
+
+ if (glamor_ddx_fallback_check_pixmap(drawable) && glamor_ddx_fallback_check_gc(gc))
+ return FALSE;
+
+ miPolyPoint(drawable, gc, mode, npt, ppt);
+ return TRUE;
+}
+
diff --git a/xorg-server/glamor/glamor_polyfillrect.c b/xorg-server/glamor/glamor_polyfillrect.c
deleted file mode 100644
index 1e361a44f..000000000
--- a/xorg-server/glamor/glamor_polyfillrect.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright © 2009 Intel Corporation
- * Copyright © 1998 Keith Packard
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- *
- * Authors:
- * Eric Anholt <eric@anholt.net>
- *
- */
-
-#include "glamor_priv.h"
-
-/** @file glamor_fillspans.c
- *
- * GC PolyFillRect implementation, taken straight from fb_fill.c
- */
-
-static Bool
-_glamor_poly_fill_rect(DrawablePtr drawable,
- GCPtr gc, int nrect, xRectangle *prect, Bool fallback)
-{
- int fullX1, fullX2, fullY1, fullY2;
- int xorg, yorg;
- int n;
- register BoxPtr pbox;
- RegionPtr pClip = fbGetCompositeClip(gc);
- Bool ret = FALSE;
-
- xorg = drawable->x;
- yorg = drawable->y;
-
- while (nrect--) {
- fullX1 = prect->x + xorg;
- fullY1 = prect->y + yorg;
- fullX2 = fullX1 + (int) prect->width;
- fullY2 = fullY1 + (int) prect->height;
-
- n = REGION_NUM_RECTS(pClip);
- pbox = REGION_RECTS(pClip);
- /*
- * clip the rectangle to each box in the clip region
- * this is logically equivalent to calling Intersect(),
- * but rectangles may overlap each other here.
- */
- while (n--) {
- int x1 = fullX1;
- int x2 = fullX2;
- int y1 = fullY1;
- int y2 = fullY2;
-
- if (pbox->x1 > x1)
- x1 = pbox->x1;
- if (pbox->x2 < x2)
- x2 = pbox->x2;
- if (pbox->y1 > y1)
- y1 = pbox->y1;
- if (pbox->y2 < y2)
- y2 = pbox->y2;
-
- pbox++;
- if (x1 >= x2 || y1 >= y2)
- continue;
- if (!glamor_fill(drawable, gc, x1, y1, x2 - x1, y2 - y1, fallback)) {
- nrect++;
- goto fail;
- }
- }
- prect++;
- }
- ret = TRUE;
- goto done;
-
- fail:
-
- if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
- && glamor_ddx_fallback_check_gc(gc))
- goto done;
-
- glamor_fallback(" to %p (%c)\n",
- drawable, glamor_get_drawable_location(drawable));
- if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
- glamor_prepare_access_gc(gc)) {
- fbPolyFillRect(drawable, gc, nrect, prect);
- }
- glamor_finish_access_gc(gc);
- glamor_finish_access(drawable);
- ret = TRUE;
-
- done:
- return ret;
-}
-
-void
-glamor_poly_fill_rect(DrawablePtr drawable,
- GCPtr gc, int nrect, xRectangle *prect)
-{
- _glamor_poly_fill_rect(drawable, gc, nrect, prect, TRUE);
-}
-
-Bool
-glamor_poly_fill_rect_nf(DrawablePtr drawable,
- GCPtr gc, int nrect, xRectangle *prect)
-{
- return _glamor_poly_fill_rect(drawable, gc, nrect, prect, FALSE);
-}
diff --git a/xorg-server/glamor/glamor_priv.h b/xorg-server/glamor/glamor_priv.h
index 4c305abfc..0cafac4b5 100644
--- a/xorg-server/glamor/glamor_priv.h
+++ b/xorg-server/glamor/glamor_priv.h
@@ -205,6 +205,7 @@ typedef struct glamor_screen_private {
Bool yInverted;
unsigned int tick;
enum glamor_gl_flavor gl_flavor;
+ int glsl_version;
int has_pack_invert;
int has_fbo_blit;
int has_map_buffer_range;
@@ -223,6 +224,20 @@ typedef struct glamor_screen_private {
/* glamor point shader */
glamor_program point_prog;
+ /* glamor spans shaders */
+ glamor_program_fill fill_spans_program;
+
+ /* glamor rect shaders */
+ glamor_program_fill poly_fill_rect_program;
+
+ /* glamor glyphblt shaders */
+ glamor_program_fill poly_glyph_blt_progs;
+
+ /* glamor text shaders */
+ glamor_program_fill poly_text_progs;
+ glamor_program te_text_prog;
+ glamor_program image_text_prog;
+
/* vertext/elment_index buffer object for render */
GLuint vbo, ebo;
/** Next offset within the VBO that glamor_get_vbo_space() will use. */
@@ -584,8 +599,6 @@ extern int glamor_debug_level;
/* glamor.c */
PixmapPtr glamor_get_drawable_pixmap(DrawablePtr drawable);
-Bool glamor_destroy_pixmap(PixmapPtr pixmap);
-
glamor_pixmap_fbo *glamor_pixmap_detach_fbo(glamor_pixmap_private *
pixmap_priv);
void glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo);
@@ -674,19 +687,9 @@ Bool glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
Bool glamor_solid_boxes(PixmapPtr pixmap,
BoxPtr box, int nbox, unsigned long fg_pixel);
-/* glamor_fillspans.c */
-void glamor_fill_spans(DrawablePtr drawable,
- GCPtr gc,
- int n, DDXPointPtr points, int *widths, int sorted);
-
void glamor_init_solid_shader(ScreenPtr screen);
void glamor_fini_solid_shader(ScreenPtr screen);
-/* glamor_getspans.c */
-void glamor_get_spans(DrawablePtr drawable,
- int wmax, DDXPointPtr points, int *widths,
- int nspans, char *dst_start);
-
/* glamor_glyphs.c */
Bool glamor_realize_glyph_caches(ScreenPtr screen);
void glamor_glyphs_fini(ScreenPtr screen);
@@ -697,14 +700,6 @@ void glamor_glyphs(CARD8 op,
INT16 xSrc,
INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr *glyphs);
-/* glamor_setspans.c */
-void glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
- DDXPointPtr points, int *widths, int n, int sorted);
-
-/* glamor_polyfillrect.c */
-void glamor_poly_fill_rect(DrawablePtr drawable,
- GCPtr gc, int nrect, xRectangle *prect);
-
/* glamor_polylines.c */
void glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
DDXPointPtr points);
@@ -967,6 +962,39 @@ RegionPtr glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
int dstx, int dsty,
unsigned long bitPlane);
+/* glamor_text.c */
+int glamor_poly_text8(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, char *chars);
+
+int glamor_poly_text16(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, unsigned short *chars);
+
+void glamor_image_text8(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, char *chars);
+
+void glamor_image_text16(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, unsigned short *chars);
+
+/* glamor_spans.c */
+void
+glamor_fill_spans(DrawablePtr drawable,
+ GCPtr gc,
+ int n, DDXPointPtr points, int *widths, int sorted);
+
+void
+glamor_get_spans(DrawablePtr drawable, int wmax,
+ DDXPointPtr points, int *widths, int count, char *dst);
+
+void
+glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
+ DDXPointPtr points, int *widths, int numPoints, int sorted);
+
+/* glamor_rects.c */
+void
+glamor_poly_fill_rect(DrawablePtr drawable,
+ GCPtr gc, int nrect, xRectangle *prect);
+
+/* glamor_glyphblt.c */
void glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
int x, int y, unsigned int nglyph,
CharInfoPtr *ppci, void *pglyphBase);
@@ -992,9 +1020,6 @@ void glamor_composite_rectangles(CARD8 op,
xRenderColor *color,
int num_rects, xRectangle *rects);
-extern _X_EXPORT void glamor_egl_screen_init(ScreenPtr screen,
- struct glamor_context *glamor_ctx);
-
/* glamor_xv */
typedef struct {
uint32_t transform_index;
@@ -1039,4 +1064,6 @@ void glamor_fini_xv_shader(ScreenPtr screen);
//#define GLYPHS_NO_EDEGEMAP_OVERLAP_CHECK
#define GLYPHS_EDEGE_OVERLAP_LOOSE_CHECK
+#include "glamor_font.h"
+
#endif /* GLAMOR_PRIV_H */
diff --git a/xorg-server/glamor/glamor_program.c b/xorg-server/glamor/glamor_program.c
index e2e1434ee..0f4d0f06a 100644
--- a/xorg-server/glamor/glamor_program.c
+++ b/xorg-server/glamor/glamor_program.c
@@ -45,9 +45,8 @@ use_tile(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
static const glamor_facet glamor_fill_tile = {
.name = "tile",
- .version = 130,
- .vs_exec = " fill_pos = fill_offset + primitive.xy + pos;\n",
- .fs_exec = " gl_FragColor = texelFetch(sampler, ivec2(mod(fill_pos,fill_size)), 0);\n",
+ .vs_exec = " fill_pos = (fill_offset + primitive.xy + pos) / fill_size;\n",
+ .fs_exec = " gl_FragColor = texture2D(sampler, fill_pos);\n",
.locations = glamor_program_location_fill,
.use = use_tile,
};
@@ -108,6 +107,7 @@ static glamor_location_var location_vars[] = {
{
.location = glamor_program_location_fill,
.vs_vars = ("uniform vec2 fill_offset;\n"
+ "uniform vec2 fill_size;\n"
"varying vec2 fill_pos;\n"),
.fs_vars = ("uniform sampler2D sampler;\n"
"uniform vec2 fill_size;\n"
@@ -240,16 +240,8 @@ glamor_build_program(ScreenPtr screen,
flags |= fill->flags;
version = MAX(version, fill->version);
- if (version >= 130) {
-
- /* Would be nice to have a cleaner test for GLSL 1.30 support,
- * but for now this should suffice
- */
- if (glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP ||
- epoxy_gl_version() < 30) {
- goto fail;
- }
- }
+ if (version > glamor_priv->glsl_version)
+ goto fail;
vs_vars = vs_location_vars(locations);
fs_vars = fs_location_vars(locations);
diff --git a/xorg-server/glamor/glamor_rects.c b/xorg-server/glamor/glamor_rects.c
new file mode 100644
index 000000000..7731edec4
--- /dev/null
+++ b/xorg-server/glamor/glamor_rects.c
@@ -0,0 +1,189 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * 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 the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS 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 OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include "glamor_priv.h"
+#include "glamor_program.h"
+#include "glamor_transform.h"
+
+static const glamor_facet glamor_facet_polyfillrect_130 = {
+ .name = "poly_fill_rect",
+ .version = 130,
+ .vs_vars = "attribute vec4 primitive;\n",
+ .vs_exec = (" vec2 pos = primitive.zw * vec2(gl_VertexID&1, (gl_VertexID&2)>>1);\n"
+ GLAMOR_POS(gl_Position, (primitive.xy + pos))),
+};
+
+static const glamor_facet glamor_facet_polyfillrect_120 = {
+ .name = "poly_fill_rect",
+ .vs_vars = "attribute vec2 primitive;\n",
+ .vs_exec = (" vec2 pos = vec2(0,0);\n"
+ GLAMOR_POS(gl_Position, primitive.xy)),
+};
+
+static Bool
+glamor_poly_fill_rect_gl(DrawablePtr drawable,
+ GCPtr gc, int nrect, xRectangle *prect)
+{
+ ScreenPtr screen = drawable->pScreen;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_pixmap_private *pixmap_priv;
+ glamor_program *prog;
+ int off_x, off_y;
+ GLshort *v;
+ char *vbo_offset;
+ int box_x, box_y;
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ goto bail;
+
+ glamor_get_context(glamor_priv);
+
+ if (glamor_priv->glsl_version >= 130) {
+ prog = glamor_use_program_fill(pixmap, gc,
+ &glamor_priv->poly_fill_rect_program,
+ &glamor_facet_polyfillrect_130);
+
+ if (!prog)
+ goto bail_ctx;
+
+ /* Set up the vertex buffers for the points */
+
+ v = glamor_get_vbo_space(drawable->pScreen, nrect * sizeof (xRectangle), &vbo_offset);
+
+ glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+ glVertexAttribDivisor(GLAMOR_VERTEX_POS, 1);
+ glVertexAttribPointer(GLAMOR_VERTEX_POS, 4, GL_SHORT, GL_FALSE,
+ 4 * sizeof (short), vbo_offset);
+
+ memcpy(v, prect, nrect * sizeof (xRectangle));
+
+ glamor_put_vbo_space(screen);
+ } else {
+ int n;
+
+ prog = glamor_use_program_fill(pixmap, gc,
+ &glamor_priv->poly_fill_rect_program,
+ &glamor_facet_polyfillrect_120);
+
+ if (!prog)
+ goto bail_ctx;
+
+ /* Set up the vertex buffers for the points */
+
+ v = glamor_get_vbo_space(drawable->pScreen, nrect * 8 * sizeof (short), &vbo_offset);
+
+ glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+ glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_SHORT, GL_FALSE,
+ 2 * sizeof (short), vbo_offset);
+
+ for (n = 0; n < nrect; n++) {
+ v[0] = prect->x; v[1] = prect->y;
+ v[2] = prect->x; v[3] = prect->y + prect->height;
+ v[4] = prect->x + prect->width; v[5] = prect->y + prect->height;
+ v[6] = prect->x + prect->width; v[7] = prect->y;
+ prect++;
+ v += 8;
+ }
+
+ glamor_put_vbo_space(screen);
+ }
+
+ glEnable(GL_SCISSOR_TEST);
+
+ glamor_pixmap_loop(pixmap_priv, box_x, box_y) {
+ int nbox = RegionNumRects(gc->pCompositeClip);
+ BoxPtr box = RegionRects(gc->pCompositeClip);
+
+ glamor_set_destination_drawable(drawable, box_x, box_y, TRUE, FALSE, prog->matrix_uniform, &off_x, &off_y);
+
+ while (nbox--) {
+ glScissor(box->x1 + off_x,
+ box->y1 + off_y,
+ box->x2 - box->x1,
+ box->y2 - box->y1);
+ box++;
+ if (glamor_priv->glsl_version >= 130)
+ glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, nrect);
+ else {
+ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
+ glDrawArrays(GL_QUADS, 0, nrect * 4);
+ } else {
+ int i;
+ for (i = 0; i < nrect; i++) {
+ glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4);
+ }
+ }
+ }
+ }
+ }
+
+ glDisable(GL_SCISSOR_TEST);
+ glDisable(GL_COLOR_LOGIC_OP);
+ if (glamor_priv->glsl_version >= 130)
+ glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
+ glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+
+ glamor_put_context(glamor_priv);
+ return TRUE;
+bail_ctx:
+ glDisable(GL_COLOR_LOGIC_OP);
+ glamor_put_context(glamor_priv);
+bail:
+ return FALSE;
+}
+
+static void
+glamor_poly_fill_rect_bail(DrawablePtr drawable,
+ GCPtr gc, int nrect, xRectangle *prect)
+{
+ glamor_fallback("to %p (%c)\n", drawable,
+ glamor_get_drawable_location(drawable));
+ if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
+ glamor_prepare_access_gc(gc)) {
+ fbPolyFillRect(drawable, gc, nrect, prect);
+ }
+ glamor_finish_access_gc(gc);
+ glamor_finish_access(drawable);
+}
+
+void
+glamor_poly_fill_rect(DrawablePtr drawable,
+ GCPtr gc, int nrect, xRectangle *prect)
+{
+ if (glamor_poly_fill_rect_gl(drawable, gc, nrect, prect))
+ return;
+ glamor_poly_fill_rect_bail(drawable, gc, nrect, prect);
+}
+
+Bool
+glamor_poly_fill_rect_nf(DrawablePtr drawable,
+ GCPtr gc, int nrect, xRectangle *prect)
+{
+ if (glamor_poly_fill_rect_gl(drawable, gc, nrect, prect))
+ return TRUE;
+ if (glamor_ddx_fallback_check_pixmap(drawable) && glamor_ddx_fallback_check_gc(gc))
+ return FALSE;
+ glamor_poly_fill_rect_bail(drawable, gc, nrect, prect);
+ return TRUE;
+}
diff --git a/xorg-server/glamor/glamor_setspans.c b/xorg-server/glamor/glamor_setspans.c
deleted file mode 100644
index a51e4c5be..000000000
--- a/xorg-server/glamor/glamor_setspans.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright © 2009 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- *
- * Authors:
- * Eric Anholt <eric@anholt.net>
- * Zhigang Gong <zhigang.gong@linux.intel.com>
- *
- */
-
-#include "glamor_priv.h"
-
-static Bool
-_glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
- DDXPointPtr points, int *widths, int numPoints, int sorted,
- Bool fallback)
-{
- PixmapPtr dest_pixmap = glamor_get_drawable_pixmap(drawable);
- glamor_pixmap_private *dest_pixmap_priv;
- int i;
- uint8_t *drawpixels_src = (uint8_t *) src;
- RegionPtr clip = fbGetCompositeClip(gc);
- BoxRec *pbox;
- int x_off, y_off;
- Bool ret = FALSE;
-
- dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
- if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) {
- glamor_fallback("pixmap has no fbo.\n");
- goto fail;
- }
-
- if (gc->alu != GXcopy) {
- glamor_fallback("SetSpans with non-copy ALU.\n");
- goto fail;
- }
-
- if (!glamor_set_planemask(dest_pixmap, gc->planemask))
- goto fail;
-
- glamor_get_drawable_deltas(drawable, dest_pixmap, &x_off, &y_off);
- for (i = 0; i < numPoints; i++) {
-
- int n = REGION_NUM_RECTS(clip);
-
- pbox = REGION_RECTS(clip);
- while (n--) {
- int x1 = points[i].x;
- int x2 = x1 + widths[i];
- int y1 = points[i].y;
-
- if (pbox->y1 > points[i].y || pbox->y2 < points[i].y)
- break;
- x1 = x1 > pbox->x1 ? x1 : pbox->x1;
- x2 = x2 < pbox->x2 ? x2 : pbox->x2;
- if (x1 >= x2)
- continue;
- glamor_upload_sub_pixmap_to_texture(dest_pixmap, x1 + x_off,
- y1 + y_off, x2 - x1, 1,
- PixmapBytePad(widths[i],
- drawable->depth),
- drawpixels_src, 0);
- }
- drawpixels_src += PixmapBytePad(widths[i], drawable->depth);
- }
- ret = TRUE;
- goto done;
-
- fail:
- if (!fallback && glamor_ddx_fallback_check_pixmap(drawable))
- goto done;
-
- glamor_fallback("to %p (%c)\n",
- drawable, glamor_get_drawable_location(drawable));
- if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
- glamor_prepare_access_gc(gc)) {
- fbSetSpans(drawable, gc, src, points, widths, numPoints, sorted);
- }
- glamor_finish_access_gc(gc);
- glamor_finish_access(drawable);
- ret = TRUE;
-
- done:
- return ret;
-}
-
-void
-glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
- DDXPointPtr points, int *widths, int n, int sorted)
-{
- _glamor_set_spans(drawable, gc, src, points, widths, n, sorted, TRUE);
-}
-
-Bool
-glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc, char *src,
- DDXPointPtr points, int *widths, int n, int sorted)
-{
- return _glamor_set_spans(drawable, gc, src, points,
- widths, n, sorted, FALSE);
-}
diff --git a/xorg-server/glamor/glamor_spans.c b/xorg-server/glamor/glamor_spans.c
new file mode 100644
index 000000000..98842cdde
--- /dev/null
+++ b/xorg-server/glamor/glamor_spans.c
@@ -0,0 +1,438 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * 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 the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS 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 OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include "glamor_priv.h"
+#include "glamor_transform.h"
+#include "glamor_transfer.h"
+
+glamor_program fill_spans_progs[4];
+
+static const glamor_facet glamor_facet_fillspans_130 = {
+ .name = "fill_spans",
+ .version = 130,
+ .vs_vars = "attribute vec3 primitive;\n",
+ .vs_exec = (" vec2 pos = vec2(primitive.z,1) * vec2(gl_VertexID&1, (gl_VertexID&2)>>1);\n"
+ GLAMOR_POS(gl_Position, (primitive.xy + pos))),
+};
+
+static const glamor_facet glamor_facet_fillspans_120 = {
+ .name = "fill_spans",
+ .vs_vars = "attribute vec2 primitive;\n",
+ .vs_exec = (" vec2 pos = vec2(0,0);\n"
+ GLAMOR_POS(gl_Position, primitive.xy)),
+};
+
+static Bool
+glamor_fill_spans_gl(DrawablePtr drawable,
+ GCPtr gc,
+ int n, DDXPointPtr points, int *widths, int sorted)
+{
+ ScreenPtr screen = drawable->pScreen;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_pixmap_private *pixmap_priv;
+ glamor_program *prog;
+ int off_x, off_y;
+ GLshort *v;
+ char *vbo_offset;
+ int c;
+ int box_x, box_y;
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ goto bail;
+
+ glamor_get_context(glamor_priv);
+
+ if (glamor_priv->glsl_version >= 130) {
+ prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->fill_spans_program,
+ &glamor_facet_fillspans_130);
+
+ if (!prog)
+ goto bail_ctx;
+
+ /* Set up the vertex buffers for the points */
+
+ v = glamor_get_vbo_space(drawable->pScreen, n * (4 * sizeof (GLshort)), &vbo_offset);
+
+ glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+ glVertexAttribDivisor(GLAMOR_VERTEX_POS, 1);
+ glVertexAttribPointer(GLAMOR_VERTEX_POS, 3, GL_SHORT, GL_FALSE,
+ 4 * sizeof (GLshort), vbo_offset);
+
+ for (c = 0; c < n; c++) {
+ v[0] = points->x;
+ v[1] = points->y;
+ v[2] = *widths++;
+ points++;
+ v += 4;
+ }
+
+ glamor_put_vbo_space(screen);
+ } else {
+ prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->fill_spans_program,
+ &glamor_facet_fillspans_120);
+
+ if (!prog)
+ goto bail_ctx;
+
+ /* Set up the vertex buffers for the points */
+
+ v = glamor_get_vbo_space(drawable->pScreen, n * 8 * sizeof (short), &vbo_offset);
+
+ glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+ glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_SHORT, GL_FALSE,
+ 2 * sizeof (short), vbo_offset);
+
+ for (c = 0; c < n; c++) {
+ v[0] = points->x; v[1] = points->y;
+ v[2] = points->x; v[3] = points->y + 1;
+ v[4] = points->x + *widths; v[5] = points->y + 1;
+ v[6] = points->x + *widths; v[7] = points->y;
+
+ widths++;
+ points++;
+ v += 8;
+ }
+
+ glamor_put_vbo_space(screen);
+ }
+
+ glEnable(GL_SCISSOR_TEST);
+
+ glamor_pixmap_loop(pixmap_priv, box_x, box_y) {
+ int nbox = RegionNumRects(gc->pCompositeClip);
+ BoxPtr box = RegionRects(gc->pCompositeClip);
+
+ glamor_set_destination_drawable(drawable, box_x, box_y, FALSE, FALSE, prog->matrix_uniform, &off_x, &off_y);
+
+ while (nbox--) {
+ glScissor(box->x1 + off_x,
+ box->y1 + off_y,
+ box->x2 - box->x1,
+ box->y2 - box->y1);
+ box++;
+ if (glamor_priv->glsl_version >= 130)
+ glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, n);
+ else {
+ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
+ glDrawArrays(GL_QUADS, 0, 4 * n);
+ } else {
+ int i;
+ for (i = 0; i < n; i++) {
+ glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4);
+ }
+ }
+ }
+ }
+ }
+
+ glDisable(GL_SCISSOR_TEST);
+ glDisable(GL_COLOR_LOGIC_OP);
+ if (glamor_priv->glsl_version >= 130)
+ glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
+ glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+
+ glamor_put_context(glamor_priv);
+ return TRUE;
+bail_ctx:
+ glDisable(GL_COLOR_LOGIC_OP);
+ glamor_put_context(glamor_priv);
+bail:
+ return FALSE;
+}
+
+static void
+glamor_fill_spans_bail(DrawablePtr drawable,
+ GCPtr gc,
+ int n, DDXPointPtr points, int *widths, int sorted)
+{
+ if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
+ glamor_prepare_access_gc(gc)) {
+ fbFillSpans(drawable, gc, n, points, widths, sorted);
+ }
+ glamor_finish_access_gc(gc);
+ glamor_finish_access(drawable);
+}
+
+void
+glamor_fill_spans(DrawablePtr drawable,
+ GCPtr gc,
+ int n, DDXPointPtr points, int *widths, int sorted)
+{
+ if (glamor_fill_spans_gl(drawable, gc, n, points, widths, sorted))
+ return;
+ glamor_fill_spans_bail(drawable, gc, n, points, widths, sorted);
+}
+
+Bool
+glamor_fill_spans_nf(DrawablePtr drawable,
+ GCPtr gc,
+ int n, DDXPointPtr points, int *widths, int sorted)
+{
+ if (glamor_fill_spans_gl(drawable, gc, n, points, widths, sorted))
+ return TRUE;
+
+ if (glamor_ddx_fallback_check_pixmap(drawable) && glamor_ddx_fallback_check_gc(gc))
+ return FALSE;
+
+ glamor_fill_spans_bail(drawable, gc, n, points, widths, sorted);
+ return TRUE;
+}
+
+static Bool
+glamor_get_spans_gl(DrawablePtr drawable, int wmax,
+ DDXPointPtr points, int *widths, int count, char *dst)
+{
+ ScreenPtr screen = drawable->pScreen;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_pixmap_private *pixmap_priv;
+ int box_x, box_y;
+ int n;
+ char *d;
+ GLenum type;
+ GLenum format;
+ int off_x, off_y;
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ goto bail;
+
+ glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
+
+ glamor_format_for_pixmap(pixmap, &format, &type);
+
+ glamor_get_context(glamor_priv);
+
+ glamor_pixmap_loop(pixmap_priv, box_x, box_y) {
+ BoxPtr box = glamor_pixmap_box_at(pixmap_priv, box_x, box_y);
+ glamor_pixmap_fbo *fbo = glamor_pixmap_fbo_at(pixmap_priv, box_x, box_y);
+
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo->fb);
+ glPixelStorei(GL_PACK_ALIGNMENT, 4);
+
+ d = dst;
+ for (n = 0; n < count; n++) {
+ int x1 = points[n].x + off_x;
+ int y = points[n].y + off_y;
+ int w = widths[n];
+ int x2 = x1 + w;
+ char *l;
+
+ l = d;
+ d += PixmapBytePad(w, drawable->depth);
+
+ /* clip */
+ if (x1 < box->x1) {
+ l += (box->x1 - x1) * (drawable->bitsPerPixel >> 3);
+ x1 = box->x1;
+ }
+ if (x2 > box->x2)
+ x2 = box->x2;
+
+ if (x1 >= x2)
+ continue;
+ if (y < box->y1)
+ continue;
+ if (y >= box->y2)
+ continue;
+
+ glReadPixels(x1 - box->x1, y - box->y1, x2 - x1, 1, format, type, l);
+ }
+ }
+
+ glamor_put_context(glamor_priv);
+ return TRUE;
+bail:
+ return FALSE;
+}
+
+static void
+glamor_get_spans_bail(DrawablePtr drawable, int wmax,
+ DDXPointPtr points, int *widths, int count, char *dst)
+{
+ if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RO))
+ fbGetSpans(drawable, wmax, points, widths, count, dst);
+ glamor_finish_access(drawable);
+}
+
+void
+glamor_get_spans(DrawablePtr drawable, int wmax,
+ DDXPointPtr points, int *widths, int count, char *dst)
+{
+ if (glamor_get_spans_gl(drawable, wmax, points, widths, count, dst))
+ return;
+ glamor_get_spans_bail(drawable, wmax, points, widths, count, dst);
+}
+
+Bool
+glamor_get_spans_nf(DrawablePtr drawable, int wmax,
+ DDXPointPtr points, int *widths, int count, char *dst)
+{
+ if (glamor_get_spans_gl(drawable, wmax, points, widths, count, dst))
+ return TRUE;
+
+ if (glamor_ddx_fallback_check_pixmap(drawable))
+ return FALSE;
+
+ glamor_get_spans_bail(drawable, wmax, points, widths, count, dst);
+ return TRUE;
+}
+
+static Bool
+glamor_set_spans_gl(DrawablePtr drawable, GCPtr gc, char *src,
+ DDXPointPtr points, int *widths, int numPoints, int sorted)
+{
+ ScreenPtr screen = drawable->pScreen;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_pixmap_private *pixmap_priv;
+ int box_x, box_y;
+ int n;
+ char *s;
+ GLenum type;
+ GLenum format;
+ int off_x, off_y;
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ goto bail;
+
+ if (gc->alu != GXcopy)
+ goto bail;
+
+ if (!glamor_pm_is_solid(&pixmap->drawable, gc->planemask))
+ goto bail;
+
+ glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
+ glamor_format_for_pixmap(pixmap, &format, &type);
+
+ glamor_get_context(glamor_priv);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+
+ glamor_pixmap_loop(pixmap_priv, box_x, box_y) {
+ BoxPtr box = glamor_pixmap_box_at(pixmap_priv, box_x, box_y);
+ glamor_pixmap_fbo *fbo = glamor_pixmap_fbo_at(pixmap_priv, box_x, box_y);
+
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, fbo->tex);
+
+ s = src;
+ for (n = 0; n < numPoints; n++) {
+
+ BoxPtr clip_box = RegionRects(gc->pCompositeClip);
+ int nclip_box = RegionNumRects(gc->pCompositeClip);
+ int w = widths[n];
+ int y = points[n].y;
+ int x = points[n].x;
+
+ while (nclip_box--) {
+ int x1 = x;
+ int x2 = x + w;
+ int y1 = y;
+ char *l = s;
+
+ /* clip to composite clip */
+ if (x1 < clip_box->x1) {
+ l += (clip_box->x1 - x1) * (drawable->bitsPerPixel >> 3);
+ x1 = clip_box->x1;
+ }
+ if (x2 > clip_box->x2)
+ x2 = clip_box->x2;
+
+ if (y < clip_box->y1)
+ continue;
+ if (y >= clip_box->y2)
+ continue;
+
+ /* adjust to pixmap coordinates */
+ x1 += off_x;
+ x2 += off_x;
+ y1 += off_y;
+
+ if (x1 < box->x1) {
+ l += (box->x1 - x1) * (drawable->bitsPerPixel >> 3);
+ x1 = box->x1;
+ }
+ if (x2 > box->x2)
+ x2 = box->x2;
+
+ if (x1 >= x2)
+ continue;
+ if (y1 < box->y1)
+ continue;
+ if (y1 >= box->y2)
+ continue;
+
+ glTexSubImage2D(GL_TEXTURE_2D, 0,
+ x1 - box->x1, y1 - box->y1, x2 - x1, 1,
+ format, type,
+ l);
+ }
+ s += PixmapBytePad(w, drawable->depth);
+ }
+ }
+
+ glamor_put_context(glamor_priv);
+ return TRUE;
+
+bail:
+ return FALSE;
+}
+
+static void
+glamor_set_spans_bail(DrawablePtr drawable, GCPtr gc, char *src,
+ DDXPointPtr points, int *widths, int numPoints, int sorted)
+{
+ if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) && glamor_prepare_access_gc(gc))
+ fbSetSpans(drawable, gc, src, points, widths, numPoints, sorted);
+ glamor_finish_access_gc(gc);
+ glamor_finish_access(drawable);
+}
+
+void
+glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
+ DDXPointPtr points, int *widths, int numPoints, int sorted)
+{
+ if (glamor_set_spans_gl(drawable, gc, src, points, widths, numPoints, sorted))
+ return;
+ glamor_set_spans_bail(drawable, gc, src, points, widths, numPoints, sorted);
+}
+
+Bool
+glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc, char *src,
+ DDXPointPtr points, int *widths, int numPoints, int sorted)
+{
+ if (glamor_set_spans_gl(drawable, gc, src, points, widths, numPoints, sorted))
+ return TRUE;
+
+ if (glamor_ddx_fallback_check_pixmap(drawable) && glamor_ddx_fallback_check_gc(gc))
+ return FALSE;
+
+ glamor_set_spans_bail(drawable, gc, src, points, widths, numPoints, sorted);
+ return TRUE;
+}
diff --git a/xorg-server/glamor/glamor_text.c b/xorg-server/glamor/glamor_text.c
new file mode 100644
index 000000000..0e4b74c56
--- /dev/null
+++ b/xorg-server/glamor/glamor_text.c
@@ -0,0 +1,526 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * 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 the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS 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 OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include "glamor_priv.h"
+#include <dixfontstr.h>
+#include "glamor_transform.h"
+
+/*
+ * Fill in the array of charinfo pointers for the provided characters. For
+ * missing characters, place a NULL in the array so that the charinfo array
+ * aligns exactly with chars
+ */
+
+static void
+glamor_get_glyphs(FontPtr font, glamor_font_t *glamor_font,
+ int count, char *chars, Bool sixteen, CharInfoPtr *charinfo)
+{
+ unsigned long nglyphs;
+ FontEncoding encoding;
+ int char_step;
+
+ if (sixteen) {
+ char_step = 2;
+ if (FONTLASTROW(font) == 0)
+ encoding = Linear16Bit;
+ else
+ encoding = TwoD16Bit;
+ } else {
+ char_step = 1;
+ encoding = Linear8Bit;
+ }
+
+ /* If the font has a default character, then we don't have to
+ * worry about missing glyphs, so just get the whole string all at
+ * once. Otherwise, we have to fetch chars one at a time to notice
+ * missing ones.
+ */
+ if (glamor_font->default_char) {
+ GetGlyphs(font, (unsigned long) count, (unsigned char *) chars,
+ encoding, &nglyphs, charinfo);
+ } else {
+ int c;
+ for (c = 0; c < count; c++) {
+ GetGlyphs(font, 1, (unsigned char *) chars,
+ encoding, &nglyphs, &charinfo[c]);
+ if (!nglyphs)
+ charinfo[c] = NULL;
+ chars += char_step;
+ }
+ }
+}
+
+/*
+ * Construct quads for the provided list of characters and draw them
+ */
+
+static int
+glamor_text(DrawablePtr drawable, GCPtr gc,
+ glamor_font_t *glamor_font,
+ glamor_program *prog,
+ int x, int y,
+ int count, char *s_chars, CharInfoPtr *charinfo,
+ Bool sixteen)
+{
+ unsigned char *chars = (unsigned char *) s_chars;
+ FontPtr font = gc->font;
+ int off_x, off_y;
+ int c;
+ int nglyph;
+ GLshort *v;
+ char *vbo_offset;
+ CharInfoPtr ci;
+ int firstRow = font->info.firstRow;
+ int firstCol = font->info.firstCol;
+ int glyph_spacing_x = glamor_font->glyph_width_bytes * 8;
+ int glyph_spacing_y = glamor_font->glyph_height;
+ int box_x, box_y;
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
+
+ /* Set the font as texture 1 */
+
+ glActiveTexture(GL_TEXTURE1);
+ glBindTexture(GL_TEXTURE_2D, glamor_font->texture_id);
+ glUniform1i(prog->font_uniform, 1);
+
+ /* Set up the vertex buffers for the font and destination */
+
+ v = glamor_get_vbo_space(drawable->pScreen, count * (6 * sizeof (GLshort)), &vbo_offset);
+
+ glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+ glVertexAttribDivisor(GLAMOR_VERTEX_POS, 1);
+ glVertexAttribPointer(GLAMOR_VERTEX_POS, 4, GL_SHORT, GL_FALSE,
+ 6 * sizeof (GLshort), vbo_offset);
+
+ glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ glVertexAttribDivisor(GLAMOR_VERTEX_SOURCE, 1);
+ glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_SHORT, GL_FALSE,
+ 6 * sizeof (GLshort), vbo_offset + 4 * sizeof (GLshort));
+
+ /* Set the vertex coordinates */
+ nglyph = 0;
+
+ for (c = 0; c < count; c++) {
+ if ((ci = *charinfo++)) {
+ int x1 = x + ci->metrics.leftSideBearing;
+ int y1 = y - ci->metrics.ascent;
+ int width = GLYPHWIDTHPIXELS(ci);
+ int height = GLYPHHEIGHTPIXELS(ci);
+ int tx, ty = 0;
+ int row = 0, col;
+
+ x += ci->metrics.characterWidth;
+
+ if (sixteen) {
+ if (ci == glamor_font->default_char) {
+ row = glamor_font->default_row;
+ col = glamor_font->default_col;
+ } else {
+ row = chars[0];
+ col = chars[1];
+ }
+ if (FONTLASTROW(font) != 0)
+ ty = (row - firstRow) * glyph_spacing_y;
+ else
+ col += row << 8;
+ } else {
+ if (ci == glamor_font->default_char)
+ col = glamor_font->default_col;
+ else
+ col = chars[0];
+ }
+
+ tx = (col - firstCol) * glyph_spacing_x;
+
+ v[ 0] = x1;
+ v[ 1] = y1;
+ v[ 2] = width;
+ v[ 3] = height;
+ v[ 4] = tx;
+ v[ 5] = ty;
+
+ v += 6;
+ nglyph++;
+ }
+ chars += 1 + sixteen;
+ }
+ glamor_put_vbo_space(drawable->pScreen);
+
+ if (nglyph != 0) {
+
+ glEnable(GL_SCISSOR_TEST);
+
+ glamor_pixmap_loop(pixmap_priv, box_x, box_y) {
+ BoxPtr box = RegionRects(gc->pCompositeClip);
+ int nbox = RegionNumRects(gc->pCompositeClip);
+
+ glamor_set_destination_drawable(drawable, box_x, box_y, TRUE, FALSE, prog->matrix_uniform, &off_x, &off_y);
+
+ /* Run over the clip list, drawing the glyphs
+ * in each box
+ */
+
+ while (nbox--) {
+ glScissor(box->x1 + off_x,
+ box->y1 + off_y,
+ box->x2 - box->x1,
+ box->y2 - box->y1);
+ box++;
+ glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, nglyph);
+ }
+ }
+ glDisable(GL_SCISSOR_TEST);
+ }
+
+ glVertexAttribDivisor(GLAMOR_VERTEX_SOURCE, 0);
+ glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
+ glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+ glDisable(GL_COLOR_LOGIC_OP);
+
+ return x;
+}
+
+static const char vs_vars_text[] =
+ "attribute vec4 primitive;\n"
+ "attribute vec2 source;\n"
+ "varying vec2 glyph_pos;\n";
+
+static const char vs_exec_text[] =
+ " vec2 pos = primitive.zw * vec2(gl_VertexID&1, (gl_VertexID&2)>>1);\n"
+ GLAMOR_POS(gl_Position, (primitive.xy + pos))
+ " glyph_pos = source + pos;\n";
+
+static const char fs_vars_text[] =
+ "varying vec2 glyph_pos;\n";
+
+static const char fs_exec_text[] =
+ " ivec2 itile_texture = ivec2(glyph_pos);\n"
+ " uint x = uint(itile_texture.x & 7);\n"
+ " itile_texture.x >>= 3;\n"
+ " uint texel = texelFetch(font, itile_texture, 0).x;\n"
+ " uint bit = (texel >> x) & uint(1);\n"
+ " if (bit == uint(0))\n"
+ " discard;\n";
+
+static const char fs_exec_te[] =
+ " ivec2 itile_texture = ivec2(glyph_pos);\n"
+ " uint x = uint(itile_texture.x & 7);\n"
+ " itile_texture.x >>= 3;\n"
+ " uint texel = texelFetch(font, itile_texture, 0).x;\n"
+ " uint bit = (texel >> x) & uint(1);\n"
+ " if (bit == uint(0))\n"
+ " gl_FragColor = bg;\n"
+ " else\n"
+ " gl_FragColor = fg;\n";
+
+static const glamor_facet glamor_facet_poly_text = {
+ .name = "poly_text",
+ .version = 130,
+ .vs_vars = vs_vars_text,
+ .vs_exec = vs_exec_text,
+ .fs_vars = fs_vars_text,
+ .fs_exec = fs_exec_text,
+ .source_name = "source",
+ .locations = glamor_program_location_font,
+};
+
+static Bool
+glamor_poly_text(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, char *chars, Bool sixteen, int *final_pos)
+{
+ ScreenPtr screen = drawable->pScreen;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_program *prog;
+ glamor_pixmap_private *pixmap_priv;
+ glamor_font_t *glamor_font;
+ CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */
+
+ glamor_font = glamor_font_get(drawable->pScreen, gc->font);
+ if (!glamor_font)
+ goto bail;
+
+ glamor_get_glyphs(gc->font, glamor_font, count, chars, sixteen, charinfo);
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ goto bail;
+
+ glamor_get_context(glamor_priv);
+
+ prog = glamor_use_program_fill(pixmap, gc, &glamor_priv->poly_text_progs, &glamor_facet_poly_text);
+
+ if (!prog)
+ goto bail_ctx;
+
+ x = glamor_text(drawable, gc, glamor_font, prog,
+ x, y, count, chars, charinfo, sixteen);
+
+ glDisable(GL_COLOR_LOGIC_OP);
+
+ glamor_put_context(glamor_priv);
+
+ glamor_priv->state = RENDER_STATE;
+ glamor_priv->render_idle_cnt = 0;
+
+ *final_pos = x;
+ return TRUE;
+
+bail_ctx:
+ glDisable(GL_COLOR_LOGIC_OP);
+ glamor_put_context(glamor_priv);
+bail:
+ return FALSE;
+}
+
+Bool
+glamor_poly_text8_nf(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, char *chars, int *final_pos)
+{
+ if (glamor_poly_text(drawable, gc, x, y, count, chars, FALSE, final_pos))
+ return TRUE;
+ if (glamor_ddx_fallback_check_pixmap(drawable) && glamor_ddx_fallback_check_gc(gc))
+ return FALSE;
+ *final_pos = miPolyText8(drawable, gc, x, y, count, chars);
+ return TRUE;
+}
+
+int
+glamor_poly_text8(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, char *chars)
+{
+ int final_pos;
+
+ if (glamor_poly_text(drawable, gc, x, y, count, chars, FALSE, &final_pos))
+ return final_pos;
+ return miPolyText8(drawable, gc, x, y, count, chars);
+}
+
+Bool
+glamor_poly_text16_nf(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, unsigned short *chars, int *final_pos)
+{
+ if (glamor_poly_text(drawable, gc, x, y, count, (char *) chars, TRUE, final_pos))
+ return TRUE;
+
+ if (glamor_ddx_fallback_check_pixmap(drawable) && glamor_ddx_fallback_check_gc(gc))
+ return FALSE;
+ *final_pos = miPolyText16(drawable, gc, x, y, count, chars);
+ return TRUE;
+}
+
+int
+glamor_poly_text16(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, unsigned short *chars)
+{
+ int final_pos;
+
+ if (glamor_poly_text(drawable, gc, x, y, count, (char *) chars, TRUE, &final_pos))
+ return final_pos;
+ return miPolyText16(drawable, gc, x, y, count, chars);
+}
+
+/*
+ * Draw image text, which is always solid in copy mode and has the
+ * background cleared while painting the text. For fonts which have
+ * their bitmap metrics exactly equal to the area to clear, we can use
+ * the accelerated version which paints both fg and bg at the same
+ * time. Otherwise, clear the whole area and then paint the glyphs on
+ * top
+ */
+
+static const glamor_facet glamor_facet_image_text = {
+ .name = "image_text",
+ .version = 130,
+ .vs_vars = vs_vars_text,
+ .vs_exec = vs_exec_text,
+ .fs_vars = fs_vars_text,
+ .fs_exec = fs_exec_text,
+ .source_name = "source",
+ .locations = glamor_program_location_font,
+};
+
+static Bool
+use_image_solid(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
+{
+ return glamor_set_solid(pixmap, gc, FALSE, prog->fg_uniform);
+}
+
+static const glamor_facet glamor_facet_image_fill = {
+ .name = "solid",
+ .fs_exec = " gl_FragColor = fg;\n",
+ .locations = glamor_program_location_fg,
+ .use = use_image_solid,
+};
+
+static Bool
+glamor_te_text_use(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg)
+{
+ if (!glamor_set_solid(pixmap, gc, FALSE, prog->fg_uniform))
+ return FALSE;
+ glamor_set_color(pixmap, gc->bgPixel, prog->bg_uniform);
+ return TRUE;
+}
+
+static const glamor_facet glamor_facet_te_text = {
+ .name = "te_text",
+ .version = 130,
+ .vs_vars = vs_vars_text,
+ .vs_exec = vs_exec_text,
+ .fs_vars = fs_vars_text,
+ .fs_exec = fs_exec_te,
+ .locations = glamor_program_location_fg | glamor_program_location_bg | glamor_program_location_font,
+ .source_name = "source",
+ .use = glamor_te_text_use,
+};
+
+static Bool
+glamor_image_text(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, char *chars,
+ Bool sixteen)
+{
+ ScreenPtr screen = drawable->pScreen;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_program *prog;
+ glamor_pixmap_private *pixmap_priv;
+ glamor_font_t *glamor_font;
+ const glamor_facet *prim_facet;
+ const glamor_facet *fill_facet;
+ CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ return FALSE;
+
+ glamor_font = glamor_font_get(drawable->pScreen, gc->font);
+ if (!glamor_font)
+ return FALSE;
+
+ glamor_get_glyphs(gc->font, glamor_font, count, chars, sixteen, charinfo);
+
+ glamor_get_context(glamor_priv);
+
+ if (TERMINALFONT(gc->font))
+ prog = &glamor_priv->te_text_prog;
+ else
+ prog = &glamor_priv->image_text_prog;
+
+ if (prog->failed)
+ goto bail;
+
+ if (!prog->prog) {
+ if (TERMINALFONT(gc->font)) {
+ prim_facet = &glamor_facet_te_text;
+ fill_facet = NULL;
+ } else {
+ prim_facet = &glamor_facet_image_text;
+ fill_facet = &glamor_facet_image_fill;
+ }
+
+ if (!glamor_build_program(screen, prog, prim_facet, fill_facet))
+ goto bail;
+ }
+
+ if (!TERMINALFONT(gc->font)) {
+ int width = 0;
+ int c;
+ RegionRec region;
+ BoxRec box;
+ int off_x, off_y;
+
+ /* Check planemask before drawing background to
+ * bail early if it's not OK
+ */
+ if (!glamor_set_planemask(pixmap, gc->planemask))
+ goto bail;
+ for (c = 0; c < count; c++)
+ if (charinfo[c])
+ width += charinfo[c]->metrics.characterWidth;
+
+ glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
+
+ if (width >= 0) {
+ box.x1 = off_x + drawable->x + x;
+ box.x2 = off_x + drawable->x + x + width;
+ } else {
+ box.x1 = off_x + drawable->x + x + width;
+ box.x2 = off_x + drawable->x + x;
+ }
+ box.y1 = off_y + drawable->y + y - gc->font->info.fontAscent;
+ box.y2 = off_y + drawable->y + y + gc->font->info.fontDescent;
+ RegionInit(&region, &box, 1);
+ RegionIntersect(&region, &region, gc->pCompositeClip);
+ glamor_solid_boxes(pixmap, RegionRects(&region), RegionNumRects(&region), gc->bgPixel);
+ RegionUninit(&region);
+ }
+
+ if (!glamor_use_program(pixmap, gc, prog, NULL))
+ goto bail;
+
+ (void) glamor_text(drawable, gc, glamor_font, prog,
+ x, y, count, chars, charinfo, sixteen);
+
+ glamor_put_context(glamor_priv);
+
+ glamor_priv->state = RENDER_STATE;
+ glamor_priv->render_idle_cnt = 0;
+
+ return TRUE;
+
+bail:
+ glDisable(GL_COLOR_LOGIC_OP);
+ glamor_put_context(glamor_priv);
+ return FALSE;
+}
+
+Bool
+glamor_image_text8_nf(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, char *chars)
+{
+ return glamor_image_text(drawable, gc, x, y, count, chars, FALSE);
+}
+
+void
+glamor_image_text8(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, char *chars)
+{
+ if (!glamor_image_text(drawable, gc, x, y, count, chars, FALSE))
+ miImageText8(drawable, gc, x, y, count, chars);
+}
+
+Bool
+glamor_image_text16_nf(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, unsigned short *chars)
+{
+ return glamor_image_text(drawable, gc, x, y, count, (char *) chars, FALSE);
+}
+
+void
+glamor_image_text16(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int count, unsigned short *chars)
+{
+ if (!glamor_image_text(drawable, gc, x, y, count, (char *) chars, TRUE))
+ miImageText16(drawable, gc, x, y, count, chars);
+}
diff --git a/xorg-server/glamor/glamor_transfer.c b/xorg-server/glamor/glamor_transfer.c
new file mode 100644
index 000000000..0378bb076
--- /dev/null
+++ b/xorg-server/glamor/glamor_transfer.c
@@ -0,0 +1,264 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * 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 the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS 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 OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include "glamor_priv.h"
+#include "glamor_transfer.h"
+
+/* XXX a kludge for now */
+void
+glamor_format_for_pixmap(PixmapPtr pixmap, GLenum *format, GLenum *type)
+{
+ switch (pixmap->drawable.depth) {
+ case 24:
+ case 32:
+ *format = GL_BGRA;
+ *type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ break;
+ case 16:
+ *format = GL_RGB;
+ *type = GL_UNSIGNED_SHORT_5_6_5;
+ break;
+ case 15:
+ *format = GL_BGRA;
+ *type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+ break;
+ case 8:
+ *format = GL_ALPHA;
+ *type = GL_UNSIGNED_BYTE;
+ break;
+ default:
+ FatalError("Invalid pixmap depth %d\n", pixmap->drawable.depth);
+ break;
+ }
+}
+
+/*
+ * Write a region of bits into a pixmap
+ */
+void
+glamor_upload_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
+ int dx_src, int dy_src,
+ int dx_dst, int dy_dst,
+ uint8_t *bits, uint32_t byte_stride)
+{
+ ScreenPtr screen = pixmap->drawable.pScreen;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
+ int box_x, box_y;
+ int bytes_per_pixel = pixmap->drawable.bitsPerPixel >> 3;
+ GLenum type;
+ GLenum format;
+
+ glamor_format_for_pixmap(pixmap, &format, &type);
+
+ glamor_get_context(glamor_priv);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, byte_stride / bytes_per_pixel);
+
+ glamor_pixmap_loop(priv, box_x, box_y) {
+ BoxPtr box = glamor_pixmap_box_at(priv, box_x, box_y);
+ glamor_pixmap_fbo *fbo = glamor_pixmap_fbo_at(priv, box_x, box_y);
+ BoxPtr boxes = in_boxes;
+ int nbox = in_nbox;
+
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, fbo->tex);
+
+ while (nbox--) {
+
+ /* compute drawable coordinates */
+ int x1 = boxes->x1 + dx_dst;
+ int x2 = boxes->x2 + dx_dst;
+ int y1 = boxes->y1 + dy_dst;
+ int y2 = boxes->y2 + dy_dst;
+
+ boxes++;
+
+ if (x1 < box->x1)
+ x1 = box->x1;
+ if (box->x2 < x2)
+ x2 = box->x2;
+
+ if (x2 <= x1)
+ continue;
+
+ if (y1 < box->y1)
+ y1 = box->y1;
+ if (box->y2 < y2)
+ y2 = box->y2;
+
+ if (y2 <= y1)
+ continue;
+
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, y1 - dy_dst + dy_src);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, x1 - dx_dst + dx_src);
+
+ glTexSubImage2D(GL_TEXTURE_2D, 0,
+ x1 - box->x1, y1 - box->y1,
+ x2 - x1, y2 - y1,
+ format, type,
+ bits);
+ }
+ }
+
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+ glamor_put_context(glamor_priv);
+}
+
+/*
+ * Upload a region of data
+ */
+
+void
+glamor_upload_region(PixmapPtr pixmap, RegionPtr region,
+ int region_x, int region_y,
+ uint8_t *bits, uint32_t byte_stride)
+{
+ glamor_upload_boxes(pixmap, RegionRects(region), RegionNumRects(region),
+ -region_x, -region_y,
+ 0, 0,
+ bits, byte_stride);
+}
+
+/*
+ * Take the data in the pixmap and stuff it back into the FBO
+ */
+void
+glamor_upload_pixmap(PixmapPtr pixmap)
+{
+ BoxRec box;
+
+ box.x1 = 0;
+ box.x2 = pixmap->drawable.width;
+ box.y1 = 0;
+ box.y2 = pixmap->drawable.height;
+ glamor_upload_boxes(pixmap, &box, 1, 0, 0, 0, 0,
+ pixmap->devPrivate.ptr, pixmap->devKind);
+}
+
+/*
+ * Read stuff from the pixmap FBOs and write to memory
+ */
+void
+glamor_download_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
+ int dx_src, int dy_src,
+ int dx_dst, int dy_dst,
+ uint8_t *bits, uint32_t byte_stride)
+{
+ ScreenPtr screen = pixmap->drawable.pScreen;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
+ int box_x, box_y;
+ int bytes_per_pixel = pixmap->drawable.bitsPerPixel >> 3;
+ GLenum type;
+ GLenum format;
+
+ glamor_format_for_pixmap(pixmap, &format, &type);
+
+ glamor_get_context(glamor_priv);
+
+ glPixelStorei(GL_PACK_ALIGNMENT, 4);
+ glPixelStorei(GL_PACK_ROW_LENGTH, byte_stride / bytes_per_pixel);
+
+ glamor_pixmap_loop(priv, box_x, box_y) {
+ BoxPtr box = glamor_pixmap_box_at(priv, box_x, box_y);
+ glamor_pixmap_fbo *fbo = glamor_pixmap_fbo_at(priv, box_x, box_y);
+ BoxPtr boxes = in_boxes;
+ int nbox = in_nbox;
+
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo->fb);
+
+ while (nbox--) {
+
+ /* compute drawable coordinates */
+ int x1 = boxes->x1 + dx_src;
+ int x2 = boxes->x2 + dx_src;
+ int y1 = boxes->y1 + dy_src;
+ int y2 = boxes->y2 + dy_src;
+
+ boxes++;
+
+ if (x1 < box->x1)
+ x1 = box->x1;
+ if (box->x2 < x2)
+ x2 = box->x2;
+
+ if (y1 < box->y1)
+ y1 = box->y1;
+ if (box->y2 < y2)
+ y2 = box->y2;
+
+ if (x2 <= x1)
+ continue;
+ if (y2 <= y1)
+ continue;
+
+ glPixelStorei(GL_PACK_SKIP_PIXELS, x1 - dx_src + dx_dst);
+ glPixelStorei(GL_PACK_SKIP_ROWS, y1 - dy_src + dy_dst);
+ glReadPixels(x1 - box->x1, y1 - box->y1, x2 - x1, y2 - y1, format, type, bits);
+ }
+ }
+ glPixelStorei(GL_PACK_ROW_LENGTH, 0);
+ glPixelStorei(GL_PACK_SKIP_ROWS, 0);
+ glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
+ glamor_put_context(glamor_priv);
+}
+
+/*
+ * Read data from the pixmap FBO
+ */
+void
+glamor_download_rect(PixmapPtr pixmap, int x, int y, int w, int h, uint8_t *bits)
+{
+ BoxRec box;
+
+ box.x1 = x;
+ box.x2 = x + w;
+ box.y1 = y;
+ box.y2 = y + h;
+
+ glamor_download_boxes(pixmap, &box, 1, 0, 0, -x, -y,
+ bits, PixmapBytePad(w, pixmap->drawable.depth));
+}
+
+/*
+ * Pull the data from the FBO down to the pixmap
+ */
+void
+glamor_download_pixmap(PixmapPtr pixmap)
+{
+ BoxRec box;
+
+ box.x1 = 0;
+ box.x2 = pixmap->drawable.width;
+ box.y1 = 0;
+ box.y2 = pixmap->drawable.height;
+
+ glamor_download_boxes(pixmap, &box, 1, 0, 0, 0, 0,
+ pixmap->devPrivate.ptr, pixmap->devKind);
+}
diff --git a/xorg-server/glamor/glamor_transfer.h b/xorg-server/glamor/glamor_transfer.h
new file mode 100644
index 000000000..de8186a70
--- /dev/null
+++ b/xorg-server/glamor/glamor_transfer.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * 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 the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS 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 OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef _GLAMOR_TRANSFER_H_
+#define _GLAMOR_TRANSFER_H_
+
+void
+glamor_format_for_pixmap(PixmapPtr pixmap, GLenum *format, GLenum *type);
+
+void
+glamor_upload_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
+ int dx_src, int dy_src,
+ int dx_dst, int dy_dst,
+ uint8_t *bits, uint32_t byte_stride);
+
+void
+glamor_upload_region(PixmapPtr pixmap, RegionPtr region,
+ int region_x, int region_y,
+ uint8_t *bits, uint32_t byte_stride);
+
+void
+glamor_upload_pixmap(PixmapPtr pixmap);
+
+void
+glamor_download_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
+ int dx_src, int dy_src,
+ int dx_dst, int dy_dst,
+ uint8_t *bits, uint32_t byte_stride);
+
+void
+glamor_download_rect(PixmapPtr pixmap, int x, int y, int w, int h, uint8_t *bits);
+
+void
+glamor_download_pixmap(PixmapPtr pixmap);
+
+#endif /* _GLAMOR_TRANSFER_H_ */
diff --git a/xorg-server/glamor/glamor_xv.c b/xorg-server/glamor/glamor_xv.c
index 17745a4e8..4e60fa3a4 100644
--- a/xorg-server/glamor/glamor_xv.c
+++ b/xorg-server/glamor/glamor_xv.c
@@ -114,18 +114,6 @@ glamor_init_xv_shader(ScreenPtr screen)
glamor_put_context(glamor_priv);
}
-void
-glamor_fini_xv_shader(ScreenPtr screen)
-{
- glamor_screen_private *glamor_priv;
-
- glamor_priv = glamor_get_screen_private(screen);
- glamor_get_context(glamor_priv);
-
- glDeleteProgram(glamor_priv->xv_prog);
- glamor_put_context(glamor_priv);
-}
-
#define ClipValue(v,min,max) ((v) < (min) ? (min) : (v) > (max) ? (max) : (v))
#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
@@ -559,6 +547,8 @@ glamor_xv_init(ScreenPtr screen, int num_texture_ports)
XF86VideoAdaptorPtr adapt;
int i;
+ glamor_init_xv_shader(screen);
+
adapt = calloc(1, sizeof(XF86VideoAdaptorRec) + num_texture_ports *
(sizeof(glamor_port_private) + sizeof(DevUnion)));
if (adapt == NULL)