From 68f9084d9efc0018421d178920261de129301ff1 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 7 Nov 2019 23:24:51 -0500 Subject: [PATCH] Fixes timing of wrap. --- Outputs/OpenGL/ScanTarget.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Outputs/OpenGL/ScanTarget.cpp b/Outputs/OpenGL/ScanTarget.cpp index 33443532e..606c57531 100644 --- a/Outputs/OpenGL/ScanTarget.cpp +++ b/Outputs/OpenGL/ScanTarget.cpp @@ -228,11 +228,8 @@ void ScanTarget::end_data(size_t actual_length) { &write_area_texture_[size_t(write_pointers_.write_area) * data_type_size_], data_type_size_); - // The write area was allocated in the knowledge that there's sufficient - // distance left on the current line, but there's a risk of exactly filling - // the final line, in which case this should wrap back to 0. + // Advance to the end of the current run. write_pointers_.write_area += actual_length + 1; - write_pointers_.write_area %= (write_area_texture_.size() / data_type_size_); // Also bookend the end. memcpy( @@ -240,6 +237,11 @@ void ScanTarget::end_data(size_t actual_length) { &write_area_texture_[size_t(write_pointers_.write_area - 2) * data_type_size_], data_type_size_); + // The write area was allocated in the knowledge that there's sufficient + // distance left on the current line, but there's a risk of exactly filling + // the final line, in which case this should wrap back to 0. + write_pointers_.write_area %= (write_area_texture_.size() / data_type_size_); + // Record that no further end_data calls are expected. data_is_allocated_ = false; }