summaryrefslogtreecommitdiff
path: root/xserver/glamor
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2016-08-09 18:59:56 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2016-08-09 18:59:56 +0000
commit3e81c965a468dfb01615d5ec68812bcdca147faa (patch)
tree6a9f713393a7cd977cb7eaf1968824e739adc830 /xserver/glamor
parent12009397d721440f38cf1bd9356b5c6b86b46ac7 (diff)
Update to xserver 1.18.4
tested by krw@ and dcoppa@ ok dcoppa@
Diffstat (limited to 'xserver/glamor')
-rw-r--r--xserver/glamor/Makefile.in3
-rw-r--r--xserver/glamor/glamor.c45
-rw-r--r--xserver/glamor/glamor.h1
-rw-r--r--xserver/glamor/glamor_composite_glyphs.c5
-rw-r--r--xserver/glamor/glamor_compositerects.c18
-rw-r--r--xserver/glamor/glamor_copy.c8
-rw-r--r--xserver/glamor/glamor_dash.c3
-rw-r--r--xserver/glamor/glamor_egl.c11
-rw-r--r--xserver/glamor/glamor_fbo.c4
-rw-r--r--xserver/glamor/glamor_priv.h28
-rw-r--r--xserver/glamor/glamor_program.c8
-rw-r--r--xserver/glamor/glamor_render.c94
-rw-r--r--xserver/glamor/glamor_spans.c3
-rw-r--r--xserver/glamor/glamor_text.c13
-rw-r--r--xserver/glamor/glamor_transfer.c3
-rw-r--r--xserver/glamor/glamor_transform.c12
-rw-r--r--xserver/glamor/glamor_transform.h4
17 files changed, 202 insertions, 61 deletions
diff --git a/xserver/glamor/Makefile.in b/xserver/glamor/Makefile.in
index c277ec5ee..ad052407a 100644
--- a/xserver/glamor/Makefile.in
+++ b/xserver/glamor/Makefile.in
@@ -207,6 +207,8 @@ BASE_FONT_PATH = @BASE_FONT_PATH@
BUILD_DATE = @BUILD_DATE@
BUILD_TIME = @BUILD_TIME@
BUNDLE_ID_PREFIX = @BUNDLE_ID_PREFIX@
+BUNDLE_VERSION = @BUNDLE_VERSION@
+BUNDLE_VERSION_STRING = @BUNDLE_VERSION_STRING@
CC = @CC@
CCAS = @CCAS@
CCASDEPMODE = @CCASDEPMODE@
@@ -438,6 +440,7 @@ XPBPROXY_CFLAGS = @XPBPROXY_CFLAGS@
XPBPROXY_LIBS = @XPBPROXY_LIBS@
XQUARTZ_LIBS = @XQUARTZ_LIBS@
XQUARTZ_SPARKLE = @XQUARTZ_SPARKLE@
+XQUARTZ_SPARKLE_FEED_URL = @XQUARTZ_SPARKLE_FEED_URL@
XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
diff --git a/xserver/glamor/glamor.c b/xserver/glamor/glamor.c
index 8b5eb5493..3956d6663 100644
--- a/xserver/glamor/glamor.c
+++ b/xserver/glamor/glamor.c
@@ -140,6 +140,42 @@ glamor_get_pixmap_texture(PixmapPtr pixmap)
return pixmap_priv->fbo->tex;
}
+void
+glamor_bind_texture(glamor_screen_private *glamor_priv, GLenum texture,
+ glamor_pixmap_fbo *fbo, Bool destination_red)
+{
+ glActiveTexture(texture);
+ glBindTexture(GL_TEXTURE_2D, fbo->tex);
+
+ /* If we're pulling data from a GL_RED texture, then whether we
+ * want to make it an A,0,0,0 result or a 0,0,0,R result depends
+ * on whether the destination is also a GL_RED texture.
+ *
+ * For GL_RED destinations, we need to leave the bits in the R
+ * channel. For all other destinations, we need to clear out the R
+ * channel so that it returns zero for R, G and B.
+ *
+ * Note that we're leaving the SWIZZLE_A value alone; for GL_RED
+ * destinations, that means we'll actually be returning R,0,0,R,
+ * but it doesn't matter as the bits in the alpha channel aren't
+ * going anywhere.
+ */
+
+ /* Is the operand a GL_RED fbo?
+ */
+
+ if (glamor_fbo_red_is_alpha(glamor_priv, fbo)) {
+
+ /* If destination is also GL_RED, then preserve the bits in
+ * the R channel */
+
+ if (destination_red)
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED);
+ else
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_ZERO);
+ }
+}
+
PixmapPtr
glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
unsigned int usage)
@@ -814,3 +850,12 @@ glamor_name_from_pixmap(PixmapPtr pixmap, CARD16 *stride, CARD32 *size)
}
return -1;
}
+
+void
+glamor_finish(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+
+ glamor_make_current(glamor_priv);
+ glFinish();
+}
diff --git a/xserver/glamor/glamor.h b/xserver/glamor/glamor.h
index 0aa6d5604..250dc83e4 100644
--- a/xserver/glamor/glamor.h
+++ b/xserver/glamor/glamor.h
@@ -342,6 +342,7 @@ extern _X_EXPORT void glamor_destroy_gc(GCPtr gc);
extern Bool _X_EXPORT glamor_change_window_attributes(WindowPtr pWin, unsigned long mask);
extern void _X_EXPORT glamor_copy_window(WindowPtr window, DDXPointRec old_origin, RegionPtr src_region);
+extern _X_EXPORT void glamor_finish(ScreenPtr screen);
#define HAS_GLAMOR_TEXT 1
#ifdef GLAMOR_FOR_XORG
diff --git a/xserver/glamor/glamor_composite_glyphs.c b/xserver/glamor/glamor_composite_glyphs.c
index f51ff6dad..cc0aa6f37 100644
--- a/xserver/glamor/glamor_composite_glyphs.c
+++ b/xserver/glamor/glamor_composite_glyphs.c
@@ -246,8 +246,7 @@ glamor_glyphs_flush(CARD8 op, PicturePtr src, PicturePtr dst,
glamor_put_vbo_space(drawable->pScreen);
glEnable(GL_SCISSOR_TEST);
- glActiveTexture(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_2D, atlas_fbo->tex);
+ glamor_bind_texture(glamor_priv, GL_TEXTURE1, atlas_fbo, FALSE);
for (;;) {
if (!glamor_use_program_render(prog, op, src, dst))
@@ -558,7 +557,7 @@ glamor_free_glyph_atlas(struct glamor_glyph_atlas *atlas)
if (!atlas)
return;
if (atlas->atlas)
- FreePicture(atlas->atlas, 0);
+ (*atlas->atlas->drawable.pScreen->DestroyPixmap)(atlas->atlas);
free (atlas);
}
diff --git a/xserver/glamor/glamor_compositerects.c b/xserver/glamor/glamor_compositerects.c
index 885a6c065..199e62705 100644
--- a/xserver/glamor/glamor_compositerects.c
+++ b/xserver/glamor/glamor_compositerects.c
@@ -107,7 +107,6 @@ glamor_composite_rectangles(CARD8 op,
struct glamor_pixmap_private *priv;
pixman_region16_t region;
pixman_box16_t *boxes;
- int dst_x, dst_y;
int num_boxes;
PicturePtr source = NULL;
Bool need_free_region = FALSE;
@@ -225,17 +224,18 @@ glamor_composite_rectangles(CARD8 op,
RegionExtents(&region)->x2, RegionExtents(&region)->y2,
RegionNumRects(&region));
- glamor_get_drawable_deltas(dst->pDrawable, pixmap, &dst_x, &dst_y);
- pixman_region_translate(&region, dst_x, dst_y);
-
- DEBUGF("%s: pixmap +(%d, %d) extents (%d, %d),(%d, %d)\n",
- __FUNCTION__, dst_x, dst_y,
- RegionExtents(&region)->x1, RegionExtents(&region)->y1,
- RegionExtents(&region)->x2, RegionExtents(&region)->y2);
-
boxes = pixman_region_rectangles(&region, &num_boxes);
if (op == PictOpSrc || op == PictOpClear) {
CARD32 pixel;
+ int dst_x, dst_y;
+
+ glamor_get_drawable_deltas(dst->pDrawable, pixmap, &dst_x, &dst_y);
+ pixman_region_translate(&region, dst_x, dst_y);
+
+ DEBUGF("%s: pixmap +(%d, %d) extents (%d, %d),(%d, %d)\n",
+ __FUNCTION__, dst_x, dst_y,
+ RegionExtents(&region)->x1, RegionExtents(&region)->y1,
+ RegionExtents(&region)->x2, RegionExtents(&region)->y2);
if (op == PictOpClear)
pixel = 0;
diff --git a/xserver/glamor/glamor_copy.c b/xserver/glamor/glamor_copy.c
index 5fed89f0c..3501a0d24 100644
--- a/xserver/glamor/glamor_copy.c
+++ b/xserver/glamor/glamor_copy.c
@@ -38,8 +38,8 @@ use_copyarea(PixmapPtr dst, GCPtr gc, glamor_program *prog, void *arg)
struct copy_args *args = arg;
glamor_pixmap_fbo *src = args->src;
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, src->tex);
+ glamor_bind_texture(glamor_get_screen_private(dst->drawable.pScreen),
+ GL_TEXTURE0, src, TRUE);
glUniform2f(prog->fill_offset_uniform, args->dx, args->dy);
glUniform2f(prog->fill_size_inv_uniform, 1.0f/src->width, 1.0f/src->height);
@@ -67,8 +67,8 @@ use_copyplane(PixmapPtr dst, GCPtr gc, glamor_program *prog, void *arg)
struct copy_args *args = arg;
glamor_pixmap_fbo *src = args->src;
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, src->tex);
+ glamor_bind_texture(glamor_get_screen_private(dst->drawable.pScreen),
+ GL_TEXTURE0, src, TRUE);
glUniform2f(prog->fill_offset_uniform, args->dx, args->dy);
glUniform2f(prog->fill_size_inv_uniform, 1.0f/src->width, 1.0f/src->height);
diff --git a/xserver/glamor/glamor_dash.c b/xserver/glamor/glamor_dash.c
index a6a11c1a2..3c19dba32 100644
--- a/xserver/glamor/glamor_dash.c
+++ b/xserver/glamor/glamor_dash.c
@@ -188,8 +188,7 @@ glamor_dash_setup(DrawablePtr drawable, GCPtr gc)
/* Set the dash pattern as texture 1 */
- glActiveTexture(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_2D, dash_priv->fbo->tex);
+ glamor_bind_texture(glamor_priv, GL_TEXTURE1, dash_priv->fbo, FALSE);
glUniform1i(prog->dash_uniform, 1);
glUniform1f(prog->dash_length_uniform, dash_pixmap->drawable.width);
diff --git a/xserver/glamor/glamor_egl.c b/xserver/glamor/glamor_egl.c
index 80a97f7a1..5aacbedef 100644
--- a/xserver/glamor/glamor_egl.c
+++ b/xserver/glamor/glamor_egl.c
@@ -823,11 +823,6 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
glamor_egl->has_gem = glamor_egl_check_has_gem(fd);
-#ifndef GLAMOR_GLES2
- eglBindAPI(EGL_OPENGL_API);
-#else
- eglBindAPI(EGL_OPENGL_ES_API);
-#endif
if (!eglInitialize
(glamor_egl->display, &glamor_egl->major, &glamor_egl->minor)) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR, "eglInitialize() failed\n");
@@ -835,6 +830,12 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
goto error;
}
+#ifndef GLAMOR_GLES2
+ eglBindAPI(EGL_OPENGL_API);
+#else
+ eglBindAPI(EGL_OPENGL_ES_API);
+#endif
+
version = eglQueryString(glamor_egl->display, EGL_VERSION);
xf86Msg(X_INFO, "%s: EGL version %s:\n", glamor_name, version);
diff --git a/xserver/glamor/glamor_fbo.c b/xserver/glamor/glamor_fbo.c
index c6ba095c0..5bfffe501 100644
--- a/xserver/glamor/glamor_fbo.c
+++ b/xserver/glamor/glamor_fbo.c
@@ -340,10 +340,8 @@ _glamor_create_tex(glamor_screen_private *glamor_priv,
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- if (format == glamor_priv->one_channel_format && format == GL_RED) {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_ZERO);
+ if (format == glamor_priv->one_channel_format && format == GL_RED)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_RED);
- }
glamor_priv->suppress_gl_out_of_memory_logging = true;
glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0,
format, GL_UNSIGNED_BYTE, NULL);
diff --git a/xserver/glamor/glamor_priv.h b/xserver/glamor/glamor_priv.h
index a70f10eb4..9d403977f 100644
--- a/xserver/glamor/glamor_priv.h
+++ b/xserver/glamor/glamor_priv.h
@@ -593,6 +593,34 @@ void glamor_fini_pixmap_fbo(ScreenPtr screen);
Bool glamor_pixmap_fbo_fixup(ScreenPtr screen, PixmapPtr pixmap);
void glamor_fbo_expire(glamor_screen_private *glamor_priv);
+/* Return whether 'picture' is alpha-only */
+static inline Bool glamor_picture_is_alpha(PicturePtr picture)
+{
+ return picture->format == PICT_a1 || picture->format == PICT_a8;
+}
+
+/* Return whether 'fbo' is storing alpha bits in the red channel */
+static inline Bool
+glamor_fbo_red_is_alpha(glamor_screen_private *glamor_priv, glamor_pixmap_fbo *fbo)
+{
+ /* True when the format is GL_RED (that can only happen when our one channel format is GL_RED */
+ return fbo->format == GL_RED;
+}
+
+/* Return whether 'picture' is storing alpha bits in the red channel */
+static inline Bool
+glamor_picture_red_is_alpha(PicturePtr picture)
+{
+ /* True when the picture is alpha only and the screen is using GL_RED for alpha pictures */
+ return glamor_picture_is_alpha(picture) &&
+ glamor_get_screen_private(picture->pDrawable->pScreen)->one_channel_format == GL_RED;
+}
+
+void glamor_bind_texture(glamor_screen_private *glamor_priv,
+ GLenum texture,
+ glamor_pixmap_fbo *fbo,
+ Bool destination_red);
+
glamor_pixmap_fbo *glamor_create_fbo_array(glamor_screen_private *glamor_priv,
int w, int h, GLenum format,
int flag, int block_w, int block_h,
diff --git a/xserver/glamor/glamor_program.c b/xserver/glamor/glamor_program.c
index 0a94de62f..dec116c75 100644
--- a/xserver/glamor/glamor_program.c
+++ b/xserver/glamor/glamor_program.c
@@ -445,6 +445,7 @@ static struct blendinfo composite_op_info[] = {
static void
glamor_set_blend(CARD8 op, glamor_program_alpha alpha, PicturePtr dst)
{
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(dst->pDrawable->pScreen);
GLenum src_blend, dst_blend;
struct blendinfo *op_info;
@@ -459,6 +460,9 @@ glamor_set_blend(CARD8 op, glamor_program_alpha alpha, PicturePtr dst)
break;
}
+ if (glamor_priv->gl_flavor != GLAMOR_GL_ES2)
+ glDisable(GL_COLOR_LOGIC_OP);
+
if (op == PictOpSrc)
return;
@@ -527,6 +531,7 @@ use_source_picture(CARD8 op, PicturePtr src, PicturePtr dst, glamor_program *pro
glamor_set_blend(op, prog->alpha, dst);
return glamor_set_texture((PixmapPtr) src->pDrawable,
+ glamor_picture_red_is_alpha(dst),
0, 0,
prog->fill_offset_uniform,
prog->fill_size_inv_uniform);
@@ -545,7 +550,8 @@ use_source_1x1_picture(CARD8 op, PicturePtr src, PicturePtr dst, glamor_program
{
glamor_set_blend(op, prog->alpha, dst);
- return glamor_set_texture_pixmap((PixmapPtr) src->pDrawable);
+ return glamor_set_texture_pixmap((PixmapPtr) src->pDrawable,
+ glamor_picture_red_is_alpha(dst));
}
static const glamor_facet glamor_source_1x1_picture = {
diff --git a/xserver/glamor/glamor_render.c b/xserver/glamor/glamor_render.c
index 73ac831ee..d70316d36 100644
--- a/xserver/glamor/glamor_render.c
+++ b/xserver/glamor/glamor_render.c
@@ -105,7 +105,7 @@ glamor_create_composite_fs(struct shader_key *key)
/* The texture and the pixmap size is not match eaxctly, so can't sample it directly.
* rel_sampler will recalculate the texture coords.*/
const char *rel_sampler =
- " vec4 rel_sampler(sampler2D tex_image, vec2 tex, vec4 wh, int repeat)\n"
+ " vec4 rel_sampler_rgba(sampler2D tex_image, vec2 tex, vec4 wh, int repeat)\n"
"{\n"
" if (repeat >= RepeatFix) {\n"
" tex = rel_tex_coord(tex, wh, repeat);\n"
@@ -117,6 +117,19 @@ glamor_create_composite_fs(struct shader_key *key)
" }\n"
" }\n"
" return texture2D(tex_image, tex);\n"
+ "}\n"
+ " vec4 rel_sampler_rgbx(sampler2D tex_image, vec2 tex, vec4 wh, int repeat)\n"
+ "{\n"
+ " if (repeat >= RepeatFix) {\n"
+ " tex = rel_tex_coord(tex, wh, repeat);\n"
+ " if (repeat == RepeatFix + RepeatNone) {\n"
+ " if (tex.x < 0.0 || tex.x >= 1.0 || \n"
+ " tex.y < 0.0 || tex.y >= 1.0)\n"
+ " return vec4(0.0, 0.0, 0.0, 0.0);\n"
+ " tex = (fract(tex) / wh.xy);\n"
+ " }\n"
+ " }\n"
+ " return vec4(texture2D(tex_image, tex).rgb, 1.0);\n"
"}\n";
const char *source_solid_fetch =
@@ -131,8 +144,8 @@ glamor_create_composite_fs(struct shader_key *key)
"uniform vec4 source_wh;"
"vec4 get_source()\n"
"{\n"
- " return rel_sampler(source_sampler, source_texture,\n"
- " source_wh, source_repeat_mode);\n"
+ " return rel_sampler_rgba(source_sampler, source_texture,\n"
+ " source_wh, source_repeat_mode);\n"
"}\n";
const char *source_pixmap_fetch =
"varying vec2 source_texture;\n"
@@ -140,9 +153,8 @@ glamor_create_composite_fs(struct shader_key *key)
"uniform vec4 source_wh;\n"
"vec4 get_source()\n"
"{\n"
- " return vec4(rel_sampler(source_sampler, source_texture,\n"
- " source_wh, source_repeat_mode).rgb,\n"
- " 1.0);\n"
+ " return rel_sampler_rgbx(source_sampler, source_texture,\n"
+ " source_wh, source_repeat_mode);\n"
"}\n";
const char *mask_none =
"vec4 get_mask()\n"
@@ -161,8 +173,8 @@ glamor_create_composite_fs(struct shader_key *key)
"uniform vec4 mask_wh;\n"
"vec4 get_mask()\n"
"{\n"
- " return rel_sampler(mask_sampler, mask_texture,\n"
- " mask_wh, mask_repeat_mode);\n"
+ " return rel_sampler_rgba(mask_sampler, mask_texture,\n"
+ " mask_wh, mask_repeat_mode);\n"
"}\n";
const char *mask_pixmap_fetch =
"varying vec2 mask_texture;\n"
@@ -170,8 +182,8 @@ glamor_create_composite_fs(struct shader_key *key)
"uniform vec4 mask_wh;\n"
"vec4 get_mask()\n"
"{\n"
- " return vec4(rel_sampler(mask_sampler, mask_texture,\n"
- " mask_wh, mask_repeat_mode).rgb, 1.0);\n"
+ " return rel_sampler_rgbx(mask_sampler, mask_texture,\n"
+ " mask_wh, mask_repeat_mode);\n"
"}\n";
const char *dest_swizzle_default =
@@ -500,15 +512,24 @@ static void
glamor_set_composite_texture(glamor_screen_private *glamor_priv, int unit,
PicturePtr picture,
PixmapPtr pixmap,
- GLuint wh_location, GLuint repeat_location)
+ GLuint wh_location, GLuint repeat_location,
+ glamor_pixmap_private *dest_priv)
{
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
+ glamor_pixmap_fbo *fbo = pixmap_priv->fbo;
float wh[4];
int repeat_type;
glamor_make_current(glamor_priv);
- glActiveTexture(GL_TEXTURE0 + unit);
- glBindTexture(GL_TEXTURE_2D, pixmap_priv->fbo->tex);
+
+ /* The red channel swizzling doesn't depend on whether we're using
+ * 'fbo' as source or mask as we must have the same answer in case
+ * the same fbo is being used for both. That means the mask
+ * channel will sometimes get red bits in the R channel, and
+ * sometimes get zero bits in the R channel, which is harmless.
+ */
+ glamor_bind_texture(glamor_priv, GL_TEXTURE0 + unit, fbo,
+ glamor_fbo_red_is_alpha(glamor_priv, dest_priv->fbo));
repeat_type = picture->repeatType;
switch (picture->repeatType) {
case RepeatNone:
@@ -557,8 +578,8 @@ glamor_set_composite_texture(glamor_screen_private *glamor_priv, int unit,
*
**/
if (glamor_pixmap_priv_is_large(pixmap_priv) ||
- (glamor_priv->gl_flavor == GLAMOR_GL_ES2 && repeat_type == RepeatNone &&
- picture->transform)) {
+ ((!PICT_FORMAT_A(picture->format) || glamor_priv->gl_flavor == GLAMOR_GL_ES2) &&
+ repeat_type == RepeatNone && picture->transform)) {
glamor_pixmap_fbo_fix_wh_ratio(wh, pixmap, pixmap_priv);
glUniform4fv(wh_location, 1, wh);
@@ -1068,7 +1089,8 @@ glamor_composite_set_shader_blend(glamor_screen_private *glamor_priv,
glamor_set_composite_texture(glamor_priv, 0,
shader->source,
shader->source_pixmap, shader->source_wh,
- shader->source_repeat_mode);
+ shader->source_repeat_mode,
+ dest_priv);
}
if (key->mask != SHADER_MASK_NONE) {
@@ -1080,10 +1102,14 @@ glamor_composite_set_shader_blend(glamor_screen_private *glamor_priv,
glamor_set_composite_texture(glamor_priv, 1,
shader->mask,
shader->mask_pixmap, shader->mask_wh,
- shader->mask_repeat_mode);
+ shader->mask_repeat_mode,
+ dest_priv);
}
}
+ if (glamor_priv->gl_flavor != GLAMOR_GL_ES2)
+ glDisable(GL_COLOR_LOGIC_OP);
+
if (op_info->source_blend == GL_ONE && op_info->dest_blend == GL_ZERO) {
glDisable(GL_BLEND);
}
@@ -1144,12 +1170,12 @@ glamor_composite_with_shader(CARD8 op,
}
}
+ glamor_make_current(glamor_priv);
+
glamor_set_destination_pixmap_priv_nc(glamor_priv, dest_pixmap, dest_pixmap_priv);
glamor_composite_set_shader_blend(glamor_priv, dest_pixmap_priv, &key, shader, &op_info);
glamor_set_alu(screen, GXcopy);
- glamor_make_current(glamor_priv);
-
glamor_priv->has_source_coords = key.source != SHADER_SOURCE_SOLID;
glamor_priv->has_mask_coords = (key.mask != SHADER_MASK_NONE &&
key.mask != SHADER_MASK_SOLID);
@@ -1392,6 +1418,36 @@ glamor_composite_clipped_region(CARD8 op,
DEBUGF("clipped (%d %d) (%d %d) (%d %d) width %d height %d \n",
x_source, y_source, x_mask, y_mask, x_dest, y_dest, width, height);
+ /* Is the composite operation equivalent to a copy? */
+ if (!mask && !source->alphaMap && !dest->alphaMap
+ && source->pDrawable && !source->transform
+ && ((op == PictOpSrc
+ && (source->format == dest->format
+ || (PICT_FORMAT_COLOR(dest->format)
+ && PICT_FORMAT_COLOR(source->format)
+ && dest->format == PICT_FORMAT(PICT_FORMAT_BPP(source->format),
+ PICT_FORMAT_TYPE(source->format),
+ 0,
+ PICT_FORMAT_R(source->format),
+ PICT_FORMAT_G(source->format),
+ PICT_FORMAT_B(source->format)))))
+ || (op == PictOpOver
+ && source->format == dest->format
+ && !PICT_FORMAT_A(source->format)))
+ && x_source >= 0 && y_source >= 0
+ && (x_source + width) <= source->pDrawable->width
+ && (y_source + height) <= source->pDrawable->height) {
+ x_source += source->pDrawable->x;
+ y_source += source->pDrawable->y;
+ x_dest += dest->pDrawable->x;
+ y_dest += dest->pDrawable->y;
+ glamor_copy(source->pDrawable, dest->pDrawable, NULL,
+ box, nbox, x_source - x_dest,
+ y_source - y_dest, FALSE, FALSE, 0, NULL);
+ ok = TRUE;
+ goto out;
+ }
+
/* XXX is it possible source mask have non-zero drawable.x/y? */
if (source
&& ((!source->pDrawable
diff --git a/xserver/glamor/glamor_spans.c b/xserver/glamor/glamor_spans.c
index 89a9c5102..5217d0434 100644
--- a/xserver/glamor/glamor_spans.c
+++ b/xserver/glamor/glamor_spans.c
@@ -294,8 +294,7 @@ glamor_set_spans_gl(DrawablePtr drawable, GCPtr gc, char *src,
BoxPtr box = glamor_pixmap_box_at(pixmap_priv, box_index);
glamor_pixmap_fbo *fbo = glamor_pixmap_fbo_at(pixmap_priv, box_index);
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, fbo->tex);
+ glamor_bind_texture(glamor_priv, GL_TEXTURE0, fbo, TRUE);
s = src;
for (n = 0; n < numPoints; n++) {
diff --git a/xserver/glamor/glamor_text.c b/xserver/glamor/glamor_text.c
index c305305f4..cf165cad8 100644
--- a/xserver/glamor/glamor_text.c
+++ b/xserver/glamor/glamor_text.c
@@ -446,16 +446,17 @@ glamor_image_text(DrawablePtr drawable, GCPtr gc,
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;
+ box.x1 = drawable->x + x;
+ box.x2 = drawable->x + x + width;
} else {
- box.x1 = off_x + drawable->x + x + width;
- box.x2 = off_x + drawable->x + x;
+ box.x1 = drawable->x + x + width;
+ box.x2 = 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;
+ box.y1 = drawable->y + y - gc->font->info.fontAscent;
+ box.y2 = drawable->y + y + gc->font->info.fontDescent;
RegionInit(&region, &box, 1);
RegionIntersect(&region, &region, gc->pCompositeClip);
+ RegionTranslate(&region, off_x, off_y);
glamor_solid_boxes(pixmap, RegionRects(&region), RegionNumRects(&region), gc->bgPixel);
RegionUninit(&region);
}
diff --git a/xserver/glamor/glamor_transfer.c b/xserver/glamor/glamor_transfer.c
index ed81195b6..d788d06f4 100644
--- a/xserver/glamor/glamor_transfer.c
+++ b/xserver/glamor/glamor_transfer.c
@@ -83,8 +83,7 @@ glamor_upload_boxes(PixmapPtr pixmap, BoxPtr in_boxes, int in_nbox,
BoxPtr boxes = in_boxes;
int nbox = in_nbox;
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, fbo->tex);
+ glamor_bind_texture(glamor_priv, GL_TEXTURE0, fbo, TRUE);
while (nbox--) {
diff --git a/xserver/glamor/glamor_transform.c b/xserver/glamor/glamor_transform.c
index fc96fd670..eff500c6d 100644
--- a/xserver/glamor/glamor_transform.c
+++ b/xserver/glamor/glamor_transform.c
@@ -158,7 +158,7 @@ glamor_set_solid(PixmapPtr pixmap,
}
Bool
-glamor_set_texture_pixmap(PixmapPtr texture)
+glamor_set_texture_pixmap(PixmapPtr texture, Bool destination_red)
{
glamor_pixmap_private *texture_priv;
@@ -170,8 +170,9 @@ glamor_set_texture_pixmap(PixmapPtr texture)
if (glamor_pixmap_priv_is_large(texture_priv))
return FALSE;
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, texture_priv->fbo->tex);
+ glamor_bind_texture(glamor_get_screen_private(texture->drawable.pScreen),
+ GL_TEXTURE0,
+ texture_priv->fbo, destination_red);
/* we're not setting the sampler uniform here as we always use
* GL_TEXTURE0, and the default value for uniforms is zero. So,
@@ -182,12 +183,13 @@ glamor_set_texture_pixmap(PixmapPtr texture)
Bool
glamor_set_texture(PixmapPtr texture,
+ Bool destination_red,
int off_x,
int off_y,
GLint offset_uniform,
GLint size_inv_uniform)
{
- if (!glamor_set_texture_pixmap(texture))
+ if (!glamor_set_texture_pixmap(texture, destination_red))
return FALSE;
glUniform2f(offset_uniform, off_x, off_y);
@@ -208,6 +210,7 @@ glamor_set_tiled(PixmapPtr pixmap,
return FALSE;
return glamor_set_texture(gc->tile.pixmap,
+ TRUE,
-gc->patOrg.x,
-gc->patOrg.y,
offset_uniform,
@@ -289,6 +292,7 @@ glamor_set_stippled(PixmapPtr pixmap,
return FALSE;
return glamor_set_texture(stipple,
+ FALSE,
-gc->patOrg.x,
-gc->patOrg.y,
offset_uniform,
diff --git a/xserver/glamor/glamor_transform.h b/xserver/glamor/glamor_transform.h
index 5a520ebb0..70d2c1671 100644
--- a/xserver/glamor/glamor_transform.h
+++ b/xserver/glamor/glamor_transform.h
@@ -48,10 +48,12 @@ glamor_set_color(PixmapPtr pixmap,
}
Bool
-glamor_set_texture_pixmap(PixmapPtr texture);
+glamor_set_texture_pixmap(PixmapPtr texture,
+ Bool destination_red);
Bool
glamor_set_texture(PixmapPtr texture,
+ Bool destination_red,
int off_x,
int off_y,
GLint offset_uniform,