Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqnxrasterbackingstore.cpp
Go to the documentation of this file.
1// Copyright (C) 2011 - 2013 BlackBerry Limited. All rights reserved.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
7#include "qqnxscreen.h"
8#include "qqnxglobal.h"
9
10#include <QtCore/QDebug>
11#include <QtGui/QBackingStore>
12
13#include <private/qhighdpiscaling_p.h>
14
15#include <errno.h>
16
17QT_BEGIN_NAMESPACE
18
19QQnxRasterBackingStore::QQnxRasterBackingStore(QWindow *window)
20 : QPlatformBackingStore(window),
21 m_needsPosting(false),
22 m_scrolled(false)
23{
24 qCDebug(lcQpaBackingStore) << Q_FUNC_INFO << "w =" << window;
25
26 m_window = window;
27}
28
30{
31 qCDebug(lcQpaBackingStore) << Q_FUNC_INFO << "w =" << window();
32}
33
35{
36 if (platformWindow() && platformWindow()->hasBuffers())
37 return platformWindow()->renderBuffer().image();
38
39 return 0;
40}
41
42void QQnxRasterBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
43{
44 Q_UNUSED(offset);
45
46 qCDebug(lcQpaBackingStore) << Q_FUNC_INFO << "w =" << this->window();
47
48 // Sometimes this method is called even though there is nothing to be
49 // flushed (posted in "screen" parlance), for instance, after an expose
50 // event directly follows a geometry change event.
51 if (!m_needsPosting)
52 return;
53
54 auto *targetWindow = window
55 ? static_cast<QQnxRasterWindow *>(window->handle()) : platformWindow();
56
57 if (targetWindow)
58 targetWindow->post(region); // update the display with newly rendered content
59
60 m_needsPosting = false;
61 m_scrolled = false;
62}
63
64void QQnxRasterBackingStore::resize(const QSize &size, const QRegion &staticContents)
65{
66 Q_UNUSED(staticContents);
67 qCDebug(lcQpaBackingStore) << Q_FUNC_INFO << "w =" << window() << ", s =" << size;
68
69 // NOTE: defer resizing window buffers until next paint as
70 // resize() can be called multiple times before a paint occurs
71 m_requestedSize = size;
72}
73
74bool QQnxRasterBackingStore::scroll(const QRegion &area, int dx, int dy)
75{
76 qCDebug(lcQpaBackingStore) << Q_FUNC_INFO << "w =" << window();
77
78 m_needsPosting = true;
79
80 if (!m_scrolled) {
81#if defined(QQNX_INCREMENTAL_RASTER_UPDATE)
82 platformWindow()->scroll(area, dx, dy, true);
83#else
84 platformWindow()->scroll(area, dx, dy, false);
85 const QSize backingStoreSize = QHighDpi::toNativePixels(backingStore()->size(), window());
86 QRegion remainder = QRect(QPoint(0, 0), backingStoreSize);
87 remainder -= area.translated(dx, dy);
88 platformWindow()->scroll(remainder, 0, 0, true);
89#endif
90 m_scrolled = true;
91 return true;
92 }
93 return false;
94}
95
96void QQnxRasterBackingStore::beginPaint(const QRegion &region)
97{
98 Q_UNUSED(region);
99
100 qCDebug(lcQpaBackingStore) << Q_FUNC_INFO << "w =" << window();
101 m_needsPosting = true;
102
103 platformWindow()->adjustBufferSize(
104 QHighDpi::toNativePixels(m_requestedSize, window()));
105
106#if defined(QQNX_INCREMENTAL_RASTER_UPDATE)
107 if (window()->requestedFormat().alphaBufferSize() > 0) {
108 auto platformScreen = static_cast<QQnxScreen *>(platformWindow()->screen());
109 for (const QRect &r : region) {
110 // Clear transparent regions
111 const int bg[] = {
112 SCREEN_BLIT_COLOR, 0x00000000,
113 SCREEN_BLIT_DESTINATION_X, r.x(),
114 SCREEN_BLIT_DESTINATION_Y, r.y(),
115 SCREEN_BLIT_DESTINATION_WIDTH, r.width(),
116 SCREEN_BLIT_DESTINATION_HEIGHT, r.height(),
117 SCREEN_BLIT_END
118 };
119 Q_SCREEN_CHECKERROR(screen_fill(platformScreen->nativeContext(),
120 platformWindow()->renderBuffer().nativeBuffer(), bg),
121 "failed to clear transparent regions");
122 }
123 Q_SCREEN_CHECKERROR(screen_flush_blits(platformScreen->nativeContext(),
124 SCREEN_WAIT_IDLE), "failed to flush blits");
125 }
126#else
127 if (!m_scrolled) {
128 const QSize backingStoreSize = QHighDpi::toNativePixels(backingStore()->size(), window());
129 platformWindow()->scroll(QRect(QPoint(0, 0), backingStoreSize), 0, 0, true);
130 }
131#endif
132}
133
135{
136 qCDebug(lcQpaBackingStore) << Q_FUNC_INFO << "w =" << window();
137}
138
139QQnxRasterWindow *QQnxRasterBackingStore::platformWindow() const
140{
141 Q_ASSERT(m_window->handle());
142 return static_cast<QQnxRasterWindow*>(m_window->handle());
143}
144
145QT_END_NAMESPACE
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.
void resize(const QSize &size, const QRegion &staticContents) override
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 flush(QWindow *window, const QRegion &region, const QPoint &offset) override
Flushes the given region from the specified window.
void endPaint() override
This function is called after painting onto the surface has ended.
QQnxBuffer & renderBuffer()
bool hasBuffers() const