summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-10-10 14:16:23 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-10 16:54:52 +0200
commitac03f59ccc0c0d654b107a52ff3d4d2963dddd2d (patch)
tree5ff791a74f1c8bba20d6ead8399931234af9597b
parentd45502c2aa69fdb0b97c33de2bcc2ae6986f2e4f (diff)
Removed src/gui/opengl/qopenglcolormap.*
The QGLColormap API was used by QGLWidget, not very relevant in the Qt 5 core API. Change-Id: I3c75ac09cbc292e707aea62759c09277f834de8d Reviewed-on: http://codereview.qt-project.org/6333 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
-rw-r--r--src/gui/opengl/opengl.pri2
-rw-r--r--src/gui/opengl/qopenglcolormap.cpp297
-rw-r--r--src/gui/opengl/qopenglcolormap.h105
3 files changed, 0 insertions, 404 deletions
diff --git a/src/gui/opengl/opengl.pri b/src/gui/opengl/opengl.pri
index 4ee7af4569..3c5ab932ba 100644
--- a/src/gui/opengl/opengl.pri
+++ b/src/gui/opengl/opengl.pri
@@ -24,7 +24,6 @@ HEADERS += opengl/qopengl.h \
opengl/qopengltextureglyphcache_p.h \
opengl/qopenglshadercache_p.h \
opengl/qopenglshadercache_meego_p.h \
- opengl/qopenglcolormap.h \
opengl/qtriangulator_p.h \
opengl/qrbtree_p.h
@@ -42,7 +41,6 @@ SOURCES += opengl/qopengl.cpp \
opengl/qopenglcustomshaderstage.cpp \
opengl/qopengltriangulatingstroker.cpp \
opengl/qopengltextureglyphcache.cpp \
- opengl/qopenglcolormap.cpp \
opengl/qtriangulator.cpp
#INCLUDEPATH += ../3rdparty/harfbuzz/src
diff --git a/src/gui/opengl/qopenglcolormap.cpp b/src/gui/opengl/qopenglcolormap.cpp
deleted file mode 100644
index 386358ac23..0000000000
--- a/src/gui/opengl/qopenglcolormap.cpp
+++ /dev/null
@@ -1,297 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \class QOpenGLColormap
- \brief The QOpenGLColormap class is used for installing custom colormaps into
- a QOpenGLWidget.
-
- \module OpenGL
- \ingroup painting-3D
- \ingroup shared
-
- QOpenGLColormap provides a platform independent way of specifying and
- installing indexed colormaps for a QOpenGLWidget. QOpenGLColormap is
- especially useful when using the OpenGL color-index mode.
-
- Under X11 you must use an X server that supports either a \c
- PseudoColor or \c DirectColor visual class. If your X server
- currently only provides a \c GrayScale, \c TrueColor, \c
- StaticColor or \c StaticGray visual, you will not be able to
- allocate colorcells for writing. If this is the case, try setting
- your X server to 8 bit mode. It should then provide you with at
- least a \c PseudoColor visual. Note that you may experience
- colormap flashing if your X server is running in 8 bit mode.
-
- The size() of the colormap is always set to 256
- colors. Note that under Windows you can also install colormaps
- in child widgets.
-
- This class uses \l{implicit sharing} as a memory and speed
- optimization.
-
- Example of use:
- \snippet doc/src/snippets/code/src_opengl_qopenglcolormap.cpp 0
-
- \sa QOpenGLWidget::setColormap(), QOpenGLWidget::colormap()
-*/
-
-/*!
- \fn Qt::HANDLE QOpenGLColormap::handle()
-
- \internal
-
- Returns the handle for this color map.
-*/
-
-/*!
- \fn void QOpenGLColormap::setHandle(Qt::HANDLE handle)
-
- \internal
-
- Sets the handle for this color map to \a handle.
-*/
-
-#include "qopenglcolormap.h"
-
-QT_BEGIN_NAMESPACE
-
-QOpenGLColormap::QOpenGLColormapData QOpenGLColormap::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0 };
-
-/*!
- Construct a QOpenGLColormap.
-*/
-QOpenGLColormap::QOpenGLColormap()
- : d(&shared_null)
-{
- d->ref.ref();
-}
-
-
-/*!
- Construct a shallow copy of \a map.
-*/
-QOpenGLColormap::QOpenGLColormap(const QOpenGLColormap &map)
- : d(map.d)
-{
- d->ref.ref();
-}
-
-/*!
- Dereferences the QOpenGLColormap and deletes it if this was the last
- reference to it.
-*/
-QOpenGLColormap::~QOpenGLColormap()
-{
- if (!d->ref.deref())
- cleanup(d);
-}
-
-void QOpenGLColormap::cleanup(QOpenGLColormap::QOpenGLColormapData *x)
-{
- delete x->cells;
- x->cells = 0;
- delete x;
-}
-
-/*!
- Assign a shallow copy of \a map to this QOpenGLColormap.
-*/
-QOpenGLColormap & QOpenGLColormap::operator=(const QOpenGLColormap &map)
-{
- map.d->ref.ref();
- if (!d->ref.deref())
- cleanup(d);
- d = map.d;
- return *this;
-}
-
-/*!
- \fn void QOpenGLColormap::detach()
- \internal
-
- Detaches this QOpenGLColormap from the shared block.
-*/
-
-void QOpenGLColormap::detach_helper()
-{
- QOpenGLColormapData *x = new QOpenGLColormapData;
- x->ref = 1;
- x->cmapHandle = 0;
- x->cells = 0;
- if (d->cells) {
- x->cells = new QVector<QRgb>(256);
- *x->cells = *d->cells;
- }
- if (!d->ref.deref())
- cleanup(d);
- d = x;
-}
-
-/*!
- Set cell at index \a idx in the colormap to color \a color.
-*/
-void QOpenGLColormap::setEntry(int idx, QRgb color)
-{
- detach();
- if (!d->cells)
- d->cells = new QVector<QRgb>(256);
- d->cells->replace(idx, color);
-}
-
-/*!
- Set an array of cells in this colormap. \a count is the number of
- colors that should be set, \a colors is the array of colors, and
- \a base is the starting index. The first element in \a colors
- is set at \a base in the colormap.
-*/
-void QOpenGLColormap::setEntries(int count, const QRgb *colors, int base)
-{
- detach();
- if (!d->cells)
- d->cells = new QVector<QRgb>(256);
-
- Q_ASSERT_X(colors && base >= 0 && (base + count) <= d->cells->size(), "QOpenGLColormap::setEntries",
- "preconditions not met");
- for (int i = 0; i < count; ++i)
- setEntry(base + i, colors[i]);
-}
-
-/*!
- Returns the QRgb value in the colorcell with index \a idx.
-*/
-QRgb QOpenGLColormap::entryRgb(int idx) const
-{
- if (d == &shared_null || !d->cells)
- return 0;
- else
- return d->cells->at(idx);
-}
-
-/*!
- \overload
-
- Set the cell with index \a idx in the colormap to color \a color.
-*/
-void QOpenGLColormap::setEntry(int idx, const QColor &color)
-{
- setEntry(idx, color.rgb());
-}
-
-/*!
- Returns the QRgb value in the colorcell with index \a idx.
-*/
-QColor QOpenGLColormap::entryColor(int idx) const
-{
- if (d == &shared_null || !d->cells)
- return QColor();
- else
- return QColor(d->cells->at(idx));
-}
-
-/*!
- Returns true if the colormap is empty or it is not in use
- by a QOpenGLWidget; otherwise returns false.
-
- A colormap with no color values set is considered to be empty.
- For historical reasons, a colormap that has color values set
- but which is not in use by a QOpenGLWidget is also considered empty.
-
- Compare size() with zero to determine if the colormap is empty
- regardless of whether it is in use by a QOpenGLWidget or not.
-
- \sa size()
-*/
-bool QOpenGLColormap::isEmpty() const
-{
- return d == &shared_null || d->cells == 0 || d->cells->size() == 0 || d->cmapHandle == 0;
-}
-
-
-/*!
- Returns the number of colorcells in the colormap.
-*/
-int QOpenGLColormap::size() const
-{
- return d->cells ? d->cells->size() : 0;
-}
-
-/*!
- Returns the index of the color \a color. If \a color is not in the
- map, -1 is returned.
-*/
-int QOpenGLColormap::find(QRgb color) const
-{
- if (d->cells)
- return d->cells->indexOf(color);
- return -1;
-}
-
-/*!
- Returns the index of the color that is the closest match to color
- \a color.
-*/
-int QOpenGLColormap::findNearest(QRgb color) const
-{
- int idx = find(color);
- if (idx >= 0)
- return idx;
- int mapSize = size();
- int mindist = 200000;
- int r = qRed(color);
- int g = qGreen(color);
- int b = qBlue(color);
- int rx, gx, bx, dist;
- for (int i = 0; i < mapSize; ++i) {
- QRgb ci = d->cells->at(i);
- rx = r - qRed(ci);
- gx = g - qGreen(ci);
- bx = b - qBlue(ci);
- dist = rx * rx + gx * gx + bx * bx; // calculate distance
- if (dist < mindist) { // minimal?
- mindist = dist;
- idx = i;
- }
- }
- return idx;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/opengl/qopenglcolormap.h b/src/gui/opengl/qopenglcolormap.h
deleted file mode 100644
index b05e3f331d..0000000000
--- a/src/gui/opengl/qopenglcolormap.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QOPENGLCOLORMAP_H
-#define QOPENGLCOLORMAP_H
-
-#include <QtGui/qcolor.h>
-#include <QtCore/qvector.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class Q_GUI_EXPORT QOpenGLColormap
-{
-public:
- QOpenGLColormap();
- QOpenGLColormap(const QOpenGLColormap &);
- ~QOpenGLColormap();
-
- QOpenGLColormap &operator=(const QOpenGLColormap &);
-
- bool isEmpty() const;
- int size() const;
- void detach();
-
- void setEntries(int count, const QRgb * colors, int base = 0);
- void setEntry(int idx, QRgb color);
- void setEntry(int idx, const QColor & color);
- QRgb entryRgb(int idx) const;
- QColor entryColor(int idx) const;
- int find(QRgb color) const;
- int findNearest(QRgb color) const;
-
-protected:
- Qt::HANDLE handle() { return d ? d->cmapHandle : 0; }
- void setHandle(Qt::HANDLE ahandle) { d->cmapHandle = ahandle; }
-
-private:
- struct QOpenGLColormapData {
- QBasicAtomicInt ref;
- QVector<QRgb> *cells;
- Qt::HANDLE cmapHandle;
- };
-
- QOpenGLColormapData *d;
- static struct QOpenGLColormapData shared_null;
- static void cleanup(QOpenGLColormapData *x);
- void detach_helper();
-
- friend class QOpenGLWidget;
- friend class QOpenGLWidgetPrivate;
-};
-
-inline void QOpenGLColormap::detach()
-{
- if (d->ref != 1)
- detach_helper();
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QOPENGLCOLORMAP_H