[mutter/wayland] surface-actor: Implement is_argb32 generically for both X11 and Wayland



commit cc0488f1e29da928e1c66e363b59582752d1ea32
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Mar 25 17:02:50 2014 -0400

    surface-actor: Implement is_argb32 generically for both X11 and Wayland
    
    cogl_texture_get_components can be used on both X11 and Wayland
    backends. Technically, the detection is different: we actually
    check the actual RENDER format in the old code, while Cogl simply
    assumes that any pixmap with a depth >= 32 is ARGB32. Since Cogl
    already seems to be working with its internal checks, it makes
    more sense to  use Cogl's check rather than keeping our own.

 src/compositor/meta-surface-actor-wayland.c |   26 ------------------------
 src/compositor/meta-surface-actor-x11.c     |   29 +--------------------------
 src/compositor/meta-surface-actor.c         |   21 ++++++++++++++++++-
 src/compositor/meta-surface-actor.h         |    1 -
 4 files changed, 21 insertions(+), 56 deletions(-)
---
diff --git a/src/compositor/meta-surface-actor-wayland.c b/src/compositor/meta-surface-actor-wayland.c
index 3389b61..e0c6ff7 100644
--- a/src/compositor/meta-surface-actor-wayland.c
+++ b/src/compositor/meta-surface-actor-wayland.c
@@ -81,31 +81,6 @@ meta_surface_actor_wayland_pre_paint (MetaSurfaceActor *actor)
 }
 
 static gboolean
-meta_surface_actor_wayland_is_argb32 (MetaSurfaceActor *actor)
-{
-  MetaShapedTexture *stex = meta_surface_actor_get_texture (actor);
-  CoglTexture *texture = meta_shaped_texture_get_texture (stex);
-
-  /* If we don't have a texture, like during initialization, assume
-   * that we're ARGB32. */
-  if (!texture)
-    return TRUE;
-
-  switch (cogl_texture_get_components (texture))
-    {
-    case COGL_TEXTURE_COMPONENTS_A:
-    case COGL_TEXTURE_COMPONENTS_RGBA:
-      return TRUE;
-    case COGL_TEXTURE_COMPONENTS_RG:
-    case COGL_TEXTURE_COMPONENTS_RGB:
-    case COGL_TEXTURE_COMPONENTS_DEPTH:
-      return FALSE;
-    default:
-      g_assert_not_reached ();
-    }
-}
-
-static gboolean
 meta_surface_actor_wayland_is_visible (MetaSurfaceActor *actor)
 {
   /* TODO: ensure that the buffer isn't NULL, implement
@@ -159,7 +134,6 @@ meta_surface_actor_wayland_class_init (MetaSurfaceActorWaylandClass *klass)
 
   surface_actor_class->process_damage = meta_surface_actor_wayland_process_damage;
   surface_actor_class->pre_paint = meta_surface_actor_wayland_pre_paint;
-  surface_actor_class->is_argb32 = meta_surface_actor_wayland_is_argb32;
   surface_actor_class->is_visible = meta_surface_actor_wayland_is_visible;
 
   surface_actor_class->should_unredirect = meta_surface_actor_wayland_should_unredirect;
diff --git a/src/compositor/meta-surface-actor-x11.c b/src/compositor/meta-surface-actor-x11.c
index 5cab15f..f6c9fb1 100644
--- a/src/compositor/meta-surface-actor-x11.c
+++ b/src/compositor/meta-surface-actor-x11.c
@@ -28,7 +28,6 @@
 #include "meta-surface-actor-x11.h"
 
 #include <X11/extensions/Xcomposite.h>
-#include <X11/extensions/Xrender.h>
 #include <cogl/cogl-texture-pixmap-x11.h>
 
 #include <meta/errors.h>
@@ -54,7 +53,6 @@ struct _MetaSurfaceActorX11Private
   guint does_full_damage  : 1;
 
   /* Other state... */
-  guint argb32 : 1;
   guint received_damage : 1;
   guint size_changed : 1;
 
@@ -266,28 +264,6 @@ meta_surface_actor_x11_pre_paint (MetaSurfaceActor *actor)
   update_pixmap (self);
 }
 
