Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/skia/apple/MetalWindowContext.mm
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,16 @@
}

id<MTLCommandBuffer> commandBuffer([_commandQueue commandBuffer]);
[commandBuffer presentDrawable:_currentDrawable];
[commandBuffer commit];
if (_layer.presentsWithTransaction) {
// Present inside the current Core Animation transaction: commit, wait
// until the command buffer is scheduled, then present the drawable
// directly (CAMetalLayer.presentsWithTransaction documentation).
[commandBuffer commit];
[commandBuffer waitUntilScheduled];
[_currentDrawable present];
} else {
[commandBuffer presentDrawable:_currentDrawable];
[commandBuffer commit];
}
_skSurface = nullptr;
}
18 changes: 18 additions & 0 deletions packages/skia/apple/SkiaUIView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,24 @@ - (void)drawRect:(CGRect)rect {
}
}

#if !TARGET_OS_OSX
- (void)didMoveToWindow {
[super didMoveToWindow];
// A frame drawn while the view was detached from the window (an inactive
// tab, a covered screen) is never presented, so redraw the current picture
// as soon as the view is back in a window instead of showing the last
// frame that was presented before it left. Present it inside the current
// Core Animation transaction so it is on screen in the same frame the view
// appears rather than one later.
if (self.window != nil && _impl != nullptr) {
CAMetalLayer *layer = (CAMetalLayer *)_impl->getLayer();
layer.presentsWithTransaction = YES;
_impl->getDrawView()->redraw();
layer.presentsWithTransaction = NO;
}
}
#endif // !TARGET_OS_OSX

#pragma mark Layout

- (void)layoutSubviews {
Expand Down
Loading