Fix performance issues hiding/drawing brush preview w/certain quicktools

This fix a performance problem using the eyedropper (Alt modifier) when
the current tool uses a brush with huge boundaries (e.g. Eraser with
a 64px brush).
This commit is contained in:
David Capello 2015-06-19 09:45:58 -03:00
parent cb6c7283f4
commit b70be3ccd4

View File

@ -1123,28 +1123,32 @@ void Editor::updateQuicktool()
tools::Tool* new_quicktool = m_customizationDelegate->getQuickTool(current_tool);
// Check if the current state accept the given quicktool.
if (new_quicktool && !m_state->acceptQuickTool(new_quicktool))
if (new_quicktool &&
!m_state->acceptQuickTool(new_quicktool))
return;
// Hide the drawing cursor with the current tool brush size before
// we change the quicktool. In this way we avoid using the
// quicktool brush size to clean the current tool cursor.
// If the quick tool has changed we update the brush cursor, the
// context bar, and the status bar. Things that depends on the
// current tool.
//
// TODO Create a new Document concept of multiple extra cels: we
// need an extra cel for the drawing cursor, other for the moving
// pixels, etc. In this way we'll not have conflicts between
// different uses of the same extra cel.
if (m_state->requireBrushPreview())
hideDrawingCursor();
// TODO We could add a quick tool observer for this
if (old_quicktool != new_quicktool) {
// Hide the drawing cursor with the current tool brush size before
// we change the quicktool. In this way we avoid using the
// quicktool brush size to clean the current tool cursor.
//
// TODO Create a new Document concept of multiple extra cels: we
// need an extra cel for the drawing cursor, other for the moving
// pixels, etc. In this way we'll not have conflicts between
// different uses of the same extra cel.
if (m_state->requireBrushPreview())
hideDrawingCursor();
m_quicktool = new_quicktool;
m_quicktool = new_quicktool;
if (m_state->requireBrushPreview())
showDrawingCursor();
if (m_state->requireBrushPreview())
showDrawingCursor();
// If the tool has changed, we must to update the status bar because
// the new tool can display something different in the status bar (e.g. Eyedropper)
if (old_quicktool != m_quicktool) {
m_state->onQuickToolChange(this);
updateStatusBar();