Disable anti-aliasing on the GL context, as that's often implemented
multi-sampling and it appears generally slow with Angle on Windows.Since
we do anti-aliasing ourselves, so it is not needed.
Group all fields we need to determine a physical font into one FontRequest
structure and use that throughout.
That way adding more fields will require less changes.
Place them in a HashMap that's indexed by the path. This needs further
tuning, for example to also be applied to embedded images, and the cache
shouldn't hold a strong reference. But it makes the berlin page
playable.
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.
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%;
}
}
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.
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.
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.
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.
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
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
The use of the texture atlas may result in pixels from adjacent textures
bleeding into the currently rendered texture. The standard technique appears to be
to add a padding around each image.
We already keep the context in an RC, might as well keep another copy :-)
This re-applies commit 9b0dfa14b5 but
replaces the Clone trait on Shader, which would lead to duplicate and
too early program deletion, with an Rc<Shader>.