diff --git a/Outputs/CRT/Internals/TextureBuilder.hpp b/Outputs/CRT/Internals/TextureBuilder.hpp index f0b211686..01c7967c5 100644 --- a/Outputs/CRT/Internals/TextureBuilder.hpp +++ b/Outputs/CRT/Internals/TextureBuilder.hpp @@ -98,6 +98,21 @@ class TextureBuilder { /// allocated, indicating their final resting locations and their lengths. void flush(const std::function &write_areas, size_t count)> &); + /// A Bookender helps to paper over precision errors when rendering; its job is to provide single-sample + /// extensions that duplicate the left and right edges of a written area. By default the texture builder will + /// simply copy the appropriate number of bytes per pixel, but if the client is using a packed pixel format + /// then that may be incorrect, e.g. if each sample is a byte but contains two pixels, each in a single nibble, + /// then the correct duplication might be a byte composed of copies of the two top nibbles as the left bookend, + /// and one composed of copies of the two bottom nibbles on the right. + struct Bookender { + /// Writes to left_bookend the sample that should appear as a continuation before the left_value; + /// writes to right_bookend the sample that should appear as a continuation after right_value. + void add_bookends(uint8_t *const left_value, uint8_t *const right_value, uint8_t *left_bookend, uint8_t *right_bookend); + }; + + /// Sets the current bookender. Will be called synchronously within the builder-writing thread. + void set_bookender(Bookender *bookender); + private: // the buffer size size_t bytes_per_pixel_;