Qt 4.8
Public Functions | Protected Variables | List of all members
QBlittablePixmapData Class Referenceabstract

#include <qpixmap_blitter_p.h>

Inheritance diagram for QBlittablePixmapData:
QPixmapData QDirectFbBlitterPlatformPixmap

Public Functions

QBlittableblittable () const
 
QImagebuffer ()
 
virtual QBlittablecreateBlittable (const QSize &size, bool alpha) const =0
 
void fill (const QColor &color)
 
void fromImage (const QImage &image, Qt::ImageConversionFlags flags)
 
bool hasAlphaChannel () const
 
void markRasterOverlay (const QRectF &)
 
void markRasterOverlay (const QPointF &, const QTextItem &)
 
void markRasterOverlay (const QVectorPath &)
 
void markRasterOverlay (const QPainterPath &)
 
void markRasterOverlay (const QRect *rects, int rectCount)
 
void markRasterOverlay (const QRectF *rects, int rectCount)
 
void markRasterOverlay (const QPointF *points, int pointCount)
 
void markRasterOverlay (const QPoint *points, int pointCount)
 
int metric (QPaintDevice::PaintDeviceMetric metric) const
 
QPaintEnginepaintEngine () const
 
 QBlittablePixmapData ()
 
void resize (int width, int height)
 
void setBlittable (QBlittable *blittable)
 
QImage toImage () const
 
void unmarkRasterOverlay (const QRectF &)
 
 ~QBlittablePixmapData ()
 
- Public Functions inherited from QPixmapData
virtual QPixmap alphaChannel () const
 
qint64 cacheKey () const
 
ClassId classId () const
 
int colorCount () const
 
virtual void copy (const QPixmapData *data, const QRect &rect)
 
virtual QPixmapDatacreateCompatiblePixmapData () const
 
int depth () const
 
virtual bool fromData (const uchar *buffer, uint len, const char *format, Qt::ImageConversionFlags flags)
 
virtual bool fromFile (const QString &filename, const char *format, Qt::ImageConversionFlags flags)
 
virtual void fromImageReader (QImageReader *imageReader, Qt::ImageConversionFlags flags)
 
int height () const
 
bool isNull () const
 
virtual QBitmap mask () const
 
QT_DEPRECATED int numColors () const
 
PixelType pixelType () const
 
 QPixmapData (PixelType pixelType, int classId)
 
virtual QPixmapDataruntimeData () const
 
virtual bool scroll (int dx, int dy, const QRect &rect)
 
int serialNumber () const
 
virtual void setAlphaChannel (const QPixmap &alphaChannel)
 
virtual void setMask (const QBitmap &mask)
 
virtual QImage toImage (const QRect &rect) const
 
virtual QPixmap transformed (const QTransform &matrix, Qt::TransformationMode mode) const
 
int width () const
 
virtual ~QPixmapData ()
 

Protected Variables

bool m_alpha
 
QScopedPointer< QBlittablem_blittable
 
QScopedPointer< QBlitterPaintEnginem_engine
 
- Protected Variables inherited from QPixmapData
int d
 
int h
 
bool is_null
 
int w
 

Additional Inherited Members

- Public Types inherited from QPixmapData
enum  ClassId {
  RasterClass, X11Class, MacClass, DirectFBClass,
  OpenGLClass, OpenVGClass, RuntimeClass, BlitterClass,
  CustomClass = 1024
}
 
enum  PixelType { PixmapType, BitmapType }
 
- Static Public Functions inherited from QPixmapData
static QPixmapDatacreate (int w, int h, PixelType type)
 
- Protected Functions inherited from QPixmapData
void setSerialNumber (int serNo)
 

Detailed Description

Definition at line 51 of file qpixmap_blitter_p.h.

Constructors and Destructors

◆ QBlittablePixmapData()

QBlittablePixmapData::QBlittablePixmapData ( )

Definition at line 59 of file qpixmap_blitter.cpp.

61  , m_alpha(false)
62 #ifdef QT_BLITTER_RASTEROVERLAY
63  ,m_rasterOverlay(0), m_unmergedCopy(0)
64 #endif //QT_BLITTER_RASTEROVERLAY
65 {
67 }
QPixmapData(PixelType pixelType, int classId)
Definition: qpixmapdata.cpp:68
static int global_ser_no
void setSerialNumber(int serNo)

◆ ~QBlittablePixmapData()

QBlittablePixmapData::~QBlittablePixmapData ( )

Definition at line 69 of file qpixmap_blitter.cpp.

70 {
71 #ifdef QT_BLITTER_RASTEROVERLAY
72  delete m_rasterOverlay;
73  delete m_unmergedCopy;
74 #endif //QT_BLITTER_RASTEROVERLAY
75 }

Functions

◆ blittable()

QBlittable * QBlittablePixmapData::blittable ( ) const

Definition at line 77 of file qpixmap_blitter.cpp.

Referenced by buffer(), QDirectFbConvenience::dfbSurfaceForPlatformPixmap(), QDirectFbBlitter::drawPixmapOpacity(), fill(), QDirectFbWindowSurface::flush(), hasAlphaChannel(), QDirectFbWindowSurface::scroll(), and toImage().

78 {
79  if (!m_blittable) {
80  QBlittablePixmapData *that = const_cast<QBlittablePixmapData *>(this);
82  }
83 
84  return m_blittable.data();
85 }
T * data() const
Returns the value of the pointer referenced by this object.
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
virtual QBlittable * createBlittable(const QSize &size, bool alpha) const =0
QScopedPointer< QBlittable > m_blittable

◆ buffer()

QImage * QBlittablePixmapData::buffer ( )
virtual

Reimplemented from QPixmapData.

Definition at line 179 of file qpixmap_blitter.cpp.

Referenced by fromImage(), and paintEngine().

180 {
181  return blittable()->lock();
182 }
QImage * lock()
Definition: qblittable.cpp:89
QBlittable * blittable() const

◆ createBlittable()

virtual QBlittable* QBlittablePixmapData::createBlittable ( const QSize size,
bool  alpha 
) const
pure virtual

Implemented in QDirectFbBlitterPlatformPixmap.

Referenced by blittable().

◆ fill()

void QBlittablePixmapData::fill ( const QColor color)
virtual

Implements QPixmapData.

Definition at line 134 of file qpixmap_blitter.cpp.

135 {
136  if (blittable()->capabilities() & QBlittable::AlphaFillRectCapability) {
137  blittable()->unlock();
139  } else if (color.alpha() == 255 && blittable()->capabilities() & QBlittable::SolidRectCapability) {
140  blittable()->unlock();
141  blittable()->fillRect(QRectF(0,0,w,h),color);
142  } else {
143  // Need to be backed with an alpha channel now. It would be nice
144  // if we could just change the format, e.g. when going from
145  // RGB32 -> ARGB8888.
146  if (color.alpha() != 255 && !hasAlphaChannel()) {
147  m_blittable.reset(0);
148  m_engine.reset(0);
149  m_alpha = true;
150  }
151 
152  uint pixel;
153  switch (blittable()->lock()->format()) {
155  pixel = PREMUL(color.rgba());
156  break;
158  pixel = qargb8565(color.rgba()).rawValue();
159  break;
161  pixel = qargb8555(color.rgba()).rawValue();
162  break;
164  pixel = qargb6666(color.rgba()).rawValue();
165  break;
167  pixel = qargb4444(color.rgba()).rawValue();
168  break;
169  default:
170  pixel = color.rgba();
171  break;
172  }
173  //so premultiplied formats are supported and ARGB32 and RGB32
174  blittable()->lock()->fill(pixel);
175  }
176 
177 }
virtual void fillRect(const QRectF &rect, const QColor &color)=0
void fill(uint pixel)
Fills the entire image with the given pixelValue.
Definition: qimage.cpp:2032
QImage * lock()
Definition: qblittable.cpp:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
bool hasAlphaChannel() const
Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x)
unsigned int uint
Definition: qglobal.h:996
QScopedPointer< QBlitterPaintEngine > m_engine
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
Capabilities capabilities() const
Definition: qblittable.cpp:71
virtual void alphaFillRect(const QRectF &rect, const QColor &color, QPainter::CompositionMode cmode)
Definition: qblittable_p.h:81
ushort alpha
Returns the alpha color component of this color.
Definition: qcolor.h:242
void unlock()
Definition: qblittable.cpp:100
static QReadWriteLock lock
Definition: proxyconf.cpp:399
QScopedPointer< QBlittable > m_blittable
QRgb rgba() const
Returns the RGB value of the color, including its alpha.
Definition: qcolor.cpp:1019
QBlittable * blittable() const

◆ fromImage()

void QBlittablePixmapData::fromImage ( const QImage image,
Qt::ImageConversionFlags  flags 
)
virtual

Implements QPixmapData.

Definition at line 194 of file qpixmap_blitter.cpp.

196 {
197  m_alpha = image.hasAlphaChannel();
198  resize(image.width(),image.height());
199  markRasterOverlay(QRect(0,0,w,h));
200  QImage *thisImg = buffer();
201 
202  QImage correctFormatPic = image;
203  if (correctFormatPic.format() != thisImg->format())
204  correctFormatPic = correctFormatPic.convertToFormat(thisImg->format(), flags);
205 
206  uchar *mem = thisImg->bits();
207  const uchar *bits = correctFormatPic.bits();
208  int bytesCopied = 0;
209  while (bytesCopied < correctFormatPic.byteCount()) {
210  memcpy(mem,bits,correctFormatPic.bytesPerLine());
211  mem += thisImg->bytesPerLine();
212  bits += correctFormatPic.bytesPerLine();
213  bytesCopied+=correctFormatPic.bytesPerLine();
214  }
215 }
int byteCount() const
Returns the number of bytes occupied by the image data.
Definition: qimage.cpp:1800
bool hasAlphaChannel() const
Returns true if the image has a format that respects the alpha channel, otherwise returns false...
Definition: qimage.cpp:6495
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
void markRasterOverlay(const QRectF &)
unsigned char uchar
Definition: qglobal.h:994
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
uchar * bits()
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1946
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
Definition: qimage.cpp:3966
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
void resize(int width, int height)

◆ hasAlphaChannel()

bool QBlittablePixmapData::hasAlphaChannel ( ) const
virtual

Implements QPixmapData.

Definition at line 189 of file qpixmap_blitter.cpp.

Referenced by fill().

190 {
191  return blittable()->lock()->hasAlphaChannel();
192 }
bool hasAlphaChannel() const
Returns true if the image has a format that respects the alpha channel, otherwise returns false...
Definition: qimage.cpp:6495
QImage * lock()
Definition: qblittable.cpp:89
QBlittable * blittable() const

◆ markRasterOverlay() [1/8]

void QBlittablePixmapData::markRasterOverlay ( const QRectF rect)
inline

Definition at line 105 of file qpixmap_blitter_p.h.

Referenced by fromImage().

