This repository has been archived by the owner on Oct 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
API
71 lines (44 loc) · 2.19 KB
/
API
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
=== FreeJ API
In this document i try to summarize the internal organization of FreeJ API
how things are distributed and which functions are more useful to operate.
| This document is quite short, but technical.
| If you just want to use FreeJ, you don't need to read it at all.
right now there is a tree organization, here i try to represent it:
Screen---(Blit)______________Layer_____Effect
\ vvvv \____Effect
\-(Blit)____Layer__Effect \___Effect
\ vvvv \__Effect ...
(Blit)__Layer \_Effect
\Effect
...
the Context is holding the list of layers, cycling thru them during
FreeJ's execution.
each Layer holds the list of active Filters.
each Filter is a plugin loaded and served by the Plugger.
the Blit Chain consists of blit operations to sum Layers to the
Context.
see how i'm using the API to this engine in freej.cpp
To create Layers providing a filename using javascript:
Layer foolay = create_layer("path/to/file");
add_layer(foolay);
then you init your new layer
if(foolay) {
foolay->init(&freej); // <- you pass a pointer to freej env
freej.layers->add(foolay); // and then you add it to the chain
}
=== Implement a new Layer?
If you are implementing a new Layer you need to implement just a few
methods, the most is inherited from a parent class:
MyLayer inherits the class Layer and implements the following:
bool open(char *file) /* called to open MyLayer's source
returns false if is not accessible */
bool init(Context *scr) /* if the open was succesful, call this
and the Layer will enter the chain */
bool feed() /* this function is executed by the Context when
it needs to grab more data in the Layer */
bool close() /* you need to call this when you want to close
the Layer, in case you *initialized* it */
If you are implementing a new Layer, you don't need to care about
threading or synchronizing the execution: just be sure to correctly
free all the buffers you malloc ;)
also compile --with-dmalloc to use a good memory fencing library