Cleaning for opengl rendering prep.
This commit is contained in:
parent
402f381d10
commit
7c6a92f4ec
58 changed files with 570 additions and 533 deletions
|
@ -1,7 +1,6 @@
|
|||
#include "WaylandEglWindowInterface.h"
|
||||
|
||||
#include "FileLogger.h"
|
||||
#include "OpenGlInterface.h"
|
||||
|
||||
#include <wayland-egl.h>
|
||||
|
||||
|
@ -59,7 +58,7 @@ void WaylandEglWindowInterface::initialize(wl_surface* surface, int width, int h
|
|||
}
|
||||
}
|
||||
|
||||
void WaylandEglWindowInterface::draw()
|
||||
void WaylandEglWindowInterface::beforePaint()
|
||||
{
|
||||
if (!mEglSurface)
|
||||
{
|
||||
|
@ -70,8 +69,14 @@ void WaylandEglWindowInterface::draw()
|
|||
{
|
||||
MLOG_ERROR("Made current failed");
|
||||
}
|
||||
}
|
||||
|
||||
OpenGlInterface::draw(nullptr);
|
||||
void WaylandEglWindowInterface::afterPaint()
|
||||
{
|
||||
if (!mEglSurface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!eglSwapBuffers(mEglInterface->getDisplay(), mEglSurface))
|
||||
{
|
||||
|
|
|
@ -15,7 +15,8 @@ public:
|
|||
|
||||
void initialize(wl_surface* surface, int width, int height);
|
||||
|
||||
void draw();
|
||||
void beforePaint();
|
||||
void afterPaint();
|
||||
|
||||
private:
|
||||
wl_egl_window* mEglWindow{nullptr};
|
||||
|
|
|
@ -81,13 +81,13 @@ void WaylandInterface::initialize()
|
|||
initializeHardwareRendering();
|
||||
}
|
||||
|
||||
const auto num_windows = mDesktopManager->GetWindowManager()->getNumWindows();
|
||||
const auto num_windows = mDesktopManager->getWindowManager()->getNumWindows();
|
||||
for(std::size_t idx=0; idx< num_windows; idx++)
|
||||
{
|
||||
addWindow(mDesktopManager->GetWindowManager()->getWindow(idx));
|
||||
addWindow(mDesktopManager->getWindowManager()->getWindow(idx));
|
||||
}
|
||||
|
||||
mDesktopManager->GetWindowManager()->GetMainWindow()->show();
|
||||
mDesktopManager->getWindowManager()->getMainWindow()->show();
|
||||
}
|
||||
|
||||
void WaylandInterface::initializeHardwareRendering()
|
||||
|
|
|
@ -2,11 +2,14 @@
|
|||
|
||||
#include "WaylandEglWindowInterface.h"
|
||||
#include "ImagePrimitives.h"
|
||||
#include "DrawingContext.h"
|
||||
|
||||
void WaylandSurface::add(mt::Window* window, wl_compositor* compositor, xdg_wm_base* xdg_wm_base, std::shared_ptr<WaylandBuffer> buffer, WaylandEglInterface* eglInterface)
|
||||
{
|
||||
auto wayland_window = std::make_unique<WaylandSurface>(window, compositor, xdg_wm_base, buffer, eglInterface);
|
||||
window->SetPlatformWindow(std::move(wayland_window));
|
||||
|
||||
const auto drawing_mode = eglInterface ? DrawingMode::GRAPH : DrawingMode::RASTER;
|
||||
window->setPlatformWindow(std::move(wayland_window), drawing_mode);
|
||||
}
|
||||
|
||||
WaylandSurface::WaylandSurface(mt::Window* window, wl_compositor* compositor, xdg_wm_base* xdg_wm_base, std::shared_ptr<WaylandBuffer> buffer, WaylandEglInterface* eglInterface)
|
||||
|
@ -62,7 +65,7 @@ void WaylandSurface::initialize()
|
|||
xdg_toplevel_set_title(mXdgTopLevel, "Example client");
|
||||
|
||||
auto region = wl_compositor_create_region(mCompositor);
|
||||
wl_region_add(region, 0, 0, mWindow->GetWidth(), mWindow->GetHeight());
|
||||
wl_region_add(region, 0, 0, mWindow->getWidth(), mWindow->getHeight());
|
||||
wl_surface_set_opaque_region(mSurface, region);
|
||||
|
||||
wl_surface_commit(mSurface);
|
||||
|
@ -71,56 +74,65 @@ void WaylandSurface::initialize()
|
|||
void WaylandSurface::onConfigure(xdg_surface *xdg_surface, uint32_t serial)
|
||||
{
|
||||
xdg_surface_ack_configure(xdg_surface, serial);
|
||||
paint(nullptr);
|
||||
beforePaint(nullptr);
|
||||
}
|
||||
|
||||
void WaylandSurface::paint(mt::Screen* screen)
|
||||
void WaylandSurface::beforePaint(mt::Screen* screen)
|
||||
{
|
||||
if (mEglWindowInterface)
|
||||
{
|
||||
paintHardware();
|
||||
mEglWindowInterface->initialize(mSurface, mWindow->getWidth(), mWindow->getHeight());
|
||||
mEglWindowInterface->beforePaint();
|
||||
}
|
||||
else
|
||||
{
|
||||
paintSoftware();
|
||||
beforePaintSoftware();
|
||||
}
|
||||
}
|
||||
|
||||
void WaylandSurface::paintHardware()
|
||||
void WaylandSurface::afterPaint(mt::Screen* screen)
|
||||
{
|
||||
mEglWindowInterface->initialize(mSurface, mWindow->GetWidth(), mWindow->GetHeight());
|
||||
mEglWindowInterface->draw();
|
||||
if (mEglWindowInterface)
|
||||
{
|
||||
mEglWindowInterface->afterPaint();
|
||||
}
|
||||
else
|
||||
{
|
||||
afterPaintSoftware();
|
||||
}
|
||||
}
|
||||
|
||||
void WaylandSurface::paintSoftware()
|
||||
unsigned WaylandSurface::getImageBufferSize() const
|
||||
{
|
||||
auto buffer = drawFrame();
|
||||
wl_surface_attach(mSurface, buffer, 0, 0);
|
||||
//wl_surface_damage(mSurface, 0, 0, UINT32_MAX, UINT32_MAX);
|
||||
wl_surface_commit(mSurface);
|
||||
}
|
||||
const auto width = mWindow->getWidth();
|
||||
const auto height = mWindow->getHeight();
|
||||
const int stride = width * mWorkingBitDepth;
|
||||
|
||||
wl_buffer* WaylandSurface::drawFrame()
|
||||
{
|
||||
const auto width = mWindow->GetWidth();
|
||||
const auto height = mWindow->GetHeight();
|
||||
|
||||
const int bitDepth = 4;
|
||||
|
||||
const int stride = width * bitDepth;
|
||||
//const int numBuffers = 2; // i.e. front/back
|
||||
const int numBuffers = 1;
|
||||
const int shm_pool_size = height * stride * numBuffers;
|
||||
return height * stride * mNumFrameBuffers;
|
||||
}
|
||||
|
||||
void WaylandSurface::beforePaintSoftware()
|
||||
{
|
||||
const auto width = mWindow->getWidth();
|
||||
const auto height = mWindow->getHeight();
|
||||
const int stride = width * mWorkingBitDepth;
|
||||
|
||||
const int shm_pool_size = getImageBufferSize();
|
||||
|
||||
mBuffer->initializeSharedBuffer(shm_pool_size);
|
||||
mBuffer->setUpPool(shm_pool_size, width, height, stride);
|
||||
|
||||
int offset = 0;
|
||||
|
||||
ImagePrimitives::drawCheckerboard(mBuffer->getPoolData(), width, height, offset);
|
||||
|
||||
mBuffer->tearDownPool(shm_pool_size);
|
||||
|
||||
return mBuffer->getWorkingBuffer();
|
||||
//ImagePrimitives::drawCheckerboard(mBuffer->getPoolData(), width, height, offset);
|
||||
}
|
||||
|
||||
void WaylandSurface::afterPaintSoftware()
|
||||
{
|
||||
const int shm_pool_size = getImageBufferSize();
|
||||
mBuffer->tearDownPool(shm_pool_size);
|
||||
|
||||
wl_surface_attach(mSurface, mBuffer->getWorkingBuffer(), 0, 0);
|
||||
//wl_surface_damage(mSurface, 0, 0, UINT32_MAX, UINT32_MAX);
|
||||
wl_surface_commit(mSurface);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,13 +37,13 @@ public:
|
|||
private:
|
||||
void initialize();
|
||||
|
||||
void paint(mt::Screen* screen) override;
|
||||
void beforePaint(mt::Screen* screen) override;
|
||||
void afterPaint(mt::Screen* screen) override;
|
||||
|
||||
void paintHardware();
|
||||
void paintSoftware();
|
||||
void beforePaintSoftware();
|
||||
void afterPaintSoftware();
|
||||
|
||||
|
||||
wl_buffer* drawFrame();
|
||||
unsigned getImageBufferSize() const;
|
||||
|
||||
mt::Window* mWindow{nullptr};
|
||||
|
||||
|
@ -57,6 +57,8 @@ private:
|
|||
xdg_surface_listener mXdgSurfaceListener;
|
||||
|
||||
xdg_toplevel* mXdgTopLevel{nullptr};
|
||||
unsigned mWorkingBitDepth{4};
|
||||
unsigned mNumFrameBuffers{1};
|
||||
};
|
||||
|
||||
using WaylandSurfacePtr = std::unique_ptr<WaylandSurface>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue