Proper check for rawzor libraries.
[rawtherapee-fixes.git] / rtengine / updater.cc
blobcffc716d80451ebe3636ccefe70def1f5c5f55c2
1 /*
2 * This file is part of RawTherapee.
4 * Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
6 * RawTherapee is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * RawTherapee is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
19 #include <updater.h>
20 #include <gdkmm.h>
22 Updater::Updater () :
23 change (0),
24 ipc (NULL),
25 pl (NULL),
26 running (false)
30 ProcParams* Updater::changing (int what) {
32 mutex.lock ();
33 change |= what;
34 return &params;
37 void Updater::changed () {
39 mutex.unlock ();
40 startProcessing ();
43 void Updater::clearState () {
45 mutex.lock ();
46 change = 0;
47 mutex.unlock ();
50 ProcParams* Updater::getParams () {
52 return &params;
55 void Updater::startProcessing () {
57 #undef THREAD_PRIORITY_NORMAL
59 tstart.lock ();
60 if (ipc && !running) {
61 running = true;
62 tstart.unlock ();
63 Glib::Thread::create(sigc::mem_fun(*this, &Updater::process), 0, false, true, Glib::THREAD_PRIORITY_NORMAL);
65 else
66 tstart.unlock ();
69 void Updater::process () {
71 processing.lock ();
72 if (pl)
73 pl->setProcessingState (true);
75 int ch;
77 mutex.lock ();
78 while (change && ipc) {
79 ipc->params.copy (&params);
80 ch = change;
81 change = 0;
82 mutex.unlock ();
83 if (ch<=16384)
84 ipc->update (ch);
85 mutex.lock ();
87 mutex.unlock ();
88 tstart.lock ();
89 running = false;
90 tstart.unlock ();
92 if (pl)
93 pl->setProcessingState (false);
94 processing.unlock ();
97 void Updater::stop () {
99 if (running) {
100 change = 0;
101 processing.lock ();
102 processing.unlock ();