GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
include
core
gp_progress_callback.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: LGPL-2.1-or-later
2
/*
3
* Copyright (C) 2009-2024 Cyril Hrubis <metan@ucw.cz>
4
*/
5
17
#ifndef CORE_GP_PROGRESS_CALLBACK_H
18
#define CORE_GP_PROGRESS_CALLBACK_H
19
20
#include <
core/gp_types.h
>
21
28
struct
gp_progress_cb
{
30
float
percentage
;
31
33
int (*
callback
)(
struct
gp_progress_cb
*self);
35
void
*
priv
;
36
38
int
flags
;
39
51
unsigned
int
threads
;
52
};
53
65
static
inline
int
gp_progress_cb_report
(
gp_progress_cb
*
callback
,
66
unsigned
int
val,
unsigned
int
max,
67
unsigned
int
mul __attribute__((unused)))
68
{
69
if
(!
callback
)
70
return
0;
71
72
if
(val % 100)
73
return
0;
74
75
callback
->percentage = 100.00 * val / max;
76
return
callback
->callback(
callback
);
77
}
78
79
static
inline
void
gp_progress_cb_done(
gp_progress_cb
*
callback
)
80
{
81
if
(!
callback
)
82
return
;
83
84
callback
->percentage = 100;
85
callback
->callback(
callback
);
86
}
87
88
#define GP_PROGRESS_CALLBACK(name, pcallback, ppriv) \
89
gp_progress_cb name = { \
90
.callback = pcallback, \
91
.priv = ppriv, \
92
};
93
94
#endif
/* CORE_GP_PROGRESS_CALBACK_H */
gp_types.h
A common types.
gp_progress_cb_report
static int gp_progress_cb_report(gp_progress_cb *callback, unsigned int val, unsigned int max, unsigned int mul __attribute__((unused)))
Reports progress.
Definition
gp_progress_callback.h:65
gp_progress_cb
Progress callback.
Definition
gp_progress_callback.h:28
gp_progress_cb::callback
int(* callback)(struct gp_progress_cb *self)
A progress callback handler.
Definition
gp_progress_callback.h:33
gp_progress_cb::percentage
float percentage
Current progress.
Definition
gp_progress_callback.h:30
gp_progress_cb::threads
unsigned int threads
A number of threads.
Definition
gp_progress_callback.h:51
gp_progress_cb::flags
int flags
Flags to be used by the loaders. Do not touch!
Definition
gp_progress_callback.h:38
gp_progress_cb::priv
void * priv
User private pointer.
Definition
gp_progress_callback.h:35
Generated by
1.12.0