summaryrefslogtreecommitdiff
path: root/backend/genesys/image_buffer.h
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2020-09-10 19:11:27 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2020-09-10 19:11:27 +0200
commit7e9455b3b15671ff99ed168638c405e2acedb6df (patch)
tree444e59ece236e09dc153f665e42160aeb0208c24 /backend/genesys/image_buffer.h
parentbc8a517abd2e11e1435f4ef042cfcc8648b62ef7 (diff)
parentbce41b3c37c2a68e7dab234ce0247755a61ceb40 (diff)
Merge branch 'release/debian/1.0.31-1_experimental1' into masterdebian/1.0.31-1_experimental1
Diffstat (limited to 'backend/genesys/image_buffer.h')
-rw-r--r--backend/genesys/image_buffer.h65
1 files changed, 13 insertions, 52 deletions
diff --git a/backend/genesys/image_buffer.h b/backend/genesys/image_buffer.h
index 43c3eb7..1910244 100644
--- a/backend/genesys/image_buffer.h
+++ b/backend/genesys/image_buffer.h
@@ -56,72 +56,33 @@ class ImageBuffer
{
public:
using ProducerCallback = std::function<bool(std::size_t size, std::uint8_t* out_data)>;
+ static constexpr std::uint64_t BUFFER_SIZE_UNSET = std::numeric_limits<std::uint64_t>::max();
ImageBuffer() {}
ImageBuffer(std::size_t size, ProducerCallback producer);
- std::size_t size() const { return size_; }
- std::size_t available() const { return size_ - buffer_offset_; }
+ std::size_t available() const { return curr_size_ - buffer_offset_; }
- bool get_data(std::size_t size, std::uint8_t* out_data);
-
-private:
- ProducerCallback producer_;
- std::size_t size_ = 0;
-
- std::size_t buffer_offset_ = 0;
- std::vector<std::uint8_t> buffer_;
-};
-
-class FakeBufferModel
-{
-public:
- FakeBufferModel() {}
-
- void push_step(std::size_t buffer_size, std::size_t row_bytes);
-
- std::size_t available_space() const;
-
- void simulate_read(std::size_t size);
+ // allows adjusting the amount of data left so that we don't do a full size read from the
+ // producer on the last iteration. Set to BUFFER_SIZE_UNSET to ignore buffer size.
+ std::uint64_t remaining_size() const { return remaining_size_; }
+ void set_remaining_size(std::uint64_t bytes) { remaining_size_ = bytes; }
-private:
- std::vector<std::size_t> sizes_;
- std::vector<std::size_t> available_sizes_;
- std::vector<std::size_t> row_bytes_;
-};
-
-// This class is similar to ImageBuffer, but preserves historical peculiarities of buffer handling
-// in the backend to preserve exact behavior
-class ImageBufferGenesysUsb
-{
-public:
- using ProducerCallback = std::function<void(std::size_t size, std::uint8_t* out_data)>;
-
- ImageBufferGenesysUsb() {}
- ImageBufferGenesysUsb(std::size_t total_size, const FakeBufferModel& buffer_model,
- ProducerCallback producer);
-
- std::size_t remaining_size() const { return remaining_size_; }
-
- void set_remaining_size(std::size_t bytes) { remaining_size_ = bytes; }
-
- std::size_t available() const { return buffer_end_ - buffer_offset_; }
+ // May be used to force the last read to be rounded up of a certain number of bytes
+ void set_last_read_multiple(std::uint64_t bytes) { last_read_multiple_ = bytes; }
bool get_data(std::size_t size, std::uint8_t* out_data);
private:
+ ProducerCallback producer_;
+ std::size_t size_ = 0;
+ std::size_t curr_size_ = 0;
- std::size_t get_read_size();
-
- std::size_t remaining_size_ = 0;
+ std::uint64_t remaining_size_ = BUFFER_SIZE_UNSET;
+ std::uint64_t last_read_multiple_ = BUFFER_SIZE_UNSET;
std::size_t buffer_offset_ = 0;
- std::size_t buffer_end_ = 0;
std::vector<std::uint8_t> buffer_;
-
- FakeBufferModel buffer_model_;
-
- ProducerCallback producer_;
};
} // namespace genesys