mirror of
https://github.com/brl/mutter.git
synced 2025-02-16 13:24:09 +00:00
clutter: Don't use CoglHandle to store framebuffers
Better just not lose type informatoin. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
This commit is contained in:
parent
ea2f4efaef
commit
de4e59a39b
@ -80,7 +80,7 @@
|
||||
|
||||
struct _ClutterOffscreenEffectPrivate
|
||||
{
|
||||
CoglHandle offscreen;
|
||||
CoglOffscreen *offscreen;
|
||||
CoglPipeline *pipeline;
|
||||
CoglHandle texture;
|
||||
|
||||
@ -260,6 +260,7 @@ clutter_offscreen_effect_pre_paint (ClutterEffect *effect,
|
||||
{
|
||||
ClutterOffscreenEffect *self = CLUTTER_OFFSCREEN_EFFECT (effect);
|
||||
ClutterOffscreenEffectPrivate *priv = self->priv;
|
||||
CoglFramebuffer *offscreen;
|
||||
ClutterActorBox raw_box, box;
|
||||
ClutterActor *stage;
|
||||
graphene_matrix_t projection, modelview;
|
||||
@ -321,7 +322,8 @@ clutter_offscreen_effect_pre_paint (ClutterEffect *effect,
|
||||
if (!update_fbo (effect, target_width, target_height, resource_scale))
|
||||
goto disable_effect;
|
||||
|
||||
clutter_paint_context_push_framebuffer (paint_context, priv->offscreen);
|
||||
offscreen = COGL_FRAMEBUFFER (priv->offscreen);
|
||||
clutter_paint_context_push_framebuffer (paint_context, offscreen);
|
||||
|
||||
/* We don't want the FBO contents to be transformed. That could waste memory
|
||||
* (e.g. during zoom), or result in something that's not rectangular (clipped
|
||||
@ -331,30 +333,30 @@ clutter_offscreen_effect_pre_paint (ClutterEffect *effect,
|
||||
* contents on screen...
|
||||
*/
|
||||
clutter_actor_get_transform (priv->stage, &modelview);
|
||||
cogl_framebuffer_set_modelview_matrix (priv->offscreen, &modelview);
|
||||
cogl_framebuffer_set_modelview_matrix (offscreen, &modelview);
|
||||
|
||||
/* Set up the viewport so that it has the same size as the stage (avoid
|
||||
* distortion), but translated to account for the FBO offset...
|
||||
*/
|
||||
cogl_framebuffer_set_viewport (priv->offscreen,
|
||||
cogl_framebuffer_set_viewport (offscreen,
|
||||
-priv->fbo_offset_x,
|
||||
-priv->fbo_offset_y,
|
||||
stage_width,
|
||||
stage_height);
|
||||
|
||||
/* Copy the stage's projection matrix across to the framebuffer */
|
||||
/* Copy the stage's projection matrix across to the offscreen */
|
||||
_clutter_stage_get_projection_matrix (CLUTTER_STAGE (priv->stage),
|
||||
&projection);
|
||||
|
||||
cogl_framebuffer_set_projection_matrix (priv->offscreen, &projection);
|
||||
cogl_framebuffer_set_projection_matrix (offscreen, &projection);
|
||||
|
||||
cogl_color_init_from_4ub (&transparent, 0, 0, 0, 0);
|
||||
cogl_framebuffer_clear (priv->offscreen,
|
||||
cogl_framebuffer_clear (offscreen,
|
||||
COGL_BUFFER_BIT_COLOR |
|
||||
COGL_BUFFER_BIT_DEPTH,
|
||||
&transparent);
|
||||
|
||||
cogl_framebuffer_push_matrix (priv->offscreen);
|
||||
cogl_framebuffer_push_matrix (offscreen);
|
||||
|
||||
/* Override the actor's opacity to fully opaque - we paint the offscreen
|
||||
* texture with the actor's paint opacity, so we need to do this to avoid
|
||||
|
@ -73,7 +73,7 @@ struct _TestCoglboxPrivate
|
||||
{
|
||||
CoglHandle texhand_id;
|
||||
CoglHandle texture_id;
|
||||
CoglHandle offscreen_id;
|
||||
CoglFramebuffer *framebuffer;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (TestCoglbox, test_coglbox, CLUTTER_TYPE_ACTOR);
|
||||
@ -111,11 +111,11 @@ test_coglbox_paint (ClutterActor *self,
|
||||
|
||||
pipeline = cogl_pipeline_new (ctx);
|
||||
cogl_pipeline_set_color4ub (pipeline, 0xff, 0, 0, 0xff);
|
||||
cogl_framebuffer_draw_rectangle (priv->offscreen_id, pipeline,
|
||||
cogl_framebuffer_draw_rectangle (priv->framebuffer, pipeline,
|
||||
20, 20, 20 + 100, 20 + 100);
|
||||
|
||||
cogl_pipeline_set_color4ub (pipeline, 0, 0xff, 0, 0xff);
|
||||
cogl_framebuffer_draw_rectangle (priv->offscreen_id, pipeline,
|
||||
cogl_framebuffer_draw_rectangle (priv->framebuffer, pipeline,
|
||||
80, 80, 80 + 100, 80 + 100);
|
||||
cogl_object_unref (pipeline);
|
||||
|
||||
@ -146,7 +146,7 @@ test_coglbox_dispose (GObject *object)
|
||||
priv = TEST_COGLBOX_GET_PRIVATE (object);
|
||||
|
||||
cogl_object_unref (priv->texture_id);
|
||||
cogl_object_unref (priv->offscreen_id);
|
||||
cogl_object_unref (priv->framebuffer);
|
||||
|
||||
G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object);
|
||||
}
|
||||
@ -257,22 +257,23 @@ test_coglbox_map (ClutterActor *actor)
|
||||
CLUTTER_ACTOR_CLASS (test_coglbox_parent_class)->map (actor);
|
||||
|
||||
printf ("Creating offscreen\n");
|
||||
priv->offscreen_id = cogl_offscreen_new_with_texture (priv->texture_id);
|
||||
if (!cogl_framebuffer_allocate (priv->offscreen_id, &error))
|
||||
priv->framebuffer =
|
||||
COGL_FRAMEBUFFER (cogl_offscreen_new_with_texture (priv->texture_id));
|
||||
if (!cogl_framebuffer_allocate (priv->framebuffer, &error))
|
||||
g_error ("Failed to allocate framebuffer: %s", error->message);
|
||||
|
||||
stage = clutter_actor_get_stage (actor);
|
||||
clutter_stage_get_perspective (CLUTTER_STAGE (stage), &perspective);
|
||||
clutter_actor_get_size (stage, &stage_width, &stage_height);
|
||||
|
||||
setup_viewport (priv->offscreen_id,
|
||||
setup_viewport (priv->framebuffer,
|
||||
stage_width, stage_height,
|
||||
perspective.fovy,
|
||||
perspective.aspect,
|
||||
perspective.z_near,
|
||||
perspective.z_far);
|
||||
|
||||
if (priv->offscreen_id == NULL)
|
||||
if (!priv->framebuffer)
|
||||
printf ("Failed creating offscreen to texture!\n");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user