xcb: Reduce number of created colormaps
Create a colormap per visual, not per window. Pick-to: 5.15 Change-Id: I97d94618f159b4beaffd4a1afe0611233ced6676 Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
bf075da800
commit
7aacc8144e
@ -131,6 +131,9 @@ QXcbVirtualDesktop::QXcbVirtualDesktop(QXcbConnection *connection, xcb_screen_t
|
||||
QXcbVirtualDesktop::~QXcbVirtualDesktop()
|
||||
{
|
||||
delete m_xSettings;
|
||||
|
||||
for (auto cmap : qAsConst(m_visualColormaps))
|
||||
xcb_free_colormap(xcb_connection(), cmap);
|
||||
}
|
||||
|
||||
QDpi QXcbVirtualDesktop::dpi() const
|
||||
@ -493,6 +496,22 @@ quint8 QXcbVirtualDesktop::depthOfVisual(xcb_visualid_t visualid) const
|
||||
return *it;
|
||||
}
|
||||
|
||||
xcb_colormap_t QXcbVirtualDesktop::colormapForVisual(xcb_visualid_t visualid) const
|
||||
{
|
||||
auto it = m_visualColormaps.constFind(visualid);
|
||||
if (it != m_visualColormaps.constEnd())
|
||||
return *it;
|
||||
|
||||
auto cmap = xcb_generate_id(xcb_connection());
|
||||
xcb_create_colormap(xcb_connection(),
|
||||
XCB_COLORMAP_ALLOC_NONE,
|
||||
cmap,
|
||||
screen()->root,
|
||||
visualid);
|
||||
m_visualColormaps.insert(visualid, cmap);
|
||||
return cmap;
|
||||
}
|
||||
|
||||
QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDesktop,
|
||||
xcb_randr_output_t outputId, xcb_randr_get_output_info_reply_t *output)
|
||||
: QXcbObject(connection)
|
||||
|
@ -107,6 +107,7 @@ public:
|
||||
const xcb_visualtype_t *visualForFormat(const QSurfaceFormat &format) const;
|
||||
const xcb_visualtype_t *visualForId(xcb_visualid_t) const;
|
||||
quint8 depthOfVisual(xcb_visualid_t) const;
|
||||
xcb_colormap_t colormapForVisual(xcb_visualid_t) const;
|
||||
|
||||
private:
|
||||
QRect getWorkArea() const;
|
||||
@ -133,6 +134,7 @@ private:
|
||||
QString m_windowManagerName;
|
||||
QMap<xcb_visualid_t, xcb_visualtype_t> m_visuals;
|
||||
QMap<xcb_visualid_t, quint8> m_visualDepths;
|
||||
mutable QMap<xcb_visualid_t, xcb_colormap_t> m_visualColormaps;
|
||||
uint16_t m_rotation = 0;
|
||||
};
|
||||
|
||||
@ -190,6 +192,7 @@ public:
|
||||
|
||||
const xcb_visualtype_t *visualForFormat(const QSurfaceFormat &format) const { return m_virtualDesktop->visualForFormat(format); }
|
||||
const xcb_visualtype_t *visualForId(xcb_visualid_t visualid) const;
|
||||
xcb_colormap_t colormapForVisual(xcb_visualid_t visualid) const { return m_virtualDesktop->colormapForVisual(visualid); }
|
||||
quint8 depthOfVisual(xcb_visualid_t visualid) const { return m_virtualDesktop->depthOfVisual(visualid); }
|
||||
|
||||
QString name() const override { return m_outputName; }
|
||||
|
@ -363,14 +363,9 @@ void QXcbWindow::create()
|
||||
return result;
|
||||
};
|
||||
|
||||
xcb_colormap_t cmap = XCB_COLORMAP_NONE;
|
||||
if ((window()->supportsOpenGL() && haveOpenGL()) || m_format.hasAlpha()) {
|
||||
m_cmap = xcb_generate_id(xcb_connection());
|
||||
xcb_create_colormap(xcb_connection(),
|
||||
XCB_COLORMAP_ALLOC_NONE,
|
||||
m_cmap,
|
||||
xcb_parent_id,
|
||||
m_visualId);
|
||||
|
||||
cmap = platformScreen->colormapForVisual(m_visualId);
|
||||
mask |= XCB_CW_COLORMAP;
|
||||
}
|
||||
|
||||
@ -381,7 +376,7 @@ void QXcbWindow::create()
|
||||
type == Qt::Popup || type == Qt::ToolTip || (window()->flags() & Qt::BypassWindowManagerHint),
|
||||
type == Qt::Popup || type == Qt::Tool || type == Qt::SplashScreen || type == Qt::ToolTip || type == Qt::Drawer,
|
||||
defaultEventMask,
|
||||
m_cmap
|
||||
cmap
|
||||
};
|
||||
|
||||
m_window = xcb_generate_id(xcb_connection());
|
||||
@ -552,9 +547,7 @@ void QXcbWindow::destroy()
|
||||
xcb_destroy_window(xcb_connection(), m_window);
|
||||
m_window = 0;
|
||||
}
|
||||
if (m_cmap) {
|
||||
xcb_free_colormap(xcb_connection(), m_cmap);
|
||||
}
|
||||
|
||||
m_mapped = false;
|
||||
|
||||
if (m_pendingSyncRequest)
|
||||
|
@ -233,7 +233,6 @@ protected:
|
||||
quint8 mode, quint8 detail, xcb_timestamp_t timestamp);
|
||||
|
||||
xcb_window_t m_window = 0;
|
||||
xcb_colormap_t m_cmap = 0;
|
||||
|
||||
uint m_depth = 0;
|
||||
QImage::Format m_imageFormat = QImage::Format_ARGB32_Premultiplied;
|
||||
|
Loading…
x
Reference in New Issue
Block a user