7#include "pipeline_SDF_texture_map.hpp"
8#include "pipeline_SDF_atlas_rect.hpp"
9#include "pipeline_SDF_specialization_constants.hpp"
10#include "../text/font_glyph_ids.hpp"
11#include "../required.hpp"
12#include "../logger.hpp"
13#include "../vspan.hpp"
14#include "../numeric_array.hpp"
16#include <vma/vk_mem_alloc.h>
17#include <vulkan/vulkan.hpp>
19#include <unordered_map>
22class gui_device_vulkan;
30struct attributed_glyph;
33namespace tt::pipeline_SDF {
41 static constexpr int atlasImageWidth = 1024;
42 static constexpr int atlasImageHeight = 1024;
43 static_assert(atlasImageWidth == atlasImageHeight,
"needed for fwidth(textureCoord)");
45 static constexpr int atlasMaximumNrImages = 16;
46 static constexpr int stagingImageWidth = 128;
47 static constexpr int stagingImageHeight = 128;
49 static constexpr float atlasTextureCoordinateMultiplier = 1.0f / atlasImageWidth;
50 static constexpr float drawfontSize = 28.0f;
52 static constexpr float scaledDrawBorder = drawBorder / drawfontSize;
56 vk::ShaderModule vertexShaderModule;
57 vk::ShaderModule fragmentShaderModule;
61 vk::SpecializationInfo fragmentShaderSpecializationInfo;
69 vk::Sampler atlasSampler;
70 vk::DescriptorImageInfo atlasSamplerDescriptorImageInfo;
72 i32x4 atlasAllocationPosition = {};
95 void drawInCommandBuffer(vk::CommandBuffer &commandBuffer);
130 aarect clippingRectangle)
noexcept;
157 void addAtlasImage();
171 [[nodiscard]]
bool _placeVertices(
176 aarect clippingRectangle)
noexcept;
200 [[nodiscard]]
bool _placeVertices(
This is a RGBA floating point color.
Definition color.hpp:39
static constexpr float max_distance
Max distance in pixels represented by the signed distance field.
Definition sdf_r8.hpp:21
Definition gui_device_vulkan.hpp:23
Definition Pipeline_SDF_atlas_rect.hpp:16
Definition Pipeline_SDF_device_shared.hpp:38
void placeVertices(vspan< vertex > &vertices, font_glyph_ids const &glyphs, rect box, color color, aarect clippingRectangle) noexcept
Place vertices for a single glyph.
static aarect getBoundingBox(font_glyph_ids const &glyphs) noexcept
Get the bounding box, including draw border of a glyph.
int atlasAllocationMaxHeight
During allocation on a row, we keep track of the tallest glyph.
Definition Pipeline_SDF_device_shared.hpp:74
void prepareStagingPixmapForDrawing()
This will transition the staging texture to 'general' for writing by the CPU.
atlas_rect allocateRect(f32x4 drawExtent) noexcept
Allocate an glyph in the atlas.
void placeVertices(vspan< vertex > &vertices, shaped_text const &text, matrix3 transform, aarect clippingRectangle, color color) noexcept
Draw the text on the screen.
void destroy(gui_device_vulkan *vulkanDevice)
void uploadStagingPixmapToAtlas(atlas_rect location)
Once drawing in the staging pixmap is completed, you can upload it to the atlas.
void placeVertices(vspan< vertex > &vertices, shaped_text const &text, matrix3 transform, aarect clippingRectangle) noexcept
Draw the text on the screen.
void prepareAtlas(shaped_text const &text) noexcept
Prepare the atlas for drawing a text.
void prepareAtlasForRendering()
This will transition the atlas to 'shader-read'.
Definition Pipeline_SDF_specialization_constants.hpp:12
Definition Pipeline_SDF_texture_map.hpp:18
A 4D vector.
Definition ivec.hpp:38
Class which represents an rectangle.
Definition rect.hpp:16
Definition attributed_glyph.hpp:17
Definition font_glyph_ids.hpp:78
shaped_text represent a piece of text shaped to be displayed.
Definition shaped_text.hpp:22