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
6#include "qqnxscreen.h"
7#include "qqnxglobal.h"
8
9#include <QtCore/QDebug>
10#include <QtGui/QBackingStore>
11
12#include <errno.h>
13
14QT_BEGIN_NAMESPACE
15
16QQnxRasterBackingStore::QQnxRasterBackingStore(QWindow *window)
17 : QPlatformBackingStore(window),
18 m_needsPosting(false),
19 m_scrolled(false)
20{
21 qCDebug(lcQpaBackingStore) << Q_FUNC_INFO << "w =" << window;
22
23 m_window = window;
24}
25
27{
28 qCDebug(lcQpaBackingStore) << Q_FUNC_INFO << "w =" << window();
29}
30
32{
33 if (platformWindow() && platformWindow()->hasBuffers())
34 return platformWindow()->renderBuffer().image();
35
36 return 0;
37}
38
39void QQnxRasterBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
40{
41 Q_UNUSED(offset);
42
43 qCDebug(lcQpaBackingStore) << Q_FUNC_INFO << "w =" << this->window();
44
45 // Sometimes this method is called even though there is nothing to be
46 // flushed (posted in "screen" parlance), for instance, after an expose
47 // event directly follows a geometry change event.
48 if (!m_needsPosting)
49 return;
50
51 auto *targetWindow = window
52 ? static_cast<QQnxRasterWindow *>(window->handle()) : platformWindow();
53
54 if (targetWindow)
55 targetWindow->post(region); // update the display with newly rendered content
56
57 m_needsPosting = false;
58 m_scrolled = false;
59}
60
61void QQnxRasterBackingStore::resize(const QSize &size, const QRegion &staticContents)
62{
63 Q_UNUSED(size);
64 Q_UNUSED(staticContents);
65 qCDebug(lcQpaBackingStore) << Q_FUNC_INFO << "w =" << window() << ", s =" << size;
66
67 // NOTE: defer resizing window buffers until next paint as
68 // resize() can be called multiple times before a paint occurs
69}
70
71bool QQnxRasterBackingStore::scroll(const QRegion &area, int dx, int dy)
72{
73 qCDebug(lcQpaBackingStore) << Q_FUNC_INFO << "w =" << window();
74
75 m_needsPosting = true;
76
77 if (!m_scrolled) {
78#if defined(QQNX_INCREMENTAL_RASTER_UPDATE)
79 platformWindow()->scroll(area, dx, dy, true);
80#else
81 platformWindow()->scroll(area, dx, dy, false);
82 QRegion remainder = QRect(QPoint(0, 0), backingStore()->size());
83 remainder -= area.translated(dx, dy);
84 platformWindow()->scroll(remainder, 0, 0, true);
85#endif
86 m_scrolled = true;
87 return true;
88 }
89 return false;
90}
91
92void QQnxRasterBackingStore::beginPaint(const QRegion &region)
93{
94 Q_UNUSED(region);
95
96 qCDebug(lcQpaBackingStore) << Q_FUNC_INFO << "w =" << window();
97 m_needsPosting = true;
98
99 platformWindow()->adjustBufferSize();
100
101#if defined(QQNX_INCREMENTAL_RASTER_UPDATE)
102 if (window()->requestedFormat().alphaBufferSize() > 0) {
103 auto platformScreen = static_cast<QQnxScreen *>(platformWindow()->screen());
104 for (const QRect &r : region) {
105 // Clear transparent regions
106 const int bg[] = {
107 SCREEN_BLIT_COLOR, 0x00000000,
108 SCREEN_BLIT_DESTINATION_X, r.x(),
109 SCREEN_BLIT_DESTINATION_Y, r.y(),
110 SCREEN_BLIT_DESTINATION_WIDTH, r.width(),
111 SCREEN_BLIT_DESTINATION_HEIGHT, r.height(),
112 SCREEN_BLIT_END
113 };
114 Q_SCREEN_CHECKERROR(screen_fill(platformScreen->nativeContext(),
115 platformWindow()->renderBuffer().nativeBuffer(), bg),
116 "failed to clear transparent regions");
117 }
118 Q_SCREEN_CHECKERROR(screen_flush_blits(platformScreen->nativeContext(),
119 SCREEN_WAIT_IDLE), "failed to flush blits");
120 }
121#else
122 if (!m_scrolled)
123 platformWindow()->scroll(QRect(QPoint(0, 0), backingStore()->size()), 0, 0, true);
124#endif
125}
126
128{
129 qCDebug(lcQpaBackingStore) << Q_FUNC_INFO << "w =" << window();
130}
131
132QQnxRasterWindow *QQnxRasterBackingStore::platformWindow() const
133{
134 Q_ASSERT(m_window->handle());
135 return static_cast<QQnxRasterWindow*>(m_window->handle());
136}
137
138QT_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.
bool hasBuffers() const