Skip to content

Commit

Permalink
Merge pull request #19 from redhog/dont-update-all-textures
Browse files Browse the repository at this point in the history
Don't update all textures all the time
  • Loading branch information
Egil Möller authored Feb 5, 2020
2 parents 5c6d2e9 + c371d6b commit 83a8107
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
8 changes: 6 additions & 2 deletions glass-renderer/item.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void item_constructor(Item *item, Window window) {
item->prop_size = NULL;
item->prop_coords = NULL;
item->prop_draw_type = NULL;
item->draw_cycles_left = 0;

if (window == root) {
Atom layer = XInternAtom(display, "IG_LAYER_ROOT", False);
Expand Down Expand Up @@ -116,8 +117,11 @@ void item_draw(Rendering *rendering) {
Shader *shader = rendering->shader;

if (!rendering->view->picking) {
texture_from_pixmap(&item->window_texture, item->window_pixmap);

if (item->draw_cycles_left > 0) {
texture_from_pixmap(&item->window_texture, item->window_pixmap);
item->draw_cycles_left--;
}

glUniform1i(shader->window_sampler_attr, rendering->texture_unit);
glActiveTexture(GL_TEXTURE0 + rendering->texture_unit);
glBindTexture(GL_TEXTURE_2D, item->window_texture.texture_id);
Expand Down
2 changes: 2 additions & 0 deletions glass-renderer/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ struct ItemStruct {

Pixmap window_pixmap;
Texture window_texture;

int draw_cycles_left;
};

extern List *items_all;
Expand Down
10 changes: 8 additions & 2 deletions glass-renderer/wm.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ struct backtrace_state *trace_state;
#endif


#define AUTOMATIC_REDRAWS 10

List *views = NULL;
List *shaders = NULL;
GLuint picking_fb;
Expand Down Expand Up @@ -82,7 +84,7 @@ void cycle_draw() {
}

void trigger_draw() {
draw_cycles_left = 10;
draw_cycles_left = AUTOMATIC_REDRAWS;
if (!drawn_this_cycle) {
draw();
drawn_this_cycle = True;
Expand Down Expand Up @@ -274,7 +276,11 @@ Bool main_event_handler_function(EventHandler *handler, XEvent *event) {
} else if (event->type == damage_event + XDamageNotify) {
DEBUG("event.damage", "Received XDamageNotify: %d\n", ((XDamageNotifyEvent *) event)->drawable);
// Subtract all the damage, repairing the window.
trigger_draw();
Item *item = item_get_from_window(((XDamageNotifyEvent *) event)->drawable, False);
if (item) {
item->draw_cycles_left = AUTOMATIC_REDRAWS;
trigger_draw();
}
} else if (event->type == shape_event + ShapeNotify) {
//fprintf(stderr, "Received ShapeNotify\n");
//XShapeEvent *event = (XShapeEvent*) &e;
Expand Down

0 comments on commit 83a8107

Please sign in to comment.