Cleaning for mesh addition.

This commit is contained in:
James Grogan 2022-11-13 17:02:09 +00:00
parent 8e0ce22b57
commit 402f381d10
67 changed files with 655 additions and 456 deletions

View file

@ -71,7 +71,7 @@ void WaylandEglWindowInterface::draw()
MLOG_ERROR("Made current failed");
}
OpenGlInterface::draw();
OpenGlInterface::draw(nullptr);
if (!eglSwapBuffers(mEglInterface->getDisplay(), mEglSurface))
{

View file

@ -24,7 +24,7 @@ XcbGlWindowInterface::~XcbGlWindowInterface()
void XcbGlWindowInterface::draw()
{
OpenGlInterface::draw();
OpenGlInterface::draw(nullptr);
swapBuffers();
}

View file

@ -120,7 +120,7 @@ void XcbInterface::createGraphicsContext()
auto gc = xcb_generate_id(mConnection);
xcb_drawable_t window = xcb_screen->GetNativeScreen()->root;
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES;
uint32_t values[2] = {XcbLayerInterface::GetColor(240, 240, 240), 0};
uint32_t values[2] = {XcbLayerInterface::getColor(240, 240, 240), 0};
xcb_create_gc(mConnection, gc, window, mask, values);
xcb_screen->SetGraphicsContext(gc);
}

View file

@ -1,47 +1,47 @@
#include "XcbLayerInterface.h"
#include "XcbTextInterface.h"
#include "RectangleElement.h"
#include "RectangleNode.h"
#include "VisualLayer.h"
#include <memory>
uint32_t XcbLayerInterface::GetColor(const Color* color)
uint32_t XcbLayerInterface::getColor(const Color* color)
{
return XcbLayerInterface::GetColor(color->GetR(), color->GetG(), color->GetB());
return XcbLayerInterface::getColor(color->GetR(), color->GetG(), color->GetB());
}
uint32_t XcbLayerInterface::GetColor(int r, int g, int b)
uint32_t XcbLayerInterface::getColor(int r, int g, int b)
{
return b + (g<<8) + (r<<16);
}
void XcbLayerInterface::ModifyGcColor(xcb_connection_t* connection, xcb_gcontext_t gc, const Color* color)
void XcbLayerInterface::modifyGcColor(xcb_connection_t* connection, xcb_gcontext_t gc, const Color* color)
{
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES;
uint32_t values[2] = {XcbLayerInterface::GetColor(color), 0};
uint32_t values[2] = {XcbLayerInterface::getColor(color), 0};
xcb_change_gc(connection, gc, mask, values);
}
void XcbLayerInterface::AddLayer(xcb_connection_t* connection, xcb_screen_t* screen, xcb_window_t window, xcb_gcontext_t gc, VisualLayer* layer)
void XcbLayerInterface::addLayer(xcb_connection_t* connection, xcb_screen_t* screen, xcb_window_t window, xcb_gcontext_t gc, VisualLayer* layer)
{
if(layer->HasText())
if(layer->hasText())
{
XcbTextInterface::AddTextElement(connection, screen, window, layer->GetText());
XcbTextInterface::AddTextElement(connection, screen, window, layer->getText());
}
else if(layer->HasShape())
else if(layer->hasShape())
{
auto shape = layer->GetShape();
if(shape->GetType() == GeometryElement::Type::Rectangle)
auto shape = layer->getShape();
if(shape->getType() == GeometryNode::Type::Rectangle)
{
const auto rectangle = dynamic_cast<RectangleElement*>(shape);
const auto loc = rectangle->GetLocation();
const auto width = static_cast<uint16_t>(rectangle->GetWidth());
const auto height = static_cast<uint16_t>(rectangle->GetHeight());
const auto rectangle = dynamic_cast<RectangleNode*>(shape);
const auto loc = rectangle->getLocation();
const auto width = static_cast<uint16_t>(rectangle->getWidth());
const auto height = static_cast<uint16_t>(rectangle->getHeight());
xcb_rectangle_t rectangles[] = { { static_cast<int16_t>(loc.GetX()),
static_cast<int16_t>(loc.GetY()), width, height} };
XcbLayerInterface::ModifyGcColor(connection, gc, rectangle->GetFillColor());
XcbLayerInterface::modifyGcColor(connection, gc, &rectangle->getFillColor());
xcb_poly_fill_rectangle(connection, window, gc, 1, rectangles);
}
}

View file

@ -8,12 +8,12 @@ class VisualLayer;
class XcbLayerInterface
{
public:
static uint32_t GetColor(const Color* color);
static uint32_t getColor(const Color* color);
static uint32_t GetColor(int r, int g, int b);
static uint32_t getColor(int r, int g, int b);
static void ModifyGcColor(xcb_connection_t* connection, xcb_gcontext_t gc, const Color* color);
static void modifyGcColor(xcb_connection_t* connection, xcb_gcontext_t gc, const Color* color);
static void AddLayer(xcb_connection_t* connection, xcb_screen_t* screen, xcb_window_t window, xcb_gcontext_t gc, VisualLayer* layer);
static void addLayer(xcb_connection_t* connection, xcb_screen_t* screen, xcb_window_t window, xcb_gcontext_t gc, VisualLayer* layer);
};

View file

@ -1,14 +1,14 @@
#include "XcbTextInterface.h"
#include "XcbLayerInterface.h"
#include "VisualLayer.h"
#include "Color.h"
#include "RectangleElement.h"
#include <string.h>
xcb_gcontext_t XcbTextInterface::GetFontGC(xcb_connection_t *connection,
xcb_screen_t *screen, xcb_window_t window, const char* font_name,
const TextElement* textElement)
const TextNode* textElement)
{
xcb_font_t font = xcb_generate_id(connection);
xcb_open_font(connection, font, strlen(font_name), font_name);
@ -16,7 +16,7 @@ xcb_gcontext_t XcbTextInterface::GetFontGC(xcb_connection_t *connection,
/* create graphics context */
xcb_gcontext_t gc = xcb_generate_id(connection);
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
auto fillColor = XcbLayerInterface::GetColor(textElement->GetFillColor());
auto fillColor = XcbLayerInterface::getColor(&textElement->getFillColor());
uint32_t value_list[3] = {screen->black_pixel, fillColor, font };
xcb_create_gc(connection, gc, window, mask, value_list);
@ -28,15 +28,15 @@ xcb_gcontext_t XcbTextInterface::GetFontGC(xcb_connection_t *connection,
void XcbTextInterface::AddTextElement(xcb_connection_t* connection,
xcb_screen_t* screen, xcb_window_t window,
const TextElement* textElement)
const TextNode* textElement)
{
/* get graphics context */
auto gc = XcbTextInterface::GetFontGC(connection, screen, window,
textElement->GetFontLabel().c_str(), textElement);
textElement->getFontLabel().c_str(), textElement);
/* draw the text */
const auto content = textElement->GetContent();
Pixel loc = textElement->GetLocation();
const auto content = textElement->getContent();
Pixel loc = textElement->getLocation();
xcb_image_text_8(connection, content.length(), window, gc,
loc.GetX(), loc.GetY(), content.c_str());

View file

@ -1,17 +1,16 @@
#pragma once
#include "TextElement.h"
#include "TextNode.h"
#include <xcb/xcb.h>
class XcbTextInterface
{
public:
static xcb_gcontext_t GetFontGC(xcb_connection_t* connection,
xcb_screen_t*screen, xcb_window_t window, const char*font_name,
const TextElement* textElement);
static xcb_gcontext_t GetFontGC(xcb_connection_t* connection, xcb_screen_t*screen, xcb_window_t window,
const char* font_name, const TextNode* textElement);
static void AddTextElement(xcb_connection_t* connection,
xcb_screen_t* screen, xcb_window_t window,
const TextElement* textElement);
xcb_screen_t* screen, xcb_window_t window, const TextNode* textElement);
};