From 0584516f4201a47a99f680404a5d635a613eb27c Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Wed, 9 May 2012 17:49:04 -0400 Subject: [PATCH] mutter-never-slice-shape-mask.patch, mutter-use-cogl-texrect-api.patch: Fix window texturing on hardware without ARB_texture_non_power_of_two (#813648) --- mutter-never-slice-shape-mask.patch | 43 ++++ mutter-use-cogl-texrect-api.patch | 321 ++++++++++++++++++++++++++++ mutter.spec | 12 +- 3 files changed, 375 insertions(+), 1 deletion(-) create mode 100644 mutter-never-slice-shape-mask.patch create mode 100644 mutter-use-cogl-texrect-api.patch diff --git a/mutter-never-slice-shape-mask.patch b/mutter-never-slice-shape-mask.patch new file mode 100644 index 0000000..797fdde --- /dev/null +++ b/mutter-never-slice-shape-mask.patch @@ -0,0 +1,43 @@ +From a22859a64a60b38346ce7faabad6a9a48d7a8d9f Mon Sep 17 00:00:00 2001 +From: Robert Bragg +Date: Wed, 25 Apr 2012 00:48:19 +0000 +Subject: shaped-texture: never slice shape mask texture + +Since Cogl doesn't support multi-texturing with sliced textures and the +shape texture is combined with the texture-from-pixmap texture we need +to make sure we never construct a sliced mask texture. This patch simply +passes the COGL_TEXTURE_NO_SLICE flag to cogl_texture_from_data when +creating the shape mask texture. + +https://bugzilla.gnome.org/show_bug.cgi?id=674731 +--- +diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c +index 07bd93c..182d23b 100644 +--- a/src/compositor/meta-shaped-texture.c ++++ b/src/compositor/meta-shaped-texture.c +@@ -313,12 +313,17 @@ meta_shaped_texture_ensure_mask (MetaShapedTexture *stex) + } + else + #endif /* GL_TEXTURE_RECTANGLE_ARB */ +- priv->mask_texture = cogl_texture_new_from_data (tex_width, tex_height, +- COGL_TEXTURE_NONE, +- COGL_PIXEL_FORMAT_A_8, +- COGL_PIXEL_FORMAT_ANY, +- stride, +- mask_data); ++ { ++ /* Note: we don't allow slicing for this texture because we ++ * need to use it with multi-texturing which doesn't support ++ * sliced textures */ ++ priv->mask_texture = cogl_texture_new_from_data (tex_width, tex_height, ++ COGL_TEXTURE_NO_SLICING, ++ COGL_PIXEL_FORMAT_A_8, ++ COGL_PIXEL_FORMAT_ANY, ++ stride, ++ mask_data); ++ } + + g_free (mask_data); + +-- +cgit v0.9.0.2 diff --git a/mutter-use-cogl-texrect-api.patch b/mutter-use-cogl-texrect-api.patch new file mode 100644 index 0000000..11950b3 --- /dev/null +++ b/mutter-use-cogl-texrect-api.patch @@ -0,0 +1,321 @@ +From ed358c8f4b1200e8532dcc0b249f51752d2695eb Mon Sep 17 00:00:00 2001 +From: Neil Roberts +Date: Fri, 23 Mar 2012 18:51:25 +0000 +Subject: meta-texture-rectangle: Use Cogl's API to create a rectangle texture + +Cogl now has public experimental API to create a rectangle texture +which we can use instead of creating a foreign texture with GL. This +avoids Mutter depending on Cogl including a GL header from its public +headers which it might not do in future. + +https://bugzilla.gnome.org/show_bug.cgi?id=672711 +--- +diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c +index 182d23b..ae21945 100644 +--- a/src/compositor/meta-shaped-texture.c ++++ b/src/compositor/meta-shaped-texture.c +@@ -250,7 +250,6 @@ meta_shaped_texture_ensure_mask (MetaShapedTexture *stex) + int i; + int n_rects; + int stride; +- GLenum paint_gl_target; + + /* If we have no shape region and no (or an empty) overlay region, we + * don't need to create a full mask texture, so quit early. */ +@@ -293,26 +292,14 @@ meta_shaped_texture_ensure_mask (MetaShapedTexture *stex) + + install_overlay_path (stex, mask_data, tex_width, tex_height, stride); + +- cogl_texture_get_gl_texture (paint_tex, NULL, &paint_gl_target); +- +-#ifdef GL_TEXTURE_RECTANGLE_ARB +- if (paint_gl_target == GL_TEXTURE_RECTANGLE_ARB) +- { +- priv->mask_texture +- = meta_texture_rectangle_new (tex_width, tex_height, +- 0, /* flags */ +- /* data format */ +- COGL_PIXEL_FORMAT_A_8, +- /* internal GL format */ +- GL_ALPHA, +- /* internal cogl format */ +- COGL_PIXEL_FORMAT_A_8, +- /* rowstride */ +- stride, +- mask_data); +- } ++ if (meta_texture_rectangle_check (paint_tex)) ++ priv->mask_texture = meta_texture_rectangle_new (tex_width, tex_height, ++ COGL_PIXEL_FORMAT_A_8, ++ COGL_PIXEL_FORMAT_A_8, ++ stride, ++ mask_data, ++ NULL /* error */); + else +-#endif /* GL_TEXTURE_RECTANGLE_ARB */ + { + /* Note: we don't allow slicing for this texture because we + * need to use it with multi-texturing which doesn't support +diff --git a/src/compositor/meta-texture-rectangle.c b/src/compositor/meta-texture-rectangle.c +index d699729..af6817f 100644 +--- a/src/compositor/meta-texture-rectangle.c ++++ b/src/compositor/meta-texture-rectangle.c +@@ -5,7 +5,7 @@ + * + * Authored By Neil Roberts + * +- * Copyright (C) 2011 Intel Corporation ++ * Copyright (C) 2011, 2012 Intel Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as +@@ -25,94 +25,77 @@ + + #include + +-#include "meta-texture-rectangle.h" +- +-#ifdef GL_TEXTURE_RECTANGLE_ARB ++#define CLUTTER_ENABLE_EXPERIMENTAL_API ++#define COGL_ENABLE_EXPERIMENTAL_API + +-static void (* pf_glGetIntegerv) (GLenum pname, GLint *params); +-static void (* pf_glTexImage2D) (GLenum target, GLint level, +- GLint internalFormat, +- GLsizei width, GLsizei height, +- GLint border, GLenum format, GLenum type, +- const GLvoid *pixels); +-static void (* pf_glGenTextures) (GLsizei n, GLuint *textures); +-static void (* pf_glDeleteTextures) (GLsizei n, const GLuint *texture); +-static void (* pf_glBindTexture) (GLenum target, GLuint texture); +- +-static void +-rectangle_texture_destroy_cb (void *user_data) +-{ +- GLuint tex = GPOINTER_TO_UINT (user_data); +- +- pf_glDeleteTextures (1, &tex); +-} +- +-#endif /* GL_TEXTURE_RECTANGLE_ARB */ ++#include ++#include "meta-texture-rectangle.h" + +-CoglHandle ++CoglTexture * + meta_texture_rectangle_new (unsigned int width, + unsigned int height, +- CoglTextureFlags flags, + CoglPixelFormat format, +- GLenum internal_gl_format, +- GLenum internal_format, ++ CoglPixelFormat internal_format, + unsigned int rowstride, +- const guint8 *data) ++ const guint8 *data, ++ GError **error) + { +- CoglHandle cogl_tex = COGL_INVALID_HANDLE; +- +-#ifdef GL_TEXTURE_RECTANGLE_ARB +- +- static CoglUserDataKey user_data_key; +- GLint old_binding; +- GLuint tex; +- +- if (pf_glGenTextures == NULL) +- { +- pf_glGetIntegerv = (void *) cogl_get_proc_address ("glGetIntegerv"); +- pf_glTexImage2D = (void *) cogl_get_proc_address ("glTexImage2D"); +- pf_glGenTextures = (void *) cogl_get_proc_address ("glGenTextures"); +- pf_glDeleteTextures = (void *) cogl_get_proc_address ("glDeleteTextures"); +- pf_glBindTexture = (void *) cogl_get_proc_address ("glBindTexture"); +- } +- +- pf_glGenTextures (1, &tex); +- pf_glGetIntegerv (GL_TEXTURE_BINDING_RECTANGLE_ARB, &old_binding); +- pf_glBindTexture (GL_TEXTURE_RECTANGLE_ARB, tex); +- pf_glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, +- internal_gl_format, width, height, +- 0, internal_gl_format, +- GL_UNSIGNED_BYTE, NULL); +- pf_glBindTexture (GL_TEXTURE_RECTANGLE_ARB, old_binding); ++ ClutterBackend *backend = ++ clutter_get_default_backend (); ++ CoglContext *context = ++ clutter_backend_get_cogl_context (backend); ++ CoglTextureRectangle *tex_rect; ++ ++ tex_rect = cogl_texture_rectangle_new_with_size (context, ++ width, height, ++ internal_format, ++ error); ++ if (tex_rect == NULL) ++ return NULL; + +- cogl_tex = cogl_texture_new_from_foreign (tex, +- GL_TEXTURE_RECTANGLE_ARB, +- width, height, +- 0, 0, /* no waste */ +- internal_format); +- +- /* Cogl won't destroy the GL texture when a foreign texture is used +- so we need to destroy it manually. We can set a destroy +- notification callback to do this transparently */ +- cogl_object_set_user_data (cogl_tex, +- &user_data_key, +- GUINT_TO_POINTER (tex), +- rectangle_texture_destroy_cb); +- +- /* Use cogl_texture_set_region instead of uploading the data +- directly with GL calls so that we can let Cogl deal with setting +- the pixel store parameters and handling format conversion */ + if (data) +- cogl_texture_set_region (cogl_tex, +- 0, 0, /* src x/y */ +- 0, 0, /* dst x/y */ +- width, height, /* dst width/height */ +- width, height, /* src width/height */ ++ cogl_texture_set_region (COGL_TEXTURE (tex_rect), ++ 0, 0, /* src_x/y */ ++ 0, 0, /* dst_x/y */ ++ width, height, /* dst_width/height */ ++ width, height, /* width/height */ + format, + rowstride, + data); + +-#endif /* GL_TEXTURE_RECTANGLE_ARB */ ++ return COGL_TEXTURE (tex_rect); ++} ++ ++static void ++texture_rectangle_check_cb (CoglTexture *sub_texture, ++ const float *sub_texture_coords, ++ const float *meta_coords, ++ void *user_data) ++{ ++ gboolean *result = user_data; ++ ++ if (cogl_is_texture_rectangle (sub_texture)) ++ *result = TRUE; ++} ++ ++/* Determines if the given texture is using a rectangle texture as its ++ * primitive texture type. Eventually this function could be replaced ++ * with cogl_texture_get_type if Cogl makes that public. ++ * ++ * http://git.gnome.org/browse/cogl/commit/?h=8012eee31 ++ */ ++gboolean ++meta_texture_rectangle_check (CoglTexture *texture) ++{ ++ gboolean result = FALSE; ++ ++ cogl_meta_texture_foreach_in_region (COGL_META_TEXTURE (texture), ++ 0.0f, 0.0f, /* tx_1 / ty_1 */ ++ 1.0f, 1.0f, /* tx_2 / ty_2 */ ++ COGL_PIPELINE_WRAP_MODE_REPEAT, ++ COGL_PIPELINE_WRAP_MODE_REPEAT, ++ texture_rectangle_check_cb, ++ &result); + +- return cogl_tex; ++ return result; + } +diff --git a/src/compositor/meta-texture-rectangle.h b/src/compositor/meta-texture-rectangle.h +index b777316..7372b29 100644 +--- a/src/compositor/meta-texture-rectangle.h ++++ b/src/compositor/meta-texture-rectangle.h +@@ -30,15 +30,17 @@ + + G_BEGIN_DECLS + +-CoglHandle ++CoglTexture * + meta_texture_rectangle_new (unsigned int width, + unsigned int height, +- CoglTextureFlags flags, + CoglPixelFormat format, +- GLenum internal_gl_format, +- GLenum internal_format, ++ CoglPixelFormat internal_format, + unsigned int rowstride, +- const guint8 *data); ++ const guint8 *data, ++ GError **error); ++ ++gboolean ++meta_texture_rectangle_check (CoglTexture *texture); + + G_END_DECLS + +diff --git a/src/compositor/meta-texture-tower.c b/src/compositor/meta-texture-tower.c +index 0025472..2dee777 100644 +--- a/src/compositor/meta-texture-tower.c ++++ b/src/compositor/meta-texture-tower.c +@@ -98,18 +98,6 @@ meta_texture_tower_free (MetaTextureTower *tower) + g_slice_free (MetaTextureTower, tower); + } + +-#ifdef GL_TEXTURE_RECTANGLE_ARB +-static gboolean +-texture_is_rectangle (CoglHandle texture) +-{ +- GLuint gl_tex; +- GLenum gl_target; +- +- cogl_texture_get_gl_texture (texture, &gl_tex, &gl_target); +- return gl_target == GL_TEXTURE_RECTANGLE_ARB; +-} +-#endif /* GL_TEXTURE_RECTANGLE_ARB */ +- + /** + * meta_texture_tower_set_base_texture: + * @tower: a #MetaTextureTower +@@ -354,13 +342,11 @@ get_paint_level (int width, int height) + return (int)(0.5 + lambda); + } + +-#ifdef GL_TEXTURE_RECTANGLE_ARB + static gboolean + is_power_of_two (int x) + { + return (x & (x - 1)) == 0; + } +-#endif /* GL_TEXTURE_RECTANGLE_ARB */ + + static void + texture_tower_create_texture (MetaTextureTower *tower, +@@ -368,25 +354,23 @@ texture_tower_create_texture (MetaTextureTower *tower, + int width, + int height) + { +-#ifdef GL_TEXTURE_RECTANGLE_ARB + if ((!is_power_of_two (width) || !is_power_of_two (height)) && +- texture_is_rectangle (tower->textures[level - 1])) ++ meta_texture_rectangle_check (tower->textures[level - 1])) + { + tower->textures[level] = + meta_texture_rectangle_new (width, height, +- 0, /* flags */ + /* data format */ + TEXTURE_FORMAT, +- /* internal GL format */ +- GL_RGBA, + /* internal cogl format */ + TEXTURE_FORMAT, + /* rowstride */ + width * 4, ++ /* data */ ++ NULL, ++ /* error */ + NULL); + } + else +-#endif /* GL_TEXTURE_RECTANGLE_ARB */ + { + tower->textures[level] = cogl_texture_new_with_size (width, height, + COGL_TEXTURE_NO_AUTO_MIPMAP, +-- +cgit v0.9.0.2 diff --git a/mutter.spec b/mutter.spec index 1d9189f..0005df3 100644 --- a/mutter.spec +++ b/mutter.spec @@ -1,6 +1,6 @@ Name: mutter Version: 3.4.1 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Window and compositing manager based on Clutter Group: User Interface/Desktops @@ -8,6 +8,9 @@ License: GPLv2+ #VCS: git:git://git.gnome.org/mutter Source0: http://download.gnome.org/sources/%{name}/3.4/%{name}-%{version}.tar.xz +Patch0: mutter-never-slice-shape-mask.patch +Patch1: mutter-use-cogl-texrect-api.patch + BuildRequires: clutter-devel >= 1.7.5 BuildRequires: pango-devel BuildRequires: startup-notification-devel @@ -63,6 +66,8 @@ utilities for testing Metacity/Mutter themes. %prep %setup -q +%patch0 -p1 +%patch1 -p1 %build (if ! test -x configure; then NOCONFIGURE=1 ./autogen.sh; fi; @@ -131,6 +136,11 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || : %doc %{_mandir}/man1/mutter-window-demo.1.gz %changelog +* Wed May 09 2012 Adam Jackson 3.4.1-3 +- mutter-never-slice-shape-mask.patch, mutter-use-cogl-texrect-api.patch: + Fix window texturing on hardware without ARB_texture_non_power_of_two + (#813648) + * Wed Apr 18 2012 Kalev Lember - 3.4.1-2 - Silence glib-compile-schemas scriplets