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
qsgsoftwarepixmaprenderer.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
6
7#include <QtQuick/QSGSimpleRectNode>
8
9#include <QElapsedTimer>
10
11Q_LOGGING_CATEGORY(lcPixmapRenderer, "qt.scenegraph.softwarecontext.pixmapRenderer")
12
14
20
25
30
35
37{
38 QElapsedTimer renderTimer;
39
40 // Setup background item
41 setBackgroundRect(m_projectionRect.normalized(), qreal(1));
43
44 renderTimer.start();
46 qint64 buildRenderListTime = renderTimer.restart();
47
48 // Optimize Renderlist
49 // Right now there is an assumption that when possible the same pixmap will
50 // be reused. So we can treat it like a backing store in that we can assume
51 // that when the pixmap is not being resized, the data can be reused. What is
52 // different though is that everything should be marked as dirty on a resize.
54 qint64 optimizeRenderListTime = renderTimer.restart();
55
56 if (!isOpaque() && target->devType() == QInternal::Pixmap) {
57 // This fill here is wasteful, but necessary because it is the only way
58 // to force a QImage based pixmap to have an alpha channel.
59 static_cast<QPixmap *>(target)->fill(Qt::transparent);
60 }
61
64 painter.setWindow(m_projectionRect);
65 auto rc = static_cast<QSGSoftwareRenderContext *>(context());
66 QPainter *prevPainter = rc->m_activePainter;
67 rc->m_activePainter = &painter;
68
69 QRegion paintedRegion = renderNodes(&painter);
70 qint64 renderTime = renderTimer.elapsed();
71
72 rc->m_activePainter = prevPainter;
73 qCDebug(lcPixmapRenderer) << "pixmapRender" << paintedRegion << buildRenderListTime << optimizeRenderListTime << renderTime;
74}
75
77{
78 m_projectionRect = projectionRect;
79}
80
\inmodule QtCore
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
@ Antialiasing
Definition qpainter.h:52
void setWindow(const QRect &window)
Sets the painter's window to the given rectangle, and enables view transformations.
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
\inmodule QtCore\reentrant
Definition qrect.h:30
QRect normalized() const noexcept
Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height.
Definition qrect.cpp:277
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
QColor clearColor() const
Returns the color that clears the framebuffer at the beginning of the rendering.
void setBackgroundColor(const QColor &color)
void setBackgroundRect(const QRect &rect, qreal devicePixelRatio)
QSGRenderContext * context() const
void renderScene() override
Renders the scene.
void renderScene() final
Renders the scene.
void setProjectionRect(const QRect &projectionRect)
Combined button and popup list for selecting options.
@ transparent
Definition qnamespace.h:47
static void * context
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLenum target
long long qint64
Definition qtypes.h:60
double qreal
Definition qtypes.h:187
ba fill(true)
QPainter painter(this)
[7]