Skip to content

Commit 624b164

Browse files
authored
Bump Rive (#52)
1 parent cff80e7 commit 624b164

File tree

783 files changed

+85742
-116419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

783 files changed

+85742
-116419
lines changed

.github/workflows/build_linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ env:
2828
INSTALL_DEPS: >-
2929
libasound2-dev libjack-jackd2-dev ladspa-sdk libcurl4-openssl-dev libfreetype6-dev
3030
libx11-dev libxcomposite-dev libxcursor-dev libxcursor-dev libxext-dev libxi-dev libxinerama-dev
31-
libxrandr-dev libxrender-dev libglu1-mesa-dev mesa-common-dev
31+
libxrandr-dev libxrender-dev libglu1-mesa-dev libegl1-mesa-dev mesa-common-dev
3232
3333
jobs:
3434
configure:

cmake/yup_modules.cmake

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ function (yup_add_module module_path module_group)
328328

329329
# ==== Assign Configurations Dynamically
330330
set (global_properties "dependencies|defines|options|searchpaths")
331-
set (platform_properties "^(.*)Deps$|^(.*)Defines$|^(.*)Libs$|^(.*)Frameworks$|^(.*)WeakFrameworks$|^(.*)Options$|^(.*)Packages$|^(.*)Searchpaths$")
331+
set (platform_properties "^(.*)Deps$|^(.*)Defines$|^(.*)Libs$|^(.*)Frameworks$|^(.*)WeakFrameworks$|^(.*)Options$|^(.*)Packages$|^(.*)Searchpaths$|^(.*)CppStandard$")
332332

333333
set (parsed_config "")
334334
foreach (module_config ${module_configs})
@@ -356,6 +356,10 @@ function (yup_add_module module_path module_group)
356356

357357
# ==== Setup Platform-Specific Configurations
358358
if (YUP_PLATFORM_IOS)
359+
if (module_appleCppStandard)
360+
set (module_cpp_standard "${module_appleCppStandard}")
361+
endif()
362+
359363
if (PLATFORM MATCHES "^(SIMULATOR.*)$")
360364
list (APPEND module_dependencies ${module_iosSimDeps})
361365
list (APPEND module_defines ${module_iosSimDefines})
@@ -365,6 +369,9 @@ function (yup_add_module module_path module_group)
365369
list (APPEND module_searchpaths ${module_iosSimSearchpaths})
366370
_yup_module_prepare_frameworks ("${module_iosSimFrameworks}" "${module_iosSimWeakFrameworks}" module_iosSimframeworks)
367371
list (APPEND module_frameworks ${module_iosSimframeworks})
372+
if (module_iosSimCppStandard)
373+
set (module_cpp_standard "${module_iosSimCppStandard}")
374+
endif()
368375
else()
369376
list (APPEND module_dependencies ${module_iosDeps})
370377
list (APPEND module_defines ${module_iosDefines})
@@ -374,6 +381,9 @@ function (yup_add_module module_path module_group)
374381
list (APPEND module_searchpaths ${module_iosSearchpaths})
375382
_yup_module_prepare_frameworks ("${module_iosFrameworks}" "${module_iosWeakFrameworks}" module_iosFrameworks)
376383
list (APPEND module_frameworks ${module_iosFrameworks})
384+
if (module_iosCppStandard)
385+
set (module_cpp_standard "${module_iosCppStandard}")
386+
endif()
377387
endif()
378388

379389
list (APPEND module_dependencies ${module_appleDeps})
@@ -386,6 +396,9 @@ function (yup_add_module module_path module_group)
386396
list (APPEND module_frameworks ${module_appleFrameworks})
387397

388398
elseif (YUP_PLATFORM_OSX)
399+
if (module_appleCppStandard)
400+
set (module_cpp_standard "${module_appleCppStandard}")
401+
endif()
389402
list (APPEND module_dependencies ${module_osxDeps})
390403
list (APPEND module_dependencies ${module_appleDeps})
391404
list (APPEND module_defines ${module_osxDefines})
@@ -402,8 +415,14 @@ function (yup_add_module module_path module_group)
402415
list (APPEND module_frameworks ${module_osxFrameworks})
403416
_yup_module_prepare_frameworks ("${module_appleFrameworks}" "${module_appleWeakFrameworks}" module_appleFrameworks)
404417
list (APPEND module_frameworks ${module_appleFrameworks})
418+
if (module_osxCppStandard)
419+
set (module_cpp_standard "${module_osxCppStandard}")
420+
endif()
405421

406422
elseif (YUP_PLATFORM_LINUX)
423+
if (module_linuxCppStandard)
424+
set (module_cpp_standard "${module_linuxCppStandard}")
425+
endif()
407426
list (APPEND module_dependencies ${module_linuxDeps})
408427
list (APPEND module_defines ${module_linuxDefines})
409428
list (APPEND module_options ${module_linuxOptions})
@@ -416,6 +435,9 @@ function (yup_add_module module_path module_group)
416435
endforeach()
417436

418437
elseif (YUP_PLATFORM_EMSCRIPTEN)
438+
if (module_wasmCppStandard)
439+
set (module_cpp_standard "${module_wasmCppStandard}")
440+
endif()
419441
list (APPEND module_dependencies ${module_wasmDeps})
420442
list (APPEND module_defines ${module_wasmDefines})
421443
list (APPEND module_options ${module_wasmOptions})
@@ -424,6 +446,9 @@ function (yup_add_module module_path module_group)
424446
list (APPEND module_searchpaths ${module_wasmSearchpaths})
425447

426448
elseif (YUP_PLATFORM_ANDROID)
449+
if (module_androidCppStandard)
450+
set (module_cpp_standard "${module_androidCppStandard}")
451+
endif()
427452
list (APPEND module_dependencies ${module_androidDeps})
428453
list (APPEND module_defines ${module_androidDefines})
429454
list (APPEND module_options ${module_androidOptions})
@@ -432,15 +457,25 @@ function (yup_add_module module_path module_group)
432457
list (APPEND module_searchpaths ${module_androidSearchpaths})
433458

434459
elseif (YUP_PLATFORM_MSFT)
460+
if (module_msftCppStandard)
461+
set (module_cpp_standard "${module_msftCppStandard}")
462+
endif()
435463
list (APPEND module_dependencies ${module_windowsDeps})
436464
list (APPEND module_defines ${module_windowsDefines})
437465
list (APPEND module_options ${module_windowsOptions})
438466
_yup_resolve_variable_paths ("${module_windowsSearchpaths}" module_windowsSearchpaths)
439467
list (APPEND module_searchpaths ${module_windowsSearchpaths})
468+
440469
if (MINGW)
441470
list (APPEND module_libs ${module_mingwLibs})
471+
if (module_mingwCppStandard)
472+
set (module_cpp_standard "${module_mingwCppStandard}")
473+
endif()
442474
else()
443475
list (APPEND module_libs ${module_windowsLibs})
476+
if (module_windowsCppStandard)
477+
set (module_cpp_standard "${module_windowsCppStandard}")
478+
endif()
444479
endif()
445480
endif()
446481

modules/yup_graphics/context/yup_GraphicsContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class JUCE_API GraphicsContext
5959
bool synchronousShaderCompilations = false; ///< Controls whether shader compilations are done synchronously.
6060
bool enableReadPixels = false; ///< Enables reading pixels directly from the framebuffer.
6161
bool disableRasterOrdering = false; ///< Disables specific raster ordering features for performance.
62+
bool allowHeadlessRendering = false; ///< Allows rendering without a visible window (headless mode).
6263
LoaderFunction loaderFunction = nullptr; ///< Loader function (used by GL/Vulkan).
6364
};
6465

modules/yup_graphics/fonts/yup_StyledText.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ void StyledText::update()
303303
maxSize.getWidth(),
304304
ellipsisLine == lineIndex,
305305
isEllipsisLineLast,
306-
&ellipsisRun));
306+
&ellipsisRun,
307+
y));
307308
}
308309

309310
float x = line.startX;

modules/yup_graphics/native/yup_GraphicsContext_d3d.cpp

Lines changed: 71 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121

2222
#if YUP_RIVE_USE_D3D
2323
#include "rive/renderer/rive_renderer.hpp"
24-
#include "rive/renderer/d3d/render_context_d3d_impl.hpp"
25-
#include "rive/renderer/d3d/d3d11.hpp"
24+
#include "rive/renderer/d3d11/render_context_d3d_impl.hpp"
25+
#include "rive/renderer/d3d11/d3d11.hpp"
26+
#include <dxgi1_2.h>
2627

2728
namespace yup
2829
{
@@ -33,85 +34,115 @@ class LowLevelRenderContextD3D : public GraphicsContext
3334
LowLevelRenderContextD3D (ComPtr<IDXGIFactory2> d3dFactory,
3435
ComPtr<ID3D11Device> gpu,
3536
ComPtr<ID3D11DeviceContext> gpuContext,
36-
const rive::gpu::RenderContextD3DImpl::ContextOptions& contextOptions)
37-
: m_d3dFactory (std::move (d3dFactory))
37+
bool isHeadless,
38+
const rive::gpu::D3DContextOptions& contextOptions)
39+
: m_isHeadless (isHeadless)
40+
, m_d3dFactory (std::move (d3dFactory))
3841
, m_gpu (std::move (gpu))
3942
, m_gpuContext (std::move (gpuContext))
40-
, m_plsContext (rive::gpu::RenderContextD3DImpl::MakeContext (m_gpu, m_gpuContext, contextOptions))
43+
, m_renderContext (rive::gpu::RenderContextD3DImpl::MakeContext (m_gpu, m_gpuContext, contextOptions))
4144
{
4245
}
4346

4447
float dpiScale (void*) const override { return 1.0f; }
4548

46-
rive::Factory* factory() override { return m_plsContext.get(); }
49+
rive::Factory* factory() override { return m_renderContext.get(); }
4750

48-
rive::gpu::RenderContext* renderContext() override { return m_plsContext.get(); }
51+
rive::gpu::RenderContext* renderContext() override { return m_renderContext.get(); }
4952

5053
rive::gpu::RenderTarget* renderTarget() override { return m_renderTarget.get(); }
5154

5255
void onSizeChanged (void* window, int width, int height, uint32_t sampleCount) override
5356
{
54-
m_swapchain.Reset();
55-
56-
DXGI_SWAP_CHAIN_DESC1 scd {};
57-
scd.Width = width;
58-
scd.Height = height;
59-
scd.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
60-
scd.SampleDesc.Count = 1;
61-
scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_UNORDERED_ACCESS;
62-
scd.BufferCount = 2;
63-
scd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
64-
65-
VERIFY_OK (m_d3dFactory->CreateSwapChainForHwnd (m_gpu.Get(),
66-
(HWND) window,
67-
&scd,
68-
nullptr,
69-
nullptr,
70-
m_swapchain.ReleaseAndGetAddressOf()));
71-
72-
auto plsContextImpl = m_plsContext->static_impl_cast<rive::gpu::RenderContextD3DImpl>();
73-
m_renderTarget = plsContextImpl->makeRenderTarget (width, height);
57+
if (! m_isHeadless)
58+
{
59+
m_swapchain.Reset();
60+
61+
DXGI_SWAP_CHAIN_DESC1 scd {};
62+
scd.Width = width;
63+
scd.Height = height;
64+
scd.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
65+
scd.SampleDesc.Count = 1;
66+
scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_UNORDERED_ACCESS;
67+
scd.BufferCount = 2;
68+
scd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
69+
70+
VERIFY_OK (m_d3dFactory->CreateSwapChainForHwnd (m_gpu.Get(),
71+
(HWND) window,
72+
&scd,
73+
nullptr,
74+
nullptr,
75+
m_swapchain.ReleaseAndGetAddressOf()));
76+
}
77+
else
78+
{
79+
D3D11_TEXTURE2D_DESC desc {};
80+
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
81+
desc.MipLevels = 1;
82+
desc.Width = width;
83+
desc.Height = height;
84+
desc.SampleDesc.Count = 1;
85+
desc.ArraySize = 1;
86+
desc.Usage = D3D11_USAGE_DEFAULT;
87+
desc.BindFlags = D3D11_BIND_RENDER_TARGET;
88+
desc.CPUAccessFlags = 0;
89+
desc.MiscFlags = 0;
90+
VERIFY_OK (m_gpu->CreateTexture2D (&desc, nullptr, &m_headlessDrawTexture));
91+
}
92+
93+
auto renderContextImpl = m_renderContext->static_impl_cast<rive::gpu::RenderContextD3DImpl>();
94+
m_renderTarget = renderContextImpl->makeRenderTarget (width, height);
7495
m_readbackTexture = nullptr;
7596
}
7697

7798
std::unique_ptr<rive::Renderer> makeRenderer (int width, int height) override
7899
{
79-
return std::make_unique<rive::RiveRenderer> (m_plsContext.get());
100+
return std::make_unique<rive::RiveRenderer> (m_renderContext.get());
80101
}
81102

82103
void begin (const rive::gpu::RenderContext::FrameDescriptor& frameDescriptor) override
83104
{
84-
m_plsContext->beginFrame (frameDescriptor);
105+
m_renderContext->beginFrame (frameDescriptor);
85106
}
86107

87108
void end (void*) override
88109
{
89110
if (m_renderTarget->targetTexture() == nullptr)
90111
{
91-
ComPtr<ID3D11Texture2D> backbuffer;
92-
VERIFY_OK (m_swapchain->GetBuffer (0,
93-
__uuidof (ID3D11Texture2D),
94-
reinterpret_cast<void**> (backbuffer.ReleaseAndGetAddressOf())));
95-
96-
m_renderTarget->setTargetTexture (backbuffer);
112+
if (m_isHeadless)
113+
{
114+
m_renderTarget->setTargetTexture (m_headlessDrawTexture);
115+
}
116+
else
117+
{
118+
ComPtr<ID3D11Texture2D> backbuffer;
119+
VERIFY_OK (m_swapchain->GetBuffer (0,
120+
__uuidof (ID3D11Texture2D),
121+
reinterpret_cast<void**> (backbuffer.ReleaseAndGetAddressOf())));
122+
123+
m_renderTarget->setTargetTexture (backbuffer);
124+
}
97125
}
98126

99127
rive::gpu::RenderContext::FlushResources flushDesc;
100128
flushDesc.renderTarget = m_renderTarget.get();
101-
m_plsContext->flush (flushDesc);
129+
m_renderContext->flush (flushDesc);
102130

103-
m_swapchain->Present (0, 0);
131+
if (! m_isHeadless)
132+
m_swapchain->Present (0, 0);
104133

105134
m_renderTarget->setTargetTexture (nullptr);
106135
}
107136

108137
private:
138+
const bool m_isHeadless;
109139
ComPtr<IDXGIFactory2> m_d3dFactory;
110140
ComPtr<ID3D11Device> m_gpu;
111141
ComPtr<ID3D11DeviceContext> m_gpuContext;
112142
ComPtr<IDXGISwapChain1> m_swapchain;
113143
ComPtr<ID3D11Texture2D> m_readbackTexture;
114-
std::unique_ptr<rive::gpu::RenderContext> m_plsContext;
144+
ComPtr<ID3D11Texture2D> m_headlessDrawTexture;
145+
std::unique_ptr<rive::gpu::RenderContext> m_renderContext;
115146
rive::rcp<rive::gpu::RenderTargetD3D> m_renderTarget;
116147
};
117148

@@ -123,7 +154,7 @@ std::unique_ptr<GraphicsContext> juce_constructDirect3DGraphicsContext (Graphics
123154

124155
ComPtr<IDXGIAdapter> adapter;
125156
DXGI_ADAPTER_DESC adapterDesc {};
126-
rive::gpu::RenderContextD3DImpl::ContextOptions contextOptions;
157+
rive::gpu::D3DContextOptions contextOptions;
127158

128159
if (fiddleOptions.disableRasterOrdering)
129160
{
@@ -168,6 +199,7 @@ std::unique_ptr<GraphicsContext> juce_constructDirect3DGraphicsContext (Graphics
168199
std::move (factory),
169200
std::move (gpu),
170201
std::move (gpuContext),
202+
fiddleOptions.allowHeadlessRendering,
171203
contextOptions);
172204
}
173205

0 commit comments

Comments
 (0)