6#include "TTauri/GUI/PipelineSDF_TextureMap.hpp"
7#include "TTauri/GUI/PipelineSDF_AtlasRect.hpp"
8#include "TTauri/GUI/PipelineSDF_SpecializationConstants.hpp"
9#include "TTauri/GUI/GUIDevice_forward.hpp"
10#include "TTauri/Text/FontGlyphIDs.hpp"
11#include "TTauri/Foundation/required.hpp"
12#include "TTauri/Foundation/logger.hpp"
13#include "TTauri/Foundation/vspan.hpp"
14#include "TTauri/Foundation/ivec.hpp"
15#include "TTauri/Foundation/rect.hpp"
16#include <vma/vk_mem_alloc.h>
17#include <vulkan/vulkan.hpp>
19#include <unordered_map>
22template<
typename T>
struct PixelMap;
29struct AttributedGlyph;
32namespace tt::PipelineSDF {
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 ivec atlasAllocationPosition = {};
94 void drawInCommandBuffer(vk::CommandBuffer &commandBuffer);
146 void addAtlasImage();
Class which represents an axis-aligned rectangle.
Definition aarect.hpp:13
A 4D vector.
Definition ivec.hpp:37
A 4x4 matrix.
Definition mat.hpp:18
Class which represents an axis-aligned rectangle.
Definition rect.hpp:15
static constexpr float max_distance
Max distance in pixels represented by the signed distance field.
Definition SDF8.hpp:20
A 4D vector.
Definition vec.hpp:37
Definition GUIDevice_vulkan.hpp:22
Definition PipelineSDF_AtlasRect.hpp:16
Definition PipelineSDF_DeviceShared.hpp:37
AtlasRect allocateRect(vec drawExtent) noexcept
Allocate an glyph in the atlas.
void prepareAtlas(ShapedText const &text) noexcept
Prepare the atlas for drawing a text.
int atlasAllocationMaxHeight
During allocation on a row, we keep track of the tallest glyph.
Definition PipelineSDF_DeviceShared.hpp:73
void prepareAtlasForRendering()
This will transition the atlas to 'shader-read'.
void uploadStagingPixmapToAtlas(AtlasRect location)
Once drawing in the staging pixmap is completed, you can upload it to the atlas.
void placeVertices(vspan< Vertex > &vertices, FontGlyphIDs const &glyphs, rect box, vec color, aarect clippingRectangle) noexcept
Place vertices for a single glyph.
void prepareStagingPixmapForDrawing()
This will transition the staging texture to 'general' for writing by the CPU.
void destroy(GUIDevice *vulkanDevice)
void placeVertices(vspan< Vertex > &vertices, ShapedText const &text, mat transform, aarect clippingRectangle, vec color) noexcept
Draw the text on the screen.
static aarect getBoundingBox(FontGlyphIDs const &glyphs) noexcept
Get the bounding box, including draw border of a glyph.
void placeVertices(vspan< Vertex > &vertices, ShapedText const &text, mat transform, aarect clippingRectangle) noexcept
Draw the text on the screen.
Definition PipelineSDF_SpecializationConstants.hpp:11
Definition PipelineSDF_TextureMap.hpp:14
Definition AttributedGlyph.hpp:15
Definition FontGlyphIDs.hpp:77
ShapedText represent a piece of text shaped to be displayed.
Definition ShapedText.hpp:21