mirror of
https://github.com/TomHarte/CLK.git
synced 2024-07-11 04:28:58 +00:00
Added an extra flag to avoid potential race condition on is_full_, being reset from the background despite a write area not having been allocated.
This commit is contained in:
parent
d51f185dc7
commit
7fd02e7f4c
@ -43,6 +43,7 @@ TextureBuilder::TextureBuilder(size_t bytes_per_pixel, GLenum texture_unit) :
|
|||||||
write_areas_start_y_(0),
|
write_areas_start_y_(0),
|
||||||
is_full_(false),
|
is_full_(false),
|
||||||
did_submit_(false),
|
did_submit_(false),
|
||||||
|
has_write_area_(false),
|
||||||
number_of_write_areas_(0)
|
number_of_write_areas_(0)
|
||||||
{
|
{
|
||||||
image_.resize(bytes_per_pixel * InputBufferBuilderWidth * InputBufferBuilderHeight);
|
image_.resize(bytes_per_pixel * InputBufferBuilderWidth * InputBufferBuilderHeight);
|
||||||
@ -105,6 +106,7 @@ uint8_t *TextureBuilder::allocate_write_area(size_t required_length)
|
|||||||
else
|
else
|
||||||
write_areas_.push_back(next_write_area);
|
write_areas_.push_back(next_write_area);
|
||||||
number_of_write_areas_++;
|
number_of_write_areas_++;
|
||||||
|
has_write_area_ = true;
|
||||||
|
|
||||||
return pointer_to_location(next_write_area.x, next_write_area.y);
|
return pointer_to_location(next_write_area.x, next_write_area.y);
|
||||||
}
|
}
|
||||||
@ -116,8 +118,9 @@ bool TextureBuilder::is_full()
|
|||||||
|
|
||||||
void TextureBuilder::reduce_previous_allocation_to(size_t actual_length)
|
void TextureBuilder::reduce_previous_allocation_to(size_t actual_length)
|
||||||
{
|
{
|
||||||
if(is_full_) return;
|
if(is_full_ || !has_write_area_) return;
|
||||||
|
|
||||||
|
has_write_area_ = false;
|
||||||
WriteArea &write_area = write_areas_[number_of_write_areas_-1];
|
WriteArea &write_area = write_areas_[number_of_write_areas_-1];
|
||||||
write_area.length = (uint16_t)actual_length;
|
write_area.length = (uint16_t)actual_length;
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ class TextureBuilder {
|
|||||||
size_t number_of_write_areas_;
|
size_t number_of_write_areas_;
|
||||||
bool is_full_;
|
bool is_full_;
|
||||||
bool did_submit_;
|
bool did_submit_;
|
||||||
|
bool has_write_area_;
|
||||||
inline uint8_t *pointer_to_location(uint16_t x, uint16_t y);
|
inline uint8_t *pointer_to_location(uint16_t x, uint16_t y);
|
||||||
|
|
||||||
// Usually: the start position for the current batch of write areas.
|
// Usually: the start position for the current batch of write areas.
|
||||||
|
Loading…
Reference in New Issue
Block a user