Delete window cache surface on quit
This commit is contained in:
parent
41633b1e56
commit
fcda17c7d3
3 changed files with 9 additions and 6 deletions
|
|
@ -110,7 +110,7 @@ void DrawingProgramCache::clear_own_cached_surfaces() {
|
|||
std::erase_if(nodeCacheMap, [&](auto& nodeCachePair) {
|
||||
return nodeCachePair.second.attachedDrawingProgramCache == this;
|
||||
});
|
||||
if(windowCache.attachedDrawingProgramCache == this)
|
||||
if(windowCache.attachedDrawingProgramCache == this) // Don't delete the cache surface. We don't have to reallocate it if the window size didn't change
|
||||
windowCache.attachedDrawingProgramCache = nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -338,10 +338,6 @@ void DrawingProgramCache::refresh_draw_cache(const std::shared_ptr<DrawingProgra
|
|||
nodeCacheMap.emplace(bvhNode, nodeCache); // Set the nodeCache after rendering is done, so that the draw function doesnt assume we have this node cached
|
||||
}
|
||||
|
||||
void DrawingProgramCache::set_clear_window_cache() {
|
||||
windowCache.attachedDrawingProgramCache = nullptr;
|
||||
}
|
||||
|
||||
void DrawingProgramCache::allocate_window_cache_area() {
|
||||
const Vector2i& windowSize = drawP.world.main.window.size;
|
||||
#ifdef USE_BACKEND_OPENGLES_3_0
|
||||
|
|
@ -502,6 +498,10 @@ void DrawingProgramCache::draw_cache_image_to_canvas(SkCanvas* canvas, const Dra
|
|||
}
|
||||
}
|
||||
|
||||
void DrawingProgramCache::delete_window_cache_surface() {
|
||||
windowCache.surface = nullptr;
|
||||
}
|
||||
|
||||
DrawingProgramCache::~DrawingProgramCache() {
|
||||
clear_own_cached_surfaces();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class DrawingProgramCache {
|
|||
void update_and_draw_cached_canvas(SkCanvas* canvas, const DrawData& drawData);
|
||||
void draw_components_to_canvas(SkCanvas* canvas, const DrawData& drawData, const std::optional<SCollision::AABB<WorldScalar>>& drawBounds);
|
||||
void invalidate_cache_at_aabb(const SCollision::AABB<WorldScalar>& aabb);
|
||||
void set_clear_window_cache();
|
||||
static void delete_window_cache_surface();
|
||||
|
||||
CanvasComponentContainer::ObjInfo* get_front_object_colliding_with_in_editing_layer(const SCollision::ColliderCollection<float>& cC);
|
||||
~DrawingProgramCache();
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@
|
|||
#include <SDL3/SDL_scancode.h>
|
||||
#include <SDL3/SDL_video.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include "DrawingProgram/DrawingProgramCache.hpp"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
|
|
@ -793,6 +794,8 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) {
|
|||
}
|
||||
|
||||
void SDL_AppQuit(void *appstate, SDL_AppResult result) {
|
||||
DrawingProgramCache::delete_window_cache_surface();
|
||||
|
||||
MainStruct& mS = *((MainStruct*)appstate);
|
||||
try {
|
||||
mS.m->save_config();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue