1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00
Commit graph

343 commits

Author SHA1 Message Date
reuk
28414a6af8
Global: Avoid floating-point equality checks where possible 2023-04-04 19:55:11 +01:00
Anthony Nicholls
05d5c94990
Native: Rename all native files for improved consistency 2023-04-04 19:54:29 +01:00
reuk
16929c26f7
OpenGLContext: Avoid calling NSView::window from displaylink thread 2023-03-14 19:08:07 +00:00
reuk
af2a4a7e2a
OpenGL: Avoid enabling GL_TEXTURE_2D in core profile contexts 2023-03-06 12:35:26 +00:00
reuk
c08a1827b5
OpenGL: Ensure flushBuffer can't be called simultaneously from multiple threads on macOS 10.13 or earlier
On these platforms, calling flushBuffer from multiple threads
simultaneously will lead to deadlocks.
2023-03-02 12:03:31 +00:00
reuk
ae45bb4c35
OpenGLContext: Fix signature of DEBUGPROC 2023-02-22 21:00:18 +00:00
reuk
a59cba010b
ColourGradient: Create lookup tables using non-premultiplied colours
The OpenGL renderer uses ColourGradient::createLookupTable to generate
gradient textures. However, the tweening method used was different to
the tweening used by CoreGraphics gradients, and by the software
renderer.

Gradient tweening is now computed using non-premultiplied colours, to
ensure consistency between gradients rendered using OpenGL, and with
other renderers.
2023-02-09 17:54:19 +00:00
reuk
f2d0d9cde8
OpenGL: Add back CVDisplayLink-driven drawing 2022-12-14 11:12:32 +00:00
reuk
0fbd7d7b3f
Functional: Add ScopeGuard implementation 2022-11-02 11:38:29 +00:00
reuk
7e404118b5
OpenGL: Correctly report OpenGL rendering scale in Pro Tools 2022.7 on Windows 2022-09-27 15:18:21 +01:00
reuk
19175ff698
OpenGL: Ensure that macOS uses the same (sRGB) colour space everywhere 2022-09-27 15:18:21 +01:00
reuk
2ae87f95f1
OpenGL: Carry out all GL rendering on a single thread 2022-09-27 15:18:21 +01:00
reuk
ae3bfdb1d2
OpenGL: Avoid occasional deadlock when destroying contexts 2022-09-26 18:03:47 +01:00
reuk
ff1d5d6da4
OpenGL: Only assert on high-severity errors 2022-09-26 18:03:47 +01:00
reuk
8ec8e36f5c OpenGLContext: Swap buffers on the main thread
This change fixes an issue where opening multiple OpenGLContexts on
certain versions of macOS (observed on 10.13) could cause a deadlock.

The issue can be reproduced by:
- Attaching an OpenGL context to the AudioPluginDemo editor
- Opening multiple copies of the editor simultaneously in a plugin host.
  I tested with Live 10.

I also observed the issue in a standalone app that opened new windows
containing OpenGLContexts on a timer.
2022-08-31 17:42:48 +01:00
reuk
322aa64459 OpenGLContext: Share CVDisplayLinks with NSViewComponentPeer 2022-08-31 17:42:47 +01:00
reuk
b27af5def9 OpenGL: Tidying 2022-08-31 17:42:47 +01:00
reuk
e64f87b26c OpenGL: Allow setting window bounds from repaint callback
On Windows, the OpenGL context window sometimes receives a repaint
request after moving between screens with different scale factors.
If the screen has changed size/scale since the last paint operation,
failing to invalidate the painted area may cause the screen contents
to be drawn at the wrong scale until paint is next called.
2022-08-31 17:42:47 +01:00
reuk
02b5ab748a OpenGL: Add support for a few more OpenGL profiles
- 4.1 and 4.3 contexts can now be requested
- The requested context version is no longer ignored on Linux
- Debugging contexts are now enabled in Debug builds with GL 4.3
- Fixes a bug where glEnable(GL_TEXTURE_2D) was called in core profiles
2022-08-31 17:42:47 +01:00
Tom Poole
2ec861d99e Update licensing banners to JUCE 7 2022-05-16 17:55:48 +01:00
Tom Poole
dea3fe60e4 Update copyright banners 2022-04-04 12:36:32 +01:00
reuk
45ae98effd
OpenGLContext: Correctly size GL view when using a non-unity global scale 2022-02-23 10:56:12 +00:00
reuk
0223e44ae7
Image: Keep track of contiguous buffer size to avoid heap buffer overflows
In CoreGraphicsPixelData::createImage, image data was copied from a
BitmapData created from the Image passed into the function.

The BitmapData instance didn't keep track of the size of the buffer it
pointed to, so the buffer size was computed by multiplying the
BitmapData height by its line stride. However, if the BitmapData pointed
to a subsection of an image, the `data` pointer might be offset from
the allocated region, and `data + lineStride * height` would point past
the end of the allocated region. Trying to read/copy this range would
cause a heap buffer overflow at the end of the range.

This change adjusts BitmapData so that it keeps track of the size of the
allocated region. Taking a subsection of an image should subtract the
data pointer offset from the size of the allocated region.
2022-02-23 10:56:09 +00:00
reuk
d3c4017685
OpenGLContext: Only create and use a VAO in contexts using the core profile 2022-02-18 16:43:27 +00:00
reuk
199885baa8
OpenGL: Avoid deprecated function when querying available extensions
In OpenGL 3 and up, GL_EXTENSIONS is deprecated as an argument of
glGetString and glGetStringi should be used instead.
2022-02-18 16:43:27 +00:00
reuk
01e71bc351
OpenGL: Avoid races on viewportArea and scale data members 2022-01-27 18:43:22 +00:00
reuk
1ff05d3333
OpenGL: Avoid querying the native view hierarchy from a background thread on macOS 2021-12-15 14:14:07 +00:00
reuk
48c6087faf Thread: Update macOS thread priority calculation
The Apple threading documentation [^1] says the following:

