Video: (almost) completely removed framebuffer surface
Again, useless since there's no more window surface with accelerated rendering. getSurface() remains since it's still used in quite a lot of places. Will removed ASAP.
This commit is contained in:
parent
ea395c1fb5
commit
e205e42d44
3 changed files with 6 additions and 52 deletions
|
@ -789,13 +789,15 @@ void discard_input()
|
|||
|
||||
void peek_for_resize()
|
||||
{
|
||||
#if 0
|
||||
SDL_Event events[100];
|
||||
int num = SDL_PeepEvents(events, 100, SDL_PEEKEVENT, SDL_WINDOWEVENT, SDL_WINDOWEVENT);
|
||||
for(int i = 0; i < num; ++i) {
|
||||
if(events[i].type == SDL_WINDOWEVENT && events[i].window.event == SDL_WINDOWEVENT_RESIZED) {
|
||||
CVideo::get_singleton().update_framebuffer();
|
||||
// Add something here if needed.
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void call_in_main_thread(const std::function<void(void)>& f)
|
||||
|
|
|
@ -66,8 +66,8 @@ void trigger_full_redraw()
|
|||
SDL_Event event;
|
||||
event.type = SDL_WINDOWEVENT;
|
||||
event.window.event = SDL_WINDOWEVENT_RESIZED;
|
||||
event.window.data1 = (*frameBuffer).h;
|
||||
event.window.data2 = (*frameBuffer).w;
|
||||
event.window.data1 = CVideo::get_singleton().getx();
|
||||
event.window.data2 = CVideo::get_singleton().gety();
|
||||
|
||||
for(const auto& layer : draw_layers) {
|
||||
layer->handle_window_event(event);
|
||||
|
@ -177,48 +177,15 @@ void CVideo::make_fake()
|
|||
fake_screen_ = true;
|
||||
refresh_rate_ = 1;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 6)
|
||||
frameBuffer = SDL_CreateRGBSurfaceWithFormat(0, 16, 16, 24, SDL_PIXELFORMAT_BGR888);
|
||||
#else
|
||||
frameBuffer = SDL_CreateRGBSurface(0, 16, 16, 24, 0xFF0000, 0xFF00, 0xFF, 0);
|
||||
#endif
|
||||
|
||||
image::set_pixel_format(frameBuffer->format);
|
||||
}
|
||||
|
||||
void CVideo::make_test_fake(const unsigned width, const unsigned height)
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 6)
|
||||
frameBuffer = SDL_CreateRGBSurfaceWithFormat(0, width, height, 32, SDL_PIXELFORMAT_BGR888);
|
||||
#else
|
||||
frameBuffer = SDL_CreateRGBSurface(0, width, height, 32, 0xFF0000, 0xFF00, 0xFF, 0);
|
||||
#endif
|
||||
|
||||
image::set_pixel_format(frameBuffer->format);
|
||||
|
||||
fake_interactive = true;
|
||||
refresh_rate_ = 1;
|
||||
}
|
||||
|
||||
void CVideo::update_framebuffer()
|
||||
{
|
||||
if(!window) {
|
||||
return;
|
||||
}
|
||||
|
||||
surface fb = SDL_GetWindowSurface(*window);
|
||||
if(!frameBuffer) {
|
||||
frameBuffer = fb;
|
||||
} else {
|
||||
if(sdl_get_version() >= version_info(2, 0, 6)) {
|
||||
// Because SDL has already freed the old framebuffer,
|
||||
// ensure that we won't attempt to free it.
|
||||
frameBuffer.clear_without_free();
|
||||
}
|
||||
|
||||
frameBuffer.assign(fb);
|
||||
}
|
||||
}
|
||||
|
||||
void CVideo::init_window()
|
||||
{
|
||||
|
@ -254,11 +221,6 @@ void CVideo::init_window()
|
|||
refresh_rate_ = currentDisplayMode.refresh_rate != 0 ? currentDisplayMode.refresh_rate : 60;
|
||||
|
||||
event_handler_.join_global();
|
||||
|
||||
update_framebuffer();
|
||||
if(frameBuffer) {
|
||||
image::set_pixel_format(frameBuffer->format);
|
||||
}
|
||||
}
|
||||
|
||||
void CVideo::set_window_mode(const MODE_EVENT mode, const point& size)
|
||||
|
@ -289,11 +251,6 @@ void CVideo::set_window_mode(const MODE_EVENT mode, const point& size)
|
|||
window->center();
|
||||
break;
|
||||
}
|
||||
|
||||
update_framebuffer();
|
||||
if(frameBuffer) {
|
||||
image::set_pixel_format(frameBuffer->format);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Rect CVideo::screen_area(bool as_pixels) const
|
||||
|
@ -511,6 +468,7 @@ std::vector<point> CVideo::get_available_resolutions(const bool include_current)
|
|||
return result;
|
||||
}
|
||||
|
||||
// TODO: REMOVE ASAP
|
||||
surface& CVideo::getSurface()
|
||||
{
|
||||
return frameBuffer;
|
||||
|
|
|
@ -179,12 +179,6 @@ public:
|
|||
const bool flip_h = false,
|
||||
const bool flip_v = false);
|
||||
|
||||
/**
|
||||
* Updates and ensures the framebuffer surface is valid.
|
||||
* This needs to be invoked immediately after a resize event or the game will crash.
|
||||
*/
|
||||
void update_framebuffer();
|
||||
|
||||
/** Clear the screen contents */
|
||||
void clear_screen();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue