summaryrefslogtreecommitdiff
path: root/backend/genesys/image_buffer.h
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2020-08-24 18:45:34 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2020-08-24 18:45:34 +0200
commit2b3e02411ecc09e7d41741b5587655c9b2f955b7 (patch)
treed839746371ecb8ed64ac81d2e37c11fcd25a00ac /backend/genesys/image_buffer.h
parent787fb1d54ec9ee5fb941ae897fb201feb9cb2fd1 (diff)
parentad38bc6ecb80ddeb562841b33258dd53659b1da6 (diff)
Update upstream source from tag 'upstream/1.0.31'
Update to upstream version '1.0.31' with Debian dir aa7a39fe56343f5e164eec83783f4c923a394865
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