FastUIDraw
Public Types | Static Public Member Functions | List of all members
fastuidraw::PainterEnums Class Reference

Class to encapsulate enumerations used in Painter interface, part of the main library libFastUIDraw. More...

#include <painter_enums.hpp>

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

Public Types

enum  blend_mode_t {
  blend_porter_duff_clear, blend_porter_duff_src, blend_porter_duff_dst, blend_porter_duff_src_over,
  blend_porter_duff_dst_over, blend_porter_duff_src_in, blend_porter_duff_dst_in, blend_porter_duff_src_out,
  blend_porter_duff_dst_out, blend_porter_duff_src_atop, blend_porter_duff_dst_atop, blend_porter_duff_xor,
  blend_porter_duff_plus, blend_porter_duff_modulate, blend_w3c_screen, blend_w3c_overlay,
  blend_w3c_darken, blend_w3c_lighten, blend_w3c_color_dodge, blend_w3c_color_burn,
  blend_w3c_hardlight, blend_w3c_softlight, blend_w3c_difference, blend_w3c_exclusion,
  blend_w3c_multiply, blend_w3c_hue, blend_w3c_saturation, blend_w3c_color,
  blend_w3c_luminosity, number_blend_mode
}
 Enumeration specifying blend modes. The following function-formulas are used in a number of the blend modes: More...
 
enum  cap_style { flat_caps, rounded_caps, square_caps, number_cap_styles }
 Enumeration specifying if and how to draw caps when stroking. More...
 
enum  fill_rule_t {
  odd_even_fill_rule, complement_odd_even_fill_rule, nonzero_fill_rule, complement_nonzero_fill_rule,
  number_fill_rule
}
 Enumerations specifying common fill rules. More...
 
enum  glyph_layout_type { glyph_layout_horizontal, glyph_layout_vertical, number_glyph_layout }
 Enumeration to indicate if glyph layout is horizontal or vertical. More...
 
enum  join_style {
  no_joins, rounded_joins, bevel_joins, miter_clip_joins,
  miter_bevel_joins, miter_joins, number_join_styles
}
 Enumeration specifying if and how to draw joins when stroking. More...
 
enum  query_stats_t {
  num_attributes, num_indices, num_datas, num_draws,
  num_headers, num_render_targets, num_ends, num_layers,
  num_deferred_coverages
}
 Enumeration to query the statistics of how much data has been packed. More...
 
enum  rotation_orientation_t { clockwise, counter_clockwise, number_rotation_orientation }
 Enumeration to specify orientation of a rotation. More...
 
enum  screen_orientation { y_increases_downwards, y_increases_upwards, number_screen_orientation }
 Enumeration to indicate in what direction the y-coordinate increases. More...
 
enum  stroking_method_t {
  stroking_method_linear, stroking_method_arc, stroking_method_number_precise_choices, stroking_method_fastest = stroking_method_number_precise_choices,
  number_stroking_methods
}
 
- Public Types inherited from fastuidraw::PainterBrushEnums
enum  filter_t { filter_nearest = 1, filter_linear = 2, filter_cubic = 3 }
 Enumeration specifying what filter to apply to an image. More...
 
enum  gradient_type_t {
  gradient_non = 0, gradient_linear, gradient_radial, gradient_sweep,
  number_gradient_types
}
 
enum  mipmap_t { apply_mipmapping, dont_apply_mipmapping }
 
enum  spread_type_t {
  spread_clamp, spread_mirror, spread_repeat, spread_mirror_repeat,
  number_spread_types
}
 

Static Public Member Functions

static enum fill_rule_t complement_fill_rule (enum fill_rule_t f)
 
static bool is_miter_join (enum join_style js)
 
static c_string label (enum screen_orientation v)
 
static c_string label (enum rotation_orientation_t v)
 
static c_string label (enum glyph_layout_type v)
 
static c_string label (enum cap_style v)
 
static c_string label (enum join_style v)
 
static c_string label (enum fill_rule_t v)
 
static c_string label (enum stroking_method_t v)
 
static c_string label (enum blend_mode_t v)
 
static c_string label (enum query_stats_t v)
 

Detailed Description

Class to encapsulate enumerations used in Painter interface, part of the main library libFastUIDraw.

Definition at line 177 of file painter_enums.hpp.

Member Enumeration Documentation

◆ blend_mode_t

Enumeration specifying blend modes. The following function-formulas are used in a number of the blend modes:

UndoAlpha(C.rgba) = (0, 0, 0) if Ca = 0
C.rgb / C.a otherwise
MinColorChannel(C.rgb) = min(C.r, C.g, C.b)
MaxColorChannel(C.rgb) = max(C.r, C.g, C.b)
Luminosity(C.rgb) = dot(C.rgb, vec3(0.30, 0.59, 0.11))
Saturation(C.rgb) = MaxColorChannel(C.rgb) - MinColorChannel(C.rgb)

The next set of functions are a little messier and written in GLSL

vec3 ClipColor(in vec3 C)
{
float L = Luminosity(C);
float MinC = MinColorChannel(C);
float MaxC = MaxColorChannel(C);
if (MinC < 0.0)
C = vec3(L) + (C - vec3(L)) * (L / (L - MinC));
if (MaxC > 1.0)
C = vec3(L) + (C - vec3(L)) * ((1 - L) / (MaxC - L));
return C;
}
vec3 OverrideLuminosity(vec3 C, vec3 L)
{
float Clum = Luminosity(C);
float Llum = Luminosity(L);
float Delta = Llum - Clum;
return ClipColor(C + vec3(Delta));
}
vec3 OverrideLuminosityAndSaturation(vec3 C, vec3 S, vec3 L)
{
float Cmin = MinColorChannel(C);
float Csat = Saturation(C);
float Ssat = Saturation(S);
if (Csat > 0.0)
{
C = (C - Cmin) * Ssat / Csat;
}
else
{
C = vec3(0.0);
}
return OverrideLuminosity(C, L);
}
Enumerator
blend_porter_duff_clear 

Porter-Duff clear mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F.rgba = (0, 0, 0, 0).

blend_porter_duff_src 

Porter-Duff src mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F = S.

blend_porter_duff_dst 

Porter-Duff dst mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F = D.

blend_porter_duff_src_over 

Porter-Duff src-over mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a + D.a * (1 - S.a)
F.rgb = S.rgb + D.rgb * (1 - S.a)
blend_porter_duff_dst_over 

Porter-Duff dst-over mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = D.a + S.a * (1 - D.a)
F.rgb = D.rgb + S.rgb * (1 - D.a)
blend_porter_duff_src_in 

Porter-Duff src-in mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a * D.a
F.rgb = S.rgb * D.a
blend_porter_duff_dst_in 

Porter-Duff dst-in mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is

F.a = S.a * D.a
F.rgb = D.rgb * S.a
blend_porter_duff_src_out 

Porter-Duff mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a * (1 - D.a)
F.rgb = S.rgb * (1 - D.a)
blend_porter_duff_dst_out 

Porter-Duff src-out mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = D.a * (1.0 - S.a)
F.rgb = D.rgb * (1.0 - S.a)
blend_porter_duff_src_atop 

Porter-Duff src-atop mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = D.a
F.rgb = S.rgb * D.a + D.rgb * (1.0 - S.a)
blend_porter_duff_dst_atop 

Porter-Duff dst-atop mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a
F.rgb = D.rgb * S.a + S.rgb * (1 - D.a)
blend_porter_duff_xor 

Porter-Duff xor mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a * (1 - D.a) + D.a * (1 - S.a)
F.rgb = S.rgb * (1 - D.a) + D.rgb * (1 - S.a)
blend_porter_duff_plus 

Plus blend mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a + D.a
F.rgb = S.rgb + D.rgb
blend_porter_duff_modulate 

Modulate blend mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a * D.a
F.rgb = S.rgb * D.rgb
blend_w3c_screen 

