Commit graph

7824 commits

Author SHA1 Message Date
Jelle Raaijmakers a41d5ffa1e LibGfx+LibGL: Allow singular matrices to be inverted
This is basically the old behavior before the GLtron port was
introduced, but `.inverse()` no longer crashes if the matrix is
singular.
2022-01-12 01:08:38 +01:00
Timothy Flynn c1a1370c2a LibJS: Use new LibUnicode API to format time zone names 2022-01-11 23:56:35 +01:00
Timothy Flynn d50f5e14f8 LibUnicode: Fall back to GMT offset when a time zone name is unavailable
The following table in TR-35 includes a web of fall back rules when the
requested time zone style is unavailable:
https://unicode.org/reports/tr35/tr35-dates.html#dfst-zone

Conveniently, the subset of styles supported by ECMA-402 (and therefore
LibUnicode) all either fall back to GMT offset or to a style that is
unsupported but itself falls back to GMT offset.
2022-01-11 23:56:35 +01:00
Timothy Flynn 8d35563f28 LibUnicode: Implement TR-35's localized GMT offset formatting
This adds an API to use LibTimeZone to convert a time zone such as
"America/New_York" to a GMT offset string like "GMT-5" (short form) or
"GMT-05:00" (long form).
2022-01-11 23:56:35 +01:00
Timothy Flynn 6409900a5b LibUnicode: Add an API to retrieve a locale's default numbering system 2022-01-11 23:56:35 +01:00
Timothy Flynn cc5e9f0579 LibJS+LibUnicode: Move replacement of number system digits to LibUnicode
There are a few algorithms in TR-35 that need to replace digits before
returning any results to callers. For example, when formatting time zone
offsets, a string like "GMT+12:34" must have its digits replaced with
the default numbering system for the desired locale.
2022-01-11 23:56:35 +01:00
Jelle Raaijmakers 1c2e07d42a LibGL: Set q parameter for glTexCoord to 1 by default
According to the manual, if `q` is not specified, it is 1.
2022-01-11 23:47:42 +01:00
Jelle Raaijmakers 260663567a LibGL: Implement glTexCoord2i 2022-01-11 23:47:42 +01:00
Jelle Raaijmakers 17ec433326 LibSoftGPU: Only render complete primitives
Previously, we were expecting triangles and quads to consist of
complete sets of vertices. However, a more common behavior is to ignore
all vertices that do not make up a full primitive. For example, OpenGL
specifies for `GL_QUADS`:

  "The total number of vertices between Begin and End is 4n + k, where
   0 ≤ k ≤ 3; if k is not zero, the final k vertices are ignored."

This changes the behavior of `Device::draw_primitives()` to both return
early if no full set of vertices was provided, and to ignore any
additional vertices that are not part of a full set.
2022-01-11 23:47:42 +01:00
Jelle Raaijmakers 69eb3b0838 LibGL: Remove duplicate private: from SoftwareGLContext.h 2022-01-11 23:47:42 +01:00
Jelle Raaijmakers a4a666152b LibGfx+LibGL: Do not crash if matrix inverse does not exist
Allow `Matrix::inverse()` to return an error and deal with those in
LibGL. Also use this opportunity to more efficiently calculate the
transpose of the model view matrix for the normal transformation.
2022-01-11 23:47:42 +01:00
Jelle Raaijmakers 03c1f1780d LibGL: Stub glPointSize 2022-01-11 23:47:42 +01:00
Jelle Raaijmakers 6363797e80 LibGL: Implement glLightModeli 2022-01-11 23:47:42 +01:00
Jelle Raaijmakers e2f79c8b5f LibGL: Implement glTexEnvi 2022-01-11 23:47:42 +01:00
Jelle Raaijmakers eea1b95ead LibGL: Implement glRotated 2022-01-11 23:47:42 +01:00
Jelle Raaijmakers a29534b531 LibGL: Implement glColor3d and glColor3ubv 2022-01-11 23:47:42 +01:00
Linus Groh 355fbcb702 LibJS: Actually implement get_iana_time_zone_offset_nanoseconds()
Instead of hard-coding an UTC offset of zero seconds, which worked for
the sole UTC time zone, we can now get the proper offset from the TZDB!
2022-01-11 22:17:39 +01:00
Linus Groh d527eb62da LibJS: Support non-UTC time zones in Temporal :^)
We can now recognize & normalize all time zones from the IANA time zone
database and not just 'UTC', which makes the LibJS Temporal
implementation a lot more useful! Thanks to the newly added LibTimeZone,
this was incredibly easy to implement :^)

This already includes these recent editorial changes in the Temporal
spec: https://github.com/tc39/proposal-temporal/commit/27bffe1
2022-01-11 22:17:39 +01:00
Linus Groh 205d63c3f0 LibTimeZone: Operate in UTC-only mode when !ENABLE_TIME_ZONE_DATA
Instead of only having dummy functions that don't work with any input,
let's at least support one time zone: 'UTC'. This matches the basic
Temporal implementation for engines without ECMA-262, for example.
2022-01-11 22:17:39 +01:00
Linus Groh f1276144ba LibJS: Check if input was exhausted after parsing UTC offset fraction
Previously parse_time_zone_numeric_utc_offset_syntax() would return true
to indicate success when parsing a string with an invalid number of
digits in the fractional seconds part (e.g. 23:59:59.9999999999).
We need to check if the lexer has any characters remaining, and return
false if that's the case.
2022-01-11 21:16:33 +01:00
Linus Groh de07312cc7 LibJS/Tests: Add Temporal.TimeZone() tests for numeric UTC offset
This works now, let's test it :^)
2022-01-11 21:16:33 +01:00
Junior Rantila 0d328f3c86 LibCore+flock: Make Core::System::waitpid more ergonomic 2022-01-11 16:04:29 +01:00
Marcus Nilsson 315e1c705f LibGUI: Don't paint text cursor if TextEditor is disabled
This looked a bit odd in the rare case of disabling a focused
TextEditor.
2022-01-11 16:00:48 +01:00
Marcus Nilsson bcf764cecf LibGUI: Change gradient colors when ValueSlider is disabled
Make it more obivous when ValueSlider is disabled by changing the
gradient colors.
2022-01-11 16:00:48 +01:00
Andrew Kaster b13846e688 LibC: Add daemon(3) implementation to match behavior of Linux and BSDs
This helper that originally appeared in 4.4BSD helps to daemonize
a process by forking, setting itself as session leader, chdir to "/" and
closing stdin/stdout.
2022-01-11 11:47:48 +01:00
Timothy Flynn 09c0324880 LibTimeZone: Begin generating GMT offset rules for each time zone
This is a rather naive implementation, but serves as a first pass at
determining the GMT offset for a time zone at a particular point in
time. This implementation ignores DST (because we are not parsing any
RULE entries yet), and ignores any offset patterns of the form "Mon>4"
or "lastSun".
2022-01-11 00:36:45 +01:00
Timothy Flynn e9c42d0bc5 LibTimeZone: Add methods to canonicalize a time zone name 2022-01-11 00:36:45 +01:00
Timothy Flynn 1c2c98ac5d LibTimeZone: Add method to convert a time zone to a string 2022-01-11 00:36:45 +01:00
Timothy Flynn d627367489 LibTimeZone: Do not separate the generated data from the main library
This CMakeLists.txt was basically copy-pasted from LibUnicode, where the
generated data is separated into its own library. This was to let other
libraries / applications decide if they actually want to link the data
because it is so large. LibTimeZone's generated data is significantly
smaller, so this separation really isn't needed.
2022-01-11 00:36:45 +01:00
Glenford Williams 6c10e9e121 LibGUI: Make Tableview handle multi-selected indexes when deleting
Previously when the delete key was pressed, only the first selected
cell index would have been deleted. This commit remedies that by first
checking when more than a single index is selected.
2022-01-11 00:18:15 +01:00
kleines Filmröllchen 2f50d8f4d3 AK+LibC+LibPthread: Introduce NoAllocationGuard
NoAllocationGuard is an RAII stack guard that prevents allocations
while it exists. This is done through a thread-local global flag which
causes malloc to crash on a VERIFY if it is false. The guard allows for
recursion.

The intended use case for this class is in real-time audio code. In such
code, allocations are really bad, and this is an easy way of dynamically
enforcing the no-allocations rule while giving the user good feedback if
it is violated. Before real-time audio code is executed, e.g. in LibDSP,
a NoAllocationGuard is instantiated. This is not done with this commit,
as currently some code in LibDSP may still incorrectly allocate in real-
time situations.

Other use cases for the Kernel have also been added, so this commit
builds on the previous to add the support both in Userland and in the
Kernel.
2022-01-11 00:08:58 +01:00
Linus Groh 471b798eb0 LibC: Implement strsep() 2022-01-10 23:47:30 +01:00
Timothy Flynn 05de9b82b8 LibJS: Include hour-cycle in DateTimeFormat options
This is a normative change to the Intl spec:
https://github.com/tc39/ecma402/commit/20e5c26

Note that this doesn't actually affect us. Its purpose is to provide the
hour-cycle to BestFitFormatMatcher. This AO is implementation defined,
and ours just invokes BasicFormatMatcher, which doesn't use this field.
We could now have LibUnicode generate this field and use it to find a
better format pattern, though.
2022-01-10 16:18:05 +01:00
Timothy Flynn 15947aa1f0 LibUnicode: Add an hour-cycle field to DateTimeFormat's format pattern 2022-01-10 16:18:05 +01:00
Marcus Nilsson 4459cb33ed LibGUI+AK: Add DRAG_DEBUG opt and put drag operations behind dbgln_if
No need to have this enabled all the time.
2022-01-10 14:23:04 +01:00
Rafał Babiarz 3132ce1d36 LibGUI: Show hours and minutes in "unsaved changes" dialogs 2022-01-09 20:25:48 -08:00
Jelle Raaijmakers 57b1dcbec9 LibGL: Add stub for glColorMaterial 2022-01-09 23:23:01 +01:00
Jelle Raaijmakers 7ad18e91e2 LibGL: Add capabilities to context parameters
Context parameters are LibGL's way of centrally defining all parameters
that can be retrieved through `glGetBoolean*`, `glGetInteger*`, etc.
The spec describes that capabilities such as `GL_LIGHTING` can also be
retrieved through these methods, but it should not be possible to
retrieve random boolean parameters through `glIsEnabled`. For example,
`GL_UNPACK_LSB_FIRST` can only be retrieved through `glGet*`.

This moves reading of capabilities to `::get_context_parameter` and
implements its use in `::gl_is_enabled`.
2022-01-09 23:21:03 +01:00
Linus Groh 09a11fa6ea LibJS: Implement proper Iterator records
Instead of using plain objects as Iterator records, causes confusion
about the object itself actually being its [[Iterator]] slot, and
requires non-standard type conversion shenanigans fpr the [[NextValue]]
and [[Done]] internal slots,  implement a proper Iterator record struct
and use it throughout.

Also annotate the remaining Iterator AOs with spec comments while we're
here.
2022-01-09 22:02:43 +01:00
Linus Groh e141f1e976 LibJS: Use Optional<Value> for potentially missing value in Iterator AOs
Given we're already moving away from using the empty Value elsewhere,
and I'm about to update most of this code, let's do this small tweak
now.
2022-01-09 22:02:43 +01:00
Daniel Bertalan e1eefe2b52 LibCrypto: Link against LibCore
The ASN1 parser calls `LibCore::DateTime::create` and
`LibCore::DateTime::now`.
2022-01-09 20:40:22 +01:00
Marcus Nilsson 708ec90bba LibGUI: Add Menu::set_children_actions_enabled() helper
This adds a helper function to Menu that allows us to set all the
children enabled/disabled.
2022-01-09 20:24:02 +01:00
Jelle Raaijmakers 29bbf56286 LibGL+LibSoftGPU: Implement viewport support
This implements the `glViewport` API call, the coordinate
transformation and the `GL_VIEWPORT` context parameter.
2022-01-09 20:22:32 +01:00
Jelle Raaijmakers d236b0ed12 LibSoftGPU: Rename window coordinate transformation function
The name `scissor_box_to_window_coordinates` was wildy inaccurate since
we are actually transforming window coordinates into whatever the
coordinate space of the backing bitmap is.
2022-01-09 20:22:32 +01:00
Stephan Unverwerth d45931b423 LibSoftGPU: Take sample from pixel center
This adds a half pixel offset to the edge value calculation in order to
sample the triangle at pixel centers. This is in line with actual OpenGL
rasterization rules and generates correctly interpolated vertex
attributes including texture coordinates.
2022-01-09 16:21:13 +03:30
Stephan Unverwerth 5028b53b49 LibSoftGPU: Make divide-by-zero guard more explicit in stats overlay
This previously assigned 1 to any divisor that was 0 which was a bit
confusing
2022-01-09 16:21:13 +03:30
Stephan Unverwerth 57215d0e1f LibSoftGPU: Allow arbitrary render target sizes
With the RASTERIZER_BLOCK_SIZE gone we can now render to any size, even
odd ones. We have to be careful to not generate out of bounds accesses
when calculating the render target and depth buffer pointers. Thus we
check the coverage mask and generate nullptrs for pixels that will not
be updated. This also masks out pixels that would touch the triangle but
are outside the render target/scissor rect bounds.
2022-01-09 16:21:13 +03:30
Stephan Unverwerth 21cad22535 LibSoftGPU: Also interpolate normal during triangle clipping 2022-01-09 16:21:13 +03:30
Stephan Unverwerth 941e9d9922 LibSoftGPU: Move alpha test into separate function 2022-01-09 16:21:13 +03:30
Stephan Unverwerth 68a1727547 LibSoftGPU: Move alpha blend factor setup out of triangle rasterization
Since the alpha blend configuration should not change between most calls
of draw_primitives it makes no sense to reinitialize the blend factors
for every rasterized triangle.
The alpha blend factors are now set up whenever the device config
changes. The blend factors are stored in struct AlphaBlendFactors.
2022-01-09 16:21:13 +03:30