Basic Font integration.
This commit is contained in:
parent
ce11c52ae5
commit
72123bc333
36 changed files with 325 additions and 198 deletions
|
@ -1,19 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "IFontEngine.h"
|
||||
#include "FontsManager.h"
|
||||
|
||||
namespace mt
|
||||
{
|
||||
class Window;
|
||||
}
|
||||
|
||||
class DesktopManager;
|
||||
class FontsManager;
|
||||
|
||||
class AbstractUIInterface
|
||||
{
|
||||
public:
|
||||
|
||||
AbstractUIInterface(DesktopManager* desktopManager, bool useHardware = false)
|
||||
AbstractUIInterface(DesktopManager* desktopManager, std::unique_ptr<FontsManager> fontsManager, bool useHardware = false)
|
||||
: mDesktopManager(desktopManager),
|
||||
mUseHardwareRendering(useHardware)
|
||||
mUseHardwareRendering(useHardware),
|
||||
mFontsManager(std::move(fontsManager))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -32,5 +38,7 @@ protected:
|
|||
virtual void initializeHardwareRendering() {};
|
||||
|
||||
DesktopManager* mDesktopManager{nullptr};
|
||||
std::unique_ptr<FontsManager> mFontsManager;
|
||||
|
||||
bool mUseHardwareRendering{false};
|
||||
};
|
||||
|
|
|
@ -7,18 +7,22 @@
|
|||
#include "Win32UiInterface.h"
|
||||
#endif
|
||||
|
||||
#include "FontsManager.h"
|
||||
|
||||
std::unique_ptr<AbstractUIInterface> UiInterfaceFactory::create(DesktopManager* desktopManager, Backend backend)
|
||||
{
|
||||
auto fonts_manager = std::make_unique<FontsManager>();
|
||||
|
||||
#ifdef __linux__
|
||||
if (backend == Backend::UNSET || backend == Backend::X11 || backend == Backend::X11_RASTER)
|
||||
{
|
||||
const bool use_hardware = (backend != Backend::X11_RASTER);
|
||||
return std::make_unique<XcbInterface>(desktopManager, use_hardware);
|
||||
return std::make_unique<XcbInterface>(desktopManager, std::move(fonts_manager), use_hardware);
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool use_hardware = (backend != Backend::WAYLAND_RASTER);
|
||||
return std::make_unique<WaylandInterface>(desktopManager, use_hardware);
|
||||
return std::make_unique<WaylandInterface>(desktopManager, std::move(fonts_manager), use_hardware);
|
||||
}
|
||||
#else
|
||||
return std::make_unique<Win32UiInterface>();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "FileLogger.h"
|
||||
#include "DesktopManager.h"
|
||||
#include "WindowManager.h"
|
||||
#include "FontsManager.h"
|
||||
|
||||
#include "WaylandSurface.h"
|
||||
#include "WaylandBuffer.h"
|
||||
|
@ -43,8 +44,8 @@ void WaylandInterface::registryHandleGlobalRemoveEvent(void *data, struct wl_reg
|
|||
|
||||
}
|
||||
|
||||
WaylandInterface::WaylandInterface(DesktopManager* desktopManager, bool useHardware)
|
||||
: AbstractUIInterface(desktopManager, useHardware),
|
||||
WaylandInterface::WaylandInterface(DesktopManager* desktopManager, std::unique_ptr<FontsManager> fontsManager, bool useHardware)
|
||||
: AbstractUIInterface(desktopManager, std::move(fontsManager), useHardware),
|
||||
mBuffer(std::make_shared<WaylandBuffer>())
|
||||
{
|
||||
mRegistryListener.global = registryHandleGlobalEvent;
|
||||
|
@ -129,7 +130,7 @@ void WaylandInterface::doXdgPong(uint32_t serial)
|
|||
|
||||
void WaylandInterface::addWindow(mt::Window* window)
|
||||
{
|
||||
WaylandSurface::add(window, mCompositor, mXdgBase, mBuffer, mEglInterface.get());
|
||||
WaylandSurface::add(window, mCompositor, mXdgBase, mBuffer, mFontsManager.get(), mEglInterface.get());
|
||||
}
|
||||
|
||||
void WaylandInterface::showWindow(mt::Window* window)
|
||||
|
|
|
@ -18,7 +18,7 @@ class WaylandInterface : public AbstractUIInterface
|
|||
{
|
||||
|
||||
public:
|
||||
WaylandInterface(DesktopManager* desktopManager, bool useHardware = true);
|
||||
WaylandInterface(DesktopManager* desktopManager, std::unique_ptr<FontsManager> fontsManager, bool useHardware = true);
|
||||
|
||||
~WaylandInterface();
|
||||
|
||||
|
|
|
@ -2,14 +2,16 @@
|
|||
|
||||
#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)
|
||||
#include "DrawingContext.h"
|
||||
#include "FontsManager.h"
|
||||
|
||||
void WaylandSurface::add(mt::Window* window, wl_compositor* compositor, xdg_wm_base* xdg_wm_base, std::shared_ptr<WaylandBuffer> buffer, FontsManager* fontsManager, WaylandEglInterface* eglInterface)
|
||||
{
|
||||
auto wayland_window = std::make_unique<WaylandSurface>(window, compositor, xdg_wm_base, buffer, eglInterface);
|
||||
|
||||
const auto drawing_mode = eglInterface ? DrawingMode::GRAPH : DrawingMode::RASTER;
|
||||
window->setPlatformWindow(std::move(wayland_window), drawing_mode);
|
||||
window->setPlatformWindow(std::move(wayland_window), fontsManager, drawing_mode);
|
||||
}
|
||||
|
||||
WaylandSurface::WaylandSurface(mt::Window* window, wl_compositor* compositor, xdg_wm_base* xdg_wm_base, std::shared_ptr<WaylandBuffer> buffer, WaylandEglInterface* eglInterface)
|
||||
|
|
|
@ -16,11 +16,13 @@ struct xdg_toplevel;
|
|||
class WaylandEglInterface;
|
||||
class WaylandEglWindowInterface;
|
||||
|
||||
class FontsManager;
|
||||
|
||||
class WaylandSurface : public IPlatformWindow
|
||||
{
|
||||
public:
|
||||
|
||||
static void add(mt::Window* window, wl_compositor* compositor, xdg_wm_base* xdg_wm_base, std::shared_ptr<WaylandBuffer> buffer, WaylandEglInterface* eglInterface);
|
||||
static void add(mt::Window* window, wl_compositor* compositor, xdg_wm_base* xdg_wm_base, std::shared_ptr<WaylandBuffer> buffer, FontsManager* fontsManager, WaylandEglInterface* eglInterface);
|
||||
|
||||
WaylandSurface(mt::Window* window, wl_compositor* compositor, xdg_wm_base* xdg_wm_base, std::shared_ptr<WaylandBuffer> buffer, WaylandEglInterface* eglInterface);
|
||||
|
||||
|
|
|
@ -18,12 +18,13 @@
|
|||
#include "XcbEventInterface.h"
|
||||
#include "XcbGlInterface.h"
|
||||
#include "FileLogger.h"
|
||||
#include "FontsManager.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
XcbInterface::XcbInterface(DesktopManager* desktopManager, bool useHardware)
|
||||
: AbstractUIInterface(desktopManager, useHardware),
|
||||
XcbInterface::XcbInterface(DesktopManager* desktopManager, std::unique_ptr<FontsManager> fontsManager, bool useHardware)
|
||||
: AbstractUIInterface(desktopManager, std::move(fontsManager), useHardware),
|
||||
mEventInterface(XcbEventInterface::Create())
|
||||
{
|
||||
|
||||
|
@ -151,7 +152,7 @@ uint32_t XcbInterface::getEventMask()
|
|||
void XcbInterface::addWindow(mt::Window* window)
|
||||
{
|
||||
auto screen = mDesktopManager->getDefaultScreen();
|
||||
XcbWindow::add(window, mConnection, screen, getEventMask(), mGlInterface.get());
|
||||
XcbWindow::add(window, mConnection, screen, getEventMask(), mFontsManager.get(), mGlInterface.get());
|
||||
}
|
||||
|
||||
void XcbInterface::onPaint()
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace mt
|
|||
class XcbInterface : public AbstractUIInterface
|
||||
{
|
||||
public:
|
||||
XcbInterface(DesktopManager* desktopManager, bool useHardware = true);
|
||||
XcbInterface(DesktopManager* desktopManager, std::unique_ptr<FontsManager> fontsManager, bool useHardware = true);
|
||||
|
||||
~XcbInterface();
|
||||
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
#include "Screen.h"
|
||||
#include "ImagePrimitives.h"
|
||||
#include "XcbGlWindowInterface.h"
|
||||
|
||||
#include "DrawingContext.h"
|
||||
#include "FontsManager.h"
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
|
@ -27,7 +29,7 @@ XcbWindow::~XcbWindow()
|
|||
xcb_destroy_window(mConnection, mHandle);
|
||||
}
|
||||
|
||||
void XcbWindow::add(mt::Window* window, xcb_connection_t* connection, mt::Screen* screen, uint32_t eventMask, XcbGlInterface* xcbGlInterface)
|
||||
void XcbWindow::add(mt::Window* window, xcb_connection_t* connection, mt::Screen* screen, uint32_t eventMask, FontsManager* fontsManager, XcbGlInterface* xcbGlInterface)
|
||||
{
|
||||
if (!screen)
|
||||
{
|
||||
|
@ -52,7 +54,7 @@ void XcbWindow::add(mt::Window* window, xcb_connection_t* connection, mt::Screen
|
|||
auto xcb_window = std::make_unique<XcbWindow>(window, hwnd, connection, xcbGlInterface);
|
||||
|
||||
const auto drawing_mode = xcbGlInterface ? DrawingMode::GRAPH : DrawingMode::RASTER;
|
||||
window->setPlatformWindow(std::move(xcb_window), drawing_mode);
|
||||
window->setPlatformWindow(std::move(xcb_window), fontsManager, drawing_mode);
|
||||
}
|
||||
|
||||
int XcbWindow::getHandle() const
|
||||
|
|
|
@ -6,6 +6,9 @@ class XcbImage;
|
|||
class XcbScreen;
|
||||
class XcbGlWindowInterface;
|
||||
class XcbGlInterface;
|
||||
|
||||
class FontsManager;
|
||||
|
||||
struct xcb_connection_t;
|
||||
|
||||
namespace mt
|
||||
|
@ -19,7 +22,7 @@ public:
|
|||
XcbWindow(mt::Window* window, int hwnd, xcb_connection_t* connection, XcbGlInterface* xcbGlInterface);
|
||||
virtual ~XcbWindow();
|
||||
|
||||
static void add(mt::Window* window, xcb_connection_t* connection, mt::Screen* screen, uint32_t eventMask, XcbGlInterface* xcbGlInterface);
|
||||
static void add(mt::Window* window, xcb_connection_t* connection, mt::Screen* screen, uint32_t eventMask, FontsManager* fontsManager, XcbGlInterface* xcbGlInterface);
|
||||
|
||||
int getHandle() const;
|
||||
unsigned getGraphicsContext() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue