Qt 4.8
qpixmap_blitter_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QPIXMAP_BLITTER_P_H
43 #define QPIXMAP_BLITTER_P_H
44 
45 #include <private/qpixmapdata_p.h>
46 #include <private/qpaintengine_blitter_p.h>
47 
48 #ifndef QT_NO_BLITTABLE
50 
52 {
53 // Q_DECLARE_PRIVATE(QBlittablePixmapData);
54 public:
57 
58  virtual QBlittable *createBlittable(const QSize &size, bool alpha) const = 0;
59  QBlittable *blittable() const;
60  void setBlittable(QBlittable *blittable);
61 
62  void resize(int width, int height);
63  int metric(QPaintDevice::PaintDeviceMetric metric) const;
64  void fill(const QColor &color);
65  QImage *buffer();
66  QImage toImage() const;
67  bool hasAlphaChannel() const;
68  void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
69 
70  QPaintEngine *paintEngine() const;
71 
72  void markRasterOverlay(const QRectF &);
73  void markRasterOverlay(const QPointF &, const QTextItem &);
74  void markRasterOverlay(const QVectorPath &);
75  void markRasterOverlay(const QPainterPath &);
76  void markRasterOverlay(const QRect *rects, int rectCount);
77  void markRasterOverlay(const QRectF *rects, int rectCount);
78  void markRasterOverlay(const QPointF *points, int pointCount);
79  void markRasterOverlay(const QPoint *points, int pointCount);
80  void unmarkRasterOverlay(const QRectF &);
81 
82 #ifdef QT_BLITTER_RASTEROVERLAY
83  void mergeOverlay();
84  void unmergeOverlay();
85  QImage *overlay();
86 
87 #endif //QT_BLITTER_RASTEROVERLAY
88 protected:
91  bool m_alpha;
92 
93 #ifdef QT_BLITTER_RASTEROVERLAY
94  QImage *m_rasterOverlay;
95  QImage *m_unmergedCopy;
96  QColor m_overlayColor;
97 
98  void markRasterOverlayImpl(const QRectF &);
99  void unmarkRasterOverlayImpl(const QRectF &);
100  QRectF clipAndTransformRect(const QRectF &) const;
101 #endif //QT_BLITTER_RASTEROVERLAY
102 
103 };
104 
106 {
107 #ifdef QT_BLITTER_RASTEROVERLAY
108  markRasterOverlayImpl(rect);
109 #else
110  Q_UNUSED(rect)
111 #endif
112 }
113 
115 {
116 #ifdef QT_BLITTER_RASTEROVERLAY
117  markRasterOverlayImpl(path.convertToPainterPath().boundingRect());
118 #else
119  Q_UNUSED(path)
120 #endif
121 }
122 
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 }
135 
136 inline void QBlittablePixmapData::markRasterOverlay(const QRect *rects, int rectCount)
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 }
147 inline void QBlittablePixmapData::markRasterOverlay(const QRectF *rects, int rectCount)
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 }
158 
159 inline void QBlittablePixmapData::markRasterOverlay(const QPointF *points, int pointCount)
160 {
161 #ifdef QT_BLITTER_RASTEROVERLAY
162 #error "not ported yet"
163 #else
164  Q_UNUSED(points);
165  Q_UNUSED(pointCount);
166 #endif
167 }
168 
169 inline void QBlittablePixmapData::markRasterOverlay(const QPoint *points, int pointCount)
170 {
171 #ifdef QT_BLITTER_RASTEROVERLAY
172 #error "not ported yet"
173 #else
174  Q_UNUSED(points);
175  Q_UNUSED(pointCount);
176 #endif
177 }
178 
180 {
181 #ifdef QT_BLITTER_RASTEROVERLAY
182 #error "not ported yet"
183 #else
184  Q_UNUSED(path);
185 #endif
186 }
187 
189 {
190 #ifdef QT_BLITTER_RASTEROVERLAY
191  unmarkRasterOverlayImpl(rect);
192 #else
193  Q_UNUSED(rect)
194 #endif
195 }
196 
198 #endif // QT_NO_BLITTABLE
199 #endif // QPIXMAP_BLITTER_P_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
virtual void fill(const QColor &color)=0
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
virtual void resize(int width, int height)=0
virtual QPaintEngine * paintEngine() const =0
QString text() const
Returns the text that should be drawn.
QRectF boundingRect() const
Returns the bounding rectangle of this painter path as a rectangle with floating point precision...
void markRasterOverlay(const QRectF &)
virtual QImage toImage() const =0
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
virtual void fromImage(const QImage &image, Qt::ImageConversionFlags flags)=0
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
virtual int metric(QPaintDevice::PaintDeviceMetric metric) const =0
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90
QScopedPointer< QBlitterPaintEngine > m_engine
virtual bool hasAlphaChannel() const =0
const QPainterPath convertToPainterPath() const
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void moveBottomLeft(const QPointF &p)
Moves the rectangle, leaving the bottom-left corner at the given position.
Definition: qrect.h:701
virtual QImage * buffer()
The QFontMetricsF class provides font metrics information.
Definition: qfontmetrics.h:145
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QScopedPointer< QBlittable > m_blittable
The QTextItem class provides all the information required to draw text in a custom paint engine...
Definition: qpaintengine.h:68
#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.
void unmarkRasterOverlay(const QRectF &)