Skip to content

Commit

Permalink
Better Framebuffer sizing
Browse files Browse the repository at this point in the history
  • Loading branch information
XITRIX committed Dec 16, 2024
1 parent fdb57c9 commit 58675d1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions Submodules/UIKit/include/platforms/ios/SkiaCtx_ios.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class SkiaCtx_ios : public SkiaCtx_sdlBase {
sk_sp<SkSurface> getBackbufferSurface() override;

float getScaleFactor() override;
NXSize getSize() override;

sk_sp<GrDirectContext> directContext() override { return context; }

Expand Down
5 changes: 4 additions & 1 deletion Submodules/UIKit/lib/UIApplicationMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ bool applicationRunLoop() {
auto scale = SkiaCtx::_main->getScaleFactor();
canvas->scale(scale, scale);

keyWindow->setFrame({ NXPoint::zero, SkiaCtx::_main->getSize() } );
UIView::animate(0.3, [keyWindow]() {
keyWindow->setFrame({ NXPoint::zero, SkiaCtx::_main->getSize() } );
});

keyWindow->layer()->presentationOrSelf()->skiaRender(canvas);
canvas->restore();

Expand Down
9 changes: 9 additions & 0 deletions Submodules/UIKit/lib/platforms/apple/ios/SkiaCtx_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
context = GrDirectContexts::MakeGL(interface);
}

NXSize SkiaCtx_ios::getSize() {
auto window = UIApplication.sharedApplication.keyWindow;
auto layer = window.layer.presentationLayer;
if (layer == NULL) layer = window.layer;
NXSize size = { layer.bounds.size.width, layer.bounds.size.height };
// printf("Size: %f | %f\n", layer.bounds.size.width, layer.bounds.size.height);
return size;
}

float SkiaCtx_ios::getScaleFactor() {
return UIApplication.sharedApplication.keyWindow.traitCollection.displayScale;
}
Expand Down

0 comments on commit 58675d1

Please sign in to comment.