50 #include <QtGui/qpaintdevice.h> 51 #include <QtGui/qwidget.h> 53 #include "private/qwindowsurface_raster_p.h" 54 #include "private/qnativeimage_p.h" 55 #include "private/qwidget_p.h" 58 #include "private/qpixmap_x11_p.h" 59 #include "private/qt_x11_p.h" 60 #include "private/qwidget_p.h" 63 #include "private/qdrawhelper_p.h" 66 #include <private/qt_cocoa_helpers_mac_p.h> 67 #include <QMainWindow> 68 #include <private/qmainwindowlayout_p.h> 95 d_ptr->
gc = XCreateGC(
X11->display, window->handle(), 0, 0);
107 #ifdef QT_MAC_USE_COCOA 110 #endif // QT_MAC_USE_COCOA 129 #if defined(Q_WS_X11) && !defined(QT_NO_MITSHM) 134 XSync(
X11->display,
false);
142 #if defined(Q_WS_X11) && !defined(QT_NO_MITSHM) 146 #if (defined(Q_WS_X11) && !defined(QT_NO_XRENDER)) || (defined(Q_WS_WIN) && !defined(Q_WS_WINCE)) 148 #if defined(Q_WS_WIN) && !defined(Q_WS_WINCE) 187 POINT ptDst = {r.
x(), r.
y()};
188 POINT ptSrc = {0, 0};
190 RECT dirty = {dirtyRect.
x(), dirtyRect.
y(),
191 dirtyRect.
x() + dirtyRect.
width(), dirtyRect.
y() + dirtyRect.
height()};
199 HDC widget_dc = widget->
getDC();
202 BitBlt(widget_dc, wbr.
x(), wbr.
y(), wbr.
width(), wbr.
height(),
203 d->image->hdc, br.
x() + offset.
x(), br.
y() + offset.
y(), SRCCOPY);
213 d->image->hdc, 0, 0, SRCCOPY);
226 d_ptr->
gc = XCreateGC(
X11->display, widget->handle(), 0, 0);
231 wrgn.translate(-wOffset);
233 if (wrgn.rectCount() != 1) {
236 XSetClipRectangles(
X11->display,
d_ptr->
gc, 0, 0, rects, num, YXBanded);
239 QPoint widgetOffset = offset + wOffset;
258 const QImage &src =
d->image->image;
264 data->xinfo = widget->
x11Info();
275 if (wrgn.rectCount() != 1)
288 #ifdef QT_MAC_USE_COCOA 290 this->needsFlush =
true;
291 this->regionToFlush += rgn;
294 qt_mac_setNeedsDisplay(widget);
300 QDBeginCGContext(port, &context);
301 CGContextRetain(context);
302 CGContextSaveGState(context);
305 CGContextTranslateCTM(context, 0, widget->
height());
306 CGContextScaleCTM(context, 1, -1);
310 for (
int i = 0; i < rects.
size(); ++i) {
312 CGContextAddRect(context, CGRectMake(rect.
x(), rect.
y(), rect.
width(), rect.
height()));
314 CGContextClip(context);
318 CGImageRef image = CGBitmapContextCreateImage(
d->image->cg);
319 CGImageRef subImage = CGImageCreateWithImageInRect(image, area);
323 CGImageRelease(subImage);
324 CGImageRelease(image);
326 QDEndCGContext(port, &context);
329 CGContextRestoreGState(context);
330 CGContextRelease(context);
331 #endif // QT_MAC_USE_COCOA 346 d->inSetGeometry =
true;
347 if (
d->image == 0 ||
d->image->width() < rect.
width() ||
d->image->height() < rect.
height()) {
348 #if (defined(Q_WS_X11) && !defined(QT_NO_XRENDER)) || (defined(Q_WS_WIN) && !defined(Q_WS_WINCE)) 359 d->inSetGeometry =
false;
361 #if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA) 367 for (
int i = 0; i < toolbarList.size(); ++i) {
371 if (tbWidget->d_func()->unifiedSurface) {
372 tbWidget->d_func()->unifiedSurface->
setGeometry(rect);
377 #endif // Q_WS_MAC && QT_MAC_USE_COCOA 389 if (!
d->image || !
d->image->hdc)
393 BitBlt(
d->image->hdc, rect.
x()+dx, rect.
y()+dy, rect.
width(), rect.
height(),
394 d->image->hdc, rect.
x(), rect.
y(), SRCCOPY);
400 if (!
d->image ||
d->image->image.isNull())
403 #if defined(Q_WS_X11) && !defined(QT_NO_MITSHM) 408 for (
int i = 0; i < rects.
size(); ++i)
427 width =
qMax(
d->image->width(), width);
428 height =
qMax(
d->image->height(), height);
431 if (width == 0 || height == 0) {
439 d->image =
new QNativeImage(width, height, format,
false, widget);
444 uchar *dst =
d->image->image.bits();
447 const int dstBytesPerLine =
d->image->image.bytesPerLine();
454 const QRect *srcRect = rects.constData();
457 int numRectsLeft = rects.
size();
460 const int dy = srcRect->
y();
463 const uchar *s = src + dy * srcBytesPerLine + bytesOffset;
464 uchar *
d = dst + dy * dstBytesPerLine + bytesOffset;
467 int numScanLinesLeft = srcRect->
height();
469 ::memcpy(d, s, numBytes);
470 d += dstBytesPerLine;
471 s += srcBytesPerLine;
472 }
while (--numScanLinesLeft);
475 }
while (--numRectsLeft);
481 #ifdef QT_MAC_USE_COCOA 487 #endif // QT_MAC_USE_COCOA T qobject_cast(QObject *object)
The QPainter class performs low-level painting on widgets and other paint devices.
The QColor class provides colors based on RGB, HSV or CMYK values.
int depth() const
Returns the color depth (bits per pixel) of the X display.
Format
The following image formats are available in Qt.
Qt::ToolBarArea toolBarArea(QToolBar *toolbar) const
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
PtrUpdateLayeredWindowIndirect ptrUpdateLayeredWindowIndirect
static mach_timebase_info_data_t info
uint translucentBackground
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
QRect rect(const QWidget *widget) const
Returns the rectangle for widget in the coordinates of this window surface.
#define it(className, varName)
void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)
void setGeometry(const QRect &rect)
Sets the currently allocated area to be the given rect.
static int bytesPerPixel(QImage::Format format)
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
virtual void setGeometry(const QRect &rect)
Sets the currently allocated area to be the given rect.
int width() const
Returns the width of the rectangle.
Q_GUI_EXPORT void * qt_getClipRects(const QRegion &r, int &num)
void prepareBuffer(QImage::Format format, QWidget *widget)
struct CGImage * CGImageRef
virtual QPoint offset(const QWidget *widget) const
Returns the offset of widget in the coordinates of this window surface.
Qt::HANDLE handle() const
Returns the pixmap's handle to the device context.
int bytesPerLine() const
Returns the number of bytes per image scanline.
static QImage::Format systemFormat()
QRect intersected(const QRect &other) const
Returns the intersection of this rectangle and the given rectangle.
QRect boundingRect() const
Returns the bounding rectangle of this region.
int height() const
Returns the height of the rectangle.
QRect rect() const
Returns the enclosing rectangle (0, 0, width(), height()) of the image.
#define SIZE(large, small, mini)
int rectCount() const
Returns the number of rectangles that will be returned in rects().
Format format() const
Returns the format of the image.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the vector...
OSWindowRef qt_mac_window_for(const QWidget *)
#define QT_BEGIN_NAMESPACE
This macro expands to.
bool hasStaticContents() const
QScopedPointer< QRasterWindowSurfacePrivate > d_ptr
The Rectangle item provides a filled rectangle with an optional border.
QSize size() const
Returns the size of the rectangle.
void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset)
Flushes the given region from the specified widget onto the screen.
bool isNull() const
Returns true if both the x and y coordinates are set to 0, otherwise returns false.
The QImage class provides a hardware-independent image representation that allows direct access to th...
static const char * data(const QByteArray &arr)
QList< QToolBar * > qtoolbarsInUnifiedToolbarList
bool scroll(const QRegion &area, int dx, int dy)
Scrolls the given area dx pixels to the right and dy downward; both dx and dy may be negative...
The QRegion class specifies a clip region for a painter.
QRasterWindowSurface(QWidget *widget, bool setDefaultSurface=true)
int depth() const
Returns the depth of the image.
void * visual() const
Returns the current visual.
Q_GUI_EXPORT HDC qt_win_display_dc()
The QWindowSurface class provides the drawing area for top-level windows.
QRegion staticContents() const
const T & at(int i) const
Returns the item at index position i in the vector.
Q_GUI_EXPORT void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const QImage &image, Drawable hd, GC gc, Display *dpy, Visual *visual, int depth)
int width() const
Returns the width of the image.
WindowSurfaceFeatures features() const
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
iterator begin()
Returns an STL-style iterator pointing to the first item in the vector.
int y() const
Returns the y-coordinate of the rectangle's top edge.
void beginPaint(const QRegion &rgn)
This function is called before painting onto the surface begins, with the region in which the paintin...
int x() const
Returns the x-coordinate of the rectangle's left edge.
QPaintDevice * paintDevice()
Implement this function to return the appropriate paint device.
The QPoint class defines a point in the plane using integer precision.
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
The QMainWindow class provides a main application window.
OSStatus qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage)
The QRect class defines a rectangle in the plane using integer precision.
int height() const
Returns the height of the image.
int y() const
Returns the y coordinate of this point.
The QPixmap class is an off-screen image representation that can be used as a paint device...
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
int x() const
Returns the x coordinate of this point.
struct CGContext * CGContextRef
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
int size() const
Returns the number of items in the vector.
QWidget * window() const
Returns a pointer to the top-level window associated with this surface.
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
The QList class is a template class that provides lists.
static int area(const QSize &s)
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.