Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qrasterbackingstore.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include <QtGui/qbackingstore.h>
7#include <QtGui/qpainter.h>
8
9#include <private/qhighdpiscaling_p.h>
10#include <qpa/qplatformwindow.h>
11
13
18
22
23void QRasterBackingStore::resize(const QSize &size, const QRegion &staticContents)
24{
25 Q_UNUSED(staticContents);
27}
28
36
41
43{
44 return m_image;
45}
46
47bool QRasterBackingStore::scroll(const QRegion &region, int dx, int dy)
48{
50 return false;
51
52 extern void qt_scrollRectInImage(QImage &, const QRect &, const QPoint &);
53
54 const qreal devicePixelRatio = m_image.devicePixelRatio();
55 const QPoint delta(dx * devicePixelRatio, dy * devicePixelRatio);
56
57 const QRect rect = region.boundingRect();
58 qt_scrollRectInImage(m_image, QRect(rect.topLeft() * devicePixelRatio, rect.size() * devicePixelRatio), delta);
59
60 return true;
61}
62
64{
65 qreal nativeWindowDevicePixelRatio = window()->handle()->devicePixelRatio();
66 QSize effectiveBufferSize = m_requestedSize * nativeWindowDevicePixelRatio;
67 if (m_image.devicePixelRatio() != nativeWindowDevicePixelRatio || m_image.size() != effectiveBufferSize) {
68 m_image = QImage(effectiveBufferSize, format());
69 m_image.setDevicePixelRatio(nativeWindowDevicePixelRatio);
72 }
73
75 return;
76
79 for (const QRect &rect : region)
81}
82
\inmodule QtGui
Definition qimage.h:37
bool hasAlphaChannel() const
Returns true if the image has a format that respects the alpha channel, otherwise returns false.
Definition qimage.cpp:4589
QSize size() const
Returns the size of the image, i.e.
Format
The following image formats are available in Qt.
Definition qimage.h:41
@ Format_RGB32
Definition qimage.h:46
@ Format_ARGB32_Premultiplied
Definition qimage.h:48
void fill(uint pixel)
Fills the entire image with the given pixelValue.
Definition qimage.cpp:1758
void setDevicePixelRatio(qreal scaleFactor)
Sets the device pixel ratio for the image.
Definition qimage.cpp:1510
qreal devicePixelRatio() const
Returns the device pixel ratio for the image.
Definition qimage.cpp:1482
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
@ CompositionMode_Source
Definition qpainter.h:101
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
The QPlatformBackingStore class provides the drawing area for top-level windows.
QWindow * window() const
Returns a pointer to the top-level window associated with this surface.
static bool isRasterSurface(QSurface *surface)
virtual qreal devicePixelRatio() const
Reimplement this function in subclass to return the device pixel ratio for the window.
\inmodule QtCore\reentrant
Definition qpoint.h:25
void resize(const QSize &size, const QRegion &staticContents) override
QImage toImage() const override
Implemented in subclasses to return the content of the backingstore as a QImage.
QRasterBackingStore(QWindow *window)
bool scroll(const QRegion &area, int dx, int dy) override
Scrolls the given area dx pixels to the right and dy downward; both dx and dy may be negative.
void beginPaint(const QRegion &region) override
This function is called before painting onto the surface begins, with the region in which the paintin...
QPaintDevice * paintDevice() override
Implement this function to return the appropriate paint device.
virtual QImage::Format format() const
\inmodule QtCore\reentrant
Definition qrect.h:30
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
QRect boundingRect() const noexcept
Returns the bounding rectangle of this region.
\inmodule QtCore
Definition qsize.h:25
\inmodule QtGui
Definition qwindow.h:63
rect
[4]
Combined button and popup list for selecting options.
@ transparent
Definition qnamespace.h:47
GLenum GLuint GLintptr GLsizeiptr size
[1]
void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)
static bool hasAlpha(const QImage &image)
#define Q_UNUSED(x)
double qreal
Definition qtypes.h:187
QPainter painter(this)
[7]
aWidget window() -> setWindowTitle("New Window Title")
[2]