0001-Initialize-framebuffer-objects-early-so-clutter-will.patch 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. From 26d339b91744dab5135ee9ea1d46fda62448ad95 Mon Sep 17 00:00:00 2001
  2. From: Jan de Groot <jgc@archlinux.org>
  3. Date: Mon, 11 Apr 2016 14:00:33 +0000
  4. Subject: [PATCH] Initialize framebuffer objects early so clutter will not
  5. abort a few operations later.
  6. Checking offscreen for COGL_INVALID_HANDLE is not sufficient, as cogl_offscreen_new_with_texture doesn't initialize framebuffer objects but lets Cogl solve this the lazy way. cogl_offscreen_new_with_texture will never return COGL_INVALID_HANDLE anyways.
  7. ---
  8. src/st/st-theme-node-drawing.c | 35 +++++++++++++++++++++++------------
  9. src/st/st-theme-node-transition.c | 18 ++++++++++++++++--
  10. 2 files changed, 39 insertions(+), 14 deletions(-)
  11. diff --git a/src/st/st-theme-node-drawing.c b/src/st/st-theme-node-drawing.c
  12. index 1f28ed9..4a6a234 100644
  13. --- a/src/st/st-theme-node-drawing.c
  14. +++ b/src/st/st-theme-node-drawing.c
  15. @@ -2247,22 +2247,33 @@ st_theme_node_prerender_shadow (StThemeNodePaintState *state)
  16. COGL_TEXTURE_NO_SLICING,
  17. COGL_PIXEL_FORMAT_ANY);
  18. if (buffer != COGL_INVALID_HANDLE)
  19. - offscreen = cogl_offscreen_new_with_texture (buffer);
  20. -
  21. - if (offscreen != COGL_INVALID_HANDLE)
  22. {
  23. - ClutterActorBox box = { 0, 0, state->box_shadow_width, state->box_shadow_height};
  24. + CoglError *error = NULL;
  25. +
  26. + offscreen = cogl_offscreen_new_with_texture (buffer);
  27. +
  28. + if (cogl_framebuffer_allocate (COGL_FRAMEBUFFER (offscreen), &error))
  29. + {
  30. + ClutterActorBox box = { 0, 0, state->box_shadow_width, state->box_shadow_height};
  31. +
  32. + cogl_framebuffer_orthographic (offscreen, 0, 0,
  33. + state->box_shadow_width,
  34. + state->box_shadow_height, 0, 1.0);
  35. + cogl_framebuffer_clear4f (offscreen, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 0);
  36. - cogl_framebuffer_orthographic (offscreen, 0, 0,
  37. - state->box_shadow_width,
  38. - state->box_shadow_height, 0, 1.0);
  39. - cogl_framebuffer_clear4f (offscreen, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 0);
  40. + st_theme_node_paint_borders (state, offscreen, &box, 0xFF);
  41. - st_theme_node_paint_borders (state, offscreen, &box, 0xFF);
  42. - cogl_handle_unref (offscreen);
  43. + cogl_handle_unref (offscreen);
  44. - state->box_shadow_pipeline = _st_create_shadow_pipeline (st_theme_node_get_box_shadow (node),
  45. - buffer);
  46. + state->box_shadow_pipeline = _st_create_shadow_pipeline (st_theme_node_get_box_shadow (node),
  47. + buffer);
  48. + }
  49. + else
  50. + {
  51. + cogl_handle_unref (offscreen);
  52. +
  53. + cogl_error_free (error);
  54. + }
  55. }
  56. if (buffer != COGL_INVALID_HANDLE)
  57. diff --git a/src/st/st-theme-node-transition.c b/src/st/st-theme-node-transition.c
  58. index 1eef17b..f3350a1 100644
  59. --- a/src/st/st-theme-node-transition.c
  60. +++ b/src/st/st-theme-node-transition.c
  61. @@ -242,6 +242,8 @@ setup_framebuffers (StThemeNodeTransition *transition,
  62. StThemeNodeTransitionPrivate *priv = transition->priv;
  63. guint width, height;
  64. + CoglError *catch_error = NULL;
  65. +
  66. /* template material to avoid unnecessary shader compilation */
  67. static CoglHandle material_template = COGL_INVALID_HANDLE;
  68. @@ -269,13 +271,25 @@ setup_framebuffers (StThemeNodeTransition *transition,
  69. if (priv->old_offscreen)
  70. cogl_handle_unref (priv->old_offscreen);
  71. priv->old_offscreen = cogl_offscreen_new_with_texture (priv->old_texture);
  72. + if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (priv->old_offscreen), &catch_error))
  73. + {
  74. + cogl_object_unref (priv->old_offscreen);
  75. + cogl_error_free (catch_error);
  76. + priv->old_offscreen = COGL_INVALID_HANDLE;
  77. + g_return_val_if_fail (priv->old_offscreen != COGL_INVALID_HANDLE, FALSE);
  78. + }
  79. if (priv->new_offscreen)
  80. cogl_handle_unref (priv->new_offscreen);
  81. priv->new_offscreen = cogl_offscreen_new_with_texture (priv->new_texture);
  82. - g_return_val_if_fail (priv->old_offscreen != COGL_INVALID_HANDLE, FALSE);
  83. - g_return_val_if_fail (priv->new_offscreen != COGL_INVALID_HANDLE, FALSE);
  84. + if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (priv->new_offscreen), &catch_error))
  85. + {
  86. + cogl_object_unref (priv->new_offscreen);
  87. + cogl_error_free (catch_error);
  88. + priv->new_offscreen = COGL_INVALID_HANDLE;
  89. + g_return_val_if_fail (priv->new_offscreen != COGL_INVALID_HANDLE, FALSE);
  90. + }
  91. if (priv->material == NULL)
  92. {
  93. --
  94. 2.7.1