[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra] krita/plugins/extensions/dockers/defaultdockers: Remove
From: Boudewijn Rempt <boud () valdyas ! org>
Date: 2011-07-24 14:30:48
Message-ID: 20110724143048.A2010A60D8 () git ! kde ! org
[Download RAW message or body]
Git commit f325b5c6daa932b3aa73e6ad10af39069517ef20 by Boudewijn Rempt.
Committed on 24/07/2011 at 16:27.
Pushed by rempt into branch 'master'.
Remove history docker
The history docker has been unmaintained and uninstalled for a long time.
It caused a lot of crashes due to multi-threading issues.
D +0 -52 krita/plugins/extensions/dockers/defaultdockers/histogramdock_factory.h
D +0 -88 krita/plugins/extensions/dockers/defaultdockers/kis_accumulating_producer.h
D +0 -109 krita/plugins/extensions/dockers/defaultdockers/kis_imagerasteredcache.h
D +0 -224 krita/plugins/extensions/dockers/defaultdockers/histogramdock.cpp
D +0 -54 krita/plugins/extensions/dockers/defaultdockers/kis_cachedhistogram.h
D +0 -111 krita/plugins/extensions/dockers/defaultdockers/kis_accumulating_producer.cc
M +0 -11 krita/plugins/extensions/dockers/defaultdockers/CMakeLists.txt
M +0 -2 krita/plugins/extensions/dockers/defaultdockers/defaultdockers.cpp
D +0 -69 krita/plugins/extensions/dockers/defaultdockers/histogram_updater.cpp
D +0 -38 krita/plugins/extensions/dockers/defaultdockers/kis_cachedhistogram.cc
D +0 -55 krita/plugins/extensions/dockers/defaultdockers/histogram_updater.h
D +0 -78 krita/plugins/extensions/dockers/defaultdockers/histogramdock.h
D +0 -197 krita/plugins/extensions/dockers/defaultdockers/kis_imagerasteredcache.cc
http://commits.kde.org/calligra/f325b5c6daa932b3aa73e6ad10af39069517ef20
diff --git a/krita/plugins/extensions/dockers/defaultdockers/CMakeLists.txt \
b/krita/plugins/extensions/dockers/defaultdockers/CMakeLists.txt index \
a8e58b4..5865ab2 100644
--- a/krita/plugins/extensions/dockers/defaultdockers/CMakeLists.txt
+++ b/krita/plugins/extensions/dockers/defaultdockers/CMakeLists.txt
@@ -2,11 +2,6 @@ set(kritadefaultdockers_PART_SRCS
kis_palette_docker.cc
kis_birdeye_box.cc
kis_layer_box.cpp
- histogramdock.cpp
- histogram_updater.cpp
- kis_accumulating_producer.cc
- kis_cachedhistogram.cc
- kis_imagerasteredcache.cc
defaultdockers.cpp
)
@@ -14,12 +9,6 @@ set(kritadefaultdockers_PART_HEADERS
kis_palette_docker.h
kis_birdeye_box.h
kis_layer_box.h
- histogramdock_factory.h
- histogramdock.h
- histogram_updater.h
- kis_accumulating_producer.h
- kis_cachedhistogram.h
- kis_imagerasteredcache.h
defaultdockers.h
)
diff --git a/krita/plugins/extensions/dockers/defaultdockers/defaultdockers.cpp \
b/krita/plugins/extensions/dockers/defaultdockers/defaultdockers.cpp index \
73a4a75..7a0cbdb 100644
--- a/krita/plugins/extensions/dockers/defaultdockers/defaultdockers.cpp
+++ b/krita/plugins/extensions/dockers/defaultdockers/defaultdockers.cpp
@@ -24,7 +24,6 @@
#include <KoDockRegistry.h>
#include "kis_debug.h"
-#include "histogramdock_factory.h"
#include "kis_birdeye_box.h"
#include "kis_layer_box.h"
#include "kis_palette_docker.h"
@@ -35,7 +34,6 @@ K_EXPORT_PLUGIN(KritaDefaultDockersPluginFactory("krita"))
KritaDefaultDockersPlugin::KritaDefaultDockersPlugin(QObject *parent, const \
QVariantList &) : QObject(parent)
{
- //KoDockRegistry::instance()->add(new KisHistogramDockFactory());
KoDockRegistry::instance()->add(new KisLayerBoxFactory());
KoDockRegistry::instance()->add(new KisBirdEyeBoxFactory());
KoDockRegistry::instance()->add(new KisPaletteDockerFactory());
diff --git a/krita/plugins/extensions/dockers/defaultdockers/histogram_updater.cpp \
b/krita/plugins/extensions/dockers/defaultdockers/histogram_updater.cpp deleted file \
mode 100644 index 4647478..0000000
--- a/krita/plugins/extensions/dockers/defaultdockers/histogram_updater.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * This file is part of the KDE project
- *
- * Copyright (c) 2005 Bart Coppens <kde@bartcoppens.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "histogram_updater.h"
-#include <QMenu>
-#include <QDockWidget>
-
-#include <klocale.h>
-#include <kiconloader.h>
-#include <kcomponentdata.h>
-#include <kmessagebox.h>
-#include <kstandarddirs.h>
-#include <kis_debug.h>
-#include <kpluginfactory.h>
-
-#include "KoDockFactoryBase.h"
-#include "KoBasicHistogramProducers.h"
-#include "KoColorSpaceRegistry.h"
-#include "KoID.h"
-
-#include "kis_global.h"
-#include "kis_types.h"
-#include "kis_image.h"
-#include "kis_view2.h"
-#include <kis_histogram_view.h>
-
-#include "kis_imagerasteredcache.h"
-#include "kis_accumulating_producer.h"
-
-HistogramDockerUpdater::HistogramDockerUpdater(QObject* /*parent*/, KisHistogramSP \
h, KisHistogramView* v,
- KisAccumulatingHistogramProducer* p)
- : m_histogram(h), m_view(v), m_producer(p)
-{
- connect(p, SIGNAL(completed()), this, SLOT(completed()));
-}
-
-void HistogramDockerUpdater::updated()
-{
- // We don't [!] do m_histogram->updateHistogram();, because that will try to \
compute
- // the histogram synchronously, while we want it asynchronously.
- m_producer->addRegionsToBinAsync();
-}
-
-void HistogramDockerUpdater::completed()
-{
- if (m_histogram) {
- m_histogram->computeHistogram();
- }
- m_view->updateHistogram();
-}
-
-#include "histogram_updater.moc"
diff --git a/krita/plugins/extensions/dockers/defaultdockers/histogram_updater.h \
b/krita/plugins/extensions/dockers/defaultdockers/histogram_updater.h deleted file \
mode 100644 index c666953..0000000
--- a/krita/plugins/extensions/dockers/defaultdockers/histogram_updater.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * This file is part of Krita
- *
- * Copyright (c) 2005 Bart Coppens <kde@bartcoppens.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef _HISTOGRAM_UPDATER_H_
-#define _HISTOGRAM_UPDATER_H_
-
-#include <QObject>
-#include <QMenu>
-#include <QDockWidget>
-
-#include <kparts/plugin.h>
-#include <kis_histogram.h>
-
-#include "kis_cachedhistogram.h"
-
-class KisAccumulatingHistogramProducer;
-class KoColorSpace;
-class KisHistogramView;
-class KisView2;
-class KoColorSpace;
-
-class HistogramDockerUpdater : public QObject
-{
- Q_OBJECT
-public:
- HistogramDockerUpdater(QObject* parent, KisHistogramSP h, KisHistogramView* v,
- KisAccumulatingHistogramProducer* p);
-public slots:
- void updated();
-private slots:
- void completed();
-private:
- KisHistogramSP m_histogram;
- KisHistogramView* m_view;
- KisAccumulatingHistogramProducer* m_producer;
-};
-
-#endif
diff --git a/krita/plugins/extensions/dockers/defaultdockers/histogramdock.cpp \
b/krita/plugins/extensions/dockers/defaultdockers/histogramdock.cpp deleted file mode \
100644 index c37e621..0000000
--- a/krita/plugins/extensions/dockers/defaultdockers/histogramdock.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * This file is part of the KDE project
- *
- * Copyright (c) 2005 Bart Coppens <kde@bartcoppens.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "histogramdock.h"
-
-#include <QDockWidget>
-#include <QLabel>
-
-#include <kis_debug.h>
-
-#include "KoBasicHistogramProducers.h"
-#include "KoColorSpaceRegistry.h"
-#include "KoID.h"
-
-#include <kis_global.h>
-#include <kis_types.h>
-#include <kis_image.h>
-#include <kis_histogram_view.h>
-#include <kis_canvas2.h>
-#include <kis_view2.h>
-
-#include "kis_imagerasteredcache.h"
-#include "kis_accumulating_producer.h"
-#include "histogram_updater.h"
-
-KisHistogramDocker::KisHistogramDocker()
- : QDockWidget(i18n("Histogram"))
- , m_canvas(0)
- , m_image(0)
- , m_factory(0)
- , m_producer(0)
- , m_cs(0)
- , m_hview(0)
- , m_cache(0)
- , m_histogram(0)
-{
-}
-
-KisHistogramDocker::~KisHistogramDocker()
-{
- uint count = m_producers . count();
- for (uint i = 0; i < count; i++) {
- delete m_producers . at(i);
- }
- m_producers.clear();
- if (m_cache)
- m_cache->deleteLater();
-
- delete m_producer;
-}
-
-void KisHistogramDocker::setCanvas(KoCanvasBase* canvas)
-{
- // "Every connection you make emits a signal, so duplicate connections emit two \
signals"
- if (m_canvas) {
- m_canvas->disconnectCanvasObserver(this);
- }
-
- m_canvas = dynamic_cast<KisCanvas2*>(canvas);
- if (m_canvas) {
- connect(m_canvas, SIGNAL(imageChanged(KisImageWSP)), \
SLOT(setImage(KisImageWSP)));
- }
-}
-
-void KisHistogramDocker::setImage(KisImageWSP image)
-{
- if (!image) return;
-
- Q_ASSERT(image);
-
- m_image = image;
-
- if (m_canvas && m_canvas->view()) {
-
-
- m_hview = 0; // producerChanged wants to setCurrentChannels, prevent that \
here
- m_cache = 0; // we try to delete it in producerChanged
- colorSpaceChanged(m_image->colorSpace()); // calls producerChanged(0)
-
- if (m_histogram) {
- m_hview = new KisHistogramView(this);
- m_hview->setHistogram(m_histogram);
- m_hview->setColor(true);
-
- // At the time we called colorSpaceChanged m_hview was not yet \
constructed, so producerChanged didn't call this
- setChannels();
-
- m_hview->setFixedSize(256, 100); // XXX if not it keeps expanding
- m_hview->setWindowTitle(i18n("Histogram"));
-
- connect(m_hview, SIGNAL(rightClicked(const QPoint&)), \
SLOT(popupMenu(const QPoint&)));
- connect(m_cache, SIGNAL(cacheUpdated()), new \
HistogramDockerUpdater(this, m_histogram, m_hview, m_producer), \
SLOT(updated()));
- connect(&m_popup, SIGNAL(triggered(QAction *)), \
SLOT(producerChanged(QAction *)));
- connect(m_canvas->view(), SIGNAL(sigLoadingFinished()), SLOT(reset()));
- connect(m_image.data(), SIGNAL(sigColorSpaceChanged(const \
KoColorSpace*)), SLOT(colorSpaceChanged(const KoColorSpace*))); // No need to force \
updates here
- m_cache->setDocker(this);
- m_cache->setImage(m_image);
-
- setWidget(m_hview);
- }
- else {
- QLabel* l = new QLabel(i18n("Histograms are not supported for images in \
the %1 colorspace.",m_cs->name()),
- m_canvas->view());
- l->setWordWrap(true);
- l->setMargin(4);
- setWidget(l);
- }
-
- } else {
- delete m_cache;
- m_cache = 0;
- }
-
-}
-
-void KisHistogramDocker::setChannels()
-{
- m_hview->setHistogram(m_histogram);
- m_hview->setColor(true);
- QList<KoChannelInfo *> channels;
- // Only display color channels
- for (int i = 0; i < m_producer->channels().count(); i++) {
- if (m_producer->channels().at(i)->channelType() == KoChannelInfo::COLOR) {
- channels.append(m_producer->channels().at(i));
- }
- }
- m_hview->setCurrentChannels(KoHistogramProducerSP(m_producer), channels);
-}
-
-void KisHistogramDocker::producerChanged(QAction *action)
-{
- int pos = m_popup.actions().indexOf(action);
-
- if (m_cache)
- m_cache->deleteLater();
- m_cache = 0;
-
- if (m_currentProducerPos < m_popup.actions().count())
- m_popup.actions().at(m_currentProducerPos)->setChecked(false);
- m_currentProducerPos = pos;
- m_popup.actions().at(m_currentProducerPos)->setChecked(true);
-
- uint count = m_producers . count();
- for (uint i = 0; i < count; i++) {
- delete m_producers . at(i);
- }
- m_producers.clear();
-
- QList<QString> keys = \
KoHistogramProducerFactoryRegistry::instance()->keysCompatibleWith(m_cs);
-
- m_factory = KoHistogramProducerFactoryRegistry::instance()->get(keys.at(pos));
-
- KisCachedHistogramObserver observer(&m_producers, m_factory, 0, 0, 0, 0, false);
-
- // We can reference observer because it will be only used as a factory to create \
new
- // instances
- m_cache = new KisImageRasteredCache(&observer);
- m_producer = new KisAccumulatingHistogramProducer(&m_producers);
-
- // use dummy layer as a source; we are not going to actually use or need it
- // All of these are SP, no need to delete them afterwards
- KisPaintDeviceSP paintDevice = new \
KisPaintDevice(KoColorSpaceRegistry::instance()->alpha8());
- m_histogram = new KisHistogram(paintDevice, paintDevice->exactBounds(),
- KoHistogramProducerSP(m_producer), LOGARITHMIC);
-
- kDebug() << "created histogram " << m_histogram;
-
- if (m_hview) {
- setChannels();
- connect(m_cache, SIGNAL(cacheUpdated()),
- new HistogramDockerUpdater(this, m_histogram, m_hview, m_producer), \
SLOT(updated()));
- }
-}
-
-void KisHistogramDocker::popupMenu(const QPoint& pos)
-{
- m_popup.popup(pos, m_popup.actions().at(m_currentProducerPos));
-}
-
-void KisHistogramDocker::colorSpaceChanged(const KoColorSpace* cs)
-{
- kDebug() << cs;
- m_cs = cs;
-
- QList<QString> keys = \
KoHistogramProducerFactoryRegistry::instance()->keysCompatibleWith(m_cs);
-
- m_popup.clear();
- m_currentProducerPos = 0;
-
- foreach (const QString &key, keys) {
- m_popup.addAction(KoHistogramProducerFactoryRegistry::instance()->get(key)->name());
- }
-
- if (m_popup.actions().size() > 0) {
- producerChanged(m_popup.actions().at(0));
- }
-}
-
-void KisHistogramDocker::reset()
-{
- kDebug() << m_image << m_image.isValid();
- if (m_image && m_image.isValid()) {
- colorSpaceChanged(m_image->colorSpace());
- }
-}
-
-#include "histogramdock.moc"
diff --git a/krita/plugins/extensions/dockers/defaultdockers/histogramdock.h \
b/krita/plugins/extensions/dockers/defaultdockers/histogramdock.h deleted file mode \
100644 index ee82302..0000000
--- a/krita/plugins/extensions/dockers/defaultdockers/histogramdock.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * This file is part of the KDE project
- *
- * Copyright (c) 2005 Bart Coppens <kde@bartcoppens.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-#ifndef HISTOGRAM_DOCK_H
-#define HISTOGRAM_DOCK_H
-
-#include <QDockWidget>
-#include <QMenu>
-
-#include <KoCanvasObserverBase.h>
-
-#include <kis_types.h>
-#include "kis_cachedhistogram.h"
-
-class KoColorSpace;
-class KoHistogramProducerFactory;
-class KisAccumulatingHistogramProducer;
-class KisCanvas2;
-class KisHistogramView;
-class KisImagerasteredCache;
-
-class KisHistogramDocker : public QDockWidget, public KoCanvasObserverBase
-{
-
- Q_OBJECT
-
-public:
- KisHistogramDocker();
- virtual ~KisHistogramDocker();
-
- /// reimplemented from KoCanvasObserverBase
- virtual void setCanvas(KoCanvasBase *canvas);
- virtual void unsetCanvas() { m_canvas = 0; }
-
-private slots:
-
- void setImage(KisImageWSP image);
- void producerChanged(QAction *action);
- void popupMenu(const QPoint & pos);
- void colorSpaceChanged(const KoColorSpace* cs);
- void reset();
-
-private:
-
- void setChannels();
-
- KisCanvas2* m_canvas;
- KisImageWSP m_image;
- KoHistogramProducerFactory* m_factory;
- KisCachedHistogramObserver::Producers m_producers;
- KisAccumulatingHistogramProducer* m_producer;
- const KoColorSpace* m_cs;
- KisHistogramView* m_hview;
- KisImageRasteredCache* m_cache;
- QMenu m_popup;
- KisHistogramSP m_histogram;
- int m_currentProducerPos;
-
-
-};
-
-#endif
diff --git a/krita/plugins/extensions/dockers/defaultdockers/histogramdock_factory.h \
b/krita/plugins/extensions/dockers/defaultdockers/histogramdock_factory.h deleted \
file mode 100644 index c527388..0000000
--- a/krita/plugins/extensions/dockers/defaultdockers/histogramdock_factory.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * This file is part of the KDE project
- *
- * Copyright (c) 2005 Bart Coppens <kde@bartcoppens.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-#ifndef HISTOGRAM_DOCK_FACTORY_H
-#define HISTOGRAM_DOCK_FACTORY_H
-
-#include "histogramdock.h"
-#include <KoDockFactoryBase.h>
-
-class KisHistogramDockFactory : public KoDockFactoryBase
-{
-public:
- KisHistogramDockFactory() {}
-
- virtual QString id() const {
- return QString("KisHistogramDocker");
- }
-
- virtual Qt::DockWidgetArea defaultDockWidgetArea() const {
- return Qt::RightDockWidgetArea;
- }
-
- virtual QDockWidget* createDockWidget() {
-
- KisHistogramDocker* dockWidget = new KisHistogramDocker();
- dockWidget->setObjectName(id());
-
- return dockWidget;
- }
-
- DockPosition defaultDockPosition() const {
- return DockRight;
- }
-};
-
-#endif
diff --git a/krita/plugins/extensions/dockers/defaultdockers/kis_accumulating_producer.cc \
b/krita/plugins/extensions/dockers/defaultdockers/kis_accumulating_producer.cc \
deleted file mode 100644 index 876ed00..0000000
--- a/krita/plugins/extensions/dockers/defaultdockers/kis_accumulating_producer.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * This file is part of Krita
- *
- * Copyright (c) 2005 Bart Coppens <kde@bartcoppens.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kis_accumulating_producer.h"
-
-#include <QThread>
-#include <QApplication>
-#include <QEvent>
-
-static const QEvent::Type EmitCompletedType = QEvent::Type(QEvent::User + 1);
-
-/**
- * The threaded producer definition in c++ file because this is really an internal \
affair.
- * Note that since we _know_ that we'll only have a single instance of it running, \
at most,
- * we don't care too much about locking and synchronization
- **/
-class KisAccumulatingHistogramProducer::ThreadedProducer : public QThread
-{
- KisAccumulatingHistogramProducer* m_source;
- bool m_stop;
-protected:
- virtual void run();
-public:
- ThreadedProducer(KisAccumulatingHistogramProducer* source)
- : m_source(source), m_stop(false) {}
- void cancel() {
- m_stop = true;
- }
-};
-
-KisAccumulatingHistogramProducer::KisAccumulatingHistogramProducer(KisCachedHistogramObserver::Producers* \
source)
- : KoBasicHistogramProducer(
- KoID("ACCHISTO", ""),
- source->at(0)->channels().count(),
- source->at(0)->numberOfBins(),
- 0),
- m_source(source)
-{
- m_thread = new ThreadedProducer(this);
-}
-
-KisAccumulatingHistogramProducer::~KisAccumulatingHistogramProducer()
-{
- m_thread->cancel();
- m_thread->wait();
- delete m_thread;
-}
-
-void KisAccumulatingHistogramProducer::addRegionsToBinAsync()
-{
- m_thread->cancel();
- m_thread->wait();
- clear();
- m_thread->start();
-}
-
-void KisAccumulatingHistogramProducer::ThreadedProducer::run()
-{
- m_stop = false;
-
- uint count = m_source->m_source->count(); // Talk about bad naming schemes...
- KisCachedHistogramObserver::Producers* source = m_source->m_source;
- QVector<vBins>& bins = m_source->m_bins;
- int channels = m_source->m_channels;
- int nrOfBins = m_source->m_nrOfBins;
-
- for (uint i = 0; i < count && !m_stop; i++) {
- KoHistogramProducer* p = source->at(i);
- m_source->m_count += p->count();
-
- for (int j = 0; j < channels && !m_stop; j++) {
- for (int k = 0; k < nrOfBins; k++) {
- bins[j][k] += p->getBinAt(j, k);
- }
- }
- }
-
- if (!m_stop) {
- // This function is thread-safe; and it takes ownership of the event
- QCoreApplication::postEvent(m_source, new QEvent(EmitCompletedType));
- }
-}
-
-bool KisAccumulatingHistogramProducer::event(QEvent* e)
-{
- if (e->type() == EmitCompletedType) {
- emit completed();
- return true;
- }
- return QObject::event(e);
-}
-
-#include "kis_accumulating_producer.moc"
-
diff --git a/krita/plugins/extensions/dockers/defaultdockers/kis_accumulating_producer.h \
b/krita/plugins/extensions/dockers/defaultdockers/kis_accumulating_producer.h deleted \
file mode 100644 index 288d0a0..0000000
--- a/krita/plugins/extensions/dockers/defaultdockers/kis_accumulating_producer.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * This file is part of Krita
- *
- * Copyright (c) 2005 Bart Coppens <kde@bartcoppens.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef _KIS_ACCUMULATING_PRODUCER_H_
-#define _KIS_ACCUMULATING_PRODUCER_H_
-
-#include <QObject>
-//Added by qt3to4:
-#include <QCustomEvent>
-
-#include <KoBasicHistogramProducers.h>
-#include "kis_cachedhistogram.h"
-
-/**
- * Kept very minimalistic because all options would require much reiterating which \
we don't want.
- * This class is multithreading! Don't expect it to contain the right data after an
- * addRegionsToBinAsync call, but await it's completed() signal. Also beware! This \
function
- * _does_ clear() before addRegionsToBinAsync! (hence not conforming to the regular \
semantics
- * of HistogramProducers if you'd take addRegionsToBinAsync = addRegionToBin, but \
since that is
- * already violated with the asynchronousity of it that is not really an issue \
anymore, I think)
- **/
-class KisAccumulatingHistogramProducer : public QObject, public \
KoBasicHistogramProducer
-{
- Q_OBJECT
-public:
- KisAccumulatingHistogramProducer(KisCachedHistogramObserver::Producers* source);
- ~KisAccumulatingHistogramProducer();
- /// Does _nothing_, use addRegionsToBinAsync
- virtual void addRegionToBin(const quint8 *, const quint8*, quint32, const \
KoColorSpace *) {}
- virtual void addRegionsToBinAsync();
- virtual QString positionToString(qreal pos) const {
- return m_source->at(0)->positionToString(pos);
- }
-
- virtual void setView(qreal, qreal) {} // No view support
- virtual qreal maximalZoom() const {
- return 1.0;
- }
-
- virtual qint32 numberOfBins() {
- return m_source->at(0)->numberOfBins();
- }
-
- virtual QList<KoChannelInfo *> channels() {
- return m_source->at(0)->channels();
- }
-
- /// Call this when the 'source' list has changed colorspace
- virtual void changedSourceProducer() {
- m_count = m_source->at(0)->channels().count();
- m_external.clear();
- makeExternalToInternal();
- }
-
-signals:
- void completed();
-
-protected:
- virtual bool event(QEvent* e);
- /// source already converts external to internal
- virtual int externalToInternal(int ext) {
- return ext;
- }
- KisCachedHistogramObserver::Producers* m_source;
-
- class ThreadedProducer;
- friend class ThreadedProducer;
- ThreadedProducer* m_thread;
-};
-
-#endif // _KIS_ACCUMULATING_PRODUCER_H_
diff --git a/krita/plugins/extensions/dockers/defaultdockers/kis_cachedhistogram.cc \
b/krita/plugins/extensions/dockers/defaultdockers/kis_cachedhistogram.cc deleted file \
mode 100644 index f68f3dd..0000000
--- a/krita/plugins/extensions/dockers/defaultdockers/kis_cachedhistogram.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * This file is part of Krita
- *
- * Copyright (c) 2005 Bart Coppens <kde@bartcoppens.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kis_cachedhistogram.h"
-
-#include <kis_paint_device.h>
-#include <kis_iterators_pixel.h>
-
-void KisCachedHistogramObserver::regionUpdated(KisPaintDeviceSP dev)
-{
- m_producer->clear();
- KisRectConstIteratorPixel srcIt = dev->createRectConstIterator(m_x, m_y, m_w, \
m_h);
- int i;
- while (!srcIt.isDone()) {
- i = srcIt.nConseqPixels();
- m_producer->addRegionToBin(srcIt.rawData(), srcIt.selectionMask(), i, \
dev->colorSpace());
- srcIt += i;
- if (i == 0)
- ++srcIt;
- }
-}
diff --git a/krita/plugins/extensions/dockers/defaultdockers/kis_cachedhistogram.h \
b/krita/plugins/extensions/dockers/defaultdockers/kis_cachedhistogram.h deleted file \
mode 100644 index 34ae9a1..0000000
--- a/krita/plugins/extensions/dockers/defaultdockers/kis_cachedhistogram.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * This file is part of Krita
- *
- * Copyright (c) 2005 Bart Coppens <kde@bartcoppens.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef _CACHED_HISTOGRAM_H_
-#define _CACHED_HISTOGRAM_H_
-
-#include <QVector>
-#include <KoHistogramProducer.h>
-
-#include "kis_imagerasteredcache.h"
-
-class KisCachedHistogramObserver : public KisImageRasteredCache::Observer
-{
-public:
- typedef QVector<KoHistogramProducer*> Producers;
- KisCachedHistogramObserver(Producers* p, KoHistogramProducerFactory* f,
- int x, int y, int w, int h, bool add = true)
- : m_producers(p), m_factory(f), m_x(x), m_y(y), m_w(w), m_h(h) {
- m_producer = m_factory->generate();
- if (add)
- m_producers->append(m_producer.data());
- }
- virtual ~KisCachedHistogramObserver() {}
-
- virtual Observer* createNew(int x, int y, int w, int h) {
- return new KisCachedHistogramObserver(m_producers, m_factory, x, y, w, h);
- }
-
- virtual void regionUpdated(KisPaintDeviceSP dev);
-private:
- Producers* m_producers;
- KoHistogramProducerFactory* m_factory;
- KoHistogramProducerSP m_producer;
- int m_x, m_y, m_w, m_h;
-};
-
-#endif // _CACHED_HISTOGRAM_H_
diff --git a/krita/plugins/extensions/dockers/defaultdockers/kis_imagerasteredcache.cc \
b/krita/plugins/extensions/dockers/defaultdockers/kis_imagerasteredcache.cc deleted \
file mode 100644 index f8b7362..0000000
--- a/krita/plugins/extensions/dockers/defaultdockers/kis_imagerasteredcache.cc
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * This file is part of the KDE project
- *
- * Copyright (c) 2005 Bart Coppens <kde@bartcoppens.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kis_imagerasteredcache.h"
-
-#include <cmath>
-
-#include <QApplication>
-
-#include <kis_debug.h>
-
-#include <kis_global.h>
-#include <kis_types.h>
-#include <kis_image.h>
-#include <kis_view2.h>
-
-KisImageRasteredCache::KisImageRasteredCache(Observer* o)
- : m_observer(o->createNew(0, 0, 0, 0))
- , m_docker(0)
-{
- m_visible = false;
- m_busy = false;
- m_imageProjection = 0;
- m_rasterSize = 64 * 4;
- m_timeOutMSec = 1000;
-
- m_timer.setSingleShot(true);
- connect(&m_timer, SIGNAL(timeout()), this, SLOT(timeOut()));
-
- m_visibilityTimer.setSingleShot(true);
- connect(&m_visibilityTimer, SIGNAL(timeout()), this, SLOT(checkVisibility()));
-}
-
-KisImageRasteredCache::~KisImageRasteredCache()
-{
- cleanUpElements();
-}
-
-void KisImageRasteredCache::setDocker(QDockWidget* docker)
-{
- m_docker = docker;
- connect(m_docker, SIGNAL(visibilityChanged(bool)), \
SLOT(setDockerVisible(bool)));
-}
-
-void KisImageRasteredCache::setImage(KisImageWSP image)
-{
- m_image = image;
- if (image && image.isValid()) {
- imageSizeChanged(image->width(), image->height());
- }
- m_visible = m_docker->isVisible();
-}
-
-void KisImageRasteredCache::setDockerVisible(bool visible)
-{
- if (visible) {
- m_visibilityTimer.start(200);
- }
- else {
- m_visibilityTimer.stop();
- }
-}
-
-void KisImageRasteredCache::checkVisibility()
-{
- if (m_docker->isVisible() && m_image.isValid()) {
- m_visible = true;
- connect(m_image, SIGNAL(sigImageUpdated(QRect)), this, \
SLOT(imageUpdated(QRect)));
- connect(m_image, SIGNAL(sigSizeChanged(qint32, qint32)), this, \
SLOT(imageSizeChanged(qint32, qint32)));
- } else {
- m_visible = false;
- disconnect();
- }
-}
-
-void KisImageRasteredCache::imageUpdated(QRect rc)
-{
- // Do our but against global warming: don't waste cpu if the histogram isn't \
visible anyway.
- if (!m_visible) return;
- if (!m_image.isValid()) return;
-
- QRect r(0, 0, m_width * m_rasterSize, m_height * m_rasterSize);
- r &= rc;
-
- int x = static_cast<int>(r.x() / m_rasterSize);
- int y = static_cast<int>(r.y() / m_rasterSize);
- int x2 = static_cast<int>(ceil(float(r.x() + r.width()) / float(m_rasterSize)));
- int y2 = static_cast<int>(ceil(float(r.y() + r.height()) / \
float(m_rasterSize)));
-
- if (!m_raster.empty()) {
- for (; x < x2; x++) {
- for (int i = y; i < y2; i++) {
- if (x < m_raster.size()) {
- if (i < m_raster[x].size()) {
- Element* e = m_raster[x][i];
- if (e && e->valid) {
- e->valid = false;
- m_queue.push_back(e);
- }
- }
- }
- }
- }
- }
-
- if (!m_busy) {
- // If the timer is already started, this resets it. That way, we update \
always
- // m_timeOutMSec milliseconds after the lastly monitored activity
- m_timer.start(m_timeOutMSec);
- }
-}
-
-void KisImageRasteredCache::imageSizeChanged(qint32 w, qint32 h)
-{
- cleanUpElements();
- m_busy = false;
-
- m_width = static_cast<int>(ceil(float(w) / float(m_rasterSize)));
- m_height = static_cast<int>(ceil(float(h) / float(m_rasterSize)));
-
- m_raster.resize(m_width);
-
- int rasterX = 0;
-
- for (int i = 0; i < m_width * m_rasterSize; i += m_rasterSize) {
- int rasterY = 0;
-
- m_raster[rasterX].resize(m_height + 1);
-
- for (int j = 0; j < m_height * m_rasterSize; j += m_rasterSize) {
- Element* e = new Element(m_observer->createNew(i, j, m_rasterSize, \
m_rasterSize));
- m_raster[rasterX][rasterY] = e;
- rasterY++;
- }
- rasterX++;
- }
-
- imageUpdated(QRect(0, 0, m_image->width(), m_image->height()));
-}
-
-void KisImageRasteredCache::timeOut()
-{
- m_busy = true;
- if (!m_image) {
- return;
- }
- // Temporary cache: while we are busy, we won't get the mergeImage time and \
again.
- if (!m_imageProjection) {
- m_imageProjection = m_image->mergedImage();
- }
- // Pick one element of the cache, and update it
- if (!m_queue.isEmpty()) {
- m_queue.front()->observer->regionUpdated(m_imageProjection);
- m_queue.front()->valid = true;
- m_queue.pop_front();
- }
-
- // If there are still elements, we need to be called again (this emulates \
processEvents)
- if (!m_queue.isEmpty()) {
- QTimer::singleShot(0, this, SLOT(timeOut()));
- } else {
- emit cacheUpdated();
- m_imageProjection = 0;
- m_busy = false;
- }
-}
-
-void KisImageRasteredCache::cleanUpElements()
-{
- for (int i = 0; i < m_raster.count(); i++) {
- for (int j = 0; j < m_raster[i].count(); j++) {
- delete m_raster[i][j];
- }
- m_raster[i].clear();
- }
- m_raster.clear();
- m_queue.clear();
-}
-
-#include "kis_imagerasteredcache.moc"
diff --git a/krita/plugins/extensions/dockers/defaultdockers/kis_imagerasteredcache.h \
b/krita/plugins/extensions/dockers/defaultdockers/kis_imagerasteredcache.h deleted \
file mode 100644 index 3a6e884..0000000
--- a/krita/plugins/extensions/dockers/defaultdockers/kis_imagerasteredcache.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * This file is part of the KDE project
- *
- * Copyright (c) 2005 Bart Coppens <kde@bartcoppens.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef _KIS_IMAGE_RASTERED_CACHE_H_
-#define _KIS_IMAGE_RASTERED_CACHE_H_
-
-#include <QObject>
-#include <QVector>
-#include <QList>
-#include <QTimer>
-#include <QDockWidget>
-
-#include <kis_image.h>
-#include <kis_paint_device.h>
-
-class KisView2;
-
-/**
- The KisImageRasteredCache keeps a big 'grid' associated with the
- image, and with each block in the grid, it has an associated element
- and then if a part of the image is changed, it queues those parts of
- the grid to be updated as well and then it slowly updates the grid
- items (and associated stuff when the image resizes and so) in this
- case, the 'elements' are mini histograms and they need to get
- updated so we put them on a queue, and if the user has done nothing
- for long enough (hence the timer), we'll update the histograms that
- became dirty
-*/
-class KisImageRasteredCache : public QObject
-{
- Q_OBJECT
-
-public:
-
- class Observer
- {
- public:
- virtual Observer* createNew(int x, int y, int w, int h) = 0;
- virtual void regionUpdated(KisPaintDeviceSP dev) = 0;
- virtual ~Observer() {}
- };
-
- KisImageRasteredCache(Observer* o);
- virtual ~KisImageRasteredCache();
-
- void setDocker(QDockWidget* docker);
- void setImage(KisImageWSP image);
-
-signals:
-
- void cacheUpdated();
-
-private slots:
- void setDockerVisible(bool visible);
- void imageUpdated(QRect rc);
- void imageSizeChanged(qint32 w, qint32 h);
- void timeOut();
- void checkVisibility();
-
-private:
-
- class Element
- {
- public:
- Element(Observer* o) : observer(o), valid(true) {}
- Observer* observer;
- bool valid;
- };
-
- typedef QVector< QVector<Element*> > Raster;
- typedef QList<Element*> Queue;
-
- void cleanUpElements();
-
- Observer* m_observer;
- Raster m_raster;
- Queue m_queue;
- QTimer m_timer;
- QTimer m_visibilityTimer; // Qt shows the docker for a short while before hiding
- // it again. This timer checks whether we are still \
visible
- // after some time.
- int m_timeOutMSec;
- int m_rasterSize;
- int m_width, m_height;
- bool m_busy;
- QDockWidget* m_docker;
- bool m_visible;
- KisPaintDeviceSP m_imageProjection;
- KisImageWSP m_image;
-};
-
-#endif // _KIS_IMAGE_RASTERED_CACHE_H_
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic