From 1a573fbeb5b4b115d9285a49cc4ba82a89f9c5fe Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 2 Jun 2015 19:28:49 -0300 Subject: [PATCH] Do not recreate the she::Surface on each render --- src/app/ui/editor/editor.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp index d6c910903..bf9c51026 100644 --- a/src/app/ui/editor/editor.cpp +++ b/src/app/ui/editor/editor.cpp @@ -476,13 +476,20 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& sprite } // Convert the render to a she::Surface - she::Surface* tmp(she::instance()->createRgbaSurface(rc.w, rc.h)); + static she::Surface* tmp; + if (!tmp || tmp->width() < rc.w || tmp->height() < rc.h) { + if (tmp) + tmp->dispose(); + + tmp = she::instance()->createRgbaSurface(rc.w, rc.h); + } + if (tmp->nativeHandle()) { convert_image_to_surface(rendered, m_sprite->palette(m_frame), tmp, 0, 0, 0, 0, rc.w, rc.h); + g->blit(tmp, 0, 0, dest_x, dest_y, rc.w, rc.h); } - tmp->dispose(); } }