Screen mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a + D.a * (1 - S.a)
F.rgb = f(UndoAlpha(S), UndoAlpha(D)) * S.a * D.a + S.rgb * (1 - D.a) + D.rgb * (1 - S.a)

where for each channel c,

f(S, D).c = S.c + D.c - S.c * D.c
blend_w3c_overlay 

Overlay mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a + D.a * (1 - S.a)
F.rgb = f(UndoAlpha(S), UndoAlpha(D)) * S.a * D.a + S.rgb * (1 - D.a) + D.rgb * (1 - S.a)

where for each channel c,

f(S, D).c =
2 * S * D, if D <= 0.5
1 - 2 * (1 - S) * (1 - D), otherwise
blend_w3c_darken 

Darken mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a + D.a * (1 - S.a)
F.rgb = f(UndoAlpha(S), UndoAlpha(D)) * S.a * D.a + S.rgb * (1 - D.a) + D.rgb * (1 - S.a)

where for each channel c,

f(S, D).c = min(S, D)
blend_w3c_lighten 

Lighten mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a + D.a * (1 - S.a)
F.rgb = f(UndoAlpha(S), UndoAlpha(D)) * S.a * D.a + S.rgb * (1 - D.a) + D.rgb * (1 - S.a)

where for each channel c,

f(S, D).c = max(S.c, D.c)
blend_w3c_color_dodge 

Color dodge mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a + D.a * (1 - S.a)
F.rgb = f(UndoAlpha(S), UndoAlpha(D)) * S.a * D.a + S.rgb * (1 - D.a) + D.rgb * (1 - S.a)

where for each channel c,

f(S, D).c =
0, if D.c <= 0
min(1, D.c / (1 - S.c)), if D.c > 0 and S.c < 1
1, if D.c > 0 and S.c >= 1
blend_w3c_color_burn 

Color burn mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a + D.a * (1 - S.a)
F.rgb = f(UndoAlpha(S), UndoAlpha(D)) * S.a * D.a + S.rgb * (1 - D.a) + D.rgb * (1 - S.a)

where for each channel c,

f(S, D).c =
1, if D.c >= 1
1 - min(1, (1 - D.c) / S.c), if D.c < 1 and S.c > 0
0, if D.c < 1 and S.c <= 0
blend_w3c_hardlight 

Harlight mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a + D.a * (1 - S.a)
F.rgb = f(UndoAlpha(S), UndoAlpha(D)) * S.a * D.a + S.rgb * (1 - D.a) + D.rgb * (1 - S.a)

where for each channel c,

f(S, D).c = 2 * S.c * D.c, if S.c <= 0.5
1 - 2 * (1 - S.c) * (1 - D.c), otherwise
blend_w3c_softlight 

Softlight mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a + D.a * (1 - S.a)
F.rgb = f(UndoAlpha(S), UndoAlpha(D)) * S.a * D.a + S.rgb * (1 - D.a) + D.rgb * (1 - S.a)

where for each channel c,

f(S, D).c =
D.c - (1 - 2 * S.c) * D.c * (1 - D.c), if S.c <= 0.5
D.c + (2 * S.c - 1) * D.c * ((16 * D.c - 12) * D.c + 3), if S.c > 0.5 and D.c <= 0.25
D.c + (2 * S.c - 1) * (sqrt(D.c) - D.c), if S.c > 0.5 and D.c > 0.25
blend_w3c_difference 

Difference mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a + D.a * (1 - S.a)
F.rgb = f(UndoAlpha(S), UndoAlpha(D)) * S.a * D.a + S.rgb * (1 - D.a) + D.rgb * (1 - S.a)

where for each channel c,

f(S, D).c = abs(S.c - D.c)
blend_w3c_exclusion 

Exclusion mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a + D.a * (1 - S.a)
F.rgb = f(UndoAlpha(S), UndoAlpha(D)) * S.a * D.a + S.rgb * (1 - D.a) + D.rgb * (1 - S.a)

where for each channel c,

f(S, D).c = S.c + D.c - 2 * S.c * D.c
blend_w3c_multiply 

