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
48
unsigned
int
threads
;
49
};
50
62
static
inline
int
gp_progress_cb_report
(
gp_progress_cb
*
callback
,
63
unsigned
int
val,
unsigned
int
max,
64
unsigned
int
mul __attribute__((unused)))
65
{
66
if
(!
callback
)
67
return
0;
68
69
if
(val % 100)
70
return
0;
71
72
callback
->percentage = 100.00 * val / max;
73
return
callback
->callback(
callback
);
74
}
75
76
static
inline
void
gp_progress_cb_done(
gp_progress_cb
*
callback
)
77
{
78
if
(!
callback
)
79
return
;
80
81
callback
->percentage = 100;
82
callback
->callback(
callback
);
83
}
84
85
#define GP_PROGRESS_CALLBACK(name, pcallback, ppriv) \
86
gp_progress_cb name = { \
87
.callback = pcallback, \
88
.priv = ppriv, \
89
};
90
91
#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:62
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:48
gp_progress_cb::priv
void * priv
User private pointer.
Definition
gp_progress_callback.h:35
Generated by
1.9.8