mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-15 21:40:34 +00:00
Add "ui::dirty_display_flag" flag to avoid flipping to the screen continuously.
This is a temporal fix to save more CPU. It will be refactored for next versions.
This commit is contained in:
parent
6971426d61
commit
fb5f086f0f
@ -115,6 +115,8 @@ void PlayAnimationCommand::onExecute(Context* context)
|
|||||||
|
|
||||||
current_editor->drawSpriteSafe(0, 0, sprite->getWidth(), sprite->getHeight());
|
current_editor->drawSpriteSafe(0, 0, sprite->getWidth(), sprite->getHeight());
|
||||||
|
|
||||||
|
ui::dirty_display_flag = true;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
poll_mouse();
|
poll_mouse();
|
||||||
poll_keyboard();
|
poll_keyboard();
|
||||||
|
@ -143,6 +143,7 @@ void PreviewCommand::onExecute(Context* context)
|
|||||||
// Redraw the screen
|
// Redraw the screen
|
||||||
if (redraw) {
|
if (redraw) {
|
||||||
redraw = false;
|
redraw = false;
|
||||||
|
dirty_display_flag = true;
|
||||||
|
|
||||||
x = pos_x + ((delta_x >> zoom) << zoom);
|
x = pos_x + ((delta_x >> zoom) << zoom);
|
||||||
y = pos_y + ((delta_y >> zoom) << zoom);
|
y = pos_y + ((delta_y >> zoom) << zoom);
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "modules/editors.h"
|
#include "modules/editors.h"
|
||||||
#include "modules/gui.h"
|
#include "modules/gui.h"
|
||||||
#include "raster/sprite.h"
|
#include "raster/sprite.h"
|
||||||
|
#include "ui/system.h"
|
||||||
#include "widgets/editor/editor.h"
|
#include "widgets/editor/editor.h"
|
||||||
#include "widgets/status_bar.h"
|
#include "widgets/status_bar.h"
|
||||||
|
|
||||||
@ -82,6 +83,8 @@ void UndoCommand::onExecute(Context* context)
|
|||||||
|
|
||||||
current_editor->drawSpriteSafe(0, 0, sprite->getWidth(), sprite->getHeight());
|
current_editor->drawSpriteSafe(0, 0, sprite->getWidth(), sprite->getHeight());
|
||||||
update_screen_for_document(document);
|
update_screen_for_document(document);
|
||||||
|
|
||||||
|
ui::dirty_display_flag = true;
|
||||||
gui_feedback();
|
gui_feedback();
|
||||||
|
|
||||||
base::this_thread::sleep_for(0.01);
|
base::this_thread::sleep_for(0.01);
|
||||||
|
@ -310,6 +310,10 @@ void gui_feedback()
|
|||||||
|
|
||||||
ui::UpdateCursorOverlay();
|
ui::UpdateCursorOverlay();
|
||||||
|
|
||||||
|
// Avoid updating a non-dirty screen over and over again.
|
||||||
|
if (!dirty_display_flag)
|
||||||
|
return;
|
||||||
|
|
||||||
// Draw overlays.
|
// Draw overlays.
|
||||||
overlays->captureOverlappedAreas();
|
overlays->captureOverlappedAreas();
|
||||||
overlays->drawOverlays();
|
overlays->drawOverlays();
|
||||||
@ -322,6 +326,8 @@ void gui_feedback()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
overlays->restoreOverlappedAreas();
|
overlays->restoreOverlappedAreas();
|
||||||
|
|
||||||
|
dirty_display_flag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets the ji_screen variable. This routine should be called
|
// Sets the ji_screen variable. This routine should be called
|
||||||
|
@ -1090,6 +1090,8 @@ void Manager::pumpQueue()
|
|||||||
#endif
|
#endif
|
||||||
/* rectfill(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1, makecol(255, 0, 0)); */
|
/* rectfill(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1, makecol(255, 0, 0)); */
|
||||||
/* vsync(); vsync(); vsync(); vsync(); */
|
/* vsync(); vsync(); vsync(); vsync(); */
|
||||||
|
|
||||||
|
dirty_display_flag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* call message handler */
|
/* call message handler */
|
||||||
|
@ -30,6 +30,7 @@ namespace ui {
|
|||||||
|
|
||||||
she::Surface* setSurface(she::Surface* newSurface);
|
she::Surface* setSurface(she::Surface* newSurface);
|
||||||
|
|
||||||
|
const gfx::Point& getPosition() const { return m_pos; }
|
||||||
gfx::Rect getBounds() const;
|
gfx::Rect getBounds() const;
|
||||||
|
|
||||||
void captureOverlappedArea(she::LockedSurface* screen);
|
void captureOverlappedArea(she::LockedSurface* screen);
|
||||||
|
@ -37,6 +37,8 @@ JRegion ji_dirty_region = NULL;
|
|||||||
int ji_screen_w = 0;
|
int ji_screen_w = 0;
|
||||||
int ji_screen_h = 0;
|
int ji_screen_h = 0;
|
||||||
|
|
||||||
|
bool dirty_display_flag = true;
|
||||||
|
|
||||||
/* Global timer. */
|
/* Global timer. */
|
||||||
|
|
||||||
volatile int ji_clock = 0;
|
volatile int ji_clock = 0;
|
||||||
@ -148,9 +150,15 @@ void SetDisplay(she::Display* display)
|
|||||||
|
|
||||||
void UpdateCursorOverlay()
|
void UpdateCursorOverlay()
|
||||||
{
|
{
|
||||||
if (mouse_cursor_overlay != NULL && mouse_scares == 0)
|
if (mouse_cursor_overlay != NULL && mouse_scares == 0) {
|
||||||
mouse_cursor_overlay->moveOverlay(gfx::Point(m_x[0]-mouse_cursor->getFocus().x,
|
gfx::Point newPos(m_x[0]-mouse_cursor->getFocus().x,
|
||||||
m_y[0]-mouse_cursor->getFocus().y));
|
m_y[0]-mouse_cursor->getFocus().y);
|
||||||
|
|
||||||
|
if (newPos != mouse_cursor_overlay->getPosition()) {
|
||||||
|
mouse_cursor_overlay->moveOverlay(newPos);
|
||||||
|
dirty_display_flag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CursorType jmouse_get_cursor()
|
CursorType jmouse_get_cursor()
|
||||||
@ -174,6 +182,8 @@ void jmouse_set_cursor(CursorType type)
|
|||||||
show_mouse(NULL);
|
show_mouse(NULL);
|
||||||
set_mouse_cursor(theme->getCursor(type));
|
set_mouse_cursor(theme->getCursor(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dirty_display_flag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void jmouse_hide()
|
void jmouse_hide()
|
||||||
|
@ -27,6 +27,10 @@ namespace ui {
|
|||||||
extern int ji_screen_w;
|
extern int ji_screen_w;
|
||||||
extern int ji_screen_h;
|
extern int ji_screen_h;
|
||||||
|
|
||||||
|
// Simple flag to indicate that something in the screen was modified
|
||||||
|
// so a flip to the real screen is needed.
|
||||||
|
extern bool dirty_display_flag;
|
||||||
|
|
||||||
void SetDisplay(she::Display* display);
|
void SetDisplay(she::Display* display);
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@ -37,6 +41,8 @@ namespace ui {
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* mouse related */
|
/* mouse related */
|
||||||
|
|
||||||
|
// Updates the position of the mouse cursor overlay depending on the
|
||||||
|
// current mouse position.
|
||||||
void UpdateCursorOverlay();
|
void UpdateCursorOverlay();
|
||||||
|
|
||||||
CursorType jmouse_get_cursor();
|
CursorType jmouse_get_cursor();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user