Attempt xcb image put.
This commit is contained in:
parent
c6d03f16d0
commit
5d984aa61d
6 changed files with 78 additions and 6 deletions
|
@ -1,6 +1,47 @@
|
|||
#pragma once
|
||||
|
||||
#include <xcb/xcb_image.h>
|
||||
|
||||
#include "Window.h"
|
||||
#include "XcbWindow.h"
|
||||
|
||||
class XcbImage
|
||||
{
|
||||
public:
|
||||
XcbImage(xcb_connection_t* connection, mt::Window* window, xcb_screen_t* screen)
|
||||
{
|
||||
mPixmap = xcb_generate_id(connection);
|
||||
auto hwnd = dynamic_cast<XcbWindow*>(window->GetPlatformWindow())->getHandle();
|
||||
const auto w = window->GetWidth();
|
||||
const auto h = window->GetHeight();
|
||||
xcb_create_pixmap(connection, screen->root_depth, mPixmap, hwnd, w, h);
|
||||
}
|
||||
|
||||
void update(mt::Window* window, xcb_screen_t* screen, xcb_connection_t* connection, xcb_gcontext_t gc)
|
||||
{
|
||||
if (!mXImage)
|
||||
{
|
||||
auto backing_image = window->getBackingImage();
|
||||
|
||||
const auto w = window->GetWidth();
|
||||
const auto h = window->GetHeight();
|
||||
|
||||
//auto data = const_cast<unsigned char*>(backing_image->getDataPtr());
|
||||
auto data = backing_image->getData();
|
||||
unsigned char* converted = &data[0];
|
||||
mXImage = xcb_image_create_native(connection, w, h, XCB_IMAGE_FORMAT_Z_PIXMAP, screen->root_depth, converted, w*h*4, converted);
|
||||
|
||||
xcb_image_put(connection, mPixmap, gc, mXImage, 0, 0, 0);
|
||||
//xcb_image_destroy(mXImage);
|
||||
}
|
||||
}
|
||||
|
||||
xcb_pixmap_t getPixMap() const
|
||||
{
|
||||
return mPixmap;
|
||||
}
|
||||
|
||||
private:
|
||||
xcb_pixmap_t mPixmap{0};
|
||||
xcb_image_t* mXImage{nullptr};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue