From 2aa942777e7ea6a17ae3e72a8c53096bdae30d26 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Thu, 12 May 2011 22:37:40 +0200 Subject: [PATCH] bye bye GLApplet --- CMakeLists.txt | 17 ---- glapplet.cpp | 213 ------------------------------------------------- glapplet.h | 88 -------------------- 3 files changed, 318 deletions(-) delete mode 100644 glapplet.cpp delete mode 100644 glapplet.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ed4459884..5d8580108 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -228,13 +228,6 @@ kde4_add_ui_files(plasma_LIB_SRCS # TEST_INCLUDES #) -if (QT_QTOPENGL_FOUND) - message(STATUS "Adding support for OpenGL applets to libplasma") - set(plasma_LIB_SRCS - ${plasma_LIB_SRCS} - glapplet.cpp) -endif(QT_QTOPENGL_FOUND) - if (PHONON_FOUND) message(STATUS "Adding support for Phonon to libplasma") include_directories(${KDE4_PHONON_INCLUDES}) @@ -265,10 +258,6 @@ if(DL_LIBRARY) target_link_libraries(plasma ${DL_LIBRARY}) endif(DL_LIBRARY) -if(QT_QTOPENGL_FOUND) - target_link_libraries(plasma ${QT_QTOPENGL_LIBRARY}) -endif(QT_QTOPENGL_FOUND) - target_link_libraries(plasma LINK_INTERFACE_LIBRARIES kdeui kdecore ${QT_QTGUI_LIBRARY}) #do NOT use GENERIC versioning -- the plasma team will take care of versioning @@ -348,12 +337,6 @@ if(NOT KDE_NO_DEPRECATED) endif(NOT KDE_NO_DEPRECATED) -if(QT_QTOPENGL_FOUND) - set(plasma_LIB_INCLUDES - ${plasma_LIB_INCLUDES} - glapplet.h) -endif(QT_QTOPENGL_FOUND) - install(FILES ${plasma_LIB_INCLUDES} DESTINATION ${INCLUDE_INSTALL_DIR}/plasma COMPONENT Devel) diff --git a/glapplet.cpp b/glapplet.cpp deleted file mode 100644 index e55f46adf..000000000 --- a/glapplet.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright 2007 Zack Rusin - * - * 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. - */ - -#include "glapplet.h" - -#include -#include -#include - -namespace Plasma { - -class GLAppletPrivate -{ -public: - GLAppletPrivate() - { - init(); - } - ~GLAppletPrivate() - { - delete pbuf; - delete dummy; - } - void init() - { - dummy = new QGLWidget((QWidget *) 0); - QGLFormat format = QGLFormat::defaultFormat(); - format.setSampleBuffers(true); - format.setAlphaBufferSize(8); - //dummy size construction - pbuf = new QGLPixelBuffer(300, 300, format, dummy); - if (pbuf->isValid()) { - pbuf->makeCurrent(); - } - } - void updateGlSize(const QSize &size) - { - if (size.width() > pbuf->width() || - size.height() > pbuf->height()) { - QGLFormat format = pbuf->format(); - delete pbuf; - pbuf = new QGLPixelBuffer(size, format, dummy); - } - } - -public: - QGLPixelBuffer *pbuf; - QGLWidget *dummy; -}; - -GLApplet::GLApplet(QGraphicsItem *parent, - const QString &serviceId, - int appletId) - : Applet(parent, serviceId, appletId), - d(new GLAppletPrivate) -{ - if (!d->dummy->isValid() || - !QGLPixelBuffer::hasOpenGLPbuffers() || - !d->pbuf->isValid()) { - setFailedToLaunch(true, i18n("This system does not support OpenGL widgets.")); - } -} - -GLApplet::GLApplet(QObject *parent, const QVariantList &args) - : Applet(parent, args), - d(new GLAppletPrivate) -{ - if (!d->dummy->isValid() || - !QGLPixelBuffer::hasOpenGLPbuffers() || - !d->pbuf->isValid()) { - setFailedToLaunch(true, i18n("This system does not support OpenGL widgets.")); - } -} - -GLApplet::~GLApplet() -{ - delete d; -} - -GLuint GLApplet::bindTexture(const QImage &image, GLenum target) -{ - Q_ASSERT(d->pbuf); - if (!d->dummy->isValid()) { - return 0; - } - return d->dummy->bindTexture(image, target); -} - -void GLApplet::deleteTexture(GLuint textureId) -{ - Q_ASSERT(d->pbuf); - d->dummy->deleteTexture(textureId); -} - -void GLApplet::paintGLInterface(QPainter *painter, - const QStyleOptionGraphicsItem *option) -{ - Q_UNUSED(painter) - Q_UNUSED(option) -} - -static inline QPainterPath headerPath(const QRectF &r, int roundness, - int headerHeight=10) -{ - QPainterPath path; - int xRnd = roundness; - int yRnd = roundness; - if (r.width() > r.height()) { - xRnd = int(roundness * r.height() / r.width()); - } else { - yRnd = int(roundness * r.width() / r.height()); - } - - if(xRnd >= 100) { // fix ranges - xRnd = 99; - } - if(yRnd >= 100) { - yRnd = 99; - } - if(xRnd <= 0 || yRnd <= 0) { // add normal rectangle - path.addRect(r); - return path; - } - - QRectF rect = r.normalized(); - - if (rect.isNull()) { - return path; - } - - qreal x = rect.x(); - qreal y = rect.y(); - qreal w = rect.width(); - qreal h = rect.height(); - qreal rxx = w * xRnd / 200; - qreal ryy = h * yRnd / 200; - // were there overflows? - if (rxx < 0) { - rxx = w / 200 * xRnd; - } - if (ryy < 0) { - ryy = h / 200 * yRnd; - } - qreal rxx2 = 2 * rxx; - qreal ryy2 = 2 * ryy; - - path.arcMoveTo(x, y, rxx2, ryy2, 90); - path.arcTo(x, y, rxx2, ryy2, 90, 90); - QPointF pt = path.currentPosition(); - path.lineTo(x, pt.y() + headerHeight); - path.lineTo(x + w, pt.y() + headerHeight); - path.lineTo(x + w, pt.y()); - path.arcTo(x + w - rxx2, y, rxx2, ryy2, 0, 90); - path.closeSubpath(); - - return path; -} - -void GLApplet::paintInterface(QPainter *painter, - const QStyleOptionGraphicsItem *option, - const QRect &contentsRect) -{ - Q_UNUSED(contentsRect) - Q_ASSERT(d->pbuf); - if ((!d->dummy->isValid() || - !d->pbuf->isValid())) { - if (!hasFailedToLaunch()) { - setFailedToLaunch(true, i18n("Your machine does not support OpenGL widgets.")); - } - - return; - } - d->pbuf->makeCurrent(); - - QMatrix m = painter->worldMatrix(); - QRect deviceRect = m.mapRect(QRect(QPoint(23, 25), boundingRect().size().toSize())); - d->updateGlSize(deviceRect.size()); - - // redirect this widget's painting into the pbuffer - QPainter p(d->pbuf); - paintGLInterface(&p, option); - - // draw the pbuffer contents to the backingstore - QImage image = d->pbuf->toImage(); - painter->drawImage(0, 0, image); -} - -void GLApplet::makeCurrent() -{ - if (!d->dummy->isValid() || !d->pbuf->isValid()) { - d->dummy->makeCurrent(); - } -} - -} // Plasma namespace - -#include "glapplet.moc" diff --git a/glapplet.h b/glapplet.h deleted file mode 100644 index f264bd3e8..000000000 --- a/glapplet.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2007 Zack Rusin - * - * 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_GLAPPLET_H -#define PLASMA_GLAPPLET_H - -#include - -#include - -namespace Plasma -{ - -class GLAppletPrivate; - -/** - * @class GLApplet plasma/glapplet.h - * - * @short Plasma Applet that is fully rendered using OpengGL - */ -class PLASMA_EXPORT_DEPRECATED GLApplet : public Applet -{ - Q_OBJECT - - public: - /** - * @arg parent the QGraphicsItem this applet is parented to - * @arg serviceId the name of the .desktop file containing the - * information about the widget - * @arg appletId a unique id used to differentiate between multiple - * instances of the same Applet type - */ - GLApplet(QGraphicsItem *parent, - const QString &serviceId, - int appletId); - - /** - * This constructor is to be used with the plugin loading systems - * found in KPluginInfo and KService. The argument list is expected - * to have two elements: the KService service ID for the desktop entry - * and an applet ID which must be a base 10 number. - * - * @arg parent a QObject parent; you probably want to pass in 0 - * @arg args a list of strings containing two entries: the service id - * and the applet id - */ - GLApplet(QObject *parent, const QVariantList &args); - - ~GLApplet(); - - GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D); - void deleteTexture(GLuint texture_id); - - /** - * Reimplement this method to render using OpenGL. QPainter passed - * to this method will always use OpenGL engine and rendering - * using OpenGL api directly is supported. - */ - virtual void paintGLInterface(QPainter *painter, - const QStyleOptionGraphicsItem *option); - void makeCurrent(); - private: - virtual void paintInterface(QPainter *painter, - const QStyleOptionGraphicsItem *option, - const QRect &contentsRect); - private: - GLAppletPrivate *const d; -}; - -} - -#endif