2009-04-02 07:42:52 +02:00
|
|
|
/*
|
2009-04-02 08:31:37 +02:00
|
|
|
* Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
|
|
|
|
* Copyright (c) 2009 Aaron Seigo <aseigo@kde.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, 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 Library 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.
|
|
|
|
*/
|
2009-04-02 07:42:52 +02:00
|
|
|
|
2009-12-27 23:16:11 +01:00
|
|
|
#ifndef PLASMA_WALLPAPERRENDERTHREAD_P_H
|
|
|
|
#define PLASMA_WALLPAPERRENDERTHREAD_P_H
|
2009-04-02 07:42:52 +02:00
|
|
|
|
|
|
|
#include <QColor>
|
|
|
|
#include <QImage>
|
|
|
|
#include <QMutex>
|
2011-04-30 13:29:38 +02:00
|
|
|
#include <QQueue>
|
2009-04-02 07:42:52 +02:00
|
|
|
#include <QThread>
|
|
|
|
#include <QWaitCondition>
|
|
|
|
|
2009-04-02 08:31:37 +02:00
|
|
|
#include "plasma/wallpaper.h"
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2011-04-30 13:29:38 +02:00
|
|
|
class WallpaperRenderRequest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
WallpaperRenderRequest()
|
|
|
|
: token(++s_token)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
QWeakPointer<QObject> requester;
|
2011-10-30 10:24:57 +01:00
|
|
|
QImage providedImage;
|
2011-04-30 13:29:38 +02:00
|
|
|
QString file;
|
|
|
|
QSize size;
|
|
|
|
Wallpaper::ResizeMethod resizeMethod;
|
|
|
|
QColor color;
|
|
|
|
int token;
|
|
|
|
|
|
|
|
static int s_token;
|
|
|
|
};
|
|
|
|
|
2009-04-02 08:31:37 +02:00
|
|
|
class WallpaperRenderThread : public QThread
|
2009-04-02 07:42:52 +02:00
|
|
|
{
|
2009-04-02 08:31:37 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2009-04-02 07:42:52 +02:00
|
|
|
public:
|
2011-04-30 13:29:38 +02:00
|
|
|
WallpaperRenderThread(const WallpaperRenderRequest &request, QObject *parent = 0);
|
2009-04-02 08:31:37 +02:00
|
|
|
virtual ~WallpaperRenderThread();
|
2009-04-02 07:42:52 +02:00
|
|
|
|
2011-04-30 13:29:38 +02:00
|
|
|
static void render(const WallpaperRenderRequest &request);
|
2009-04-02 07:42:52 +02:00
|
|
|
|
2009-04-02 08:31:37 +02:00
|
|
|
Q_SIGNALS:
|
2011-04-30 13:29:38 +02:00
|
|
|
void done(const WallpaperRenderRequest &request, const QImage &image);
|
|
|
|
|
2009-04-02 07:42:52 +02:00
|
|
|
protected:
|
|
|
|
virtual void run();
|
|
|
|
|
|
|
|
private:
|
2011-04-30 13:29:38 +02:00
|
|
|
static void checkQueue();
|
|
|
|
WallpaperRenderRequest m_request;
|
2009-04-02 07:42:52 +02:00
|
|
|
|
|
|
|
bool m_abort;
|
2011-04-30 13:29:38 +02:00
|
|
|
static int s_rendererCount;
|
|
|
|
static QQueue<WallpaperRenderRequest> s_renderQueue;
|
2009-04-02 07:42:52 +02:00
|
|
|
};
|
|
|
|
|
2009-04-02 08:31:37 +02:00
|
|
|
} // namespace Plasma
|
2009-12-27 23:16:11 +01:00
|
|
|
|
2011-07-13 21:46:19 +02:00
|
|
|
Q_DECLARE_METATYPE(Plasma::WallpaperRenderRequest)
|
2009-12-27 23:16:11 +01:00
|
|
|
#endif // PLASMA_WALLPAPERRENDERTHREAD_P_H
|