Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions clutter/clutter/clutter-damage-history.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright (C) 2007,2008,2009,2010,2011 Intel Corporation.
* Copyright (C) 2020 Red Hat Inc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/

#include "clutter-build-config.h"

#include "clutter-damage-history.h"

#define DAMAGE_HISTORY_LENGTH 0x10

struct _ClutterDamageHistory
{
cairo_region_t *damages[DAMAGE_HISTORY_LENGTH];
int index;
};

ClutterDamageHistory *
clutter_damage_history_new (void)
{
ClutterDamageHistory *history;

history = g_new0 (ClutterDamageHistory, 1);

return history;
}

void
clutter_damage_history_free (ClutterDamageHistory *history)
{
int i;

for (i = 0; i < G_N_ELEMENTS (history->damages); i++)
g_clear_pointer (&history->damages[i], cairo_region_destroy);

g_free (history);
}

gboolean
clutter_damage_history_is_age_valid (ClutterDamageHistory *history,
int age)
{
if (age >= DAMAGE_HISTORY_LENGTH ||
age < 1)
return FALSE;

if (!clutter_damage_history_lookup (history, age))
return FALSE;

return TRUE;
}

void
clutter_damage_history_record (ClutterDamageHistory *history,
const cairo_region_t *damage)
{
g_clear_pointer (&history->damages[history->index], cairo_region_destroy);
history->damages[history->index] = cairo_region_copy (damage);
}

static inline int
step_damage_index (int current,
int diff)
{
return (current + diff) & (DAMAGE_HISTORY_LENGTH - 1);
}

void
clutter_damage_history_step (ClutterDamageHistory *history)
{
history->index = step_damage_index (history->index, 1);
}

const cairo_region_t *
clutter_damage_history_lookup (ClutterDamageHistory *history,
int age)
{
return history->damages[step_damage_index (history->index, -age)];
}
42 changes: 42 additions & 0 deletions clutter/clutter/clutter-damage-history.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2007,2008,2009,2010,2011 Intel Corporation.
* Copyright (C) 2020 Red Hat Inc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef CLUTTER_DAMAGE_HISTORY_H
#define CLUTTER_DAMAGE_HISTORY_H

#include <cairo.h>
#include <glib.h>

typedef struct _ClutterDamageHistory ClutterDamageHistory;

ClutterDamageHistory * clutter_damage_history_new (void);

void clutter_damage_history_free (ClutterDamageHistory *history);

gboolean clutter_damage_history_is_age_valid (ClutterDamageHistory *history,
int age);

void clutter_damage_history_record (ClutterDamageHistory *history,
const cairo_region_t *damage);

void clutter_damage_history_step (ClutterDamageHistory *history);

const cairo_region_t * clutter_damage_history_lookup (ClutterDamageHistory *history,
int age);

#endif /* CLUTTER_DAMAGE_HISTORY_H */
28 changes: 23 additions & 5 deletions clutter/clutter/clutter-stage-view-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,28 @@

#include "clutter/clutter-stage-view.h"

void clutter_stage_view_after_paint (ClutterStageView *view);
void clutter_stage_view_after_paint (ClutterStageView *view,
cairo_region_t *redraw_clip);

void clutter_stage_view_before_swap_buffer (ClutterStageView *view,
const cairo_region_t *swap_region);

gboolean clutter_stage_view_is_dirty_viewport (ClutterStageView *view);

void clutter_stage_view_set_dirty_viewport (ClutterStageView *view,
gboolean dirty);
void clutter_stage_view_invalidate_viewport (ClutterStageView *view);

void clutter_stage_view_set_viewport (ClutterStageView *view,
float x,
float y,
float width,
float height);

gboolean clutter_stage_view_is_dirty_projection (ClutterStageView *view);

void clutter_stage_view_set_dirty_projection (ClutterStageView *view,
gboolean dirty);
void clutter_stage_view_invalidate_projection (ClutterStageView *view);

void clutter_stage_view_set_projection (ClutterStageView *view,
const CoglMatrix *matrix);

void clutter_stage_view_add_redraw_clip (ClutterStageView *view,
const cairo_rectangle_int_t *clip);
Expand All @@ -43,4 +54,11 @@ const cairo_region_t * clutter_stage_view_peek_redraw_clip (ClutterStageView *vi

cairo_region_t * clutter_stage_view_take_redraw_clip (ClutterStageView *view);


void clutter_stage_view_transform_rect_to_onscreen (ClutterStageView *view,
const cairo_rectangle_int_t *src_rect,
int dst_width,
int dst_height,
cairo_rectangle_int_t *dst_rect);

#endif /* __CLUTTER_STAGE_VIEW_PRIVATE_H__ */
Loading
Loading