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
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
4#ifndef QBACKINGSTORE_COCOA_H
5#define QBACKINGSTORE_COCOA_H
6
7#include <QtGui/private/qrasterbackingstore_p.h>
8
9#include <private/qcore_mac_p.h>
10
11#include <QScopedPointer>
13
14#include <unordered_map>
15
17
19{
20protected:
22 QCFType<CGColorSpaceRef> colorSpace() const;
23};
24
26{
28public:
31
32 void resize(const QSize &size, const QRegion &staticContents) override;
33
34 void beginPaint(const QRegion &region) override;
35 QPaintDevice *paintDevice() override;
36 void endPaint() override;
37
38 bool scroll(const QRegion &region, int dx, int dy) override;
39
40 void flush(QWindow *, const QRegion &, const QPoint &) override;
41
43 qreal sourceDevicePixelRatio,
44 const QRegion &region,
45 const QPoint &offset,
47 bool translucentBackground) override;
48
49 QImage toImage() const override;
51
52private:
53 void observeBackingPropertiesChanges();
54 bool eventFilter(QObject *watched, QEvent *event) override;
55
56 QSize m_requestedSize;
57 QRegion m_staticContents;
58
59 class GraphicsBuffer : public QIOSurfaceGraphicsBuffer
60 {
61 public:
62 GraphicsBuffer(const QSize &size, qreal devicePixelRatio,
63 const QPixelFormat &format, QCFType<CGColorSpaceRef> colorSpace);
64
65 QRegion dirtyRegion; // In unscaled coordinates
66 QImage *asImage();
67 qreal devicePixelRatio() const { return m_devicePixelRatio; }
68 bool isDirty() const { return !dirtyRegion.isEmpty(); }
69 QRegion validRegion() const;
70
71 private:
72 qreal m_devicePixelRatio;
73 QImage m_image;
74 };
75
76 void updateDirtyStates(const QRegion &paintedRegion);
77
78 void ensureBackBuffer();
79 bool recreateBackBufferIfNeeded();
80 void finalizeBackBuffer();
81
82 void blitBuffer(GraphicsBuffer *sourceBuffer, const QRegion &sourceRegion,
83 GraphicsBuffer *destinationBuffer, const QPoint &destinationOffset = QPoint());
84
85 void backingPropertiesChanged();
86 QMacNotificationObserver m_backingPropertiesObserver;
87
88 std::list<std::unique_ptr<GraphicsBuffer>> m_buffers;
89
90 void flushSubWindow(QWindow *window);
91 std::unordered_map<QWindow*, std::unique_ptr<QCALayerBackingStore>> m_subWindowBackingstores;
92 void windowDestroyed(QObject *object);
93 bool m_clearSurfaceOnPaint = true;
94};
95
97
98#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...
QPlatformGraphicsBuffer * graphicsBuffer() const override
Accessor for a backingstores graphics buffer abstraction.
QCALayerBackingStore(QWindow *window)
bool eventFilter(QObject *watched, QEvent *event) override
Filters events if this object has been installed as an event filter for the watched object.
FlushResult rhiFlush(QWindow *window, qreal sourceDevicePixelRatio, const QRegion &region, const QPoint &offset, QPlatformTextureList *textures, bool translucentBackground) override
Flushes the given region from the specified window, and compositing it with the specified textures li...
void resize(const QSize &size, const QRegion &staticContents) override
QCFType< CGColorSpaceRef > colorSpace() const
QCocoaBackingStore(QWindow *window)
\inmodule QtCore
Definition qcoreevent.h:45
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore
Definition qobject.h:103
\inmodule QtGui
The QPlatformBackingStore class provides the drawing area for top-level windows.
QWindow * window() const
Returns a pointer to the top-level window associated with this surface.
\inmodule QtCore\reentrant
Definition qpoint.h:25
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
\inmodule QtCore
Definition qsize.h:25
\inmodule QtGui
Definition qwindow.h:63
Combined button and popup list for selecting options.
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint const GLuint GLuint const GLuint * textures
GLenum GLuint GLintptr offset
GLint GLsizei GLsizei GLenum format
struct _cl_event * event
#define Q_OBJECT
double qreal
Definition qtypes.h:187