15#include <AUI/Reflect/AEnumerate.h>
16#include <AUI/Common/ASide.h>
17#include <AUI/Common/AColor.h>
18#include <AUI/Render/ABrush.h>
19#include <AUI/Util/APool.h>
20#include <AUI/Util/AArrayView.h>
21#include "AUI/Font/AFontStyle.h"
22#include "AUI/Render/ABorderStyle.h"
23#include "AUI/ASS/Property/Backdrop.h"
24#include "AUI/Util/AMetric.h"
26#include "ATextLayoutHelper.h"
27#include "IRenderViewToTexture.h"
153 virtual void draw() = 0;
155 virtual int getWidth() = 0;
156 virtual int getHeight() = 0;
172 if (mSymbols) mSymbols->last().push_back(symbol);
182 mSymbols = ATextLayoutHelper::Symbols{};
190 if (mSymbols) mSymbols->push_back({});
217 AUI_ASSERTX(
bool(mSymbols),
"call enableCachingForTextLayoutHelper() before using getTextLayoutHelper");
223 IRenderer(): mTexturePool([this] {
return createNewTexture(); }) {}
224 virtual ~IRenderer() =
default;
230 return mTexturePool.get();
272 float lineWidth = 1.f) = 0;
285 int borderWidth) = 0;
317 glm::vec2 offset) = 0;
352 glm::vec2
points[] = { p1, p2 };
413 const glm::vec2& position,
414 const glm::vec2& size,
437 const AColor& getColor()
const
449 mTransform *= transform;
458 mTransform = transform;
524 virtual glm::mat4 getProjectionMatrix()
const = 0;
526 const glm::mat4& getTransform()
532 std::uint8_t getStencilDepth() const noexcept {
533 return mStencilDepth;
536 void setStencilDepth(uint8_t stencilDepth) {
537 mStencilDepth = stencilDepth;
563 rotate({0.f, 0.f, 1.f}, angle);
566 void setAllowRenderToTexture(
bool allowRenderToTexture) {
567 mAllowRenderToTexture = allowRenderToTexture;
571 bool allowRenderToTexture() const noexcept {
572 return mAllowRenderToTexture;
583 void backdrops(glm::ivec2 position, glm::ivec2 size, std::span<ass::Backdrop::Any>
backdrops);
587 glm::mat4 mTransform;
588 AWindowBase* mWindow =
nullptr;
589 APool<ITexture> mTexturePool;
590 uint8_t mStencilDepth = 0;
592 virtual _unique<ITexture> createNewTexture() = 0;
599 void stub(glm::vec2 position, glm::vec2 size);
601 virtual void backdrops(glm::ivec2 position, glm::ivec2 size, std::span<ass::Backdrop::Preprocessed>
backdrops);
604 bool mAllowRenderToTexture =
false;
Strong type used to store angle in radians.
Definition AAngleRadians.h:42
Definition AArrayView.h:25
Describes border style, like CSS border-style.
Definition ABorderStyle.h:28
Represents a 4-component floating point color (RGBA).
Definition AColor.h:26
Stores dimensions in scalable units (dp, pt, etc...).
Definition AMetric.h:75
Utility wrapper implementing the stack-allocated (fast) optional idiom.
Definition AOptional.h:32
Represents a Unicode character string.
Definition AString.h:37
Helps mapping prerendered string with positions.
Definition ATextLayoutHelper.h:25
Definition AWindowBase.h:33
Definition IRenderer.h:158
void nextLine() noexcept
When caching for text layout helper is enabled, a new line added.
Definition IRenderer.h:189
virtual void addString(const glm::ivec2 &position, const AString &text) noexcept=0
Bakes a string with some position.
void enableCachingForTextLayoutHelper() noexcept
Notifies IMultiStringCanvas that getTextLayoutHelper() will be used.
Definition IRenderer.h:181
void notifySymbolAdded(const ATextLayoutHelper::Boundary &symbol) noexcept
Notifies IMultiStringCanvas than a symbol was added used to construct a ATextLayoutHelper.
Definition IRenderer.h:171
virtual _< IRenderer::IPrerenderedString > finalize() noexcept=0
Bakes multi string canvas to IPrerenderedString which can be used for drawing text.
ATextLayoutHelper getTextLayoutHelper() noexcept
Returns text layout helper.
Definition IRenderer.h:216
Definition IRenderer.h:151
Base class for rendering.
Definition IRenderer.h:149
virtual void popMaskAfter()=0
Switches drawing to the color buffer back from the stencil. Decreases stencil depth.
virtual _< IMultiStringCanvas > newMultiStringCanvas(const AFontStyle &style)=0
Creates new canvas for batching multiple prerender string calls.
virtual void squareSector(const ABrush &brush, const glm::vec2 &position, const glm::vec2 &size, AAngleRadians begin, AAngleRadians end)=0
Draws sector in rectangle shape. The sector is drawn clockwise from begin to end angles.
void setColor(const AColor &color)
Sets the color which is multiplied with any brush. Unlike setColorForced, the new color is multiplied...
Definition IRenderer.h:432
virtual void lines(const ABrush &brush, AArrayView< glm::vec2 > points, const ABorderStyle &style, AMetric width)=0
Draws polyline (non-loop line strip).
virtual void points(const ABrush &brush, AArrayView< glm::vec2 > points, AMetric size)=0
Draws points list.
void lines(const ABrush &brush, AArrayView< std::pair< glm::vec2, glm::vec2 > > points, const ABorderStyle &style=ABorderStyle::Solid{})
Draws multiple individual lines in a batch.
Definition IRenderer.h:398
virtual void string(glm::vec2 position, const AString &string, const AFontStyle &fs={})=0
Draws string.
void setColorForced(const AColor &color)
Sets the color which is multiplied with any brush.
Definition IRenderer.h:422
void line(const ABrush &brush, glm::vec2 p1, glm::vec2 p2, const ABorderStyle &style=ABorderStyle::Solid{}, AMetric width=1_dp)
Definition IRenderer.h:351
virtual void setBlending(Blending blending)=0
Sets blending mode.
_< ITexture > getNewTexture()
Creates new texture (image representation optimized for GPU rendering).
Definition IRenderer.h:229
void setTransform(const glm::mat4 &transform)
Sets the transform matrix which is applicable for any figure. Unlike setTransformForced,...
Definition IRenderer.h:447
virtual void roundedRectangleBorder(const ABrush &brush, glm::vec2 position, glm::vec2 size, float radius, int borderWidth)=0
Draws rounded rectangle's border.
void rotate(const glm::vec3 &axis, AAngleRadians angle)
wrapper for setTransform applying matrix rotation along the specified axis.
Definition IRenderer.h:554
void stub(glm::vec2 position, glm::vec2 size)
Draws stub (i.e., gray rectangle)
Definition IRenderer.cpp:15
virtual void roundedRectangle(const ABrush &brush, glm::vec2 position, glm::vec2 size, float radius)=0
Draws rounded rect (with antialiasing, if msaa enabled).
virtual void popMaskBefore()=0
Switches drawing to the stencil buffer instead of color buffer.
void rotate(AAngleRadians angle)
wrapper for setTransform applying matrix rotation along z axis.
Definition IRenderer.h:562
void lines(const ABrush &brush, AArrayView< glm::vec2 > points, const ABorderStyle &style=ABorderStyle::Solid{})
Draws polyline (non-loop line strip).
Definition IRenderer.h:371
virtual void setWindow(AWindowBase *window)
Sets the window to render on.
Definition IRenderer.h:511
void setTransformForced(const glm::mat4 &transform)
Sets the transform matrix which is applicable for any figure.
Definition IRenderer.h:456
virtual void rectangleBorder(const ABrush &brush, glm::vec2 position, glm::vec2 size, float lineWidth=1.f)=0
Draws rectangle's border.
void translate(const glm::vec2 &offset)
Wrapper for setTransform applying matrix translate transformation.
Definition IRenderer.h:545
virtual void lines(const ABrush &brush, AArrayView< std::pair< glm::vec2, glm::vec2 > > points, const ABorderStyle &style, AMetric width)=0
Draws multiple individual lines in a batch.
virtual void pushMaskAfter()=0
Switches drawing to the color buffer back from the stencil. Increases stencil depth.
virtual _unique< IRenderViewToTexture > newRenderViewToTexture() noexcept=0
Returns a new instance of IRenderViewToTexture interface associated with this renderer.
virtual void boxShadowInner(glm::vec2 position, glm::vec2 size, float blurRadius, float spreadRadius, float borderRadius, const AColor &color, glm::vec2 offset)=0
Draws inner (inset) rectangle-shaped shadow.
virtual void boxShadow(glm::vec2 position, glm::vec2 size, float blurRadius, const AColor &color)=0
Draws a rectangle-shaped shadow.
virtual _< IPrerenderedString > prerenderString(glm::vec2 position, const AString &text, const AFontStyle &fs)=0
Analyzes string and creates an instance of IRenderer::IPrerenderedString which helps IRenderer to eff...
virtual void pushMaskBefore()=0
witches drawing to the stencil buffer instead of color buffer.
void backdrops(glm::ivec2 position, glm::ivec2 size, std::span< ass::Backdrop::Any > backdrops)
Draws rectangular backdrop effects.
Definition IRenderer.cpp:20
virtual void rectangle(const ABrush &brush, glm::vec2 position, glm::vec2 size)=0
Draws simple rectangle.
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:178
#define AUI_ASSERTX(condition, what)
Asserts that the passed condition evaluates to true. Adds extra message string.
Definition Assert.h:74
Definition ABorderStyle.h:30
Definition AFontStyle.h:24
Definition ATextLayoutHelper.h:27
Forbids copy of your class.
Definition values.h:40