mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-26 15:32:04 +00:00
Allowed overly aggressive allocations to be cleared up after the fact.
This commit is contained in:
parent
d3d505b7bc
commit
2cb12a7513
@ -416,6 +416,8 @@ void CRT::output_colour_burst(unsigned int number_of_cycles, uint8_t phase, uint
|
||||
|
||||
void CRT::output_data(unsigned int number_of_cycles, unsigned int source_divider)
|
||||
{
|
||||
if(_current_frame_builder) _current_frame_builder->reduce_previous_allocation_to(number_of_cycles / source_divider);
|
||||
|
||||
_scans[_next_scan].type = Type::Data;
|
||||
_scans[_next_scan].number_of_cycles = number_of_cycles;
|
||||
_scans[_next_scan].tex_x = _current_frame_builder ? _current_frame_builder->_write_x_position : 0;
|
||||
|
@ -258,23 +258,23 @@ class CRT {
|
||||
CRTFrameBuilder(uint16_t width, uint16_t height, unsigned int number_of_buffers, va_list buffer_sizes);
|
||||
~CRTFrameBuilder();
|
||||
|
||||
private:
|
||||
std::vector<uint8_t> _all_runs;
|
||||
std::vector<uint8_t> _all_runs;
|
||||
|
||||
void reset();
|
||||
void complete();
|
||||
void reset();
|
||||
void complete();
|
||||
|
||||
uint8_t *get_next_run();
|
||||
friend CRT;
|
||||
uint8_t *get_next_run();
|
||||
|
||||
void allocate_write_area(int required_length);
|
||||
uint8_t *get_write_target_for_buffer(int buffer);
|
||||
void allocate_write_area(int required_length);
|
||||
void reduce_previous_allocation_to(int actual_length);
|
||||
uint8_t *get_write_target_for_buffer(int buffer);
|
||||
|
||||
// a pointer to the section of content buffer currently being
|
||||
// returned and to where the next section will begin
|
||||
uint16_t _next_write_x_position, _next_write_y_position;
|
||||
uint16_t _write_x_position, _write_y_position;
|
||||
size_t _write_target_pointer;
|
||||
// a pointer to the section of content buffer currently being
|
||||
// returned and to where the next section will begin
|
||||
uint16_t _next_write_x_position, _next_write_y_position;
|
||||
uint16_t _write_x_position, _write_y_position;
|
||||
size_t _write_target_pointer;
|
||||
int _last_allocation_amount;
|
||||
};
|
||||
|
||||
static const int kCRTNumberOfFrames = 4;
|
||||
|
@ -66,6 +66,8 @@ uint8_t *CRT::CRTFrameBuilder::get_next_run()
|
||||
|
||||
void CRT::CRTFrameBuilder::allocate_write_area(int required_length)
|
||||
{
|
||||
_last_allocation_amount = required_length;
|
||||
|
||||
if (_next_write_x_position + required_length > frame.size.width)
|
||||
{
|
||||
_next_write_x_position = 0;
|
||||
@ -80,6 +82,12 @@ void CRT::CRTFrameBuilder::allocate_write_area(int required_length)
|
||||
frame.dirty_size.width = std::max(frame.dirty_size.width, _next_write_x_position);
|
||||
}
|
||||
|
||||
void CRT::CRTFrameBuilder::reduce_previous_allocation_to(int actual_length)
|
||||
{
|
||||
_next_write_x_position -= (_last_allocation_amount - actual_length);
|
||||
}
|
||||
|
||||
|
||||
uint8_t *CRT::CRTFrameBuilder::get_write_target_for_buffer(int buffer)
|
||||
{
|
||||
return &frame.buffers[buffer].data[_write_target_pointer * frame.buffers[buffer].depth];
|
||||
|
Loading…
x
Reference in New Issue
Block a user