1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-11 04:28:58 +00:00

Introduced an intermediate buffer that collects lines before flushing them to the output buffer.

This commit is contained in:
Thomas Harte 2016-11-16 10:49:18 +08:00
parent ba2adf8bb1
commit ccedb6bea6
2 changed files with 13 additions and 5 deletions

View File

@ -121,7 +121,7 @@ OpenGLOutputBuilder::OpenGLOutputBuilder(unsigned int buffer_depth) :
_buffer_builder.reset(new CRTInputBufferBuilder(buffer_depth)); _buffer_builder.reset(new CRTInputBufferBuilder(buffer_depth));
_output_buffer.data.resize(OutputVertexBufferDataSize); _output_buffer.data.resize(OutputVertexBufferDataSize);
_source_buffer.data.resize(OutputVertexBufferDataSize); _source_buffer.data.resize(SourceVertexBufferDataSize);
glBlendFunc(GL_SRC_ALPHA, GL_CONSTANT_COLOR); glBlendFunc(GL_SRC_ALPHA, GL_CONSTANT_COLOR);
glBlendColor(0.6f, 0.6f, 0.6f, 1.0f); glBlendColor(0.6f, 0.6f, 0.6f, 1.0f);

View File

@ -96,13 +96,13 @@ class OpenGLOutputBuilder {
inline uint8_t *get_next_source_run() inline uint8_t *get_next_source_run()
{ {
if(_source_buffer.pointer == SourceVertexBufferDataSize) return nullptr; _line_buffer.data.resize(_line_buffer.pointer + SourceVertexSize);
return &_source_buffer.data[_source_buffer.pointer]; return &_line_buffer.data[_line_buffer.pointer];
} }
inline void complete_source_run() inline void complete_source_run()
{ {
_source_buffer.pointer += SourceVertexSize; _line_buffer.pointer += SourceVertexSize;
} }
inline uint8_t *get_next_output_run() inline uint8_t *get_next_output_run()
@ -113,7 +113,15 @@ class OpenGLOutputBuilder {
inline void complete_output_run() inline void complete_output_run()
{ {
_output_buffer.pointer += OutputVertexSize; size_t line_buffer_size = _line_buffer.data.size();
if(_source_buffer.pointer + line_buffer_size < SourceVertexBufferDataSize)
{
_output_buffer.pointer += OutputVertexSize;
memcpy(&_source_buffer.data[_source_buffer.pointer], _line_buffer.data.data(), _line_buffer.data.size());
_source_buffer.pointer += _line_buffer.data.size();
_line_buffer.data.resize(0);
_line_buffer.pointer = 0;
}
} }
inline void set_colour_format(ColourSpace colour_space, unsigned int colour_cycle_numerator, unsigned int colour_cycle_denominator) inline void set_colour_format(ColourSpace colour_space, unsigned int colour_cycle_numerator, unsigned int colour_cycle_denominator)