CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
UIWindowDevice.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
11#include "Forward.hpp"
14#include "UIEvent.hpp"
15#include "UIBackingStore.hpp"
16#include "UIUtility.hpp"
17#include "UIWindow.hpp"
25
26namespace CeresEngine {
27
41 class UIWindowDevice : public RefCounted<UIWindowDevice> {
42 friend class UIWindow;
43
44 public:
47
48 public: // Drawing
55
67
77
79 [[nodiscard]] virtual double getBackingScaleFactor(const UIWindow& window) const { return 1.0; }
80
81 public: // Window management
88
90 virtual void unregisterWindow(UIWindow& window);
91
92 protected:
97
104 };
105
115
116 protected:
118
121
122 public:
124
125 public: // Drawing
128
131
133 void flush(UIWindow& window, UIBackingStore& backingStore) override;
134 };
135
145
146 private:
150
164
167
171
172 public:
174 explicit UIWindowSurfaceDevice(Platform& platform, Renderer& renderer);
175
176 public: // Drawing
179
181 void flush(UIWindow& window, UIBackingStore& backingStore) override;
182
184 [[nodiscard]] double getBackingScaleFactor(const UIWindow& window) const override;
185
186 public: // Window management
189
191 void unregisterWindow(UIWindow& window) override;
192
193 private:
194 void onSurfaceEvent(UIWindow& window, const AnyInputEvent&);
197 };
198
199} // namespace CeresEngine
A type that describes any possible event type.
Definition InputEvent.hpp:142
A retain-release type of smart pointer.
Definition SmartPtr.hpp:132
An object that encapsulates rendering context for a view.
Definition GraphicsCommandBuffer.hpp:284
Definition GraphicsRenderer.hpp:21
Definition Platform.hpp:20
A simple reference counter base class.
Definition SmartPtr.hpp:438
The CeresEngine renderer.
Definition Renderer.hpp:35
The BackingStore represents store for a window or view.
Definition UIBackingStore.hpp:29
The UIWindow::Device is the backing device for one or multiple windows.
Definition UIWindowDevice.hpp:41
void notifyFrameChanged(UIWindow &window, const UIRect &newFrame)
Utility method that must be called by device implementations when the window frame changes.
UIWindowDevice() noexcept=default
virtual void flush(UIWindow &window, UIBackingStore &backingStore)
Flushes the contents of the window to the backing device.
virtual UIBackingStorePtr createBackingStore(UIWindow &window)=0
Creates a new backing store for the window or a view that belongs to the window.
virtual void unregisterWindow(UIWindow &window)
Unregisters the window from this device.
void notifyBackingScaleFactorChange(UIWindow &window, double newBackingScalingFactor)
Utility method that must be called by device implementations when the window scaling factor changes.
virtual void draw(UIBackingStore &backingStore, UIDrawCommandBuffer &commandBuffer)
Draws the UI command buffer into the backing store.
virtual UIBackingStorePtr registerWindow(UIWindow &window)
Registers a window with this device.
virtual double getBackingScaleFactor(const UIWindow &window) const
The backing scale factor.
Definition UIWindowDevice.hpp:79
A UIWindowDevice implementation that offers graphics accelerated rendering of the UI,...
Definition UIWindowDevice.hpp:113
void draw(UIBackingStore &backingStore, UIDrawCommandBuffer &drawCommandBuffer) override
Draws the UI command buffer into the backing store.
Renderer & mRenderer
Definition UIWindowDevice.hpp:117
UIWindowFramebufferDevice(Renderer &renderer)
UIRenderer mUIRenderer
The renderer that will render the UI elements on a texture.
Definition UIWindowDevice.hpp:120
void flush(UIWindow &window, UIBackingStore &backingStore) override
Flushes the contents of the window to the backing device.
UIBackingStorePtr createBackingStore(UIWindow &window) override
Creates a new backing store for the window or a view that belongs to the window.
A window that an app displays on the screen.
Definition UIWindow.hpp:42
A UIWindowDevice implementation that offers graphics accelerated rendering of the UI.
Definition UIWindowDevice.hpp:143
UIBackingStorePtr createBackingStore(UIWindow &window) override
Vector< UIWindowPtr > mDirtyWindows
A set of dirty windows.
Definition UIWindowDevice.hpp:170
HashMap< UIWindow *, WindowInformation > mWindows
A map of all registered windows.
Definition UIWindowDevice.hpp:166
void onSurfaceEvent(UIWindow &window, const AnyInputEvent &)
void flush(UIWindow &window, UIBackingStore &backingStore) override
void unregisterWindow(UIWindow &window) override
Unregisters the window from this device.
void onSurfaceResize(UIWindow &window, const Vector2 &newSize)
UIWindowSurfaceDevice(Platform &platform, Renderer &renderer)
Creates a new window surface device.
double getBackingScaleFactor(const UIWindow &window) const override
The backing scale factor.
UIBackingStorePtr registerWindow(UIWindow &window) override
Registers a window with this device.
Platform & mPlatform
The platform object that will be used to create the window surfaces that will back each UIWindow regi...
Definition UIWindowDevice.hpp:149
Definition Application.hpp:19
std::unique_ptr< T, Deleter > UPtr
UPtr is a smart pointer that owns and manages another object through a pointer and disposes of that o...
Definition SmartPtr.hpp:28
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
std::unordered_map< Key, T, Hash, KeyEqual, ScopedAllocatorAdaptor< StdAllocator< Pair< const Key, T >, RawAllocator > > > HashMap
HashMap is an associative container that contains key-value pairs with unique keys.
Definition Map.hpp:33
Rect2 UIRect
A structure that contains the location and dimensions of a rectangle.
Definition UIUtility.hpp:33
std::array< T, N > Array
Array is a container that encapsulates fixed size arrays.
Definition Array.hpp:17
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
A structure that describes information about each window registered with the device.
Definition UIWindowDevice.hpp:153
UPtr< PlatformWindow > platformWindow
The underlying platform window surface.
Definition UIWindowDevice.hpp:155
Array< EventConnection, 2 > eventConnections
An array of event connections for platformWindow.
Definition UIWindowDevice.hpp:162
GPUSwapchainPtr swapchain
A pointer to the GPU swapchain that is used to flush the contents of the window to the surface.
Definition UIWindowDevice.hpp:159