From c392c819c118f3e69ed5a79bcf0002966f83333c Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 6 Jan 2019 13:37:34 -0500 Subject: [PATCH] Switches to using the `announce` `is_visible` flag to spot line ends. --- Outputs/OpenGL/ScanTarget.cpp | 86 +++++++++++++++++------------------ Outputs/OpenGL/ScanTarget.hpp | 2 + 2 files changed, 43 insertions(+), 45 deletions(-) diff --git a/Outputs/OpenGL/ScanTarget.cpp b/Outputs/OpenGL/ScanTarget.cpp index ce9440dbb..0eab6bff8 100644 --- a/Outputs/OpenGL/ScanTarget.cpp +++ b/Outputs/OpenGL/ScanTarget.cpp @@ -223,53 +223,49 @@ void ScanTarget::submit() { } void ScanTarget::announce(Event event, bool is_visible, const Outputs::Display::ScanTarget::Scan::EndPoint &location) { - switch(event) { - default: break; - case ScanTarget::Event::BeginHorizontalRetrace: - if(active_line_) { - active_line_->end_points[1].x = location.x; - active_line_->end_points[1].y = location.y; - } - break; - case ScanTarget::Event::EndHorizontalRetrace: { - // Commit the most recent line only if any scans fell on it. - // Otherwise there's no point outputting it, it'll contribute nothing. - if(provided_scans_) { - // Store metadata if concluding a previous line. - if(active_line_) { - line_metadata_buffer_[size_t(write_pointers_.line)].is_first_in_frame = is_first_in_frame_; - line_metadata_buffer_[size_t(write_pointers_.line)].previous_frame_was_complete = frame_was_complete_; - is_first_in_frame_ = false; - } - - const auto read_pointers = read_pointers_.load(); - - // Attempt to allocate a new line; note allocation failure if necessary. - const auto next_line = uint16_t((write_pointers_.line + 1) % LineBufferHeight); - if(next_line == read_pointers.line) { - allocation_has_failed_ = true; - active_line_ = nullptr; - } else { - write_pointers_.line = next_line; - active_line_ = &line_buffer_[size_t(write_pointers_.line)]; - } - provided_scans_ = 0; - } - - if(active_line_) { - active_line_->end_points[0].x = location.x; - active_line_->end_points[0].y = location.y; - active_line_->line = write_pointers_.line; - } - } break; - case ScanTarget::Event::EndVerticalRetrace: - is_first_in_frame_ = true; - frame_was_complete_ = true; - break; + if(event == ScanTarget::Event::EndVerticalRetrace) { + is_first_in_frame_ = true; + frame_was_complete_ = true; } - // TODO: any lines that include any portion of vertical sync should be hidden. - // (maybe set a flag and zero out the line coordinates?) + if(output_is_visible_ == is_visible) return; + if(is_visible) { + // Commit the most recent line only if any scans fell on it. + // Otherwise there's no point outputting it, it'll contribute nothing. + if(provided_scans_) { + // Store metadata if concluding a previous line. + if(active_line_) { + line_metadata_buffer_[size_t(write_pointers_.line)].is_first_in_frame = is_first_in_frame_; + line_metadata_buffer_[size_t(write_pointers_.line)].previous_frame_was_complete = frame_was_complete_; + is_first_in_frame_ = false; + } + + const auto read_pointers = read_pointers_.load(); + + // Attempt to allocate a new line; note allocation failure if necessary. + const auto next_line = uint16_t((write_pointers_.line + 1) % LineBufferHeight); + if(next_line == read_pointers.line) { + allocation_has_failed_ = true; + active_line_ = nullptr; + } else { + write_pointers_.line = next_line; + active_line_ = &line_buffer_[size_t(write_pointers_.line)]; + } + provided_scans_ = 0; + } + + if(active_line_) { + active_line_->end_points[0].x = location.x; + active_line_->end_points[0].y = location.y; + active_line_->line = write_pointers_.line; + } + } else { + if(active_line_) { + active_line_->end_points[1].x = location.x; + active_line_->end_points[1].y = location.y; + } + } + output_is_visible_ = is_visible; } void ScanTarget::setup_pipeline() { diff --git a/Outputs/OpenGL/ScanTarget.hpp b/Outputs/OpenGL/ScanTarget.hpp index db549a2d1..22ad7c390 100644 --- a/Outputs/OpenGL/ScanTarget.hpp +++ b/Outputs/OpenGL/ScanTarget.hpp @@ -55,6 +55,8 @@ class ScanTarget: public Outputs::Display::ScanTarget { void submit() override; void announce(Event event, bool is_visible, const Outputs::Display::ScanTarget::Scan::EndPoint &location) override; + bool output_is_visible_ = false; + // Extends the definition of a Scan to include two extra fields, // relevant to the way that this scan target processes video. struct Scan {