Skip to content

Commit

Permalink
Remove types.h file
Browse files Browse the repository at this point in the history
Content now in pixmap.

Signed-off-by: Artem Senichev <[email protected]>
  • Loading branch information
artemsen committed Jan 28, 2024
1 parent ba1ba2d commit 952bd17
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 68 deletions.
2 changes: 1 addition & 1 deletion src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include "types.h"
#include "pixmap.h"

// Name of the general configuration section
#define GENERAL_CONFIG_SECTION "general"
Expand Down
2 changes: 1 addition & 1 deletion src/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include "types.h"
#include "pixmap.h"

/**
* Initialize font.
Expand Down
57 changes: 56 additions & 1 deletion src/pixmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,62 @@

#pragma once

#include "types.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>

/** ARGB color. */
typedef uint32_t argb_t;

// shifts for each channel in argb_t
#define ARGB_A_SHIFT 24
#define ARGB_R_SHIFT 16
#define ARGB_G_SHIFT 8
#define ARGB_B_SHIFT 0

// get channel value from argb_t
#define ARGB_GET_A(c) (((c) >> ARGB_A_SHIFT) & 0xff)
#define ARGB_GET_R(c) (((c) >> ARGB_R_SHIFT) & 0xff)
#define ARGB_GET_G(c) (((c) >> ARGB_G_SHIFT) & 0xff)
#define ARGB_GET_B(c) (((c) >> ARGB_B_SHIFT) & 0xff)

// create argb_t from channel value
#define ARGB_SET_A(a) (((a)&0xff) << ARGB_A_SHIFT)
#define ARGB_SET_R(r) (((r)&0xff) << ARGB_R_SHIFT)
#define ARGB_SET_G(g) (((g)&0xff) << ARGB_G_SHIFT)
#define ARGB_SET_B(b) (((b)&0xff) << ARGB_B_SHIFT)

// convert RGBA to ARGB
#define ARGB_SET_ABGR(c) \
((c & 0xff00ff00) | ARGB_SET_R(ARGB_GET_B(c)) | ARGB_SET_B(ARGB_GET_R(c)))

// alpha blending (a=alpha, s=target alpha, b=background, f=foreground)
#define ARGB_ALPHA_BLEND(a, s, b, f) \
ARGB_SET_A(s) | \
ARGB_SET_R((a * ARGB_GET_R(f) + (256 - a) * ARGB_GET_R(b)) >> 8) | \
ARGB_SET_G((a * ARGB_GET_G(f) + (256 - a) * ARGB_GET_G(b)) >> 8) | \
ARGB_SET_B((a * ARGB_GET_B(f) + (256 - a) * ARGB_GET_B(b)) >> 8)

/** 2D coordinates. */
struct point {
ssize_t x;
ssize_t y;
};

/** Size description. */
struct size {
size_t width;
size_t height;
};

/** Rectangle description. */
struct rect {
ssize_t x;
ssize_t y;
size_t width;
size_t height;
};

/** Pixel map. */
struct pixmap {
Expand Down
2 changes: 1 addition & 1 deletion src/sway.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include "types.h"
#include "pixmap.h"

#include <stdbool.h>

Expand Down
62 changes: 0 additions & 62 deletions src/types.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include "types.h"
#include "pixmap.h"

// Configuration parameters
#define UI_CFG_APP_ID "app_id"
Expand Down
2 changes: 1 addition & 1 deletion src/viewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#include "keybind.h"
#include "types.h"
#include "pixmap.h"

// Configuration parameters
#define VIEWER_CFG_SLIDESHOW "slideshow"
Expand Down

0 comments on commit 952bd17

Please sign in to comment.