[mutter] wayland/egl-stream: Cache texture snippet
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] wayland/egl-stream: Cache texture snippet
- Date: Fri, 10 Jan 2020 16:09:24 +0000 (UTC)
commit 76ee026caa1ab0215be389e4a33a6994ce3d26fc
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Thu Dec 5 19:43:07 2019 +0100
wayland/egl-stream: Cache texture snippet
While it's not very relevant now, as we would rarely create it anyway
since the buffer nor texture never changes for a surface, it will be in
the future, as the actor state (including its content,
MetaShapedTexture) will be synchronized by the MetaWaylandActorSurface
at a later point in time, and not by MetaWaylandSurface, at state
application time.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
src/wayland/meta-wayland-buffer.c | 2 +-
src/wayland/meta-wayland-egl-stream.c | 25 ++++++++++++++++---------
src/wayland/meta-wayland-egl-stream.h | 2 +-
3 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/src/wayland/meta-wayland-buffer.c b/src/wayland/meta-wayland-buffer.c
index 7a1ae8bdf..419e16a76 100644
--- a/src/wayland/meta-wayland-buffer.c
+++ b/src/wayland/meta-wayland-buffer.c
@@ -489,7 +489,7 @@ meta_wayland_buffer_create_snippet (MetaWaylandBuffer *buffer)
if (!buffer->egl_stream.stream)
return NULL;
- return meta_wayland_egl_stream_create_snippet ();
+ return meta_wayland_egl_stream_create_snippet (buffer->egl_stream.stream);
#else
return NULL;
#endif /* HAVE_WAYLAND_EGLSTREAM */
diff --git a/src/wayland/meta-wayland-egl-stream.c b/src/wayland/meta-wayland-egl-stream.c
index 37700c95a..3a2e1e56a 100644
--- a/src/wayland/meta-wayland-egl-stream.c
+++ b/src/wayland/meta-wayland-egl-stream.c
@@ -136,6 +136,7 @@ struct _MetaWaylandEglStream
MetaWaylandBuffer *buffer;
CoglTexture2D *texture;
gboolean is_y_inverted;
+ CoglSnippet *snippet;
};
G_DEFINE_TYPE (MetaWaylandEglStream, meta_wayland_egl_stream,
@@ -291,18 +292,22 @@ meta_wayland_egl_stream_is_y_inverted (MetaWaylandEglStream *stream)
}
CoglSnippet *
-meta_wayland_egl_stream_create_snippet (void)
+meta_wayland_egl_stream_create_snippet (MetaWaylandEglStream *stream)
{
- CoglSnippet *snippet;
+ if (!stream->snippet)
+ {
+ CoglSnippet *snippet;
- snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_LOOKUP,
- "uniform samplerExternalOES tex_external;",
- NULL);
- cogl_snippet_set_replace (snippet,
- "cogl_texel = texture2D (tex_external,\n"
- " cogl_tex_coord.xy);");
+ snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_LOOKUP,
+ "uniform samplerExternalOES tex_external;",
+ NULL);
+ cogl_snippet_set_replace (snippet,
+ "cogl_texel = texture2D (tex_external,\n"
+ " cogl_tex_coord.xy);");
+ stream->snippet = snippet;
+ }
- return snippet;
+ return cogl_object_ref (stream->snippet);
}
gboolean
@@ -343,6 +348,8 @@ meta_wayland_egl_stream_finalize (GObject *object)
meta_egl_destroy_stream (egl, egl_display, stream->egl_stream, NULL);
+ cogl_clear_object (&stream->snippet);
+
G_OBJECT_CLASS (meta_wayland_egl_stream_parent_class)->finalize (object);
}
diff --git a/src/wayland/meta-wayland-egl-stream.h b/src/wayland/meta-wayland-egl-stream.h
index fe488ed54..b8a6b1968 100644
--- a/src/wayland/meta-wayland-egl-stream.h
+++ b/src/wayland/meta-wayland-egl-stream.h
@@ -47,7 +47,7 @@ gboolean meta_wayland_egl_stream_attach (MetaWaylandEglStream *stream,
CoglTexture2D * meta_wayland_egl_stream_create_texture (MetaWaylandEglStream *stream,
GError **error);
-CoglSnippet * meta_wayland_egl_stream_create_snippet (void);
+CoglSnippet * meta_wayland_egl_stream_create_snippet (MetaWaylandEglStream *stream);
gboolean meta_wayland_egl_stream_is_y_inverted (MetaWaylandEglStream *stream);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]