106 {
107 #ifdef QT_BLITTER_RASTEROVERLAY
108  markRasterOverlayImpl(rect);
109 #else
110  Q_UNUSED(rect)
111 #endif
112 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ markRasterOverlay() [2/8]

void QBlittablePixmapData::markRasterOverlay ( const QPointF pos,
const QTextItem ti 
)
inline

Definition at line 123 of file qpixmap_blitter_p.h.

124 {
125 #ifdef QT_BLITTER_RASTEROVERLAY
126  QFontMetricsF fm(ti.font());
127  QRectF rect = fm.tightBoundingRect(ti.text());
128  rect.moveBottomLeft(pos);
129  markRasterOverlay(rect);
130 #else
131  Q_UNUSED(pos)
132  Q_UNUSED(ti)
133 #endif
134 }
QString text() const
Returns the text that should be drawn.
void markRasterOverlay(const QRectF &)
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void moveBottomLeft(const QPointF &p)
Moves the rectangle, leaving the bottom-left corner at the given position.
Definition: qrect.h:701
The QFontMetricsF class provides font metrics information.
Definition: qfontmetrics.h:145
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QFont font() const
Returns the font that should be used to draw the text.

◆ markRasterOverlay() [3/8]

void QBlittablePixmapData::markRasterOverlay ( const QVectorPath path)
inline

Definition at line 114 of file qpixmap_blitter_p.h.

115 {
116 #ifdef QT_BLITTER_RASTEROVERLAY
117  markRasterOverlayImpl(path.convertToPainterPath().boundingRect());
118 #else
119  Q_UNUSED(path)
120 #endif
121 }
QRectF boundingRect() const
Returns the bounding rectangle of this painter path as a rectangle with floating point precision...
const QPainterPath convertToPainterPath() const
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ markRasterOverlay() [4/8]

void QBlittablePixmapData::markRasterOverlay ( const QPainterPath path)
inline

Definition at line 179 of file qpixmap_blitter_p.h.

180 {
181 #ifdef QT_BLITTER_RASTEROVERLAY
182 #error "not ported yet"
183 #else
184  Q_UNUSED(path);
185 #endif
186 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ markRasterOverlay() [5/8]

void QBlittablePixmapData::markRasterOverlay ( const QRect rects,
int  rectCount 
)
inline

Definition at line 136 of file qpixmap_blitter_p.h.

137 {
138 #ifdef QT_BLITTER_RASTEROVERLAY
139  for (int i = 0; i < rectCount; i++) {
140  markRasterOverlay(rects[i]);
141  }
142 #else
143  Q_UNUSED(rects)
144  Q_UNUSED(rectCount)
145 #endif
146 }
void markRasterOverlay(const QRectF &)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ markRasterOverlay() [6/8]

void QBlittablePixmapData::markRasterOverlay ( const QRectF rects,
int  rectCount 
)
inline

Definition at line 147 of file qpixmap_blitter_p.h.

148 {
149 #ifdef QT_BLITTER_RASTEROVERLAY
150  for (int i = 0; i < rectCount; i++) {
151  markRasterOverlay(rects[i]);
152  }
153 #else
154  Q_UNUSED(rects)
155  Q_UNUSED(rectCount)
156 #endif
157 }
void markRasterOverlay(const QRectF &)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ markRasterOverlay() [7/8]

void QBlittablePixmapData::markRasterOverlay ( const QPointF points,
int  pointCount 
)
inline

Definition at line 159 of file qpixmap_blitter_p.h.

160 {
161 #ifdef QT_BLITTER_RASTEROVERLAY
162 #error "not ported yet"
163 #else
164  Q_UNUSED(points);
165  Q_UNUSED(pointCount);
166 #endif
167 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ markRasterOverlay() [8/8]

void QBlittablePixmapData::markRasterOverlay ( const QPoint points,
int  pointCount 
)
inline

Definition at line 169 of file qpixmap_blitter_p.h.

170 {
171 #ifdef QT_BLITTER_RASTEROVERLAY
172 #error "not ported yet"
173 #else
174  Q_UNUSED(points);
175  Q_UNUSED(pointCount);
176 #endif
177 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ metric()

int QBlittablePixmapData::metric ( QPaintDevice::PaintDeviceMetric  metric) const
virtual

Implements QPixmapData.

Definition at line 107 of file qpixmap_blitter.cpp.

108 {
109  switch (metric) {
111  return w;
113  return h;
115  return qRound(w * 25.4 / qt_defaultDpiX());
117  return qRound(h * 25.4 / qt_defaultDpiY());
119  return 32;
120  case QPaintDevice::PdmDpiX: // fall-through
122  return qt_defaultDpiX();
123  case QPaintDevice::PdmDpiY: // fall-through
125  return qt_defaultDpiY();
126  default:
127  qWarning("QRasterPixmapData::metric(): Unhandled metric type %d", metric);
128  break;
129  }
130 
131  return 0;
132 }
Q_GUI_EXPORT int qt_defaultDpiY()
Definition: qfont.cpp:201
Q_GUI_EXPORT int qt_defaultDpiX()
Definition: qfont.cpp:162
Q_CORE_EXPORT void qWarning(const char *,...)
int metric(QPaintDevice::PaintDeviceMetric metric) const
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ paintEngine()

QPaintEngine * QBlittablePixmapData::paintEngine ( ) const
virtual

Implements QPixmapData.

Definition at line 217 of file qpixmap_blitter.cpp.

218 {
219  if (!m_engine) {
220  QBlittablePixmapData *that = const_cast<QBlittablePixmapData *>(this);
221  that->m_engine.reset(new QBlitterPaintEngine(that));
222  }
223  return m_engine.data();
224 }
T * data() const
Returns the value of the pointer referenced by this object.
QScopedPointer< QBlitterPaintEngine > m_engine
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.

◆ resize()

void QBlittablePixmapData::resize ( int  width,
int  height 
)
virtual

Implements QPixmapData.

Definition at line 93 of file qpixmap_blitter.cpp.

Referenced by fromImage(), and setBlittable().

94 {
95 
96  m_blittable.reset(0);
97  m_engine.reset(0);
98 #ifdef Q_WS_QPA
99  d = QApplicationPrivate::platformIntegration()->screens().at(0)->depth();
100 #endif
101  w = width;
102  h = height;
103  is_null = (w <= 0 || h <= 0);
105 }
int width() const
QScopedPointer< QBlitterPaintEngine > m_engine
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
static int global_ser_no
int height() const
QScopedPointer< QBlittable > m_blittable
void setSerialNumber(int serNo)

◆ setBlittable()

void QBlittablePixmapData::setBlittable ( QBlittable blittable)

Definition at line 87 of file qpixmap_blitter.cpp.

Referenced by QDirectFbWindowSurface::resize().

88 {
89  resize(blittable->size().width(),blittable->size().height());
90  m_blittable.reset(blittable);
91 }
int width() const
Returns the width.
Definition: qsize.h:126
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
int height() const
Returns the height.
Definition: qsize.h:129
void resize(int width, int height)
QSize size() const
Definition: qblittable.cpp:77
QScopedPointer< QBlittable > m_blittable

◆ toImage()

QImage QBlittablePixmapData::toImage ( ) const
virtual

Implements QPixmapData.

Definition at line 184 of file qpixmap_blitter.cpp.

185 {
186  return blittable()->lock()->copy();
187 }
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
Definition: qimage.cpp:1410
QImage * lock()
Definition: qblittable.cpp:89
QBlittable * blittable() const

◆ unmarkRasterOverlay()

void QBlittablePixmapData::unmarkRasterOverlay ( const QRectF rect)
inline

Definition at line 188 of file qpixmap_blitter_p.h.

189 {
190 #ifdef QT_BLITTER_RASTEROVERLAY
191  unmarkRasterOverlayImpl(rect);
192 #else
193  Q_UNUSED(rect)
194 #endif
195 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

Properties

◆ m_alpha

bool QBlittablePixmapData::m_alpha
protected

Definition at line 91 of file qpixmap_blitter_p.h.

Referenced by blittable(), fill(), and fromImage().

◆ m_blittable

QScopedPointer<QBlittable> QBlittablePixmapData::m_blittable
protected

Definition at line 90 of file qpixmap_blitter_p.h.

Referenced by blittable(), fill(), resize(), and setBlittable().

◆ m_engine

QScopedPointer<QBlitterPaintEngine> QBlittablePixmapData::m_engine
protected

Definition at line 89 of file qpixmap_blitter_p.h.

Referenced by fill(), paintEngine(), and resize().


The documentation for this class was generated from the following files: