FastUIDraw
Classes | Public Types | Public Member Functions | List of all members
fastuidraw::GlyphRenderDataBandedRays Class Reference

#include <glyph_render_data_banded_rays.hpp>

Inheritance diagram for fastuidraw::GlyphRenderDataBandedRays:
Inheritance graph
[legend]

Classes

class  query_info
 

Public Types

enum  { glyph_coord_value = 32 }
 
enum  attribute_values_t {
  glyph_normalized_x, glyph_normalized_y, glyph_num_vertical_bands, glyph_num_horizontal_bands,
  glyph_offset, glyph_num_attributes
}
 
enum  band_t { band_numcurves_numbits = 8, band_curveoffset_numbits = 32 - band_numcurves_numbits, band_numcurves_bit0 = 0, band_curveoffset_bit0 = band_numcurves_bit0 + band_numcurves_numbits }
 
enum  point_packing_t
 

Public Member Functions

 GlyphRenderDataBandedRays (void)
 
void finalize (enum PainterEnums::fill_rule_t f, const Rect &glyph_rect, int max_recursion, float avg_num_curves_thresh)
 
void finalize (enum PainterEnums::fill_rule_t f, const Rect &glyph_rect)
 
void line_to (vec2 pt)
 
void move_to (vec2 pt)
 
void quadratic_to (vec2 ct, vec2 pt)
 
enum return_code query (query_info *out_info) const
 
virtual c_array< const c_stringrender_info_labels (void) const
 
virtual enum fastuidraw::return_code upload_to_atlas (GlyphAtlasProxy &atlas_proxy, GlyphAttribute::Array &attributes, c_array< float > render_costs) const
 

Detailed Description

A GlyphRenderDataBandedRays represents the data needed to build a glyph to render it directly from the geometric data of the curve. This implementation does NOT use the techinque as patented by Eric Lengyel that computes by a lookup table keyed by the 3 conditions of examing q1, q2, q3 against 0. The Lengyel technique does give a fast shader, but we cannot use it because of the patent on it. Instead, we enforece the condition 0 <= t <= 1 of the solutions to 0 = [q1, q2, q3](t) by the hammer of algebra. Assuming that the leading coefficient of the quadratic is positive the enforement then becomes

The fragment shader needs to have additional code to handle the case where the leading coefficient is negative.

The attribute data for a Glyph has:

Each horizontal band is the EXACT same height and each vertical band is the EXACT same width. The data location of a horizontal and vertical band is implicitely given from the location of the glyph data as follows (where O = start of glyph data):

The value I for horizontal bands is computed as I = ny * V and the value I for vertical bands is computed as I = nx * H where nx is the glyph x-coordinate normalized to [0, 1] and ny is the glyph y-coordinate normalized to [0, 1].

A band is encoded by band_t (which gives the number of curves and offset to the curves).

Rather than encoding where in the glyph the horizontal and vertical bands split, we just say that the bands are split in the middle always (TODO: is this wise really?)

Definition at line 77 of file glyph_render_data_banded_rays.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
glyph_coord_value 

The glyph coordinate value in each coordiante varies from -glyph_coord_value to +glyph_coord_value, i.e. the glyph is drawn as rect with min-corner (-glyph_coord_value, -glyph_coord_value) and max-corner (+glyph_coord_value, +glyph_coord_value)

Definition at line 124 of file glyph_render_data_banded_rays.hpp.

◆ attribute_values_t

This enumeration describes the meaning of the attributes. The data of the glyph is offset so that a shader can assume that the bottom left corner has glyph-coordinate (0, 0) and the top right corner has glyph-coordinate (width, height) where width and height are the width and height of the glyph in glyph coordinates.

Enumerator
glyph_normalized_x 

Value is 0 if on min-x side of glyph, value is 1 if on max-x side of glyph; packed as uint.

glyph_normalized_y 

Value is 0 if on min-y side of glyph, value is 1 if on max-y side of glyph; packed as uint.

glyph_num_vertical_bands 

the index into GlyphAttribute::m_data storing the number of vertical bands in the glyph; packing as uint.

glyph_num_horizontal_bands 

the index into GlyphAttribute::m_data storing the number of horizontal bands in the glyph; packing as uint.

glyph_offset 

the index into GlyphAttribute::m_data storing the fill rule and the offset into the store for the glyph data. The offset is encoded as follows

  • bits0-bits29 encode the offset
  • bit30 indicates to complement fill
  • bit31 up indicates odd-even fill rule and down indicates non-zero fill rule.
glyph_num_attributes 

Number attribute values needed.

Definition at line 145 of file glyph_render_data_banded_rays.hpp.

◆ band_t

