summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-05-04 10:25:36 +0200
committerSamuel Rødal <samuel.rodal@nokia.com>2011-05-04 10:26:42 +0200
commit3f3a950d6e5b5831d963e04c7ac9506de4396d5a (patch)
tree1eea2a5be184051c358f34829ae54c9245672d40 /src
parent19822fa60c2a5b649950ce9bffced6d18aa71b8e (diff)
Clean up some QWidget dependencies in gui/image.
Diffstat (limited to 'src')
-rw-r--r--src/gui/image/qnativeimage.cpp99
-rw-r--r--src/gui/image/qnativeimage_p.h10
-rw-r--r--src/gui/image/qpixmap.cpp21
-rw-r--r--src/gui/image/qpixmap.h8
-rw-r--r--src/gui/kernel/qwidget.cpp20
5 files changed, 20 insertions, 138 deletions
diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp
index 18b302e9e1..f09cf1b0ef 100644
--- a/src/gui/image/qnativeimage.cpp
+++ b/src/gui/image/qnativeimage.cpp
@@ -69,7 +69,7 @@ typedef struct {
} BITMAPINFO_MASK;
-QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool isTextBuffer, QWidget *)
+QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool isTextBuffer, QWindow *)
{
#ifndef Q_WS_WINCE
Q_UNUSED(isTextBuffer);
@@ -146,102 +146,9 @@ QImage::Format QNativeImage::systemFormat()
return QImage::Format_RGB32;
}
-
-#elif defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
-
-QNativeImage::QNativeImage(int width, int height, QImage::Format format,bool /* isTextBuffer */, QWidget *widget)
- : xshmimg(0), xshmpm(0)
-{
- if (!X11->use_mitshm) {
- image = QImage(width, height, format);
- // follow good coding practice and set xshminfo attributes, though values not used in this case
- xshminfo.readOnly = true;
- xshminfo.shmaddr = 0;
- xshminfo.shmid = 0;
- xshminfo.shmseg = 0;
- return;
- }
-
- QX11Info info = widget->x11Info();
-
- int dd = info.depth();
- Visual *vis = (Visual*) info.visual();
-
- xshmimg = XShmCreateImage(X11->display, vis, dd, ZPixmap, 0, &xshminfo, width, height);
- if (!xshmimg) {
- qWarning("QNativeImage: Unable to create shared XImage.");
- return;
- }
-
- bool ok;
- xshminfo.shmid = shmget(IPC_PRIVATE, xshmimg->bytes_per_line * xshmimg->height,
- IPC_CREAT | 0777);
- ok = xshminfo.shmid != -1;
- if (ok) {
- xshmimg->data = (char*)shmat(xshminfo.shmid, 0, 0);
- xshminfo.shmaddr = xshmimg->data;
- ok = (xshminfo.shmaddr != (char*)-1);
- if (ok)
- image = QImage((uchar *)xshmimg->data, width, height, format);
- }
- xshminfo.readOnly = false;
- if (ok) {
- ok = XShmAttach(X11->display, &xshminfo);
- XSync(X11->display, False);
- if (shmctl(xshminfo.shmid, IPC_RMID, 0) == -1)
- qWarning() << "Error while marking the shared memory segment to be destroyed";
- }
- if (!ok) {
- qWarning() << "QNativeImage: Unable to attach to shared memory segment.";
- if (xshmimg->data) {
- free(xshmimg->data);
- xshmimg->data = 0;
- }
- XDestroyImage(xshmimg);
- xshmimg = 0;
- if (xshminfo.shmaddr)
- shmdt(xshminfo.shmaddr);
- if (xshminfo.shmid != -1)
- shmctl(xshminfo.shmid, IPC_RMID, 0);
- return;
- }
- if (X11->use_mitshm_pixmaps) {
- xshmpm = XShmCreatePixmap(X11->display, DefaultRootWindow(X11->display), xshmimg->data,
- &xshminfo, width, height, dd);
- if (!xshmpm) {
- qWarning() << "QNativeImage: Unable to create shared Pixmap.";
- }
- }
-}
-
-
-QNativeImage::~QNativeImage()
-{
- if (!xshmimg)
- return;
-
- if (xshmpm) {
- XFreePixmap(X11->display, xshmpm);
- xshmpm = 0;
- }
- XShmDetach(X11->display, &xshminfo);
- xshmimg->data = 0;
- XDestroyImage(xshmimg);
- xshmimg = 0;
- shmdt(xshminfo.shmaddr);
- shmctl(xshminfo.shmid, IPC_RMID, 0);
-}
-
-QImage::Format QNativeImage::systemFormat()
-{
- if (QX11Info::appDepth() == 16)
- return QImage::Format_RGB16;
- return QImage::Format_RGB32;
-}
-
#elif defined(Q_WS_MAC)
-QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /* isTextBuffer */, QWidget *widget)
+QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /* isTextBuffer */, QWindow *)
: image(width, height, format)
{
@@ -266,7 +173,7 @@ QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /*
#endif
cg = CGBitmapContextCreate(image.bits(), width, height, 8, image.bytesPerLine(),
- QCoreGraphicsPaintEngine::macDisplayColorSpace(widget), cgflags);
+ QCoreGraphicsPaintEngine::macDisplayColorSpace(0), cgflags);
CGContextTranslateCTM(cg, 0, height);
CGContextScaleCTM(cg, 1, -1);
diff --git a/src/gui/image/qnativeimage_p.h b/src/gui/image/qnativeimage_p.h
index a0f486a7d6..00897d4d54 100644
--- a/src/gui/image/qnativeimage_p.h
+++ b/src/gui/image/qnativeimage_p.h
@@ -58,9 +58,6 @@
#ifdef Q_WS_WIN
#include "qt_windows.h"
-#elif defined(Q_WS_X11)
-#include <private/qt_x11_p.h>
-
#elif defined(Q_WS_MAC)
#include <private/qt_mac_p.h>
@@ -73,7 +70,7 @@ class QWindow;
class QNativeImage
{
public:
- QNativeImage(int width, int height, QImage::Format format, bool isTextBuffer = false, QWindow *widget = 0);
+ QNativeImage(int width, int height, QImage::Format format, bool isTextBuffer = false, QWindow *window = 0);
~QNativeImage();
inline int width() const;
@@ -88,11 +85,6 @@ public:
HBITMAP bitmap;
HBITMAP null_bitmap;
-#elif defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
- XImage *xshmimg;
- Pixmap xshmpm;
- XShmSegmentInfo xshminfo;
-
#elif defined(Q_WS_MAC)
CGContextRef cg;
#endif
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index a9f2353dd4..82d4e69de3 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -910,21 +910,24 @@ bool QPixmap::doImageIO(QImageWriter *writer, int quality) const
return writer->write(toImage());
}
-// #### Qt5: needs fixing
-// The implementation (and documentation) of
-// QPixmap::fill(const QWidget *, const QPoint &)
-// is in qwidget.cpp
-
/*!
- \fn void QPixmap::fill(const QWidget *widget, int x, int y)
+ \fn void QPixmap::fill(const QPaintDevice *device, int x, int y)
\overload
- Fills the pixmap with the \a widget's background color or pixmap.
+ \obsolete
+
+ Fills the pixmap with the \a device's background color or pixmap.
The given point, (\a x, \a y), defines an offset in widget
coordinates to which the pixmap's top-left pixel will be mapped
to.
*/
+void QPixmap::fill(const QPaintDevice *, const QPoint &)
+{
+ qWarning() << "QPixmap::fill(const QPaintDevice *device, const QPoint &offset) is deprecated, ignored";
+}
+
+
/*!
Fills the pixmap with the given \a color.
@@ -1012,7 +1015,7 @@ static void sendResizeEvents(QWidget *target)
#endif
/*!
- \fn QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rectangle)
+ \fn QPixmap QPixmap::grabWidget(QPaintDevice * widget, const QRect &rectangle)
Creates a pixmap and paints the given \a widget, restricted by the
given \a rectangle, in it. If the \a widget has any children, then
@@ -1041,7 +1044,7 @@ static void sendResizeEvents(QWidget *target)
\sa grabWindow()
*/
-QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rect)
+QPixmap QPixmap::grabWidget(QPaintDevice * widget, const QRect &rect)
{
// ### Qt5: should we keep or remove this method?
// SC solution would be to install a callback form QtWidgets, but ugly.
diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h
index 77f06b060b..1341ad2b1b 100644
--- a/src/gui/image/qpixmap.h
+++ b/src/gui/image/qpixmap.h
@@ -103,8 +103,8 @@ public:
static int defaultDepth();
void fill(const QColor &fillColor = Qt::white);
- void fill(const QWidget *widget, const QPoint &ofs);
- inline void fill(const QWidget *widget, int xofs, int yofs) { fill(widget, QPoint(xofs, yofs)); }
+ void fill(const QPaintDevice *device, const QPoint &ofs);
+ inline void fill(const QPaintDevice *device, int xofs, int yofs) { fill(device, QPoint(xofs, yofs)); }
QBitmap mask() const;
void setMask(const QBitmap &);
@@ -122,8 +122,8 @@ public:
QBitmap createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode) const;
static QPixmap grabWindow(WId, int x=0, int y=0, int w=-1, int h=-1);
- static QPixmap grabWidget(QWidget *widget, const QRect &rect);
- static inline QPixmap grabWidget(QWidget *widget, int x=0, int y=0, int w=-1, int h=-1)
+ static QPixmap grabWidget(QPaintDevice *widget, const QRect &rect);
+ static inline QPixmap grabWidget(QPaintDevice *widget, int x=0, int y=0, int w=-1, int h=-1)
{ return grabWidget(widget, QRect(x, y, w, h)); }
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 723f5cfde9..0c9e523951 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -2316,26 +2316,6 @@ void QWidgetPrivate::updateIsTranslucent()
#endif
}
-/*!
- \fn void QPixmap::fill(const QWidget *widget, const QPoint &offset)
-
- Fills the pixmap with the \a widget's background color or pixmap
- according to the given offset.
-
- The QPoint \a offset defines a point in widget coordinates to
- which the pixmap's top-left pixel will be mapped to. This is only
- significant if the widget has a background pixmap; otherwise the
- pixmap will simply be filled with the background color of the
- widget.
-*/
-
-void QPixmap::fill( const QWidget *widget, const QPoint &off )
-{
- QPainter p(this);
- p.translate(-off);
- widget->d_func()->paintBackground(&p, QRect(off, size()));
-}
-
static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrush &brush)
{
Q_ASSERT(painter);