[mutter] shaped-texture: Add API to check opaqueness
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] shaped-texture: Add API to check opaqueness
- Date: Wed, 16 Oct 2019 11:27:35 +0000 (UTC)
commit dcd0f4322aba94beb5bf782e00377c27fd9cf24c
Author: Jonas Ådahl <jadahl gmail com>
Date: Fri Aug 16 18:08:30 2019 +0200
shaped-texture: Add API to check opaqueness
It is opaque if the texture has no alpha channel, or if the opaque
region covers the whole content.
Internally uses a function that checks whether there is an alpha
channel. This API will be exposed at a later time as well.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/734
src/compositor/meta-shaped-texture-private.h | 1 +
src/compositor/meta-shaped-texture.c | 54 ++++++++++++++++++++++++++++
2 files changed, 55 insertions(+)
---
diff --git a/src/compositor/meta-shaped-texture-private.h b/src/compositor/meta-shaped-texture-private.h
index 8b078229c..58a102950 100644
--- a/src/compositor/meta-shaped-texture-private.h
+++ b/src/compositor/meta-shaped-texture-private.h
@@ -41,6 +41,7 @@ void meta_shaped_texture_set_fallback_size (MetaShapedTexture *stex,
int fallback_width,
int fallback_height);
cairo_region_t * meta_shaped_texture_get_opaque_region (MetaShapedTexture *stex);
+gboolean meta_shaped_texture_is_opaque (MetaShapedTexture *stex);
void meta_shaped_texture_set_transform (MetaShapedTexture *stex,
MetaMonitorTransform transform);
void meta_shaped_texture_set_viewport_src_rect (MetaShapedTexture *stex,
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index ba0c883f0..4cfe8af12 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -1019,6 +1019,60 @@ meta_shaped_texture_get_opaque_region (MetaShapedTexture *stex)
return stex->opaque_region;
}
+static gboolean
+meta_shaped_texture_has_alpha (MetaShapedTexture *stex)
+{
+ CoglTexture *texture;
+
+ texture = stex->texture;
+ 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;
+ }
+
+ g_warn_if_reached ();
+ return FALSE;
+}
+
+gboolean
+meta_shaped_texture_is_opaque (MetaShapedTexture *stex)
+{
+ CoglTexture *texture;
+ cairo_rectangle_int_t opaque_rect;
+
+ texture = stex->texture;
+ if (!texture)
+ return FALSE;
+
+ if (!meta_shaped_texture_has_alpha (stex))
+ return TRUE;
+
+ if (!stex->opaque_region)
+ return FALSE;
+
+ if (cairo_region_num_rectangles (stex->opaque_region) != 1)
+ return FALSE;
+
+ cairo_region_get_extents (stex->opaque_region, &opaque_rect);
+
+ ensure_size_valid (stex);
+
+ return meta_rectangle_equal (&opaque_rect,
+ &(MetaRectangle) {
+ .width = stex->dst_width,
+ .height = stex->dst_height
+ });
+}
+
void
meta_shaped_texture_set_transform (MetaShapedTexture *stex,
MetaMonitorTransform transform)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]