A band_t represents the header for listing the curves of a band. Each curve of a band is THREE points (see point_packing_t how points are packed). The packing of the curves is done as follows. Let the band have curves c1, c2, ..., cN were the curve cI has points (pI_0, pI_1, pI_2). The packing of points is:

p1_0, p1_1, p1_2, p2_0, p2_1, p2_2, .... , pN_0, pN_1, pN_2

Enumerator
band_numcurves_bit0 

first bit used to encode the number of curves in a band

band_curveoffset_bit0 

first bit used to encode the offset to the curves

Definition at line 89 of file glyph_render_data_banded_rays.hpp.

◆ point_packing_t

Points are packed as (fp16, fp16) pairs.

Definition at line 120 of file glyph_render_data_banded_rays.hpp.

Constructor & Destructor Documentation

◆ GlyphRenderDataBandedRays()

fastuidraw::GlyphRenderDataBandedRays::GlyphRenderDataBandedRays ( void  )

Ctor.

Member Function Documentation

◆ finalize() [1/2]

void fastuidraw::GlyphRenderDataBandedRays::finalize ( enum PainterEnums::fill_rule_t  f,
const Rect glyph_rect,
int  max_recursion,
float  avg_num_curves_thresh 
)

Finalize the input data after which no more contours or curves may be added; all added contours must be closed before calling finalize(). Once finalize() is called, no further data can be added. All contours added must be closed as well.

Parameters
ffill rule to use for rendering, must be one of PainterEnums::nonzero_fill_rule or PainterEnums::odd_even_fill_rule.
glyph_rectthe rect of the glpyh
max_recursionmaximum level of recursion to employ to reduce the complexity of each band. The number of bands that are generated in a dimension is 2^N where N is the number of levels of recursion used to generate bands.
avg_num_curves_threshwhen a band is generated, the average number of curves needed to perform the coverage computation is computed. When that value is lower than this parameter, the band is considered that is does not need to be reduced to smaller bands.

◆ finalize() [2/2]

void fastuidraw::GlyphRenderDataBandedRays::finalize ( enum PainterEnums::fill_rule_t  f,
const Rect glyph_rect 
)

Finalize the input data after which no more contours or curves may be added; all added contours must be closed before calling finalize(). Once finalize() is called, no further data can be added. All contours added must be closed as well. Provided as a conveniance, equivalent to

Parameters
ffill rule to use for rendering, must be one of PainterEnums::nonzero_fill_rule or PainterEnums::odd_even_fill_rule.
glyph_rectthe rect of the glpyh

◆ line_to()

void fastuidraw::GlyphRenderDataBandedRays::line_to ( vec2  pt)

Add a line segment connecting the end point of the last curve or line segment of the current contour to a given point.

Parameters
ptend point of the new line segment

◆ move_to()

void fastuidraw::GlyphRenderDataBandedRays::move_to ( vec2  pt)

Start a contour. Before starting a new contour the previous contour must be closed by calling line_to() or quadratic_to() connecting to the start point of the previous contour.

Parameters
ptstart point of the new contour

◆ quadratic_to()

void fastuidraw::GlyphRenderDataBandedRays::quadratic_to ( vec2  ct,
vec2  pt 
)

Add a quadratic curveconnecting the end point of the last curve or line segment of the current contour

Parameters
ctcontrol point of the quadratic curve
ptend point of the quadratic curve

◆ query()

enum return_code fastuidraw::GlyphRenderDataBandedRays::query ( query_info out_info) const

Query the data; may only be called after finalize(). Returns routine_fail if finalize() has not yet been called.

Parameters
out_infolocation to which to write information about this object.

◆ render_info_labels()

virtual c_array<const c_string> fastuidraw::GlyphRenderDataBandedRays::render_info_labels ( void  ) const
virtual

To be implemented by a derived class to return the strings used in GlyphRenderCostInfo::m_value; The pointer behind each of the string in the return c_array returned are required to stay valid even after the GlyphRenderData is deleted. The expectation is that the returned c_array is just c_array wrapping over a static constant array of string.

Implements fastuidraw::GlyphRenderData.

◆ upload_to_atlas()

virtual enum fastuidraw::return_code fastuidraw::GlyphRenderDataBandedRays::upload_to_atlas ( GlyphAtlasProxy atlas_proxy,
GlyphAttribute::Array attributes,
c_array< float >  render_costs 
) const
virtual

To be implemented by a derived class to upload data to a GlyphAtlas.

Parameters
atlas_proxyGlyphAtlasProxy to which to upload data
attributes(output) glyph attributes (see Glyph::attributes())
render_costs(output) an array of size render_info().size() to which to write the render costs for each entry in render_info().

Implements fastuidraw::GlyphRenderData.


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