CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
UIBackingStore.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
10#include "Forward.hpp"
13
14#include "UIWindow.hpp"
18
19namespace CeresEngine {
20
29 class UIBackingStore : public RefCounted<UIBackingStore> {
30 friend class UIWindow;
31
32 public:
33 explicit UIBackingStore() = default;
35
36 public:
38 [[nodiscard]] virtual Extent2UI getSize() const = 0;
39
41 virtual void setSize(const Extent2UI& size) = 0;
42
45
48
51
53 virtual void setSampleCount(const Optional<UInt32>& sampleCount) = 0;
54
55 public: // Implementation
57 };
58
68
69 private:
72
74 Extent2UI mSize;
75
77 bool mAntiAliasing = true;
78
81
82 mutable bool mDirty = true;
83
84 private:
87
91
97
100
104
105 public:
107 explicit UIFramebufferBackingStore(GPUDevice& device, Format format);
109
110 public:
112 [[nodiscard]] Format getFormat() const { return mFormat; }
113
115 void setFormat(Format format);
116
118 [[nodiscard]] Extent2UI getSize() const override { return mSize; }
119
121 void setSize(const Extent2UI& size) override;
122
124 [[nodiscard]] bool isAntiAliasing() const noexcept override { return mAntiAliasing; }
125
127 void setAntiAliasing(bool antiAliasing) override;
128
130 [[nodiscard]] Optional<UInt32> getSampleCount() const noexcept override { return mSampleCount; }
131
133 void setSampleCount(const Optional<UInt32>& sampleCount) override;
134
135 public:
137 [[nodiscard]] GPUImage& getColorImage() const { return *mColorImage; }
138
140 [[nodiscard]] GPUImage& getDepthStencilImage() const { return *mDepthStencilImage; }
141
143 [[nodiscard]] GPURenderPass& getRenderPass() const { return *mRenderPass; }
144
146 [[nodiscard]] GPURenderTarget& getRenderTarget() const { return *mRenderTarget; }
147
149 void rebuild();
150
153
156 };
157
158} // namespace CeresEngine
A retain-release type of smart pointer.
Definition SmartPtr.hpp:132
Definition GPUCommandBuffer.hpp:77
Definition GPUDevice.hpp:357
Definition GPUImage.hpp:331
Definition GPURenderPass.hpp:149
Definition GPURenderTarget.hpp:105
Definition Optional.hpp:17
A simple reference counter base class.
Definition SmartPtr.hpp:438
The BackingStore represents store for a window or view.
Definition UIBackingStore.hpp:29
virtual bool isAntiAliasing() const noexcept=0
virtual ~UIBackingStore() noexcept=default
virtual void setSampleCount(const Optional< UInt32 > &sampleCount)=0
virtual void setSize(const Extent2UI &size)=0
virtual void setAntiAliasing(bool antiAliasing)=0
virtual Optional< UInt32 > getSampleCount() const noexcept=0
virtual Extent2UI getSize() const =0
Represents a UIBackingStore that renders its contents to an image texture.
Definition UIBackingStore.hpp:66
UIFramebufferBackingStore(GPUDevice &device, Format format)
void setFormat(Format format)
The format of the backing store.
GPUDevicePtr mDevice
The GPU device that backs the framebuffer.
Definition UIBackingStore.hpp:86
Extent2UI mSize
The size of the backing store framebuffer.
Definition UIBackingStore.hpp:74
Optional< UInt32 > mSampleCount
If set, forces the use of the given sample count for UI rendering.
Definition UIBackingStore.hpp:80
bool isAntiAliasing() const noexcept override
If set to true, enables anti-aliased rendering of the window.
Definition UIBackingStore.hpp:124
GPUImage & getColorImage() const
The color render target image.
Definition UIBackingStore.hpp:137
Extent2UI getSize() const override
The size of the backing store framebuffer.
Definition UIBackingStore.hpp:118
void rebuild()
Invalidates the window render buffer.
GPUImagePtr mColorImage
The color render target image.
Definition UIBackingStore.hpp:90
void setSampleCount(const Optional< UInt32 > &sampleCount) override
If set, forces the use of the given sample count for UI rendering.
void setAntiAliasing(bool antiAliasing) override
If set to true, enables anti-aliased rendering of the window.
void copyTo(GPUCommandBuffer &commandBuffer, GPUImage &destinationImage)
Copies the color image contents into the given destination image.
void rebuildIfNeeded()
Invalidates the window render buffer.
GPUImagePtr mDepthStencilImage
The depth/stencil render target image.
Definition UIBackingStore.hpp:96
GPUImage & getDepthStencilImage() const
The depth/stencil render target image.
Definition UIBackingStore.hpp:140
GPURenderPassPtr mRenderPass
The GPU render pass for rendering the UI.
Definition UIBackingStore.hpp:99
Optional< UInt32 > getSampleCount() const noexcept override
If set, forces the use of the given sample count for UI rendering.
Definition UIBackingStore.hpp:130
GPURenderTarget & getRenderTarget() const
The GPU render target.
Definition UIBackingStore.hpp:146
UIFramebufferBackingStore(GPUDevice &device)
void setSize(const Extent2UI &size) override
The size of the backing store framebuffer.
GPURenderTargetPtr mRenderTarget
The GPU render target.
Definition UIBackingStore.hpp:103
GPURenderPass & getRenderPass() const
The GPU render pass for rendering the UI.
Definition UIBackingStore.hpp:143
~UIFramebufferBackingStore() noexcept override
A window that an app displays on the screen.
Definition UIWindow.hpp:42
Definition Application.hpp:19
Format
Definition TextureFormat.hpp:54
@ RGBA8UNorm
Color format: red, green, blue, alpha 8-bit normalized.
std::uint32_t UInt32
Definition DataTypes.hpp:23
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25