Commit 4d367e33 authored by Frediano Ziglio's avatar Frediano Ziglio

Use bool type for tile changed

These arrays are just used to store if the tile is changed.
This produces a bit more optimised code, is more readable
and it's clear it's a boolean value.
Signed-off-by: Frediano Ziglio's avatarFrediano Ziglio <freddy77@gmail.com>
parent a399e5ab
......@@ -552,7 +552,7 @@ int read_shm_image(display_t *d, shm_image_t *shmi, int x, int y)
return 0;
}
int display_find_changed_tiles(display_t *d, int row, int *tiles, int tiles_across)
int display_find_changed_tiles(display_t *d, int row, bool *tiles, int tiles_across)
{
int ret;
int len;
......@@ -572,7 +572,7 @@ int display_find_changed_tiles(display_t *d, int row, int *tiles, int tiles_acro
len = d->scanline->w - (i * len);
if (memcmp(old, new, sizeof(*old) * len)) {
ret++;
tiles[i]++;
tiles[i] = true;
}
}
}
......@@ -608,7 +608,7 @@ void display_copy_image_into_fullscreen(display_t *d, shm_image_t *shmi, int x,
}
int display_scan_whole_screen(display_t *d, int num_vertical_tiles, int num_horizontal_tiles,
int tiles[][num_horizontal_tiles], int *tiles_changed_in_row)
bool tiles[][num_horizontal_tiles], int *tiles_changed_in_row)
{
int ret;
int len;
......@@ -650,7 +650,7 @@ int display_scan_whole_screen(display_t *d, int num_vertical_tiles, int num_hori
len = d->fullscreen->w - (h_tile * len);
if (memcmp(old, new, sizeof(*old) * len)) {
ret++;
tiles[v_tile][h_tile]++;
tiles[v_tile][h_tile] = true;
tiles_changed_in_row[v_tile]++;
}
}
......
......@@ -21,6 +21,7 @@
#ifndef DISPLAY_H_
#define DISPLAY_H_
#include <stdbool.h>
#include <glib.h>
#include <xcb/xcb.h>
#include <xcb/damage.h>
......@@ -84,10 +85,10 @@ int display_create_screen_images(display_t *d);
void display_destroy_screen_images(display_t *d);
int display_start_event_thread(display_t *d);
void display_stop_event_thread(display_t *d);
int display_find_changed_tiles(display_t *d, int row, int *tiles, int tiles_across);
int display_find_changed_tiles(display_t *d, int row, bool *tiles, int tiles_across);
void display_copy_image_into_fullscreen(display_t *d, shm_image_t *shmi, int x, int y);
int display_scan_whole_screen(display_t *d, int num_vertical_tiles, int num_horizontal_tiles,
int tiles[][num_horizontal_tiles], int *tiles_changed_in_row);
bool tiles[][num_horizontal_tiles], int *tiles_changed_in_row);
shm_image_t *create_shm_image(display_t *d, unsigned int w, unsigned int h);
int read_shm_image(display_t *d, shm_image_t *shmi, int x, int y);
......
......@@ -196,7 +196,7 @@ static void push_tiles_report(scanner_t *scanner, int start_row, int start_col,
static void grow_changed_tiles(scanner_t *scanner G_GNUC_UNUSED,
int *tiles_changed_in_row,
int tiles_changed[][NUM_HORIZONTAL_TILES], int num_vertical_tiles)
bool tiles_changed[][NUM_HORIZONTAL_TILES], int num_vertical_tiles)
{
int i;
int j;
......@@ -227,7 +227,7 @@ static void grow_changed_tiles(scanner_t *scanner G_GNUC_UNUSED,
grow++;
if (grow) {
tiles_changed[i][j]++;
tiles_changed[i][j] = true;
tiles_changed_in_row[i]++;
}
}
......@@ -265,14 +265,14 @@ static void push_changes_across_rows(scanner_t *scanner, int *tiles_changed_in_r
push_tiles_report(scanner, start_row, 0, current_row, NUM_HORIZONTAL_TILES - 1);
}
static void push_changes_in_one_row(scanner_t *scanner, int row, int *tiles_changed)
static void push_changes_in_one_row(scanner_t *scanner, int row, bool *tiles_changed)
{
int i = 0;
int start_tile = -1;
int current_tile = -1;
for (i = 0; i < NUM_HORIZONTAL_TILES; i++) {
if (tiles_changed[i] == 0) {
if (!tiles_changed[i]) {
if (current_tile != -1) {
push_tiles_report(scanner, row, start_tile, row, current_tile);
start_tile = current_tile = -1;
......@@ -289,7 +289,7 @@ static void push_changes_in_one_row(scanner_t *scanner, int row, int *tiles_chan
}
static void push_changed_tiles(scanner_t *scanner, int *tiles_changed_in_row,
int tiles_changed[][NUM_HORIZONTAL_TILES], int num_vertical_tiles)
bool tiles_changed[][NUM_HORIZONTAL_TILES], int num_vertical_tiles)
{
int i = 0;
......@@ -327,7 +327,7 @@ static void scanner_periodic(scanner_t *scanner)
num_vertical_tiles++;
int tiles_changed_in_row[num_vertical_tiles];
int tiles_changed[num_vertical_tiles][NUM_HORIZONTAL_TILES];
bool tiles_changed[num_vertical_tiles][NUM_HORIZONTAL_TILES];
offset = scanlines[scanner->current_scanline++];
scanner->current_scanline %= NUM_SCANLINES;
......@@ -362,7 +362,7 @@ static void scan_full_screen(scanner_t *scanner)
num_vertical_tiles++;
int tiles_changed_in_row[num_vertical_tiles];
int tiles_changed[num_vertical_tiles][NUM_HORIZONTAL_TILES];
bool tiles_changed[num_vertical_tiles][NUM_HORIZONTAL_TILES];
rc = display_scan_whole_screen(&scanner->session->display,
num_vertical_tiles, NUM_HORIZONTAL_TILES,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment