mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-28 06:29:37 +00:00
Switched to simpler storage for _image
.
This commit is contained in:
parent
1f02c5df88
commit
47302de23a
@ -214,9 +214,6 @@ void CRT::advance_cycles(unsigned int number_of_cycles, unsigned int source_divi
|
||||
// if this is vertical retrace then adcance a field
|
||||
if(next_run_length == time_until_vertical_sync_event && next_vertical_sync_event == Flywheel::SyncEvent::EndRetrace)
|
||||
{
|
||||
// TODO: eliminate the below; it's to aid with debug, aligning the top of the
|
||||
// input buffer with the top of the incoming frame.
|
||||
_openGL_output_builder->release_source_buffer_write_pointer();
|
||||
if(_delegate)
|
||||
{
|
||||
_frames_since_last_delegate_call++;
|
||||
|
@ -16,15 +16,9 @@ CRTInputBufferBuilder::CRTInputBufferBuilder(size_t bytes_per_pixel) :
|
||||
_bytes_per_pixel(bytes_per_pixel),
|
||||
_next_write_x_position(0),
|
||||
_next_write_y_position(0),
|
||||
_image(new uint8_t[bytes_per_pixel * InputBufferBuilderWidth * InputBufferBuilderHeight]),
|
||||
_should_reset(false)
|
||||
_image(new uint8_t[bytes_per_pixel * InputBufferBuilderWidth * InputBufferBuilderHeight])
|
||||
{}
|
||||
|
||||
CRTInputBufferBuilder::~CRTInputBufferBuilder()
|
||||
{
|
||||
delete[] _image;
|
||||
}
|
||||
|
||||
void CRTInputBufferBuilder::allocate_write_area(size_t required_length)
|
||||
{
|
||||
if(_next_write_y_position != InputBufferBuilderHeight)
|
||||
@ -47,22 +41,16 @@ void CRTInputBufferBuilder::allocate_write_area(size_t required_length)
|
||||
}
|
||||
}
|
||||
|
||||
void CRTInputBufferBuilder::release_write_pointer()
|
||||
{
|
||||
// if(_should_reset)
|
||||
// {
|
||||
// _next_write_x_position = _next_write_y_position = 0;
|
||||
// }
|
||||
}
|
||||
|
||||
bool CRTInputBufferBuilder::reduce_previous_allocation_to(size_t actual_length)
|
||||
{
|
||||
if(_next_write_y_position == InputBufferBuilderHeight) return false;
|
||||
|
||||
uint8_t *const image_pointer = _image.get();
|
||||
|
||||
// correct if the writing cursor was reset while a client was writing
|
||||
if(_next_write_x_position == 0 && _next_write_y_position == 0 && _write_target_pointer != 1)
|
||||
{
|
||||
memmove(&_image[1], &_image[_write_target_pointer], actual_length);
|
||||
memmove(&image_pointer[1], &image_pointer[_write_target_pointer], actual_length);
|
||||
_write_target_pointer = 1;
|
||||
_last_allocation_amount = actual_length;
|
||||
_next_write_x_position = (uint16_t)(actual_length + 2);
|
||||
@ -70,12 +58,12 @@ bool CRTInputBufferBuilder::reduce_previous_allocation_to(size_t actual_length)
|
||||
|
||||
// book end the allocation with duplicates of the first and last pixel, to protect
|
||||
// against rounding errors when this run is drawn
|
||||
memcpy( &_image[(_write_target_pointer - 1) * _bytes_per_pixel],
|
||||
&_image[_write_target_pointer * _bytes_per_pixel],
|
||||
memcpy( &image_pointer[(_write_target_pointer - 1) * _bytes_per_pixel],
|
||||
&image_pointer[_write_target_pointer * _bytes_per_pixel],
|
||||
_bytes_per_pixel);
|
||||
|
||||
memcpy( &_image[(_write_target_pointer + actual_length) * _bytes_per_pixel],
|
||||
&_image[(_write_target_pointer + actual_length - 1) * _bytes_per_pixel],
|
||||
memcpy( &image_pointer[(_write_target_pointer + actual_length) * _bytes_per_pixel],
|
||||
&image_pointer[(_write_target_pointer + actual_length - 1) * _bytes_per_pixel],
|
||||
_bytes_per_pixel);
|
||||
|
||||
// return any allocated length that wasn't actually used to the available pool
|
||||
@ -86,7 +74,7 @@ bool CRTInputBufferBuilder::reduce_previous_allocation_to(size_t actual_length)
|
||||
|
||||
uint8_t *CRTInputBufferBuilder::get_image_pointer()
|
||||
{
|
||||
return _image;
|
||||
return _image.get();
|
||||
}
|
||||
|
||||
uint16_t CRTInputBufferBuilder::get_and_finalise_current_line()
|
||||
@ -98,7 +86,7 @@ uint16_t CRTInputBufferBuilder::get_and_finalise_current_line()
|
||||
|
||||
uint8_t *CRTInputBufferBuilder::get_write_target()
|
||||
{
|
||||
return (_next_write_y_position == InputBufferBuilderHeight) ? nullptr : &_image[_write_target_pointer * _bytes_per_pixel];
|
||||
return (_next_write_y_position == InputBufferBuilderHeight) ? nullptr : &_image.get()[_write_target_pointer * _bytes_per_pixel];
|
||||
}
|
||||
|
||||
uint16_t CRTInputBufferBuilder::get_last_write_x_position()
|
||||
|
@ -14,20 +14,18 @@
|
||||
#include <stddef.h>
|
||||
#include "CRTConstants.hpp"
|
||||
#include "OpenGL.hpp"
|
||||
#include <memory.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Outputs {
|
||||
namespace CRT {
|
||||
|
||||
struct CRTInputBufferBuilder {
|
||||
CRTInputBufferBuilder(size_t bytes_per_pixel);
|
||||
~CRTInputBufferBuilder();
|
||||
|
||||
void allocate_write_area(size_t required_length);
|
||||
bool reduce_previous_allocation_to(size_t actual_length);
|
||||
|
||||
uint16_t get_and_finalise_current_line();
|
||||
void release_write_pointer();
|
||||
uint8_t *get_image_pointer();
|
||||
|
||||
uint8_t *get_write_target();
|
||||
@ -53,9 +51,7 @@ struct CRTInputBufferBuilder {
|
||||
size_t _bytes_per_pixel;
|
||||
|
||||
// the buffer
|
||||
uint8_t *_image;
|
||||
|
||||
bool _should_reset;
|
||||
std::unique_ptr<uint8_t> _image;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -182,11 +182,6 @@ class OpenGLOutputBuilder {
|
||||
return _buffer_builder->get_last_write_y_position();
|
||||
}
|
||||
|
||||
inline void release_source_buffer_write_pointer()
|
||||
{
|
||||
_buffer_builder->release_write_pointer();
|
||||
}
|
||||
|
||||
void draw_frame(unsigned int output_width, unsigned int output_height, bool only_if_dirty);
|
||||
void set_openGL_context_will_change(bool should_delete_resources);
|
||||
void set_composite_sampling_function(const char *shader);
|
||||
|
Loading…
x
Reference in New Issue
Block a user