-static void
-update_is_argb32 (MetaSurfaceActorX11 *self)
-{
-  MetaSurfaceActorX11Private *priv = meta_surface_actor_x11_get_instance_private (self);
-  MetaDisplay *display = priv->display;
-  Display *xdisplay = meta_display_get_xdisplay (display);
-
-  XRenderPictFormat *format;
-  format = XRenderFindVisualFormat (xdisplay, priv->window->xvisual);
-
-  priv->argb32 = (format && format->type == PictTypeDirect && format->direct.alphaMask);
-}
-
-static gboolean
-meta_surface_actor_x11_is_argb32 (MetaSurfaceActor *actor)
-{
-  MetaSurfaceActorX11 *self = META_SURFACE_ACTOR_X11 (actor);
-  MetaSurfaceActorX11Private *priv = meta_surface_actor_x11_get_instance_private (self);
-
-  return priv->argb32;
-}
-
 static gboolean
 meta_surface_actor_x11_is_visible (MetaSurfaceActor *actor)
 {
@@ -312,7 +288,7 @@ meta_surface_actor_x11_should_unredirect (MetaSurfaceActor *actor)
   if (window->shape_region != NULL)
     return FALSE;
 
-  if (priv->argb32 && !meta_window_requested_bypass_compositor (window))
+  if (meta_surface_actor_is_argb32 (actor) && !meta_window_requested_bypass_compositor (window))
     return FALSE;
 
   if (!meta_window_is_monitor_sized (window))
@@ -405,7 +381,6 @@ meta_surface_actor_x11_class_init (MetaSurfaceActorX11Class *klass)
 
   surface_actor_class->process_damage = meta_surface_actor_x11_process_damage;
   surface_actor_class->pre_paint = meta_surface_actor_x11_pre_paint;
-  surface_actor_class->is_argb32 = meta_surface_actor_x11_is_argb32;
   surface_actor_class->is_visible = meta_surface_actor_x11_is_visible;
 
   surface_actor_class->should_unredirect = meta_surface_actor_x11_should_unredirect;
@@ -461,8 +436,6 @@ meta_surface_actor_x11_new (MetaWindow *window)
   g_signal_connect_object (priv->window, "notify::decorated",
                            G_CALLBACK (window_decorated_notify), self, 0);
 
-  update_is_argb32 (self);
-
   priv->unredirected = FALSE;
   sync_unredirected (self);
 
diff --git a/src/compositor/meta-surface-actor.c b/src/compositor/meta-surface-actor.c
index 7b4fc29..3e7db6b 100644
--- a/src/compositor/meta-surface-actor.c
+++ b/src/compositor/meta-surface-actor.c
@@ -263,7 +263,26 @@ meta_surface_actor_pre_paint (MetaSurfaceActor *self)
 gboolean
 meta_surface_actor_is_argb32 (MetaSurfaceActor *self)
 {
-  return META_SURFACE_ACTOR_GET_CLASS (self)->is_argb32 (self);
+  MetaShapedTexture *stex = meta_surface_actor_get_texture (self);
+  CoglTexture *texture = meta_shaped_texture_get_texture (stex);
+
+  /* If we don't have a texture, like during initialization, assume
+   * that we're ARGB32. */
+  if (!texture)
+    return TRUE;
+
+  switch (cogl_texture_get_components (texture))
+    {
+    case COGL_TEXTURE_COMPONENTS_A:
+    case COGL_TEXTURE_COMPONENTS_RGBA:
+      return TRUE;
+    case COGL_TEXTURE_COMPONENTS_RG:
+    case COGL_TEXTURE_COMPONENTS_RGB:
+    case COGL_TEXTURE_COMPONENTS_DEPTH:
+      return FALSE;
+    default:
+      g_assert_not_reached ();
+    }
 }
 
 gboolean
diff --git a/src/compositor/meta-surface-actor.h b/src/compositor/meta-surface-actor.h
index c06e183..3991d52 100644
--- a/src/compositor/meta-surface-actor.h
+++ b/src/compositor/meta-surface-actor.h
@@ -29,7 +29,6 @@ struct _MetaSurfaceActorClass
   void     (* process_damage)    (MetaSurfaceActor *actor,
                                   int x, int y, int width, int height);
   void     (* pre_paint)         (MetaSurfaceActor *actor);
-  gboolean (* is_argb32)         (MetaSurfaceActor *actor);
   gboolean (* is_visible)        (MetaSurfaceActor *actor);
 
   gboolean (* should_unredirect) (MetaSurfaceActor *actor);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]