1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-06 01:28:57 +00:00

Documented this interface, albeit that the English could do with a second pass, and very sightly simplified inline with current usage.

This commit is contained in:
Thomas Harte 2016-11-16 13:15:50 +08:00
parent 4d0d5eb919
commit c1a509910d
3 changed files with 13 additions and 12 deletions

View File

@ -183,8 +183,7 @@ class OpenGLOutputBuilder {
inline uint8_t *allocate_write_area(size_t required_length)
{
_texture_builder->allocate_write_area(required_length);
return _texture_builder->get_write_target();
return _texture_builder->allocate_write_area(required_length);
}
inline void reduce_previous_allocation_to(size_t actual_length)

View File

@ -20,7 +20,7 @@ InputTextureBuilder::InputTextureBuilder(size_t bytes_per_pixel) :
_image.resize(bytes_per_pixel * InputBufferBuilderWidth * InputBufferBuilderHeight);
}
void InputTextureBuilder::allocate_write_area(size_t required_length)
uint8_t *InputTextureBuilder::allocate_write_area(size_t required_length)
{
if(_next_write_y_position != InputBufferBuilderHeight)
{
@ -32,7 +32,7 @@ void InputTextureBuilder::allocate_write_area(size_t required_length)
_next_write_y_position++;
if(_next_write_y_position == InputBufferBuilderHeight)
return;
return nullptr;
}
_write_x_position = _next_write_x_position + 1;
@ -40,6 +40,9 @@ void InputTextureBuilder::allocate_write_area(size_t required_length)
_write_target_pointer = (_write_y_position * InputBufferBuilderWidth) + _write_x_position;
_next_write_x_position += required_length + 2;
}
else return nullptr;
return &_image[_write_target_pointer * _bytes_per_pixel];
}
bool InputTextureBuilder::is_full()
@ -90,11 +93,6 @@ uint16_t InputTextureBuilder::get_and_finalise_current_line()
return result;
}
uint8_t *InputTextureBuilder::get_write_target()
{
return (_next_write_y_position == InputBufferBuilderHeight) ? nullptr : &_image[_write_target_pointer * _bytes_per_pixel];
}
uint16_t InputTextureBuilder::get_last_write_x_position()
{
return _write_x_position;

View File

@ -31,7 +31,8 @@ class InputTextureBuilder {
/// Finds the first available space of at least @c required_length pixels in size. Calls must be paired off
/// with calls to @c reduce_previous_allocation_to.
void allocate_write_area(size_t required_length);
/// @returns a pointer to the allocated space if any was available; @c nullptr otherwise.
uint8_t *allocate_write_area(size_t required_length);
/// Announces that the owner is finished with the region created by the most recent @c allocate_write_area
/// and indicates that its actual final size was @c actual_length.
@ -44,14 +45,17 @@ class InputTextureBuilder {
/// @returns a pointer to the image data for this texture.
uint8_t *get_image_pointer();
uint8_t *get_write_target();
/// @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 the number of bytes per pixel as supplied to the constructor.
size_t get_bytes_per_pixel();
/// @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();
private: