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