qtbase: Fix duplicate symbol errors in static build on Mac
There is some code duplication between QMacStyle anf the Cocoa QPA
plugin regarding painting and bridging with Cocoa.
Task-number: QTBUG-29725
Change-Id: I347407a9bca47b6fccd77fb924688bd35135d96b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
(cherry picked from commit 5f948eb62d
)
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
This commit is contained in:
parent
426f2ccafc
commit
613cef516c
@ -466,10 +466,9 @@ QString qt_mac_removeMnemonics(const QString &original)
|
||||
return returnText;
|
||||
}
|
||||
|
||||
|
||||
CGColorSpaceRef m_genericColorSpace = 0;
|
||||
QHash<CGDirectDisplayID, CGColorSpaceRef> m_displayColorSpaceHash;
|
||||
bool m_postRoutineRegistered = false;
|
||||
static CGColorSpaceRef m_genericColorSpace = 0;
|
||||
static QHash<CGDirectDisplayID, CGColorSpaceRef> m_displayColorSpaceHash;
|
||||
static bool m_postRoutineRegistered = false;
|
||||
|
||||
CGColorSpaceRef qt_mac_genericColorSpace()
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ QT_BEGIN_NAMESPACE
|
||||
QCoreGraphicsPaintEngine utility functions
|
||||
*****************************************************************************/
|
||||
|
||||
void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransform *orig_xform)
|
||||
static void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransform *orig_xform)
|
||||
{
|
||||
CGAffineTransform old_xform = CGAffineTransformIdentity;
|
||||
if (orig_xform) { //setup xforms
|
||||
|
@ -458,6 +458,9 @@ static QString qt_mac_removeMnemonics(const QString &original)
|
||||
return returnText;
|
||||
}
|
||||
|
||||
static CGContextRef qt_mac_cg_context(const QPaintDevice *pdev);
|
||||
|
||||
namespace {
|
||||
class QMacCGContext
|
||||
{
|
||||
CGContextRef context;
|
||||
@ -465,7 +468,6 @@ public:
|
||||
QMacCGContext(QPainter *p);
|
||||
inline QMacCGContext() { context = 0; }
|
||||
inline QMacCGContext(const QPaintDevice *pdev) {
|
||||
extern CGContextRef qt_mac_cg_context(const QPaintDevice *);
|
||||
context = qt_mac_cg_context(pdev);
|
||||
}
|
||||
inline QMacCGContext(CGContextRef cg, bool takeOwnership=false) {
|
||||
@ -495,6 +497,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
} // anonymous namespace
|
||||
|
||||
static QColor qcolorFromCGColor(CGColorRef cgcolor)
|
||||
{
|
||||
@ -578,11 +581,11 @@ QRegion qt_mac_fromHIShapeRef(HIShapeRef shape)
|
||||
}
|
||||
|
||||
CGColorSpaceRef m_genericColorSpace = 0;
|
||||
QHash<CGDirectDisplayID, CGColorSpaceRef> m_displayColorSpaceHash;
|
||||
static QHash<CGDirectDisplayID, CGColorSpaceRef> m_displayColorSpaceHash;
|
||||
bool m_postRoutineRegistered = false;
|
||||
|
||||
CGColorSpaceRef qt_mac_displayColorSpace(const QWidget *widget);
|
||||
CGColorSpaceRef qt_mac_genericColorSpace()
|
||||
static CGColorSpaceRef qt_mac_displayColorSpace(const QWidget *widget);
|
||||
static CGColorSpaceRef qt_mac_genericColorSpace()
|
||||
{
|
||||
#if 0
|
||||
if (!m_genericColorSpace) {
|
||||
@ -606,11 +609,26 @@ CGColorSpaceRef qt_mac_genericColorSpace()
|
||||
#endif
|
||||
}
|
||||
|
||||
static void qt_mac_cleanUpMacColorSpaces()
|
||||
{
|
||||
if (m_genericColorSpace) {
|
||||
CFRelease(m_genericColorSpace);
|
||||
m_genericColorSpace = 0;
|
||||
}
|
||||
QHash<CGDirectDisplayID, CGColorSpaceRef>::const_iterator it = m_displayColorSpaceHash.constBegin();
|
||||
while (it != m_displayColorSpaceHash.constEnd()) {
|
||||
if (it.value())
|
||||
CFRelease(it.value());
|
||||
++it;
|
||||
}
|
||||
m_displayColorSpaceHash.clear();
|
||||
}
|
||||
|
||||
/*
|
||||
Ideally, we should pass the widget in here, and use CGGetDisplaysWithRect() etc.
|
||||
to support multiple displays correctly.
|
||||
*/
|
||||
CGColorSpaceRef qt_mac_displayColorSpace(const QWidget *widget)
|
||||
static CGColorSpaceRef qt_mac_displayColorSpace(const QWidget *widget)
|
||||
{
|
||||
CGColorSpaceRef colorSpace;
|
||||
|
||||
@ -639,27 +657,11 @@ CGColorSpaceRef qt_mac_displayColorSpace(const QWidget *widget)
|
||||
m_displayColorSpaceHash.insert(displayID, colorSpace);
|
||||
if (!m_postRoutineRegistered) {
|
||||
m_postRoutineRegistered = true;
|
||||
void qt_mac_cleanUpMacColorSpaces();
|
||||
qAddPostRoutine(qt_mac_cleanUpMacColorSpaces);
|
||||
}
|
||||
return colorSpace;
|
||||
}
|
||||
|
||||
void qt_mac_cleanUpMacColorSpaces()
|
||||
{
|
||||
if (m_genericColorSpace) {
|
||||
CFRelease(m_genericColorSpace);
|
||||
m_genericColorSpace = 0;
|
||||
}
|
||||
QHash<CGDirectDisplayID, CGColorSpaceRef>::const_iterator it = m_displayColorSpaceHash.constBegin();
|
||||
while (it != m_displayColorSpaceHash.constEnd()) {
|
||||
if (it.value())
|
||||
CFRelease(it.value());
|
||||
++it;
|
||||
}
|
||||
m_displayColorSpaceHash.clear();
|
||||
}
|
||||
|
||||
bool qt_macWindowIsTextured(const QWidget *window)
|
||||
{
|
||||
NSWindow *nswindow = static_cast<NSWindow*>(
|
||||
@ -6489,7 +6491,7 @@ int QMacStyle::layoutSpacing(QSizePolicy::ControlType control1,
|
||||
return_SIZE(10, 8, 6); // guess
|
||||
}
|
||||
|
||||
void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransform *orig_xform)
|
||||
static void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransform *orig_xform)
|
||||
{
|
||||
CGAffineTransform old_xform = CGAffineTransformIdentity;
|
||||
if (orig_xform) { //setup xforms
|
||||
@ -6530,6 +6532,9 @@ void qt_mac_scale_region(QRegion *region, qreal scaleFactor)
|
||||
region->setRects(&scaledRects[0], scaledRects.count());
|
||||
}
|
||||
|
||||
static CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *paintDevice);
|
||||
|
||||
namespace {
|
||||
QMacCGContext::QMacCGContext(QPainter *p)
|
||||
{
|
||||
QPaintEngine *pe = p->paintEngine();
|
||||
@ -6542,7 +6547,6 @@ QMacCGContext::QMacCGContext(QPainter *p)
|
||||
devType == QInternal::Pixmap ||
|
||||
devType == QInternal::Image)) {
|
||||
|
||||
extern CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *paintDevice);
|
||||
CGColorSpaceRef colorspace = qt_mac_colorSpaceForDeviceType(pe->paintDevice());
|
||||
uint flags = kCGImageAlphaPremultipliedFirst;
|
||||
flags |= kCGBitmapByteOrder32Host;
|
||||
@ -6584,7 +6588,9 @@ QMacCGContext::QMacCGContext(QPainter *p)
|
||||
}
|
||||
}
|
||||
|
||||
CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *paintDevice)
|
||||
} // anonymous namespace
|
||||
|
||||
static CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *paintDevice)
|
||||
{
|
||||
bool isWidget = (paintDevice->devType() == QInternal::Widget);
|
||||
return qt_mac_displayColorSpace(isWidget ? static_cast<const QWidget *>(paintDevice) : 0);
|
||||
|
Loading…
Reference in New Issue
Block a user