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
qcocoabackingstore.h
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// Qt-Security score:significant reason:default
4
5#ifndef QBACKINGSTORE_COCOA_H
6#define QBACKINGSTORE_COCOA_H
7
8#include <QtGui/private/qrasterbackingstore_p.h>
9
10#include <private/qcore_mac_p.h>
11
12#include <QScopedPointer>
14
15#include <unordered_map>
16
17QT_BEGIN_NAMESPACE
18
19class QCocoaBackingStore : public QPlatformBackingStore
20{
21protected:
22 QCocoaBackingStore(QWindow *window);
23 QCFType<CGColorSpaceRef> colorSpace() const;
24};
25
26class QCALayerBackingStore : public QObject, public QCocoaBackingStore
27{
29public:
32
33 void resize(const QSize &size, const QRegion &staticContents) override;
34
35 void beginPaint(const QRegion &region) override;
36 QPaintDevice *paintDevice() override;
37 void endPaint() override;
38
39 bool scroll(const QRegion &region, int dx, int dy) override;
40
41 void flush(QWindow *, const QRegion &, const QPoint &) override;
42
43 FlushResult rhiFlush(QWindow *window,
44 qreal sourceDevicePixelRatio,
45 const QRegion &region,
46 const QPoint &offset,
47 QPlatformTextureList *textures,
48 bool translucentBackground,
49 qreal sourceTransformFactor) override;
50
51 QImage toImage() const override;
53
54private:
55 void observeBackingPropertiesChanges();
56 bool eventFilter(QObject *watched, QEvent *event) override;
57
58 QSize m_requestedSize;
59 QRegion m_staticContents;
60
61 class GraphicsBuffer : public QIOSurfaceGraphicsBuffer
62 {
63 public:
64 GraphicsBuffer(const QSize &size, qreal devicePixelRatio,
65 const QPixelFormat &format, QCFType<CGColorSpaceRef> colorSpace);
66
67 QRegion dirtyRegion; // In unscaled coordinates
68 QImage *asImage();
69 qreal devicePixelRatio() const { return m_devicePixelRatio; }
70 bool isDirty() const { return !dirtyRegion.isEmpty(); }
71 QRegion validRegion() const;
72
73 private:
74 qreal m_devicePixelRatio;
75 QImage m_image;
76 };
77
78 void updateDirtyStates(const QRegion &paintedRegion);
79
80 void ensureBackBuffer();
81 bool recreateBackBufferIfNeeded();
82 void finalizeBackBuffer();
83
84 void blitBuffer(GraphicsBuffer *sourceBuffer, const QRegion &sourceRegion,
85 GraphicsBuffer *destinationBuffer, const QPoint &destinationOffset = QPoint());
86
87 void backingPropertiesChanged();
88 QMacNotificationObserver m_backingPropertiesObserver;
89
91
92 void flushSubWindow(QWindow *window);
94 void windowDestroyed(QObject *object);
95 bool m_clearSurfaceOnPaint = true;
96};
97
98QT_END_NAMESPACE
99
100#endif
QPaintDevice * paintDevice() override
Implement this function to return the appropriate paint device.
QImage toImage() const override
Implemented in subclasses to return the content of the backingstore as a QImage.
bool scroll(const QRegion &region, 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 endPaint() override
This function is called after painting onto the surface has ended.
void flush(QWindow *, const QRegion &, const QPoint &) override
Flushes the given region from the specified window.
void beginPaint(const QRegion &region) override
This function is called before painting onto the surface begins, with the region in which the paintin...
FlushResult rhiFlush(QWindow *window, qreal sourceDevicePixelRatio, const QRegion &region, const QPoint &offset, QPlatformTextureList *textures, bool translucentBackground, qreal sourceTransformFactor) override
Flushes the given region from the specified window, and compositing it with the specified textures li...
QPlatformGraphicsBuffer * graphicsBuffer() const override
Accessor for a backingstores graphics buffer abstraction.
bool eventFilter(QObject *watched, QEvent *event) override
Filters events if this object has been installed as an event filter for the watched object.
void resize(const QSize &size, const QRegion &staticContents) override
#define USE_LAZY_BUFFER_ALLOCATION_DURING_LIVE_WINDOW_RESIZE
QT_BEGIN_NAMESPACE void qt_scrollRectInImage(QImage &, const QRect &, const QPoint &)