> The second argument to pthread_setschedparam is the desired policy,
  which can currently be one of SCHED_FIFO (first in, first out),
  SCHED_RR (round-robin), or SCHED_OTHER. The SCHED_OTHER policy is
  generally used for extra policies that are specific to a given
  operating system, and should thus be avoided when writing portable
  code.

This appears to differ from the policy semantics on Linux and BSD, where
FIFO and RR are both explicitly real-time policies.

Therefore, on Linux/BSD we only enable the RR policy if the requested
priority is 8 or higher. Meanwhile, on macOS, we map all thread
priorities (0 - 10) onto the RR policy with an appropriate priority.

[^1]: https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/scheduler/scheduler.html
2021-12-14 22:50:09 +00:00
reuk
c5c9f080d3
OpenGL: Ensure context is initially drawn with correct scale on macOS 2021-12-03 10:15:51 +00:00
reuk
ea8b0a2d32
OpenGL: Ensure that GL views display at the correct scale on macOS 12
Previously, we were using the window's top-left position to determine
the scale to use for the OpenGLContext. However, on macOS the
backingScaleFactor of the window is not strictly related to the top-left
corner of the window, so the OpenGL view's scale could end up differing
from the backing scale factor when slowly moving a window between
displays with different backing scale factors.

On macOS, we now use the backing scale factor of the window's screen (as
maintained by AppKit), rather than trying to work out the correct
display and scale ourselves.
2021-12-01 15:44:07 +00:00
reuk
efdb3ec72f
OpenGL: Make version number parsing slightly more robust
This fixes an issue on iOS platforms where the version number string is
prefixed with "OpenGL ES " despite the Khronos docs for OpenGL ES
specifying that "The GL_VERSION and GL_SHADING_LANGUAGE_VERSION strings
begin with a version number".
2021-11-24 16:20:37 +00:00
reuk
e97f7d1c6c
OpenGLContext: Use high-priority thread for OpenGL renderer to smooth animations on M1 machines 2021-11-24 16:20:37 +00:00
reuk
6d3504adfa
OpenGLContext: Fix thread/consistency warnings on macOS
Previously, Xcode's main thread checker would complain when selecting
the "OpenGL Renderer" in the DemoRunner on macOS.
2021-10-25 09:51:20 +01:00
reuk
3768349a05
Font: Make Font and TypefaceCache threadsafe
Previously, it wasn't safe to access Font instances from multiple
threads because there was a chance that they might reference the same
shared internal state. In this case, calling getTypeface() or getAscent from
two threads simultaneously would cause a race on the typeface and ascent
data members, even though the Font instances appeared to be disjoint.

With this change in place, it is now safe to use Font instances from
multiple threads simultaneously.

It is still an error to modify the same Font instance from multiple
threads without synchronization!

    // Fine:
    Font a;
    Font b = a;

    auto futureA = std::async (std::launch::async, [&a] { /* do something with a */ });
    auto futureB = std::async (std::launch::async, [&b] { /* do something with b */ });

    // Bad idea:
    Font f;

    auto futureA = std::async (std::launch::async, [&f] { /* do something with f */ });
    auto futureB = std::async (std::launch::async, [&f] { /* do something with f */ });
2021-09-23 10:28:47 +01:00
reuk
056700572c
OpenGLPixelFormat: Tidy up equality function 2021-09-22 11:04:47 +01:00
reuk
f0d11f961b
OpenGLContext: Avoid reading from component on background thread 2021-09-22 10:23:05 +01:00
attila
5c933d4c4e macOS OpenGL: Use display refresh rate when rate limiting swapBuffers() 2021-09-10 17:47:00 +02:00
ed
f0002845d5 OpenGL: Correctly reset repaintEvent 2021-09-08 11:22:18 +01:00
reuk
80239b4d50
OpenGL: Only load the core API by default
See the breaking changes document for more details.
2021-08-11 14:31:48 +01:00
reuk
90ad1877af
OpenGL: Only use vertex arrays if the GL version is greater or equal to 3 2021-07-14 14:49:15 +01:00
reuk
d64c4277b4
OpenGL: Reinstate ifdef which was removed accidentally 2021-07-14 14:47:56 +01:00
reuk
280d97eb79 OpenGL: Check at runtime whether non-power-of-two textures are supported 2021-07-05 12:21:36 +01:00
reuk
f0b515cc73 OpenGL: Fix shader compilation on Ubuntu 18.04
Previously, we were always adding a #version 150 directive to shaders
when the GLSL version was higher than 1.2, which could cause compilation
to fail on platforms with GLSL versions between 1.2 and 1.5.
2021-07-05 12:21:36 +01:00
ed
dc61bd63e7 macOS: Manually reset repaint WaitableEvent when using CVDisplayLink 2021-06-15 10:15:02 +01:00
reuk
7ac6911ccc
Windows: Fix clang/gnu compiler warnings 2021-06-03 17:30:44 +01:00
reuk
28882b788a
OpenGL: Add missing function annotations 2021-05-27 16:06:22 +01:00
reuk
31a7c62baf
Windows: Fix and suppress some analysis warnings
This fixes warnings that are emitted when building with the `-analyze`
flag enabled.
2021-05-26 15:34:26 +01:00
reuk
54423f6583
OpenGL: Add GLEW-inspired dynamic function loading 2021-05-26 11:23:49 +01:00
Tom Poole
79fbde7099 Added preliminary support for FreeBSD 2021-03-29 14:16:46 +01:00
ed
b7e28541ca Replaced deprecated Displays methods 2020-10-27 12:38:59 +00:00