Qt 4.8
Classes | Functions
qpaintbuffer_p.h File Reference
#include <qpaintdevice.h>
#include <private/qpaintengineex_p.h>
#include <private/qtextengine_p.h>
#include <QDebug>

Go to the source code of this file.

Classes

class  QPaintBuffer
 
struct  QPaintBufferCommand
 
class  QPaintBufferEngine
 
class  QPaintBufferPrivate
 
class  QPaintBufferResource
 
class  QPaintBufferSignalProxy
 
class  QPaintEngineExReplayer
 
class  QPainterReplayer
 
class  QTextItemIntCopy
 
struct  QVectorPathCmd
 

Functions

Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &stream, const QPaintBuffer &buffer)
 
QDataStreamoperator<< (QDataStream &stream, const QPaintBufferCommand &command)
 
Q_GUI_EXPORT QDataStreamoperator>> (QDataStream &stream, QPaintBuffer &buffer)
 
QDataStreamoperator>> (QDataStream &stream, QPaintBufferCommand &command)
 
 Q_DECLARE_TYPEINFO (QPaintBufferCommand, Q_MOVABLE_TYPE)
 

Function Documentation

◆ operator<<() [1/2]

Q_GUI_EXPORT QDataStream& operator<< ( QDataStream stream,
const QPaintBuffer buffer 
)

Definition at line 2181 of file qpaintbuffer.cpp.

2182 {
2183  QHash<qint64, uint> pixmapKeys;
2184  QHash<qint64, uint> imageKeys;
2185 
2186  QHash<qint64, QPixmap> pixmaps;
2187  QHash<qint64, QImage> images;
2188 
2189  QVector<QVariant> variants = buffer.d_ptr->variants;
2190  for (int i = 0; i < variants.size(); ++i) {
2191  const QVariant &v = variants.at(i);
2192  if (v.type() == QVariant::Image) {
2193  const QImage image(v.value<QImage>());
2194 
2197 
2198  QHash<qint64, uint>::iterator it = imageKeys.find(image.cacheKey());
2199  if (it != imageKeys.end()) {
2200  entry.flags.key = *it;
2201  } else {
2202  imageKeys[image.cacheKey()] = entry.flags.key = images.size();
2203  images[images.size()] = image;
2204  }
2205 
2206  variants[i] = QVariant::fromValue(entry);
2207  } else if (v.type() == QVariant::Pixmap) {
2208  const QPixmap pixmap(v.value<QPixmap>());
2209 
2212 
2213  QHash<qint64, uint>::iterator it = pixmapKeys.find(pixmap.cacheKey());
2214  if (it != pixmapKeys.end()) {
2215  entry.flags.key = *it;
2216  } else {
2217  pixmapKeys[pixmap.cacheKey()] = entry.flags.key = pixmaps.size();
2218  pixmaps[pixmaps.size()] = pixmap;
2219  }
2220 
2221  variants[i] = QVariant::fromValue(entry);
2222  }
2223  }
2224 
2225  stream << pixmaps;
2226  stream << images;
2227 
2228  stream << buffer.d_ptr->ints;
2229  stream << buffer.d_ptr->floats;
2230  stream << variants;
2231  stream << buffer.d_ptr->commands;
2232  stream << buffer.d_ptr->boundingRect;
2233  stream << buffer.d_ptr->frames;
2234 
2235  return stream;
2236 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QPaintBufferPrivate * d_ptr
#define it(className, varName)
QVector< int > ints
static FILE * stream
QVector< QPaintBufferCommand > commands
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865
T value() const
Returns the stored value converted to the template type T.
Definition: qvariant.h:332
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QVector< QVariant > variants
QVector< qreal > floats

◆ operator<<() [2/2]

QDataStream& operator<< ( QDataStream stream,
const QPaintBufferCommand command 
)

Definition at line 2100 of file qpaintbuffer.cpp.

2101 {
2102  quint32 id = command.id;
2103  quint32 size = command.size;
2104  stream << id << size;
2105  stream << command.offset << command.offset2 << command.extra;
2106  return stream;
2107 }
static FILE * stream
unsigned int quint32
Definition: qglobal.h:938

◆ operator>>() [1/2]

Q_GUI_EXPORT QDataStream& operator>> ( QDataStream stream,
QPaintBuffer buffer 
)

Definition at line 2238 of file qpaintbuffer.cpp.

2239 {
2240  QHash<qint64, QPixmap> pixmaps;
2241  QHash<qint64, QImage> images;
2242 
2243  stream >> pixmaps;
2244  stream >> images;
2245 
2246  stream >> buffer.d_ptr->ints;
2247  stream >> buffer.d_ptr->floats;
2248  stream >> buffer.d_ptr->variants;
2249  stream >> buffer.d_ptr->commands;
2250  stream >> buffer.d_ptr->boundingRect;
2251  stream >> buffer.d_ptr->frames;
2252 
2253  QVector<QVariant> &variants = buffer.d_ptr->variants;
2254  for (int i = 0; i < variants.size(); ++i) {
2255  const QVariant &v = variants.at(i);
2258  if (entry.type == QVariant::Image)
2259  variants[i] = QVariant(images.value(entry.cacheKey));
2260  else
2261  variants[i] = QVariant(pixmaps.value(entry.cacheKey));
2262  } else if (v.canConvert<QPaintBufferCacheEntryV2>()) {
2264 
2266  variants[i] = QVariant(images.value(entry.flags.key));
2268  variants[i] = QVariant(pixmaps.value(entry.flags.key));
2269  else
2270  qWarning() << "operator<<(QDataStream &stream, QPaintBuffer &buffer): unrecognized cache entry type:" << entry.flags.type;
2271  }
2272  }
2273 
2274  return stream;
2275 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QPaintBufferPrivate * d_ptr
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
QVector< int > ints
static FILE * stream
QVector< QPaintBufferCommand > commands
bool canConvert(Type t) const
Returns true if the variant&#39;s type can be cast to the requested type, t.
Definition: qvariant.cpp:2886
Q_CORE_EXPORT void qWarning(const char *,...)
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
T value() const
Returns the stored value converted to the template type T.
Definition: qvariant.h:332
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QVector< QVariant > variants
QVector< qreal > floats

◆ operator>>() [2/2]

QDataStream& operator>> ( QDataStream stream,
QPaintBufferCommand command 
)

Definition at line 2109 of file qpaintbuffer.cpp.

2110 {
2111  quint32 id;
2112  quint32 size;
2113  stream >> id >> size;
2114  stream >> command.offset >> command.offset2 >> command.extra;
2115  command.id = id;
2116  command.size = size;
2117  return stream;
2118 }
static FILE * stream
unsigned int quint32
Definition: qglobal.h:938

◆ Q_DECLARE_TYPEINFO()

Q_DECLARE_TYPEINFO ( QPaintBufferCommand  ,
Q_MOVABLE_TYPE   
)