From bc80ae3c807287597da8c673447311807ae4ce15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 10 Jul 2019 15:38:56 +0200 Subject: [PATCH 04/28] cogl/onscreen-template: Unref the swap chain Each onscreen template owns a swap chain, but this is not released once on free https://gitlab.gnome.org/GNOME/mutter/merge_requests/682 --- cogl/cogl/cogl-onscreen-template.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cogl/cogl/cogl-onscreen-template.c b/cogl/cogl/cogl-onscreen-template.c index 1adbf4128..6ca176755 100644 --- a/cogl/cogl/cogl-onscreen-template.c +++ b/cogl/cogl/cogl-onscreen-template.c @@ -22,60 +22,63 @@ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Authors: * Robert Bragg */ #ifdef HAVE_CONFIG_H #include "cogl-config.h" #endif #include "cogl-object.h" #include "cogl-framebuffer-private.h" #include "cogl-onscreen-template-private.h" #include "cogl-gtype-private.h" #include static void _cogl_onscreen_template_free (CoglOnscreenTemplate *onscreen_template); COGL_OBJECT_DEFINE (OnscreenTemplate, onscreen_template); COGL_GTYPE_DEFINE_CLASS (OnscreenTemplate, onscreen_template); static void _cogl_onscreen_template_free (CoglOnscreenTemplate *onscreen_template) { + if (onscreen_template->config.swap_chain) + cogl_object_unref (onscreen_template->config.swap_chain); + g_slice_free (CoglOnscreenTemplate, onscreen_template); } CoglOnscreenTemplate * cogl_onscreen_template_new (CoglSwapChain *swap_chain) { CoglOnscreenTemplate *onscreen_template = g_slice_new0 (CoglOnscreenTemplate); char *user_config; onscreen_template->config.swap_chain = swap_chain; if (swap_chain) cogl_object_ref (swap_chain); else onscreen_template->config.swap_chain = cogl_swap_chain_new (); onscreen_template->config.swap_throttled = TRUE; onscreen_template->config.need_stencil = TRUE; onscreen_template->config.samples_per_pixel = 0; user_config = getenv ("COGL_POINT_SAMPLES_PER_PIXEL"); if (user_config) { unsigned long samples_per_pixel = strtoul (user_config, NULL, 10); if (samples_per_pixel != ULONG_MAX) onscreen_template->config.samples_per_pixel = samples_per_pixel; } return _cogl_onscreen_template_object_new (onscreen_template); } -- 2.26.2