Use PutImage to convert QPixmap to XRenderPicture
In case of native graphics system nothing is changed for the moment - the X11Pixmap-QPixmap bridge is continued to be used. But in case of graphics system raster (or Qt5) this relationship is no longer used. Instead the QPixmap is converted to a QImage and the image bits are put into the created X11Pixmap for this XRenderPicture. Note: Qt5 uses shm to transfer image data to drawables. This seems unsuited in this case as it's only a one time transformation. For Qt5 the native pixmap block needs to be removed and the ctor might be changed to taking an QImage as argument to make more clear that there is no mapping from QPixmap to X11Pixmap.
This commit is contained in:
parent
f20ec15053
commit
7faede41c7
2 changed files with 16 additions and 11 deletions
|
@ -23,7 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#include <QStack>
|
||||
#include <QPixmap>
|
||||
#include <QPainter>
|
||||
#include <kdebug.h>
|
||||
|
||||
namespace KWin
|
||||
|
@ -113,18 +112,23 @@ static Picture createPicture(Pixmap pix, int depth)
|
|||
|
||||
XRenderPicture::XRenderPicture(QPixmap pix)
|
||||
{
|
||||
if (Extensions::nonNativePixmaps()) {
|
||||
Pixmap xPix = XCreatePixmap(display(), rootWindow(), pix.width(), pix.height(), pix.depth());
|
||||
QPixmap tempPix = QPixmap::fromX11Pixmap(xPix, QPixmap::ExplicitlyShared);
|
||||
tempPix.fill(Qt::transparent);
|
||||
QPainter p(&tempPix);
|
||||
p.drawPixmap(QPoint(0, 0), pix);
|
||||
p.end();
|
||||
d = new XRenderPictureData(createPicture(tempPix.handle(), tempPix.depth()));
|
||||
XFreePixmap(display(), xPix);
|
||||
} else {
|
||||
if (!Extensions::nonNativePixmaps()) {
|
||||
d = new XRenderPictureData(createPicture(pix.handle(), pix.depth()));
|
||||
return;
|
||||
}
|
||||
QImage img(pix.toImage());
|
||||
const int depth = img.depth();
|
||||
xcb_pixmap_t xpix = xcb_generate_id(connection());
|
||||
xcb_create_pixmap(connection(), depth, xpix, rootWindow(), img.width(), img.height());
|
||||
|
||||
xcb_gcontext_t cid = xcb_generate_id(connection());
|
||||
xcb_create_gc(connection(), cid, xpix, 0, NULL);
|
||||
xcb_put_image(connection(), XCB_IMAGE_FORMAT_Z_PIXMAP, xpix, cid, img.width(), img.height(),
|
||||
0, 0, 0, depth, img.byteCount(), img.constBits());
|
||||
xcb_free_gc(connection(), cid);
|
||||
|
||||
d = new XRenderPictureData(createPicture(xpix, depth));
|
||||
xcb_free_pixmap(connection(), xpix);
|
||||
}
|
||||
|
||||
XRenderPicture::XRenderPicture(Pixmap pix, int depth)
|
||||
|
|
|
@ -68,6 +68,7 @@ class KWIN_EXPORT XRenderPicture
|
|||
{
|
||||
public:
|
||||
explicit XRenderPicture(Picture pic = None);
|
||||
// TODO: Qt5 - replace QPixmap by QImage to make it more obvious that it uses PutImage
|
||||
explicit XRenderPicture(QPixmap pix);
|
||||
XRenderPicture(Pixmap pix, int depth);
|
||||
operator Picture();
|
||||
|
|
Loading…
Reference in a new issue