summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qcoregraphics_p.h
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-03-22 15:13:25 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-04-19 15:34:30 +0000
commit585150e3d947d0ee30489f275e7fc39bce4fe059 (patch)
tree88352fb17f2ce89547d330a50fb5e07f58c25136 /src/gui/painting/qcoregraphics_p.h
parentb556890a9f7dd45550f0d4e9da981e2f779a943b (diff)
macOS: Clean up and deduplicate QMacCGContext
We now use QCFType to track the CGContextRef, instead of manually maintaining the lifetime of the context. A bunch of unused methods were removed, including completely broken ones like isNull(). Change-Id: Ib5a05aadbf8f228192e74c9a4c8919580b831497 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/gui/painting/qcoregraphics_p.h')
-rw-r--r--src/gui/painting/qcoregraphics_p.h36
1 files changed, 8 insertions, 28 deletions
diff --git a/src/gui/painting/qcoregraphics_p.h b/src/gui/painting/qcoregraphics_p.h
index 868c2b08b5..ba2cde8325 100644
--- a/src/gui/painting/qcoregraphics_p.h
+++ b/src/gui/painting/qcoregraphics_p.h
@@ -51,6 +51,8 @@
// We mean it.
//
+#include <QtCore/private/qcore_mac_p.h>
+
#include <QtGui/private/qtguiglobal_p.h>
#include <QtGui/qregion.h>
#include <QtGui/qpalette.h>
@@ -89,38 +91,16 @@ Q_GUI_EXPORT QBrush qt_mac_toQBrush(CGColorRef color);
class Q_GUI_EXPORT QMacCGContext
{
public:
- inline QMacCGContext() { context = 0; }
+ QMacCGContext() = default;
QMacCGContext(QPaintDevice *pdev);
QMacCGContext(QPainter *p);
- inline QMacCGContext(CGContextRef cg, bool takeOwnership = false) {
- context = cg;
- if (!takeOwnership)
- CGContextRetain(context);
- }
- inline QMacCGContext(const QMacCGContext &copy) : context(0) { *this = copy; }
- inline ~QMacCGContext() {
- if (context)
- CGContextRelease(context);
- }
- inline bool isNull() const { return context; }
- inline operator CGContextRef() { return context; }
- inline QMacCGContext &operator=(const QMacCGContext &copy) {
- if (context)
- CGContextRelease(context);
- context = copy.context;
- CGContextRetain(context);
- return *this;
- }
- inline QMacCGContext &operator=(CGContextRef cg) {
- if (context)
- CGContextRelease(context);
- context = cg;
- CGContextRetain(context); //we do not take ownership
- return *this;
- }
+
+ operator CGContextRef() { return context; }
private:
- CGContextRef context;
+ void initialize(QPaintDevice *paintDevice);
+ void initialize(const QImage *, QPainter *painter = nullptr);
+ QCFType<CGContextRef> context;
};
QT_END_NAMESPACE