plasma-framework/private/wallpaperrenderthread_p.h

84 lines
2.1 KiB
C
Raw Normal View History

/*
* 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.
*/
#ifndef PLASMA_WALLPAPERRENDERTHREAD_P_H
#define PLASMA_WALLPAPERRENDERTHREAD_P_H
#include <QColor>
#include <QImage>
#include <QMutex>
2011-04-30 13:29:38 +02:00
#include <QQueue>
#include <QThread>
#include <QWaitCondition>
#include "plasma/wallpaper.h"
namespace Plasma
{
2011-04-30 13:29:38 +02:00
class WallpaperRenderRequest
{
public:
WallpaperRenderRequest()
: token(++s_token)
{
}
QWeakPointer<QObject> requester;
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;
};
class WallpaperRenderThread : public QThread
{
Q_OBJECT
public:
2011-04-30 13:29:38 +02:00
WallpaperRenderThread(const WallpaperRenderRequest &request, QObject *parent = 0);
virtual ~WallpaperRenderThread();
2011-04-30 13:29:38 +02:00
static void render(const WallpaperRenderRequest &request);
Q_SIGNALS:
2011-04-30 13:29:38 +02:00
void done(const WallpaperRenderRequest &request, const QImage &image);
protected:
virtual void run();
private:
2011-04-30 13:29:38 +02:00
static void checkQueue();
WallpaperRenderRequest m_request;
bool m_abort;
2011-04-30 13:29:38 +02:00
static int s_rendererCount;
static QQueue<WallpaperRenderRequest> s_renderQueue;
};
} // namespace Plasma
2011-07-13 21:46:19 +02:00
Q_DECLARE_METATYPE(Plasma::WallpaperRenderRequest)
#endif // PLASMA_WALLPAPERRENDERTHREAD_P_H