From a781c3eb4d20f8ce5408ed637732c96d1349d451 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 22 Sep 2020 22:13:37 -0400 Subject: [PATCH 1/2] Resolves thread-unsafe access of `_view.bounds`. --- OSBindings/Mac/Clock Signal/ScanTarget/CSScanTarget.mm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/OSBindings/Mac/Clock Signal/ScanTarget/CSScanTarget.mm b/OSBindings/Mac/Clock Signal/ScanTarget/CSScanTarget.mm index 7076afa80..79d1bc021 100644 --- a/OSBindings/Mac/Clock Signal/ScanTarget/CSScanTarget.mm +++ b/OSBindings/Mac/Clock Signal/ScanTarget/CSScanTarget.mm @@ -278,8 +278,9 @@ using BufferingScanTarget = Outputs::Display::BufferingScanTarget; size_t _chromaKernelSize; std::atomic _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); From 9447aa38be9e4d346f4333b54eb8c2dc1d51da9f Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 22 Sep 2020 22:13:54 -0400 Subject: [PATCH 2/2] Removes debugging `printf`. --- Components/6522/Implementation/6522Implementation.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Components/6522/Implementation/6522Implementation.hpp b/Components/6522/Implementation/6522Implementation.hpp index 913ea4ee4..3e23422eb 100644 --- a/Components/6522/Implementation/6522Implementation.hpp +++ b/Components/6522/Implementation/6522Implementation.hpp @@ -120,8 +120,6 @@ template void MOS6522::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()) {