[556] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
| 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
| 6 | **
|
---|
| 7 | ** This file is part of the QtOpenVG module of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
| 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
| 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #ifndef QPIXMAPDATA_VG_P_H
|
---|
| 43 | #define QPIXMAPDATA_VG_P_H
|
---|
| 44 |
|
---|
| 45 | //
|
---|
| 46 | // W A R N I N G
|
---|
| 47 | // -------------
|
---|
| 48 | //
|
---|
| 49 | // This file is not part of the Qt API. It exists for the convenience
|
---|
| 50 | // of other Qt classes. This header file may change from version to
|
---|
| 51 | // version without notice, or even be removed.
|
---|
| 52 | //
|
---|
| 53 | // We mean it.
|
---|
| 54 | //
|
---|
| 55 |
|
---|
| 56 | #include <QtGui/private/qpixmap_raster_p.h>
|
---|
| 57 | #include <private/qvg_p.h>
|
---|
| 58 |
|
---|
| 59 | #if defined(Q_OS_SYMBIAN)
|
---|
| 60 | class RSGImage;
|
---|
| 61 | #endif
|
---|
| 62 |
|
---|
| 63 | QT_BEGIN_NAMESPACE
|
---|
| 64 |
|
---|
| 65 | class QEglContext;
|
---|
| 66 | class QVGImagePool;
|
---|
| 67 |
|
---|
| 68 | #if !defined(QT_NO_EGL)
|
---|
| 69 | class QVGPixmapData;
|
---|
| 70 | class QVGSharedContext;
|
---|
| 71 |
|
---|
| 72 | void qt_vg_register_pixmap(QVGPixmapData *pd);
|
---|
| 73 | void qt_vg_unregister_pixmap(QVGPixmapData *pd);
|
---|
| 74 | void qt_vg_hibernate_pixmaps(QVGSharedContext *context);
|
---|
| 75 | #endif
|
---|
| 76 |
|
---|
| 77 | class Q_OPENVG_EXPORT QVGPixmapData : public QPixmapData
|
---|
| 78 | {
|
---|
| 79 | public:
|
---|
| 80 | QVGPixmapData(PixelType type);
|
---|
| 81 | ~QVGPixmapData();
|
---|
| 82 |
|
---|
| 83 | QPixmapData *createCompatiblePixmapData() const;
|
---|
| 84 |
|
---|
| 85 | // Is this pixmap valid (i.e. non-zero in size)?
|
---|
| 86 | bool isValid() const;
|
---|
| 87 |
|
---|
| 88 | void resize(int width, int height);
|
---|
| 89 | void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
|
---|
| 90 |
|
---|
| 91 | void fill(const QColor &color);
|
---|
| 92 | bool hasAlphaChannel() const;
|
---|
| 93 | void setAlphaChannel(const QPixmap &alphaChannel);
|
---|
| 94 | QImage toImage() const;
|
---|
| 95 | QImage *buffer();
|
---|
| 96 | QPaintEngine* paintEngine() const;
|
---|
| 97 |
|
---|
| 98 | // Return the VGImage form of this pixmap, creating it if necessary.
|
---|
| 99 | // This assumes that there is a VG context current.
|
---|
| 100 | virtual VGImage toVGImage();
|
---|
| 101 |
|
---|
| 102 | // Return the VGImage form for a specific opacity setting.
|
---|
| 103 | virtual VGImage toVGImage(qreal opacity);
|
---|
| 104 |
|
---|
| 105 | // Detach this image from the image pool.
|
---|
| 106 | virtual void detachImageFromPool();
|
---|
| 107 |
|
---|
| 108 | // Release the VG resources associated with this pixmap and copy
|
---|
| 109 | // the pixmap's contents out of the GPU back into main memory.
|
---|
| 110 | // The VG resource will be automatically recreated the next time
|
---|
| 111 | // toVGImage() is called. Does nothing if the pixmap cannot be
|
---|
| 112 | // hibernated for some reason (e.g. VGImage is shared with another
|
---|
| 113 | // process via a SgImage).
|
---|
| 114 | virtual void hibernate();
|
---|
| 115 |
|
---|
| 116 | // Called when the QVGImagePool wants to reclaim this pixmap's
|
---|
| 117 | // VGImage objects to reuse storage.
|
---|
| 118 | virtual void reclaimImages();
|
---|
| 119 |
|
---|
| 120 | QSize size() const { return QSize(w, h); }
|
---|
| 121 |
|
---|
| 122 | #if defined(Q_OS_SYMBIAN)
|
---|
| 123 | void* toNativeType(NativeType type);
|
---|
| 124 | void fromNativeType(void* pixmap, NativeType type);
|
---|
| 125 | #endif
|
---|
| 126 |
|
---|
| 127 | protected:
|
---|
| 128 | int metric(QPaintDevice::PaintDeviceMetric metric) const;
|
---|
| 129 |
|
---|
| 130 | #if defined(Q_OS_SYMBIAN)
|
---|
| 131 | void cleanup();
|
---|
| 132 | #endif
|
---|
| 133 |
|
---|
| 134 | private:
|
---|
| 135 | QVGPixmapData *nextLRU;
|
---|
| 136 | QVGPixmapData *prevLRU;
|
---|
| 137 | bool inLRU;
|
---|
| 138 | friend class QVGImagePool;
|
---|
| 139 |
|
---|
| 140 | #if !defined(QT_NO_EGL)
|
---|
| 141 | QVGPixmapData *next;
|
---|
| 142 | QVGPixmapData *prev;
|
---|
| 143 |
|
---|
| 144 | friend void qt_vg_register_pixmap(QVGPixmapData *pd);
|
---|
| 145 | friend void qt_vg_unregister_pixmap(QVGPixmapData *pd);
|
---|
| 146 | friend void qt_vg_hibernate_pixmaps(QVGSharedContext *context);
|
---|
| 147 | #endif
|
---|
| 148 |
|
---|
| 149 | protected:
|
---|
| 150 | QSize prevSize;
|
---|
| 151 | VGImage vgImage;
|
---|
| 152 | VGImage vgImageOpacity;
|
---|
| 153 | qreal cachedOpacity;
|
---|
| 154 | mutable QImage source;
|
---|
| 155 | mutable bool recreate;
|
---|
| 156 | bool inImagePool;
|
---|
| 157 | #if !defined(QT_NO_EGL)
|
---|
| 158 | mutable QEglContext *context;
|
---|
| 159 | #endif
|
---|
| 160 |
|
---|
| 161 | void forceToImage();
|
---|
| 162 | QImage::Format sourceFormat() const;
|
---|
| 163 |
|
---|
| 164 | void destroyImageAndContext();
|
---|
| 165 | void destroyImages();
|
---|
| 166 | };
|
---|
| 167 |
|
---|
| 168 | QT_END_NAMESPACE
|
---|
| 169 |
|
---|
| 170 | #endif
|
---|