Commit graph

102 commits

Author SHA1 Message Date
Simon Wülker
3d320fa96a
Update rustfmt to the 2024 style edition (#35764)
* Use 2024 style edition

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Reformat all code

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-03-03 11:26:53 +00:00
Martin Robinson
2d09552234
prefs: Move some DebugOptions to Preferences and clean up (#34998)
- Move options configuring antialiasing and WebRender shader precache to
  the `Preferences` to group them with other related WebRender and DOM
  settings.
- Remove the option to disable antialiasing for canvases. This was
  unused.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-01-17 11:47:47 +00:00
Martin Robinson
621ddd749c
Elide lifetimes where possible after rustup (#34824)
The new version of rust allows us to elide some lifetimes and clippy is
now complaining about this. This change elides them where possible and
removes the clippy exceptions.

Fixes #34804.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-01-03 18:54:44 +00:00
Martin Robinson
0553789d48
fonts: Instantiate system fonts using system font loaders (#33747)
System fonts used to be instantiated using the system font loader and
this change restores that behavior. In addition, on macOS and FreeType
platforms font data for system fonts is loaded using memory mapping. The
benefit is that system font loaders typically are able to cache fonts in
system memory (using memory mapping, for instance) and we'd like to load
them in a the way most compatible with other applications.

On my Linux system, this manages to get the overhead of loading a very
large font down from 10ms to approximately 1ms. Subsequent runs show
even less overhead. We've measured similar gains on macOS systems.

Currently, system font data must be loaded into memory manually for
canvas and this is unlikely to change even with a switch to `vello`. The
use of explicit memmory mapping should help in this case -- though it
probably won't be possible to use this properly on macOS and Windows if
we ever want to load fonts from TTCs properly.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2024-10-10 23:09:51 +00:00
Martin Robinson
ade902207f
fonts: Use IpcSharedMemory to send font data (#33530)
This changes modifes the way that font data is sent over IPC channels.
Instead of serializing the data or sending it via IPC byte senders, font
data is copied into shared memory and a copy of the handle is sent over
the channel.

There is also the idea of sending the file handle of the on disk data of
system fonts. This could be implemented as a further followup once there
is an abstraction in `ipc-channel` over file handles.

To accomplish this, a `FontData` abstraction is added, which also allows
caching an in-memory shared `Arc<Vec<u8>>` version of the data (neeeded
by some APIs). This could also be a place for caching font tables in the
future.

Finally, the `FontCacheThread` is renamed to the `SystemFontService`
while the proxy for this is now named `SystemFontServiceProxy`.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2024-09-25 07:31:55 +00:00
Rodion Borovyk
4bf5024ee0
fix a couple of simple clipy warnings (#32813)
Signed-off-by: Rodion Borovyk <rodion.borovyk@gmail.com>
2024-07-19 13:18:34 +00:00
Martin Robinson
4907e89656
canvas: Remove as much usage of font-kit as possible (#32758)
Do font selection using Servo's font backend, which is shared with the
rest of layout. In addition, delay the creation of the `font-kit` font
until just before rendering with `raqote`. The idea is that when
`raqote` is no longer used, we can drop the `font-kit` dependency.

This change has the side-effect of fixing text rendering in canvas,
adding support for font fallback in canvas, and also correcting a bug in
font selection with size overrides.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2024-07-11 04:25:38 +00:00
Oriol Brufau
f5bdfdfe94
Upgrade Stylo to 2024-03-01 (#32089)
* Upgrade Stylo to 2024-03-01

* Fixup for https://bugzil.la/1882754

* Update test expectations
2024-04-16 12:27:51 +00:00
Oriol Brufau
fff9ef87e6
Update Stylo to 2023-10-16 (#31932)
* Update Stylo to 2023-10-16

* Fixup for https://phabricator.services.mozilla.com/D185154

* Fixup for https://phabricator.services.mozilla.com/D188216

* Fixup for https://phabricator.services.mozilla.com/D185677

* Fixup for https://phabricator.services.mozilla.com/D188566

* Fixup for https://phabricator.services.mozilla.com/D188727

* Fixup for https://phabricator.services.mozilla.com/D189475

* Fixup for https://phabricator.services.mozilla.com/D189521

* Fixup for https://phabricator.services.mozilla.com/D188812

* Fixup for https://phabricator.services.mozilla.com/D189484

* Update test expectations
2024-03-30 13:30:13 +00:00
Oriol Brufau
c07484fcb6
Update Stylo to 2023-09-01 (#31609)
* Update Stylo to 2023-09-01

* Fixup for https://phabricator.services.mozilla.com/D184929

* Fixup for https://phabricator.services.mozilla.com/D184526

* Fixup for https://phabricator.services.mozilla.com/D184525

* Fixup for https://phabricator.services.mozilla.com/D185154

* Fixup for https://phabricator.services.mozilla.com/D184685

* Fixup for https://phabricator.services.mozilla.com/D185916

* Fixup for https://phabricator.services.mozilla.com/D185492

* Fixup for https://phabricator.services.mozilla.com/D186626

* Update test expectations
2024-03-18 13:52:40 +00:00
eri
03d64d0675
clippy: Fix assorted warnings in components/ (#31628)
* clippy: fix assorted warnings in `components/`

* fix: new and default

* fix: review comments
2024-03-13 08:31:58 +00:00
eri
5c4f8cf0df
clippy: fix some warnings in components/canvas (#31563) 2024-03-08 07:24:01 +00:00
Oriol Brufau
11414d0c94 Further changes required by Servo 2023-11-21 15:36:35 +01:00
Oriol Brufau
bb55e923bb Further changes required by Servo 2023-11-06 09:35:57 +01:00
Ennui Langeweile
a6ceca6d9f
Clean up a bit of the canvas backend abstractions (#30637)
* Clean up a bit of the canvas backend abstractions

* Remove unused import
Sneaky, sneaky little hecker
2023-10-27 23:06:43 +00:00
Samson
aad2dccc9c
Strict import formatting (grouping and granularity) (#30325)
* strict imports formatting

* Reformat all imports
2023-09-11 19:16:54 +00:00
Samson
711dbbd4af
remove extern crate (#30311)
* remove extern crate

* Update components/script_plugins/lib.rs

Co-authored-by: Martin Robinson <mrobinson@igalia.com>

---------

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2023-09-08 12:11:31 +00:00
Martin Robinson
423cc34cb0 Bump euclid to 0.22
- Also updates raqote to latest with an upgrade of font-kit to 0.11
  applied on as a patch
- Update lyon_geom to the latest version

Major change:

- All matrices are now stored in row major order. This means that
  parameters to rotation functions no longer should be negated.
- `post_...()` functions are now named `then()`. `pre_transform()` is removed,
  so `then()` is used and the order of operations changed.
2023-01-26 08:59:21 +01:00
Josh Matthews
8ecc1a80a7 Skip missing glyphs when drawing 2d canvas text. 2020-08-07 13:57:57 -04:00
Utsav Oza
d1241a8d06 Fix ./mach build --release --with-layout-2020 2020-06-10 22:34:24 +05:30
Utsav Oza
34d0c313dc Enable textAlign, textBaseline and direction attributes for canvas 2020-06-10 22:34:20 +05:30
Utsav Oza
c21fde3751 Implement CanvasRenderingContext2D.font property 2020-06-10 22:11:24 +05:30
Utsav Oza
7883718c12 Query layout to resolve canvas font property value 2020-06-10 22:10:42 +05:30
Utsav Oza
f161ab8e57 Basic implementation of canvas.fillText 2020-06-10 22:10:42 +05:30
Paul Rouget
40f6cd87d4 Revert "Add a simple implementation of CanvasRenderingContext2d.fillText"
Windows crash: https://github.com/servo/servo/issues/26015
2020-03-24 10:35:52 +01:00
kaiakz
0d0ac986b7 Add a simple implementation of CanvasRenderingContext2d.fillText 2020-03-19 15:40:14 +08:00
pylbrecht
967fabb0d0 Make fill_rect() draw patterns correctly 2020-03-03 07:01:27 +01:00
pylbrecht
86ad6ed3b8 Refactor arc() and ellipse() to use lyon_geom::Arc 2020-02-26 06:45:47 +01:00
pylbrecht
ae110f2e6c Add missing CompositionStyle::Clear 2020-01-27 19:21:45 +01:00
pylbrecht
e0547855df Remove duplication for creating gradient stops 2019-12-17 19:52:03 +01:00
pylbrecht
7c8c230d93 Add transform to Pattern::Surface to properly draw images 2019-12-17 19:52:03 +01:00
pylbrecht
9a2370a3a8 Consider empty gradients in is_zero_size_gradient() 2019-12-17 19:52:02 +01:00
pylbrecht
ada7986fef Handle BlendMode::Clear in GenericDrawTarget::fill() 2019-12-17 19:52:02 +01:00
pylbrecht
a50aef6f00 Add a layer to store Pattern related information
Some information of `canvas_data::Pattern` was lost by
converting it to `raqote::Source` due to the fact that Raqote
did not store this information (e.g. linear gradient's start/end
points). We introduce another layer to keep this information for later
use (like in `is_zero_size_gradient()`).
2019-12-17 19:52:02 +01:00
pylbrecht
1aecf40922 Implement "repeat-x" and "repeat-y" for images 2019-12-17 19:52:02 +01:00
pylbrecht
25d036f05c Set images' ExtendMode based on available information 2019-12-17 19:52:02 +01:00
pylbrecht
1cdcbb25fa Handle overlapping gradient stops for linear gradients
From `addColorStop(offset, color)`s spec:
If multiple stops are added at the same offset on a gradient, they must
be placed in the order added, with the first one closest to the start of
the gradient, and each subsequent one infinitesimally further along
towards the end point (in effect causing all but the first and last stop
added at each point to be ignored)

https://www.w3.org/html/test/results/2dcontext/annotated-spec/canvas.html#testrefs.2d.gradient.interpolate.overlapu
2019-12-17 19:52:01 +01:00
pylbrecht
04e9523e5f Use push_layer_with_blend() only when necessary
push_layer_with_blend() comes at a performance cost, so we only use it
on blend modes that require it.
2019-12-17 19:52:01 +01:00
pylbrecht
a02daef7b2 Make arc() wrap angles mod 2pi 2019-12-17 19:52:01 +01:00
pylbrecht
02e3325416 Make arc() use anticlockwise argument 2019-12-17 19:52:01 +01:00
pylbrecht
da9b4c33cd Make fill() handle all composition operations 2019-12-17 19:52:00 +01:00
pylbrecht
47ee2729ec Make fill() draw uncovered pixels as (0,0,0,0) for certain composition ops 2019-12-17 19:52:00 +01:00
pylbrecht
4d4e68ca6b Respect direction when drawing arcs 2019-12-17 19:52:00 +01:00
pylbrecht
a473f50245 Respect FilterMode when drawing images 2019-12-17 19:51:59 +01:00
pylbrecht
16f06f24c5 Add check for handling equal radial gradients 2019-12-17 19:51:59 +01:00
pylbrecht
d87e5d831b Add check to handle zerosize linear gradients 2019-12-17 19:51:59 +01:00
pylbrecht
55256df0ba Use tolerance > 0 in Path::contains_point() 2019-12-17 19:51:58 +01:00
pylbrecht
5c6a12a116 Create raqote::SolidSource with premultiplied color
SolidSource expects a premultiplied color.
2019-12-17 19:51:57 +01:00
pylbrecht
77a8bc4a1d Fix conversion of image data slice 2019-12-17 19:51:57 +01:00
pylbrecht
b8b33788b6 Handle empty paths in PathBuilder::get_current_point()
The case of calling get_current_point() on empty paths has not been
handled and caused panics.
2019-12-17 19:51:57 +01:00