From 0edc043378777e049d30acfe3b1f7902d081336c Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 3 Dec 2016 20:47:19 -0500 Subject: [PATCH] Started introducing an extra layer of indirection so as to be able to bind the texture builder to the same flush and submit patern as the array builder. --- Outputs/CRT/CRT.cpp | 8 ++++---- Outputs/CRT/Internals/TextureBuilder.hpp | 22 ++++++++++------------ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Outputs/CRT/CRT.cpp b/Outputs/CRT/CRT.cpp index e4791c740..ec09e64db 100644 --- a/Outputs/CRT/CRT.cpp +++ b/Outputs/CRT/CRT.cpp @@ -315,8 +315,8 @@ void CRT::output_level(unsigned int number_of_cycles) Scan scan { .type = Scan::Type::Level, .number_of_cycles = number_of_cycles, - .tex_x = openGL_output_builder_.texture_builder.get_last_write_x_position(), - .tex_y = openGL_output_builder_.texture_builder.get_last_write_y_position() +// .tex_x = openGL_output_builder_.texture_builder.get_last_write_x_position(), +// .tex_y = openGL_output_builder_.texture_builder.get_last_write_y_position() }; output_scan(&scan); } @@ -349,8 +349,8 @@ void CRT::output_data(unsigned int number_of_cycles, unsigned int source_divider Scan scan { .type = Scan::Type::Data, .number_of_cycles = number_of_cycles, - .tex_x = openGL_output_builder_.texture_builder.get_last_write_x_position(), - .tex_y = openGL_output_builder_.texture_builder.get_last_write_y_position(), +// .tex_x = openGL_output_builder_.texture_builder.get_last_write_x_position(), +// .tex_y = openGL_output_builder_.texture_builder.get_last_write_y_position(), .source_divider = source_divider }; output_scan(&scan); diff --git a/Outputs/CRT/Internals/TextureBuilder.hpp b/Outputs/CRT/Internals/TextureBuilder.hpp index b346ab66c..211caedde 100644 --- a/Outputs/CRT/Internals/TextureBuilder.hpp +++ b/Outputs/CRT/Internals/TextureBuilder.hpp @@ -40,12 +40,6 @@ class TextureBuilder { /// and indicates that its actual final size was @c actual_length. void reduce_previous_allocation_to(size_t actual_length); - /// @returns the start column for the most recent allocated write area. - uint16_t get_last_write_x_position(); - - /// @returns the row of the most recent allocated write area. - uint16_t get_last_write_y_position(); - /// @returns @c true if all future calls to @c allocate_write_area will fail on account of the input texture /// being full; @c false if calls may succeed. bool is_full(); @@ -53,13 +47,13 @@ class TextureBuilder { /// Updates the currently-bound texture with all new data provided since the last @c submit. void submit(); + struct WriteArea { + uint16_t x, y; + size_t length; + }; + void flush(std::function &write_areas, size_t count)>); + private: - // where pixel data will be put to the next time a write is requested - uint16_t next_write_x_position_, next_write_y_position_; - - // the most recent position returned for pixel data writing - uint16_t write_x_position_, write_y_position_; - // details of the most recent allocation size_t write_target_pointer_; size_t last_allocation_amount_; @@ -70,6 +64,10 @@ class TextureBuilder { // the buffer std::vector image_; GLuint texture_name_; + + std::vector write_areas_; + size_t number_of_write_areas_; + uint16_t write_areas_start_x_, write_areas_start_y_; }; }