Commit graph

51 commits

Author SHA1 Message Date
Simon Hausmann
992f990fa8 Allow for fitting paths into a given bounding rectangle
... by applying a transformation. This allows designing a path in some
other path design tool and then make it fit using bindings.
2020-07-13 15:41:11 +02:00
Simon Hausmann
535da41ae0 More naming cleanups
PathData::PathElements has one redundant "Path" in the name, so eliminate
for Events and Elements.
2020-07-10 13:06:28 +02:00
Simon Hausmann
1f7ae1b318 Rename PathElements to PathData
as it can now consists of elements or events.
2020-07-10 13:01:05 +02:00
Simon Hausmann
69325a1a5b Get rid of PathElements::StaticElements
This functionality can be folded into SharedArray later, if needed.
2020-07-10 12:47:27 +02:00
Simon Hausmann
f45ff6ce79 Add support for stroking paths
This will make it easier to visualize the path for layouts.
2020-07-09 09:36:16 +02:00
Simon Hausmann
1ab71b8ca3 Prepare the path element setup in the run-time for extensibility
Make the anonymous struct for the LineTo variant in the PathElement enum
as separate structure, which can be introspected using rtto::FieldInfo.
2020-07-07 14:14:17 +02:00
Simon Hausmann
4e22c2839e Add the rendering primitives for rendering a path
Right now the path is limited to polygons (only LineTo elements) and only the fill color can be specified.
2020-07-01 14:58:09 +02:00
Simon Hausmann
5bae6e01a5 Prepare for the ability to embed image data
The Image's source property used to be a string. Now it is a Resource
enum, which can either be None or an absolute file path to the image on
disk. This also replaces the internal Image type.

The compiler internally resolves the img bang expression to a resource
reference, which shall remain just an absolute path. For now the target
generator passes that through, but in the future the target generator
may choose a target specific way of embedding the data and thus
generating a different Resource type in the final code (through
compile_expression in the cpp and rust generator).

The C++ binding is a bit messy as cbindgen doesn't really support
exporting enums that can be constructed on the C++ side. So instead we
use cbindgen to merely export the type internally and only use the tag
from it then. The public API is then a custom Resource type that is
meant to be binary compatible.
2020-06-09 22:54:29 +02:00
Simon Hausmann
afd7319ae5 Rename corelib to sixtyfps_corelib
This is consistent with the other packages and since corelib is now also
a cdylib, libsixtyfps_corelib.so looks much better than libcorelib.so
:-)
2020-06-09 13:27:18 +02:00
Olivier Goffart
34931e58c0 Polishing of the documentation 2020-06-08 17:57:18 +02:00
Simon Hausmann
a2c5e66bee Rename gl renderer backend package
Use a full prefixed name (sixtyfps_rendering_backend_gl) to ensure that
the created static lib can be installed without file conflicts (libgl is
not a unique name).
2020-06-04 15:30:41 +02:00
Simon Hausmann
bcc6c6a60a Move Color and RenderingPrimitive into abi::datastructures
This paves the way to replace RenderingInfo.
2020-05-22 16:07:06 +02:00
Simon Hausmann
d48faf711f Update cached rendering data only when there are changes
This introduces a separate rendering preparation step in the main
window. As a consequence, the component becomes a parameter and the
graphicstest example can't use the main window anymore.

The decision whether a new low-level primitive needs to be created or
not is made by comparing the last RenderingPrimitive against the new
one.

On the upside, this means that property changes are now reflected in the
graphics.
2020-05-22 16:07:06 +02:00
Simon Hausmann
21842bdd75 Remove the individual primitive factory functions from RenderingPrimitivesBuilder
Only use the new one that takes the new enum.
2020-05-22 16:07:06 +02:00
Simon Hausmann
f2662f0884 Simplify image primitives graphics API
Don't require a dest rect for now. Rendering is always at (0, 0) but
with the transformation applied. And the size shall for now not be a
parameter.
2020-05-22 16:07:06 +02:00
Olivier Goffart
94c58dc1c4 Add an mouse handler for the TouchArea 2020-05-20 12:03:36 +02:00
Simon Hausmann
cbd28bf745 Simplify image primitives API
Removed the source rectangle as that can also be done on the source image side,
if necessary.
2020-05-19 20:37:36 +02:00
Simon Hausmann
a7d5bd9f59 Minor rendering cleanup
Remove the x/y parameters from the rectangle primitive. They're always zero
since we always render with a transformation
matrix.
2020-05-18 16:01:53 +02:00
Simon Hausmann
6ba90975b8 Further cleanup of the internal run_event_loop
Let the callback take a frame and that's it. Then the caller can take
care of presenting it, etc.
2020-05-12 22:16:04 +02:00
Simon Hausmann
c26a2a1562 Fix GL context state handling
Make our GL context not current when done with the initialization
and make it current for the duration fo primitive creation and frame
rendering.

Fixes #4
2020-05-12 21:42:34 +02:00
Simon Hausmann
ea03e08306 Clean up rectangle creation
Use a simple shared convenience method in the GraphicsBackend trait
2020-05-12 19:22:01 +02:00
Simon Hausmann
c5bcba2c3c Added basic rendering of cache primitives to the Items 2020-05-12 16:00:41 +02:00
Simon Hausmann
85e2ac36ef Prepare for caching rendering info for Items
Replace the RenderTree with a RenderingCache that is just the free-list vector
of rendering primitives.
2020-05-12 15:44:08 +02:00
Simon Hausmann
7efcbd5816 Simplify geometry handing
Replace the use of kurbo's primitives with lyon/euclid. This means less data copying,
conversion and also no annoying precision
casts.
2020-05-11 19:23:03 +02:00
Simon Hausmann
63d3f5125e Move the main loop implementation into the core library 2020-05-11 14:30:41 +02:00
Simon Hausmann
3a954e4cea Move window system creation and other GL related code into the GL backend 2020-05-11 13:11:55 +02:00
Simon Hausmann
fbc9505425 Don't require web-sys when not targeting wasm
Not that this caused any harm, but it's pointless.
2020-05-11 11:56:10 +02:00
Simon Hausmann
fb6267649b Fix the event loop usage to only redraw when requested
This avoids spinning the CPU.
2020-05-11 11:53:51 +02:00
Simon Hausmann
5b313af9aa Use winit also when targeting wasm
This allows unifying the code paths more.
2020-05-11 10:56:33 +02:00
Simon Hausmann
9be4c88b13 Fix wasm build
Make sure that glow selects the web-sys feature when targeting wasm.
2020-05-11 10:56:33 +02:00
Simon Hausmann
932ac8e2a7 Avoid the use of glutin in the event loop itself
Replace the re-exports with winit types.
2020-05-11 10:56:33 +02:00
Simon Hausmann
4a90c08bd4 Minor cleanup
Replace winit re-exports from glutin with a direct winit dependency.
This is done to prepare for moving the code into the core library that may depend on winit but not glutin.
2020-05-11 10:56:33 +02:00
Simon Hausmann
27aca08392 Ignore some generated files
* What's in generated/ is ... generated.
* .cargo/config may contain local changes - we don't need to track
  that for now.
2020-05-11 08:59:39 +02:00
Simon Hausmann
35831c57c7 Use glow without glutin
We don't need the dependency for glow
2020-05-09 14:29:07 +02:00
Simon Hausmann
8843f655eb Reduce the binary size
Only use the png loader from image
2020-05-07 21:02:46 +02:00
Simon Hausmann
f55c4e50f0 Track the issue of keeping the GL context current 2020-05-07 20:42:28 +02:00
Simon Hausmann
c67b688a9e Add README that explains how to try the wasm build 2020-05-07 15:07:29 +02:00
Simon Hausmann
cf37242952 Implement image rendering with glow 2020-05-07 15:07:29 +02:00
Simon Hausmann
12626472c4 Fix wasm build
Get rid of the glutin dependency in the GL renderer -- the caller is now responsible for swapping buffers.
2020-05-07 15:07:29 +02:00
Simon Hausmann
e0b024d2cf Some work towards implementing the gl renderer
... in plain GL(ow). swapbuffers and clearing the color buffer is working.
2020-05-07 15:07:29 +02:00
Simon Hausmann
da57d6be04 Start the switch to glow, comment out all renderer code 2020-05-07 15:07:29 +02:00
Simon Hausmann
17d3d49a83 Use cgmath throughout
And remove usage of kurbo::Affine. That avoids extra translations.
2020-05-05 23:00:03 +02:00
Simon Hausmann
bfac827ec7 Start with image rendering
These are the basics. Still to do are fixing the alpha channel blending, the rect handling,
a texture type to avoid consuming  the image over and over again. And more :-)
2020-05-05 18:20:21 +02:00
Simon Hausmann
f3a4f75e17 Allow specifying a clear color for the frame
... and default it to white.
2020-05-05 13:51:48 +02:00
Simon Hausmann
8dff1967ad Hide data structures of the GL renderer
Don't leak this accidentally to the outside
2020-05-05 13:38:28 +02:00
Simon Hausmann
5d07a6bd5b Support specifying the color for path filling 2020-05-05 13:24:41 +02:00
Simon Hausmann
0c4283020f Render the second test rectangle using a transform
The transform is applied through a uniform at run-time.
2020-05-05 11:41:38 +02:00
Simon Hausmann
7a129d66d3 Split graphics::RenderNode into RenderNodeMut and RenderNode
This allows a read-only tree traversal and thus rendering.
2020-05-05 11:38:29 +02:00
Simon Hausmann
fc5f93fab2 First implementation of a tree of rendering nodes
The idea is that they can be recursively rendered and propagate at least
the transform but also clip in the future.

One thing that's left is to split RenderNode into RenderNode and
RenderNodeMut, so that the rendering itself can be done on a non-mutable
tree reference.
2020-05-05 11:25:03 +02:00
Olivier Goffart
a83413aabc Do not put the frame on the heap.
But this forced to make GLFrame public.
2020-05-04 18:40:09 +02:00