Multiply mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a + D.a * (1 - S.a)
F.rgb = f(UndoAlpha(S), UndoAlpha(D)) * S.a * D.a + S.rgb * (1 - D.a) + D.rgb * (1 - S.a)

where for each channel c,

f(S, D).c = S.c * D.c
blend_w3c_hue 

Hue mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a + D.a * (1 - S.a)
F.rgb = f(UndoAlpha(S), UndoAlpha(D)) * S.a * D.a + S.rgb * (1 - D.a) + D.rgb * (1 - S.a)

where

f(S.rgb, D.rgb).rgb = OverrideLuminosityAndSaturation(S.rgb, D.rgb, D.rgb)
blend_w3c_saturation 

Saturation mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a + D.a * (1 - S.a)
F.rgb = f(UndoAlpha(S), UndoAlpha(D)) * S.a * D.a + S.rgb * (1 - D.a) + D.rgb * (1 - S.a)

where

f(S.rgb, D.rgb).rgb = OverrideLuminosityAndSaturation(D.rgb, S.rgb, D.rgb)
blend_w3c_color 

Color mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a + D.a * (1 - S.a)
F.rgb = f(UndoAlpha(S), UndoAlpha(D)) * S.a * D.a + S.rgb * (1 - D.a) + D.rgb * (1 - S.a)

where

f(S.rgb, D.rgb).rgb = OverrideLuminosity(S.rgb, D.rgb)
blend_w3c_luminosity 

Luminosity mode. Letting S be the value from the fragment shader and D be the current value in the framebuffer, replaces the value in the framebuffer with F where F is:

F.a = S.a + D.a * (1 - S.a)
F.rgb = f(UndoAlpha(S), UndoAlpha(D)) * S.a * D.a + S.rgb * (1 - D.a) + D.rgb * (1 - S.a)

where

f(S.rgb, D.rgb).rgb = OverrideLuminosity(D.rgb, S.rgb)

Definition at line 393 of file painter_enums.hpp.

◆ cap_style

Enumeration specifying if and how to draw caps when stroking.

Enumerator
flat_caps 

indicates to have flat (i.e. no) caps when stroking

rounded_caps 

indicates to have rounded caps when stroking

square_caps 

indicates to have square caps when stroking

number_cap_styles 

number of cap styles

Definition at line 234 of file painter_enums.hpp.

◆ fill_rule_t

Enumerations specifying common fill rules.

Enumerator
odd_even_fill_rule 

indicates to use odd-even fill rule

complement_odd_even_fill_rule 

indicates to give the complement of the odd-even fill rule

nonzero_fill_rule 

indicates to use the non-zero fill rule

complement_nonzero_fill_rule 

indicates to give the complement of the non-zero fill rule

number_fill_rule 

count of enums

Definition at line 291 of file painter_enums.hpp.

◆ glyph_layout_type

Enumeration to indicate if glyph layout is horizontal or vertical.

Enumerator
glyph_layout_horizontal 

Glyphs are layed out horizontally, thus will use GlyphMetrics::horizontal_layout_offset() to offset the glyphs.

glyph_layout_vertical 

Glyphs are layed out vertically, thus will use GlyphMetrics::vertical_layout_offset() to offset the glyphs.

Definition at line 211 of file painter_enums.hpp.

◆ join_style

Enumeration specifying if and how to draw joins when stroking.

Enumerator
no_joins 

indicates to stroke without joins

rounded_joins 

indicates to stroke with rounded joins

bevel_joins 

indicates to stroke with bevel joins

miter_clip_joins 

indicates to stroke with miter joins where if miter distance is exceeded then the miter join is clipped to the miter distance.

miter_bevel_joins 

indicates to stroke with miter joins where if miter distance is exceeded then the miter join is drawn as a bevel join.

miter_joins 

indicates to stroke with miter joins where if miter distance is exceeded then the miter-tip is truncated to the miter distance.

number_join_styles 

number of join styles

Definition at line 247 of file painter_enums.hpp.

◆ query_stats_t

Enumeration to query the statistics of how much data has been packed.

Enumerator
num_attributes 

Offset to how many attributes processed

num_indices 

Offset to how many indices processed

num_datas 

Offset to how many uvec4 values placed onto store buffer(s).

num_draws 

Offset to how many PainterDraw objects sent

num_headers 

Offset to how many painter headers packed.

num_render_targets 

Number of distinct render targets needed.

num_ends 

Number of times PainterBackend::end() was called

num_layers 

Number of begin_layer()/end_layer() pairs called

num_deferred_coverages 

Number of begin_coverage_buffer()/end_coverage_buffer() pairs called

Definition at line 783 of file painter_enums.hpp.

◆ rotation_orientation_t

Enumeration to specify orientation of a rotation.

Enumerator
clockwise 

indicates clockwise

counter_clockwise 

indicates counter-clockwise

Definition at line 198 of file painter_enums.hpp.

◆ screen_orientation

Enumeration to indicate in what direction the y-coordinate increases.

Enumerator
y_increases_downwards 

y-coordinate increases downwards

y_increases_upwards 

y-coordinate increases upwards

Definition at line 186 of file painter_enums.hpp.

◆ stroking_method_t

Enumeration to specify how to stroke

Enumerator
stroking_method_linear 

Use linear stroking taken directly from the Path. Thus the passed StrokedPath only consists of line segments.

stroking_method_arc 

Use arc-stroking, i.e. the passed StrokedPath has both arc-segments and line segments. This results in fewer vertices with the fragment shader computing per-pixel coverage.

stroking_method_fastest 

Choose for optimal performance.

number_stroking_methods 

Number of stroking enums present.

Definition at line 304 of file painter_enums.hpp.

Member Function Documentation

◆ complement_fill_rule()

static enum fill_rule_t fastuidraw::PainterEnums::complement_fill_rule ( enum fill_rule_t  f)
static

Given a fill rule, return the fill rule for the complement.

◆ is_miter_join()

static bool fastuidraw::PainterEnums::is_miter_join ( enum join_style  js)
inlinestatic

Returns true if a join_style is a miter-type join, i.e. one of miter_clip_joins, miter_bevel_joins or miter_joins.

Parameters
jsjoin style to query

Definition at line 848 of file painter_enums.hpp.

◆ label() [1/9]

static c_string fastuidraw::PainterEnums::label ( enum screen_orientation  v)
static

Returns a c_string for an enumerated value.

Parameters
vvalue to get the label-string of.

◆ label() [2/9]

static c_string fastuidraw::PainterEnums::label ( enum rotation_orientation_t  v)
static

Returns a c_string for an enumerated value.

Parameters
vvalue to get the label-string of.

◆ label() [3/9]

static c_string fastuidraw::PainterEnums::label ( enum glyph_layout_type  v)
static

Returns a c_string for an enumerated value.

Parameters
vvalue to get the label-string of.

◆ label() [4/9]

static c_string fastuidraw::PainterEnums::label ( enum cap_style  v)
static

Returns a c_string for an enumerated value.

Parameters
vvalue to get the label-string of.

◆ label() [5/9]

static c_string fastuidraw::PainterEnums::label ( enum join_style  v)
static

Returns a c_string for an enumerated value.

Parameters
vvalue to get the label-string of.

◆ label() [6/9]

static c_string fastuidraw::PainterEnums::label ( enum fill_rule_t  v)
static

Returns a c_string for an enumerated value.

Parameters
vvalue to get the label-string of.

◆ label() [7/9]

static c_string fastuidraw::PainterEnums::label ( enum stroking_method_t  v)
static

Returns a c_string for an enumerated value.

Parameters
vvalue to get the label-string of.

◆ label() [8/9]

static c_string fastuidraw::PainterEnums::label ( enum blend_mode_t  v)
static

Returns a c_string for an enumerated value.

Parameters
vvalue to get the label-string of.

◆ label() [9/9]

static c_string fastuidraw::PainterEnums::label ( enum query_stats_t  v)
static

Returns a c_string for an enumerated value.

Parameters
vvalue to get the label-string of.

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