Sharing my experiments while working on an SLD2 extension for R3.
The View implementation of R3 relies on GOB! Everything visible is appended to a root GOB! that is the window. At a lower level, GOB! are processed by C code and rendered depending of their 'type' (color, text, svg, ...).
When using View, there is a time to build the GOB! based structure (REBOL code) and a time to render this structure to the screen (C code).
With the SDL2 extension, drawing to the window (as well as creating the window) is made thru the extension commands. A data structure is not mandatory and some experiments could be done for a Model View Controller approach against a pure Parse based approach.
I wanted to make a little comparison between the existing GOB based solution and this SDL2 extension, so here, I created a window 1000x1000 size and filled with squares of 10x10 each of random color.
GOB based solution:
probe dt [
for x-axis 0 1000 10 [
for y-axis 0 1000 10 [
append win g: make gob! [size: 10x10]
g/offset: as-pair x-axis y-axis
g/color: random 255.255.255
]
]
probe dt [show win]
]
SDL2 extension solution:
probe dt [
for x-axis 0 1000 10 [
for y-axis 0 1000 10 [
set-draw-color random 255.255.255
draw-fill-rect as-pair x-axis y-axis 10x10
]
]
refresh-screen
]
GOB! results:
speed: 20ms (show) 30ms (show + GOB structure)
memory: 9156k
SDL2ext results:
speed: 27ms
memory: 29132k
(tests performed on Windows7)
It's difficult to conclude anything as the speed and memory usage can differ from one scenario to another. The fact that GOB! are processed by C code is a plus. The SDL2 based solution consumes more memory, this memory seems to directly relate to the screen surface used.
A block 'similar' to the GOB structure could be given to the SDL2 extension in order to process the whole drawing at C level (to be investigated) but this will be in all cases be less convenient and flexible than Gob.
The motivation behind SDL2 extension is to bring a View-like to more platforms. This currently has been compiled and tested with no issues on OSX and Windows.
Another approach could be to plug the SDL2 behind GOB rendering, this would keep everything compatible.