HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes
tt::pipeline_SDF::device_shared Struct Referencefinal

Public Member Functions

 device_shared (gui_device_vulkan const &device)
 
 device_shared (device_shared const &)=delete
 
device_sharedoperator= (device_shared const &)=delete
 
 device_shared (device_shared &&)=delete
 
device_sharedoperator= (device_shared &&)=delete
 
void destroy (gui_device_vulkan *vulkanDevice)
 
atlas_rect allocateRect (extent2 drawExtent) noexcept
 Allocate an glyph in the atlas.
 
void drawInCommandBuffer (vk::CommandBuffer &commandBuffer)
 
void uploadStagingPixmapToAtlas (atlas_rect location)
 Once drawing in the staging pixmap is completed, you can upload it to the atlas.
 
void prepareStagingPixmapForDrawing ()
 This will transition the staging texture to 'general' for writing by the CPU.
 
void prepareAtlasForRendering ()
 This will transition the atlas to 'shader-read'.
 
void prepareAtlas (shaped_text const &text) noexcept
 Prepare the atlas for drawing a text.
 
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.
 
void place_vertices (vspan< vertex > &vertices, aarectangle clipping_rectangle, matrix3 transform, shaped_text const &text) noexcept
 Draw the text on the screen.
 
void place_vertices (vspan< vertex > &vertices, aarectangle clipping_rectangle, matrix3 transform, shaped_text const &text, color color) noexcept
 Draw the text on the screen.
 

Static Public Member Functions

static aarectangle getBoundingBox (font_glyph_ids const &glyphs) noexcept
 Get the bounding box, including draw border of a glyph.
 

Data Fields

gui_device_vulkan const & device
 
vk::ShaderModule vertexShaderModule
 
vk::ShaderModule fragmentShaderModule
 
specialization_constants specializationConstants
 
std::vector< vk::SpecializationMapEntry > fragmentShaderSpecializationMapEntries
 
vk::SpecializationInfo fragmentShaderSpecializationInfo
 
std::vector< vk::PipelineShaderStageCreateInfo > shaderStages
 
std::unordered_map< font_glyph_ids, atlas_rectglyphs_in_atlas
 
texture_map stagingTexture
 
std::vector< texture_mapatlasTextures
 
std::array< vk::DescriptorImageInfo, atlasMaximumNrImages > atlasDescriptorImageInfos
 
vk::Sampler atlasSampler
 
vk::DescriptorImageInfo atlasSamplerDescriptorImageInfo
 
point3 atlas_allocation_position = {}
 
int atlasAllocationMaxHeight = 0
 During allocation on a row, we keep track of the tallest glyph.
 

Static Public Attributes

static constexpr int atlasImageWidth = 1024
 
static constexpr int atlasImageHeight = 1024
 
static constexpr int atlasMaximumNrImages = 16
 
static constexpr int stagingImageWidth = 128
 
static constexpr int stagingImageHeight = 128
 
static constexpr float atlasTextureCoordinateMultiplier = 1.0f / atlasImageWidth
 
static constexpr float drawfontSize = 28.0f
 
static constexpr float drawBorder = sdf_r8::max_distance
 
static constexpr float scaledDrawBorder = drawBorder / drawfontSize
 

Member Function Documentation

◆ allocateRect()

atlas_rect tt::pipeline_SDF::device_shared::allocateRect ( extent2 drawExtent)
noexcept

Allocate an glyph in the atlas.

This may allocate an atlas texture, up to atlasMaximumNrImages.

◆ destroy()

void tt::pipeline_SDF::device_shared::destroy ( gui_device_vulkan * vulkanDevice)

Deallocate vulkan resources. This is called in the destructor of gui_device_vulkan, therefor we can not use our std::weak_ptr<gui_device_vulkan> device.

◆ getBoundingBox()

static aarectangle tt::pipeline_SDF::device_shared::getBoundingBox ( font_glyph_ids const & glyphs)
staticnoexcept

Get the bounding box, including draw border of a glyph.

◆ place_vertices() [1/3]

void tt::pipeline_SDF::device_shared::place_vertices ( vspan< vertex > & vertices,
aarectangle clipping_rectangle,
matrix3 transform,
shaped_text const & text )
noexcept

Draw the text on the screen.

Parameters
textThe box of text to draw
transformThe 2D transformation to move and rotate the box to the correct position on screen.
clippingRectangleThe clipping rectangle in screen space where glyphs should be cut off.
verticesThe vertices to draw the glyphs to.

◆ place_vertices() [2/3]

void tt::pipeline_SDF::device_shared::place_vertices ( vspan< vertex > & vertices,
aarectangle clipping_rectangle,
matrix3 transform,
shaped_text const & text,
color color )
noexcept

Draw the text on the screen.

Parameters
textThe box of text to draw
transformThe 2D transformation to move and rotate the box to the correct position on screen.
clippingRectangleThe clipping rectangle in screen space where glyphs should be cut off.
verticesThe vertices to draw the glyphs to.
colorOverride the color of the text to draw.

◆ place_vertices() [3/3]

void tt::pipeline_SDF::device_shared::place_vertices ( vspan< vertex > & vertices,
aarectangle clipping_rectangle,
rectangle box,
font_glyph_ids const & glyphs,
color color )
noexcept

Place vertices for a single glyph.

Parameters
verticesThe list of vertices to add to.
glyphsThe font-id, composed-glyphs to render
boxThe rectangle of the glyph in window coordinates; including the draw border.
colorThe color of the glyph.
clippingRectangleThe rectangle to clip the glyph.

◆ prepareAtlas()

void tt::pipeline_SDF::device_shared::prepareAtlas ( shaped_text const & text)
noexcept

Prepare the atlas for drawing a text.

◆ prepareAtlasForRendering()

void tt::pipeline_SDF::device_shared::prepareAtlasForRendering ( )

This will transition the atlas to 'shader-read'.

◆ prepareStagingPixmapForDrawing()

void tt::pipeline_SDF::device_shared::prepareStagingPixmapForDrawing ( )

This will transition the staging texture to 'general' for writing by the CPU.

◆ uploadStagingPixmapToAtlas()

void tt::pipeline_SDF::device_shared::uploadStagingPixmapToAtlas ( atlas_rect location)

Once drawing in the staging pixmap is completed, you can upload it to the atlas.

This will transition the stating texture to 'source' and the atlas to 'destination'.

Field Documentation

◆ atlasAllocationMaxHeight

int tt::pipeline_SDF::device_shared::atlasAllocationMaxHeight = 0

During allocation on a row, we keep track of the tallest glyph.


The documentation for this struct was generated from the following file: