Skip to content

Commit

Permalink
Use trait collection for display scale over window scene
Browse files Browse the repository at this point in the history
Under certain circumstances, e.g "off-screen rendering" (i.e a Rive view not added to a view hierarchy), there is no window scene available, but there are still trait collections available. When using window scene, Rive would determine it is unable to draw because there is no window scene. However, using the trait collection allows Rive to continue drawing despite not being added to a view hierarchy. This allows manual calls to `draw` to continue when the view is _not_ added to a view hierarchy.

Diffs=
13939097af Use trait collection for display scale over window scene (#8472)

Co-authored-by: David Skuza <[email protected]>
  • Loading branch information
dskuza and dskuza committed Nov 4, 2024
1 parent 2c0ac3c commit 505d6fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1d5a58004181e12fddef56e9c2a56a8d14fa451a
13939097af12ef2fa9dbd07835eed8be99f1ff08
6 changes: 3 additions & 3 deletions Source/Renderer/rive_renderer_view.mm
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ - (void)drawInRect:(CGRect)rect
{
CGFloat scale = -1;
#if TARGET_OS_IPHONE
UIWindowScene* scene = [self.window windowScene];
if (scene != nil)
CGFloat displayScale = self.traitCollection.displayScale;
if (displayScale > 0)
{
scale = scene.screen.scale;
scale = displayScale;
}
#else
NSWindow* window = self.window;
Expand Down

0 comments on commit 505d6fe

Please sign in to comment.