~ubuntu-branches/ubuntu/oneiric/koffice/oneiric-updates

« back to all changes in this revision

Viewing changes to krita/image/kis_update_scheduler.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (c) 2010 Dmitry Kazakov <dimula73@gmail.com>
 
3
 *
 
4
 *  This program is free software; you can redistribute it and/or modify
 
5
 *  it under the terms of the GNU General Public License as published by
 
6
 *  the Free Software Foundation; either version 2 of the License, or
 
7
 *  (at your option) any later version.
 
8
 *
 
9
 *  This program is distributed in the hope that it will be useful,
 
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 *  GNU General Public License for more details.
 
13
 *
 
14
 *  You should have received a copy of the GNU General Public License
 
15
 *  along with this program; if not, write to the Free Software
 
16
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
17
 */
 
18
 
 
19
#include "kis_update_scheduler.h"
 
20
 
 
21
#include "kis_merge_walker.h"
 
22
#include "kis_full_refresh_walker.h"
 
23
#include "kis_simple_update_queue.h"
 
24
 
 
25
KisUpdateScheduler::KisUpdateScheduler(KisImageWSP image)
 
26
    : m_workQueue(0)
 
27
{
 
28
    updateSettings();
 
29
 
 
30
    // The queue will update settings in a constructor itself
 
31
    m_workQueue = new KisSimpleUpdateQueue();
 
32
 
 
33
    connect(&m_updaterContext, SIGNAL(sigContinueUpdate(const QRect&)),
 
34
            image, SLOT(slotProjectionUpdated(const QRect&)),
 
35
            Qt::DirectConnection);
 
36
 
 
37
    connect(&m_updaterContext, SIGNAL(sigDoSomeUsefulWork()),
 
38
            SLOT(doSomeUsefulWork()), Qt::DirectConnection);
 
39
 
 
40
    connect(&m_updaterContext, SIGNAL(sigSpareThreadAppeared()),
 
41
            SLOT(spareThreadAppeared()), Qt::DirectConnection);
 
42
 
 
43
}
 
44
 
 
45
KisUpdateScheduler::~KisUpdateScheduler()
 
46
{
 
47
}
 
48
 
 
49
void KisUpdateScheduler::updateProjection(KisNodeSP node, const QRect& rc, const QRect &cropRect)
 
50
{
 
51
    m_workQueue->addJob(node, rc, cropRect);
 
52
    m_workQueue->processQueue(m_updaterContext);
 
53
}
 
54
 
 
55
void KisUpdateScheduler::fullRefresh(KisNodeSP root, const QRect& rc, const QRect &cropRect)
 
56
{
 
57
    KisBaseRectsWalkerSP walker = new KisFullRefreshWalker(cropRect);
 
58
    walker->collectRects(root, rc);
 
59
 
 
60
    m_workQueue->executeJobSync(walker, m_updaterContext);
 
61
}
 
62
 
 
63
void KisUpdateScheduler::updateSettings()
 
64
{
 
65
    if(m_workQueue) {
 
66
        m_workQueue->updateSettings();
 
67
    }
 
68
}
 
69
 
 
70
void KisUpdateScheduler::lock()
 
71
{
 
72
    m_workQueue->blockProcessing(m_updaterContext);
 
73
}
 
74
 
 
75
void KisUpdateScheduler::unlock()
 
76
{
 
77
    m_workQueue->startProcessing(m_updaterContext);
 
78
}
 
79
 
 
80
void KisUpdateScheduler::waitForDone()
 
81
{
 
82
    m_updaterContext.waitForDone();
 
83
    Q_ASSERT(m_workQueue->isEmpty());
 
84
}
 
85
 
 
86
void KisUpdateScheduler::doSomeUsefulWork()
 
87
{
 
88
    m_workQueue->optimize();
 
89
}
 
90
 
 
91
void KisUpdateScheduler::spareThreadAppeared()
 
92
{
 
93
    m_workQueue->processQueue(m_updaterContext);
 
94
}
 
95