mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Switches to using the announce
is_visible
flag to spot line ends.
This commit is contained in:
parent
e9d9ff0da0
commit
c392c819c1
@ -223,53 +223,49 @@ void ScanTarget::submit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScanTarget::announce(Event event, bool is_visible, const Outputs::Display::ScanTarget::Scan::EndPoint &location) {
|
void ScanTarget::announce(Event event, bool is_visible, const Outputs::Display::ScanTarget::Scan::EndPoint &location) {
|
||||||
switch(event) {
|
if(event == ScanTarget::Event::EndVerticalRetrace) {
|
||||||
default: break;
|
is_first_in_frame_ = true;
|
||||||
case ScanTarget::Event::BeginHorizontalRetrace:
|
frame_was_complete_ = true;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: any lines that include any portion of vertical sync should be hidden.
|
if(output_is_visible_ == is_visible) return;
|
||||||
// (maybe set a flag and zero out the line coordinates?)
|
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() {
|
void ScanTarget::setup_pipeline() {
|
||||||
|
@ -55,6 +55,8 @@ class ScanTarget: public Outputs::Display::ScanTarget {
|
|||||||
void submit() override;
|
void submit() override;
|
||||||
void announce(Event event, bool is_visible, const Outputs::Display::ScanTarget::Scan::EndPoint &location) 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,
|
// Extends the definition of a Scan to include two extra fields,
|
||||||
// relevant to the way that this scan target processes video.
|
// relevant to the way that this scan target processes video.
|
||||||
struct Scan {
|
struct Scan {
|
||||||
|
Loading…
Reference in New Issue
Block a user