8#include <unordered_map>
11namespace ZenitUI::Test
43 std::vector<uint8_t> pixels;
48 float charWidth{8.0f};
49 bool supportsEffects{
false};
50 bool supportsNestedTargets{
false};
51 bool supportsTargetSubRect{
false};
60 int pushEffectCount{0};
61 int createTargetCount{0};
62 int destroyTargetCount{0};
63 int pushTargetCount{0};
65 int activeTargetDepth{0};
66 int lastCreatedTargetW{0};
67 int lastCreatedTargetH{0};
68 int drawGeometryCalls{0};
69 size_t verticesSubmitted{0};
70 size_t indicesSubmitted{0};
72 int createTextureCount{0};
73 int updateTextureCount{0};
74 int destroyTextureCount{0};
77 EffectHandle lastPushedEffect{};
78 Rect lastDrawTargetSrc{};
79 Rect lastDrawTargetDst{};
81 std::vector<std::string> drawnTexts;
82 std::vector<Rect> clipStack;
83 Rect currentClip{0, 0, 1e9f, 1e9f};
84 std::vector<Transform2D> transformHistory;
86 std::vector<CapturedFloat> capturedFloat;
87 std::vector<CapturedVec2> capturedVec2;
88 std::vector<CapturedVec3> capturedVec3;
89 std::vector<CapturedVec4> capturedVec4f;
90 std::vector<CapturedColor> capturedColor;
91 std::unordered_map<uint32_t, DynamicTexture> dynamicTextures;
111 std::span<const uint32_t> indices,
119 std::string_view vsSource = {})
override;
147 uint32_t nextTargetId_{1000};
148 uint32_t nextTextureId_{2000};
149 uint32_t nextEffectId_{3000};
Per-application state: renderer, platform, pointer, focus, portals.
Abstract 2D rendering backend.
Definition UIContext.hpp:106
Recording IRenderer that tracks draw counts, clip stacks, render targets, dynamic textures,...
Definition MockRenderer.hpp:24
void updateTexture(TextureHandle t, Rect region, const uint8_t *rgbaPixels) override
Upload tightly-packed RGBA8 pixels into sub-rectangle region of texture t.
void popClip() override
Pop the current clip rectangle and restore the previous scissor region.
void drawNineSlice(TextureHandle t, NineSlice s, Rect dst, Color tint) override
Draw texture t stretched into dst using the 9-slice insets s (fixed corners, stretched edges/center).
void drawTarget(TargetHandle t, Rect dst, Color tint) override
Composite the entire render target t into logical destination rect dst, multiplied by tint.
void strokeRoundedRect(Rect r, float radiusPx, float thickness, Color c) override
Stroke a rounded border strictly inside r (CSS border-box).
TextureHandle createTexture(int w, int h, const uint8_t *rgbaPixels=nullptr) override
Allocate a dynamic RGBA8 2D texture of w x h pixels.
void fillRoundedRect(Rect r, float radiusPx, Color c) override
Fill a rectangle r with corner radius radiusPx (clamped to half the shorter side).
void drawTarget(TargetHandle t, Rect src, Rect dst, Color tint) override
Composite sub-rectangle src (target pixels) of t into logical rect dst.
void endFrame() override
Called at the end of Layout::renderFrame after all draw calls and portals have rendered.
void setEffectVec4f(EffectHandle e, const char *name, Vec4 value) override
Set a vec4 uniform named name on effect e.
bool supports(Feature f) const override
Query whether this backend implements an optional Feature.
EffectHandle createEffect(std::string_view fsSource, std::string_view vsSource={}) override
Compile and allocate a shader effect from GLSL/backend source strings.
void setEffectVec2(EffectHandle e, const char *name, Vec2 value) override
Set a vec2 uniform named name on effect e.
void popTransform() override
Pop the most recently pushed transform from the stack.
void drawTexture(TextureHandle t, Rect src, Rect dst, Color tint) override
Draw sub-rectangle src (texture pixels) of texture t into logical rect dst, multiplied by tint.
void destroyTexture(TextureHandle t) override
Release a dynamic texture previously created by createTexture.
void pushClip(Rect r) override
Push a local-space clip rectangle r, intersecting it with the current clip.
bool inTarget() const override
Return true while a pushTarget is active without a matching popTarget.
void popTarget() override
Finish drawing into the active target and restore the previous target (or main framebuffer) and stack...
void drawGeometry(std::span< const Vertex2D > vertices, std::span< const uint32_t > indices, TextureHandle tex={}) override
Draw an indexed triangle list in logical screen coordinates.
TargetHandle createTarget(int w, int h) override
Allocate an off-screen RGBA render target of w x h pixels (used when Feature::NestedTargets is suppor...
void pushEffect(EffectHandle e) override
Bind shader effect e and push it onto the effect stack (used when Feature::Effects is supported).
void destroyTarget(TargetHandle t) override
Release a render target previously allocated by createTarget.
void popEffect() override
Pop the active shader effect and restore the previous one (if any).
void destroyEffect(EffectHandle e) override
Release a shader effect previously created by createEffect.
void strokeRect(Rect r, float thickness, Color c) override
Stroke a rectangular border strictly inside r (CSS border-box).
void setEffectFloat(EffectHandle e, const char *name, float value) override
Set a float uniform named name on effect e.
void setEffectVec3(EffectHandle e, const char *name, Vec3 value) override
Set a vec3 uniform named name on effect e.
Rect getClipRect() const override
Return the active screen-space clip rectangle in logical pixels (used for culling).
void fillCircle(Vec2 center, float radius, Color c) override
Fill a circle centered at center with the given logical radius.
void setEffectVec4(EffectHandle e, const char *name, Color value) override
Set a normalized RGBA vec4 uniform (0..1 per channel) named name on effect e.
void setDpiScale(float scale) override
Notify the renderer of the active logical-to-physical DPI scale factor for the current frame.
void pushTransform(const Transform2D &t) override
Push a 2D pivot-based transform onto the transform stack.
void clearTarget(TargetHandle t, Color c) override
Clear render target t to solid color c.
void beginFrame() override
Called at the start of Layout::renderFrame before any draw calls (e.g.
void fillRect(Rect r, Color c) override
Fill an axis-aligned rectangle r with solid color c.
void pushTarget(TargetHandle t) override
Redirect subsequent draw calls to target t and clear it to transparent black.
Feature
Optional renderer capabilities queried via IRenderer::supports.
Definition UIContext.hpp:62
8-bit-per-channel RGBA color, non-premultiplied.
Definition CoreTypes.hpp:78
Opaque handle to a shader/effect owned by the asset provider.
Definition CoreTypes.hpp:142
Nine-slice inset values for scalable textures.
Definition CoreTypes.hpp:163
Axis-aligned rectangle in screen coordinates.
Definition CoreTypes.hpp:46
Opaque handle to an off-screen render target.
Definition CoreTypes.hpp:155
Definition MockRenderer.hpp:40
Opaque handle to a GPU/software texture owned by the asset provider.
Definition CoreTypes.hpp:127
2D vector with component-wise arithmetic.
Definition CoreTypes.hpp:25
3D vector.
Definition CoreTypes.hpp:34
4D vector with an implicit w = 1 default.
Definition CoreTypes.hpp:40