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 "../geometry/rectangle.hpp"
15#include <vk_mem_alloc.h>
16#include <vulkan/vulkan.hpp>
18#include <unordered_map>
21class gui_device_vulkan;
29struct attributed_glyph;
32namespace tt::pipeline_SDF {
40 static constexpr int atlasImageWidth = 1024;
41 static constexpr int atlasImageHeight = 1024;
42 static_assert(atlasImageWidth == atlasImageHeight,
"needed for fwidth(textureCoord)");
44 static constexpr int atlasMaximumNrImages = 16;
45 static constexpr int stagingImageWidth = 128;
46 static constexpr int stagingImageHeight = 128;
48 static constexpr float atlasTextureCoordinateMultiplier = 1.0f / atlasImageWidth;
49 static constexpr float drawfontSize = 28.0f;
51 static constexpr float scaledDrawBorder = drawBorder / drawfontSize;
55 vk::ShaderModule vertexShaderModule;
56 vk::ShaderModule fragmentShaderModule;
60 vk::SpecializationInfo fragmentShaderSpecializationInfo;
68 vk::Sampler atlasSampler;
69 vk::DescriptorImageInfo atlasSamplerDescriptorImageInfo;
71 point3 atlas_allocation_position = {};
94 void drawInCommandBuffer(vk::CommandBuffer &commandBuffer);
152 void addAtlasImage();
166 [[nodiscard]]
bool _place_vertices(
183 [[nodiscard]]
bool _place_vertices(
200 [[nodiscard]]
bool _place_vertices(
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
Class which represents an axis-aligned rectangle.
Definition axis_aligned_rectangle.hpp:18
Class which represents an rectangle.
Definition rectangle.hpp:16
Definition gui_device_vulkan.hpp:23
Definition pipeline_SDF_atlas_rect.hpp:17
Definition pipeline_SDF_device_shared.hpp:37
void place_vertices(vspan< vertex > &vertices, aarectangle clipping_rectangle, rectangle box, font_glyph_ids const &glyphs, color color) noexcept
Place vertices for a single glyph.
int atlasAllocationMaxHeight
During allocation on a row, we keep track of the tallest glyph.
Definition pipeline_SDF_device_shared.hpp:73
static aarectangle getBoundingBox(font_glyph_ids const &glyphs) noexcept
Get the bounding box, including draw border of a glyph.
void prepareStagingPixmapForDrawing()
This will transition the staging texture to 'general' for writing by the CPU.
atlas_rect allocateRect(extent2 drawExtent) noexcept
Allocate an glyph in the atlas.
void place_vertices(vspan< vertex > &vertices, aarectangle clipping_rectangle, matrix3 transform, shaped_text const &text) 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 place_vertices(vspan< vertex > &vertices, aarectangle clipping_rectangle, matrix3 transform, shaped_text const &text, color color) 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
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:23