Clean image types
This commit is contained in:
parent
e7683cd94e
commit
c6d03f16d0
18 changed files with 169 additions and 107 deletions
|
@ -5,11 +5,25 @@
|
|||
namespace mt
|
||||
{
|
||||
class Screen;
|
||||
class Window;
|
||||
}
|
||||
|
||||
class IPlatformWindow
|
||||
class IPlatformSurface
|
||||
{
|
||||
public:
|
||||
virtual ~IPlatformSurface() = default;
|
||||
virtual void paint(mt::Screen* screen) = 0;
|
||||
};
|
||||
|
||||
class IPlatformWindow : public IPlatformSurface
|
||||
{
|
||||
public:
|
||||
IPlatformWindow(mt::Window* window)
|
||||
: mWindow(window)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual ~IPlatformWindow() = default;
|
||||
|
||||
virtual void show() const = 0;
|
||||
|
@ -17,8 +31,8 @@ public:
|
|||
virtual void map() const = 0;
|
||||
|
||||
virtual void clear() const = 0;
|
||||
|
||||
virtual void paint(mt::Screen* screen) const = 0;
|
||||
protected:
|
||||
mt::Window* mWindow{nullptr};
|
||||
};
|
||||
|
||||
using IPlatformWindowPtr = std::unique_ptr<IPlatformWindow>;
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace mt
|
|||
Window::Window()
|
||||
:mWidth(800),
|
||||
mHeight(600),
|
||||
mBackingImage(std::make_unique<Image>(mWidth, mHeight)),
|
||||
mBackingImage(std::make_unique<Image<uint8_t> >(mWidth, mHeight)),
|
||||
mWidget(Widget::Create())
|
||||
{
|
||||
mWidget->setBounds(mWidth, mHeight);
|
||||
|
@ -96,7 +96,7 @@ void Window::SetPlatformWindow(IPlatformWindowPtr window)
|
|||
mPlatformWindow = std::move(window);
|
||||
}
|
||||
|
||||
Image* Window::getBackingImage() const
|
||||
Image<uint8_t>* Window::getBackingImage() const
|
||||
{
|
||||
return mBackingImage.get();
|
||||
}
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include "Widget.h"
|
||||
#include "Image.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
class PaintEvent;
|
||||
class MouseEvent;
|
||||
class KeyboardEvent;
|
||||
class VisualLayer;
|
||||
class Image;
|
||||
class IPlatformWindow;
|
||||
using IPlatformWindowPtr = std::unique_ptr<IPlatformWindow>;
|
||||
|
||||
|
@ -51,7 +52,7 @@ public:
|
|||
|
||||
void SetPlatformWindow(IPlatformWindowPtr window);
|
||||
|
||||
Image* getBackingImage() const;
|
||||
Image<uint8_t>* getBackingImage() const;
|
||||
|
||||
void map();
|
||||
|
||||
|
@ -67,7 +68,7 @@ private:
|
|||
unsigned mWidth {800};
|
||||
unsigned mHeight {600};
|
||||
IPlatformWindowPtr mPlatformWindow {nullptr};
|
||||
std::unique_ptr<Image> mBackingImage;
|
||||
std::unique_ptr<Image<uint8_t> > mBackingImage;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue