Commit graph

185 commits

Author SHA1 Message Date
Simon Hausmann
42f11b3270 Fix rendering of integer aligned solid fill rectangles
Without a border radius they should have sharp edges when
aligned on integer coordinates.
2020-10-27 19:30:22 +01:00
Olivier Goffart
20cfb65e53 Bump version 2020-10-22 08:41:45 +02:00
Simon Hausmann
a98da9ecc9 Draw rounded rectangles with anti-aliasing
Draw rounded rectangles using a distance function. This removes the need
to use lyon to tesselate the rounded corners and as a bonus it gives
anti-aliased borders.
2020-10-21 09:35:35 +02:00
Simon Hausmann
ccb57114ce Clean up cursor rectangle handling
Generalize this to be called a normalized rectangle and create it by hand.
2020-10-21 08:15:16 +02:00
Simon Hausmann
1887b37af7 Remove premultiply_alpha from ARGBColor again
It's not safe to use with ARGBColor<u8> because of overflows, so instead let's
use it in the place where we need it and where the precision is given.
2020-10-19 18:45:33 +02:00
Simon Hausmann
6dd08b2109 Fix color blending when using the alpha channel
Given choice of ONE_MINUS_SRC_ALPHA blending function, we assume not
only that textures are pre-multiplied with their alpha (see commit
bf396ad578), the same applies also to
flat colors.

This fixes blending such as this:

    App := Window {
        Text {
            text: "Hello World";
        }
        Rectangle {
            color: #ff335588;
            width: 100%;
            height: 100%;
        }
    }
2020-10-19 17:21:03 +02:00
Olivier Goffart
b60567d7f2 Qt style: Use an QImage that is backed by a SharedArray
This way we have one copy less of the data
2020-10-19 11:35:57 +02:00
Simon Hausmann
93df708d87 Fix clipping in the wasm demos
Enable the stencil buffer on the WebGL context attributes.
2020-10-15 07:42:33 +02:00
Simon Hausmann
f43118cc89 Remove obsolete comment 2020-10-15 07:31:57 +02:00
Simon Hausmann
41d3fe940a Use a released version of glow 2020-10-15 07:29:15 +02:00
Olivier Goffart
d57ad389e0 Default to the native style in the viewer if it is available 2020-10-14 14:51:47 +02:00
Olivier Goffart
914ec61063 Revert "Temporarily disable fetching URL on wasm"
This reverts commit 49d75e0422.
2020-10-13 11:31:18 +02:00
Olivier Goffart
49d75e0422 Temporarily disable fetching URL on wasm
We cannot depends on an unreleased version of glow for publishing
2020-10-13 10:31:34 +02:00
Olivier Goffart
5a78776170 Add a version in Cargo.toml to be sure that the crate can be published 2020-10-13 10:19:14 +02:00
Olivier Goffart
1138c9dbed Normalize the spelling of SixtyFPS 2020-10-13 07:48:55 +02:00
Olivier Goffart
9a909142a8 Disable wayland dependency by default 2020-10-10 16:10:22 +02:00
Olivier Goffart
9dbe1f874f One need image 0.23.10 to use image::ImageBuffer::as_raw 2020-10-09 12:08:18 +02:00
Simon Hausmann
51f9fc0e61 Refresh the window when loading of an HTML image completed 2020-10-09 10:44:15 +02:00
Simon Hausmann
f4b6eea646 Implement the rest of the dynamic image loading for the online editor
This works except that there's a mechanism missing for refreshing the
canvas when the image was loaded.
2020-10-09 10:10:48 +02:00
Simon Hausmann
785f23f01a Make the tex__image_2d call work
* Set cross origin for the image to "anonymous" to ask the server for permission
* Pass RGBA as internal format
2020-10-09 09:57:45 +02:00
Olivier Goffart
6c9f0691aa WIP: Attempt to get image loading in wasm
Not working
2020-10-09 09:57:45 +02:00
Simon Hausmann
0f07684fcf Clean up GLFrame::render_primitive
Move the main match out into a separate helper function in GLFrame and
keep render_primitive to just be the loop. This will also make it easier
to implement the dynamic primitives later.
2020-10-09 09:56:32 +02:00
Simon Hausmann
4ff3bf4ebf Fix crash with native style and large widgets
The native style typically allocates a texture for its surface, and if that
exceeds the size of the texture atlas, then we need to adjust instead
of crash.
2020-10-05 12:52:04 +02:00
Olivier Goffart
57ccd26393 Update winit 2020-10-03 14:55:25 +02:00
Simon Hausmann
97f8dd0d1b Use a tight bounding box around rasterized glyphs
Fixes #8
2020-10-01 13:27:14 +02:00
Simon Hausmann
fdebd8427d Improve texture atlas handling
Avoid the manual padding of images in the texture atlas. This is a
CPU-side expensive operation and we can avoid doing that by instead
adjusting the texture coordinates to map to the center of the texels.
This is also described nicely in
https://docs.microsoft.com/en-us/windows/win32/direct3d9/directly-mapping-texels-to-pixels
2020-10-01 09:51:18 +02:00
Simon Hausmann
88b94a26ea Add support for clip rectangles in the GL rendering backend 2020-09-29 11:42:02 +02:00
Simon Hausmann
f05d3c58e2 Revert "Fix crash on start-up of rusttest2"
This reverts commit 7e5b6843a4. Lyon
0.16.2 contains the fix.
2020-09-28 13:30:17 +02:00
Simon Hausmann
fe079c644e Simplify byte offset vs. char index handling in the font code
Use char_indices() already for string_to_glyphs.
2020-09-22 18:47:15 +02:00
Simon Hausmann
1e450abc9c Change layer contents placement policy to reduce visual mess when resizing
This makes window resizing much smoother. Great advice from an anonymous
Norwegian friend ;-)
2020-09-22 14:30:27 +02:00
Simon Hausmann
7e5b6843a4 Fix crash on start-up of rusttest2
Mysteriously the path tesselation of hello.60 fails with Lyon 0.16.0, so pin
it to the previous release.

Reported also in nical/lyon#607
2020-09-22 14:24:40 +02:00
Simon Hausmann
4f25b0942f Draw text selections 2020-09-21 18:43:59 +02:00
Simon Hausmann
0d751e6627 Render a text cursor for TextInput items
It doesn't look quite perfect yet, but it's a start.
2020-09-18 17:58:14 +02:00
Simon Hausmann
dd8e487acc Fix discrepancy between Text layout info and rendering
The layout_info() would calculate the text metrics based on a different effective pixel
size compared to the rendering.
2020-09-15 16:15:26 +02:00
Simon Hausmann
c69781ace2 Upgrade glow 2020-09-15 11:14:23 +02:00
Simon Hausmann
4f5d491bf7 Minor cleanup
Remove GL context parameters from texture functions that aren't needed.
2020-09-15 09:02:34 +02:00
Simon Hausmann
19cce012a0 Add ARGBColor<T> to the color API
As discussed in the last API review, this replaces the as_rgba_f32/u8
"accessor" functions by returning a struct with named fields.
2020-09-08 22:11:23 +02:00
Simon Hausmann
220dc2ee47 Fix rendering of rounded rectangles in examples preview
For something like

    Window {
        GridLayout {
            Rectangle {
                border_width: 2lx;
                border_radius: 2lx;
                border_color: black;
            }
        }
    }

The border was not fully visible and partly obscured by the window
frame, the canvas element in the case of the preview in the examples.
That looks bad, and this patch fixes it by respecting the border width
in the geometry used to stroke and fill the rectangle.
2020-09-04 14:27:58 +02:00
Simon Hausmann
b50e42a7ba Avoid large empty canvas elements in the html docs
Some of the example code does not include a Window {} element with a
size.  The html says <canvas width=100 height=100> but it turns out that
winit is not interested in these values and any newly created window
with a canvas will get an initial size of 1024x768.

This is not quite the behavior we want, preserving the canvas size may
be more sensible -- it certainly is for our docs. So this patch tries to
preserve that.
2020-09-04 10:12:34 +02:00
Simon Hausmann
570e51eaa9 Improve API of color handling of text
Make the text color a rendering variable, so that it can be passed
through as uniform to the glyph shader and applied to the gray
map of the glyphs. This avoids re-creating the glyph runs when
merely the color changes.

This already "worked" for the glyph cache based text rendering,
but it wasn't used because of the wasm canvas code path. This
patch changes that to render the text into a text using simply black
and then render that texture using our existing glyph shader,
which merely uses the alpha channel anyway.

This reduces also #cfg's.
2020-09-02 11:48:41 +02:00
Olivier Goffart
f1ad78bc25 Qt style support for the rust backend
Need to set the SIXTYFPS_STYLE=native env variable while compiling
2020-09-01 12:25:11 +02:00
Olivier Goffart
60201b9c7b Update dependencies 2020-08-31 17:38:22 +02:00
Olivier Goffart
6d41b1981d Move the Qt style to a new backend: the Qt backend
Currently the Qt backend still redirect everything to the GL backend,
but the goal is to use QPainter and QWindow

This also adds a "default" backend, whose goal is to select the proper
backend at compile time
2020-08-31 17:26:04 +02:00
Simon Hausmann
07fa020e81 Fix flickering in gallery example when pressing spin box buttons
The path shader uses only one attribute array, while the others use two.
First rendering with say the glyph shader and then the path one may leave
odd artifacts around with GLES, which is fixed by properly disabling the
vertex attribute arrays after use.

Closes: #17
2020-08-28 17:49:45 +02:00
Olivier Goffart
65acdd78b0 Use xtask to generate the headers instead of build.rs of each lib
Fixes #14
2020-08-27 11:50:09 +02:00
Olivier Goffart
80dd7dcb04 Allow to specify the canvas id when creating a new window with wasm 2020-08-26 17:01:17 +02:00
Olivier Goffart
58cdaeb8dd Update license header to mention that commertial option are available 2020-08-26 13:23:42 +02:00
Simon Hausmann
14fe897086 Move all cbindgen generated code into
sixtyfps::cbindgen_private

Having private in the name makes it clear that this is ... private,
and cbindgen helps remember that it's generated.
2020-08-25 15:29:48 +02:00
Olivier Goffart
ea1f215367 Some polishinbg of the .toml files
- Give all the sixtyfps-* create a 0.0.1 version
 - Make sure that the internal dependences are using the exact same version
   (so "=0.0.1")
 - Add the description/homepage/repository fields in the .toml files
 - Set publish=false  to crates that are not meant to be published on crates.io
2020-08-24 16:28:11 +02:00
Simon Hausmann
7f1d9f5252 Commit correct license tags to Cargo.toml
For now that's GPL-3.0 only, but this can be changed :-)
2020-08-18 10:12:59 +02:00