1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-25 18:30:07 +00:00

Vend data pointers.

This commit is contained in:
Thomas Harte 2022-07-02 21:58:23 -04:00
parent 6a8c792c63
commit 3179d0d963

View File

@ -11,6 +11,8 @@
#include "../ScanTarget.hpp"
#include <array>
namespace Outputs {
namespace Display {
namespace Software {
@ -27,14 +29,29 @@ class ScanTarget: public Outputs::Display::ScanTarget {
void set_modals(Modals) override;
Scan *begin_scan() override { return &current_scan_; }
uint8_t *begin_data(size_t, size_t) override { return nullptr; }
uint8_t *begin_data(size_t, size_t required_alignment) override {
// Achieve required alignment.
sample_buffer_pointer_ += (required_alignment - sample_buffer_pointer_) & (required_alignment - 1);
// Return target.
return &sample_buffer_[sample_buffer_pointer_];
}
void end_data(size_t actual_length) override {
sample_buffer_pointer_ += actual_length;
}
//
void submit() final;
template <InputDataType, DisplayType, ColourSpace> void process();
// Temporaries; each scan is rasterised synchronously and upon
// completion, so the storage here is a lot simpler than for
// the GPU-powered scan targets.
Scan current_scan_;
std::array<uint8_t, 2048> sample_buffer_;
size_t sample_buffer_pointer_ = 0;
};