mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-23 03:32:32 +00:00
Merge pull request #838 from TomHarte/MTKViewRace
Resolves a minor MTKView main-thread race condition.
This commit is contained in:
commit
669d8e64ab
@ -120,8 +120,6 @@ template <typename T> void MOS6522<T>::write(int address, uint8_t value) {
|
||||
registers_.auxiliary_control = value;
|
||||
evaluate_cb2_output();
|
||||
|
||||
printf("Shift mode: %d\n", shift_mode());
|
||||
|
||||
// This is a bit of a guess: reset the timer-based PB7 output to its default high level
|
||||
// any timer that timer-linked PB7 output is disabled.
|
||||
if(!timer1_is_controlling_pb7()) {
|
||||
|
@ -278,8 +278,9 @@ using BufferingScanTarget = Outputs::Display::BufferingScanTarget;
|
||||
size_t _chromaKernelSize;
|
||||
std::atomic<bool> _isUsingSupersampling;
|
||||
|
||||
// The output view.
|
||||
// The output view and its aspect ratio.
|
||||
__weak MTKView *_view;
|
||||
CGFloat _viewAspectRatio; // To avoid accessing .bounds away from the main thread.
|
||||
}
|
||||
|
||||
- (nonnull instancetype)initWithView:(nonnull MTKView *)view {
|
||||
@ -357,6 +358,7 @@ using BufferingScanTarget = Outputs::Display::BufferingScanTarget;
|
||||
@param size New drawable size in pixels
|
||||
*/
|
||||
- (void)mtkView:(nonnull MTKView *)view drawableSizeWillChange:(CGSize)size {
|
||||
_viewAspectRatio = size.width / size.height;
|
||||
[self setAspectRatio];
|
||||
|
||||
@synchronized(self) {
|
||||
@ -522,7 +524,6 @@ using BufferingScanTarget = Outputs::Display::BufferingScanTarget;
|
||||
|
||||
- (void)setAspectRatio {
|
||||
const auto modals = _scanTarget.modals();
|
||||
const auto viewAspectRatio = (_view.bounds.size.width / _view.bounds.size.height);
|
||||
simd::float3x3 sourceToDisplay{1.0f};
|
||||
|
||||
// The starting coordinate space is [0, 1].
|
||||
@ -550,7 +551,7 @@ using BufferingScanTarget = Outputs::Display::BufferingScanTarget;
|
||||
// Determine the correct zoom level. This is a combination of (i) the necessary horizontal stretch to produce a proper
|
||||
// aspect ratio; and (ii) the necessary zoom from there to either fit the visible area width or height as per a decision
|
||||
// on letterboxing or pillarboxing.
|
||||
const float aspectRatioStretch = float(modals.aspect_ratio / viewAspectRatio);
|
||||
const float aspectRatioStretch = float(modals.aspect_ratio / _viewAspectRatio);
|
||||
const float fitWidthZoom = 1.0f / (float(modals.visible_area.size.width) * aspectRatioStretch);
|
||||
const float fitHeightZoom = 1.0f / float(modals.visible_area.size.height);
|
||||
const float zoom = std::min(fitWidthZoom, fitHeightZoom);
|
||||
|
Loading…
Reference in New Issue
Block a user