FastUIDraw
|
A PainterBrush defines a brush for painting via Painter. More...
#include <painter_brush.hpp>
Public Types | |
enum | feature_bits { image_num_bits = PainterImageBrushShader::number_bits, gradient_num_bits = 4, image_bit0 = 0, gradient_bit0 = image_bit0 + image_num_bits, repeat_window_bit = gradient_bit0 + gradient_num_bits, repeat_window_x_spread_type_bit0, repeat_window_y_spread_type_bit0 = repeat_window_x_spread_type_bit0 + PainterGradientBrushShader::spread_type_num_bits, transformation_translation_bit = repeat_window_y_spread_type_bit0 + PainterGradientBrushShader::spread_type_num_bits, transformation_matrix_bit, number_feature_bits = transformation_matrix_bit + 1 } |
Enumeration describing the roles of the bits for features(). More... | |
enum | feature_masks { image_mask = FASTUIDRAW_MASK(image_bit0, image_num_bits), gradient_mask = FASTUIDRAW_MASK(gradient_bit0, gradient_num_bits), repeat_window_mask = FASTUIDRAW_MASK(repeat_window_bit, 1), repeat_window_x_spread_type_mask, repeat_window_y_spread_type_mask, repeat_window_spread_type_mask = repeat_window_x_spread_type_mask | repeat_window_y_spread_type_mask, transformation_translation_mask = FASTUIDRAW_MASK(transformation_translation_bit, 1), transformation_matrix_mask = FASTUIDRAW_MASK(transformation_matrix_bit, 1) } |
Masks generated from feature_bits, use these masks on the return value of features() to get what features are active on the brush. More... | |
enum | header_offset_t { features_offset, header_red_green_offset, header_blue_alpha_offset, header_data_size } |
enumerations for offsets to color values More... | |
enum | packing_order_t { header_packing, repeat_window_packing, transformation_translation_packing, transformation_matrix_packing, image_packing, gradient_packing } |
Enumeration giving the packing order for data of a brush. Each enumeration is an entry and when data is packed each entry starts on a multiple of the 4. More... | |
enum | repeat_window_offset_t { repeat_window_x_offset, repeat_window_y_offset, repeat_window_width_offset, repeat_window_height_offset, repeat_window_data_size } |
Enumeration that provides offset from the start of repeat window packing to data for repeat window data. More... | |
enum | transformation_matrix_offset_t { transformation_matrix_row0_col0_offset, transformation_matrix_row0_col1_offset, transformation_matrix_row1_col0_offset, transformation_matrix_row1_col1_offset, transformation_matrix_data_size, transformation_matrix_col0_row0_offset = transformation_matrix_row0_col0_offset, transformation_matrix_col0_row1_offset = transformation_matrix_row1_col0_offset, transformation_matrix_col1_row0_offset = transformation_matrix_row0_col1_offset, transformation_matrix_col1_row1_offset = transformation_matrix_row1_col1_offset } |
Enumeration that provides offset from the start of repeat transformation matrix to data for the transformation matrix data. More... | |
enum | transformation_translation_offset_t { transformation_translation_x_offset = 0, transformation_translation_y_offset, transformation_translation_data_size } |
Enumeration that provides offset from the start of repeat transformation translation to data for the transformation translation data. More... | |
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 } |
A PainterBrush defines a brush for painting via Painter.
The brush applies, in the following order:
An item shader's vertex stage provides the coordinate fed to the brush. That coordinate is procesed in the following order before it is fed to the image and gradient:
Definition at line 68 of file painter_brush.hpp.
Enumeration describing the roles of the bits for features().
Enumerator | |
---|---|
image_num_bits | Number of bits needed to encode if and how an Image is sourced from. |
gradient_num_bits | Number of bits used to encode the gradient type, see PainterBrushEnums::gradient_type_t |
image_bit0 | First bit to encode if and how the brush sources from an Image |
gradient_bit0 | first bit used to encode the PainterBrushEnums::gradient_type_t |
repeat_window_bit | Bit up if the brush has a repeat window |
transformation_translation_bit | Bit up if transformation 2x2 matrix is present |
transformation_matrix_bit | Bit up is translation is present |
number_feature_bits | Must be last enum, gives number of bits needed to hold feature bits of a PainterBrush. |
Definition at line 78 of file painter_brush.hpp.
Masks generated from feature_bits, use these masks on the return value of features() to get what features are active on the brush.
Enumerator | |
---|---|
image_mask | mask generated from image_bit0 and image_num_bits |
gradient_mask | mask generated from gradient_bit0 and gradient_num_bits |
repeat_window_mask | mask generated from repeat_window_bit |
repeat_window_x_spread_type_mask | mask generated from repeat_window_x_spread_type and PainterGradientBrushShader::spread_type_num_bits |
repeat_window_y_spread_type_mask | mask generated from repeat_window_y_spread_type and PainterGradientBrushShader::spread_type_num_bits |
repeat_window_spread_type_mask | mask of repeat_window_x_spread_type_mask and repeat_window_y_spread_type bitwise or'd together |
transformation_translation_mask | mask generated from transformation_translation_bit |
transformation_matrix_mask | mask generated from transformation_matrix_bit |
Definition at line 141 of file painter_brush.hpp.
enumerations for offsets to color values
Enumerator | |
---|---|
features_offset | offset to value of features() (packed as uint) |
header_red_green_offset | offset for color red and green value (packed as fp16 pair) |
header_blue_alpha_offset | offset for color blue and alpha value (packed as fp16 pair) |
header_data_size | number of elements to pack color |
Definition at line 240 of file painter_brush.hpp.
Enumeration giving the packing order for data of a brush. Each enumeration is an entry and when data is packed each entry starts on a multiple of the 4.
Enumerator | |
---|---|
header_packing | Color packed first, see header_offset_t for the offsets for the individual fields |
repeat_window_packing | repeat window packing, see repeat_window_offset_t for the offsets for the individual fields |
transformation_translation_packing | transformation_translation, see transformation_translation_offset_t for the offsets of the individual fields |
transformation_matrix_packing | transformation_matrix, see transformation_matrix_offset_t for the offsets of the individual fields |
image_packing | image packing as packed by PainterImageBrushShaderData |
gradient_packing | gradient packing, as packed by PainterGradientBrushShaderData |
Definition at line 195 of file painter_brush.hpp.
Enumeration that provides offset from the start of repeat window packing to data for repeat window data.
Definition at line 254 of file painter_brush.hpp.
Enumeration that provides offset from the start of repeat transformation matrix to data for the transformation matrix data.
Definition at line 269 of file painter_brush.hpp.
Enumeration that provides offset from the start of repeat transformation translation to data for the transformation translation data.
Definition at line 289 of file painter_brush.hpp.
|
inline |
Ctor. Initializes the brush to have no image, no gradient, no repeat window and no transformation with the color as (1.0, 1.0, 1.0, 1.0) which is solid white.
Definition at line 301 of file painter_brush.hpp.
|
inline |
Copy ctor.
Definition at line 307 of file painter_brush.hpp.
|
inline |
Ctor. Initializes the brush to have no image, no gradient, no repeat window and no transformation with the given color color.
pcolor | inital color |
Definition at line 317 of file painter_brush.hpp.
|
inline |
Apply a shear to the transformation of the brush.
m | matrix to which to apply |
Definition at line 610 of file painter_brush.hpp.
|
inline |
Apply a rotation to the transformation of the brush.
angle | in radians by which to rotate |
Definition at line 638 of file painter_brush.hpp.
|
inline |
Apply a shear to the transformation of the brush.
sx | scale factor in x-direction |
sy | scale factor in y-direction |
Definition at line 623 of file painter_brush.hpp.
|
inline |
Apply a translation to the transformation of the brush.
Definition at line 657 of file painter_brush.hpp.
|
inlineoverridevirtual |
To be implemented by a derived class to return a c_array of references to Image objects whose Image::type() value is Image::context_texture2d. The i'th entry in the returned array will be bound to the i'th external texture slot of the backend via the PainterDrawBreakAction objected returned by PainterBackend::bind_image(). Default implementation is to return an empty array.
Reimplemented from fastuidraw::PainterBrushShaderData.
Definition at line 857 of file painter_brush.hpp.
|
inline |
Set the color to the color, default value is (1.0, 1.0, 1.0, 1.0).
Definition at line 343 of file painter_brush.hpp.
|
inline |
Set the color to the color, default value is (1.0, 1.0, 1.0, 1.0).
Definition at line 353 of file painter_brush.hpp.
|
inline |
Returns the current color-color.
Definition at line 362 of file painter_brush.hpp.
|
inline |
Returns the value of the handle to the ColorStopSequence that the brush is set to use.
Definition at line 832 of file painter_brush.hpp.
|
overridevirtual |
To be implemented by a derived class to return the number of uvec4 blocks needed to pack the data.
Implements fastuidraw::PainterBrushShaderData.
uint32_t fastuidraw::PainterBrush::features | ( | void | ) | const |
Returns the brush features which when tested against the bit masks from feature_masks tells what features are active in the brush; features() is decoded as follows:
|
inline |
Return the gradient_type_t that the brush applies.
Definition at line 558 of file painter_brush.hpp.
PainterBrush& fastuidraw::PainterBrush::image | ( | const reference_counted_ptr< const Image > & | im, |
enum filter_t | f = filter_linear , |
||
enum mipmap_t | mipmap_filtering = apply_mipmapping |
||
) |
Sets the brush to have an image.
im | handle to image to use. If handle is invalid, then sets brush to not have an image. |
f | filter to apply to image, only has effect if im is non-nullptr |
mipmap_filtering | specifies if to apply mipmap filtering |
|
inline |
Returns a reference to the Image that the brush is set to use; if there is no such image, returns nullptr.
Definition at line 821 of file painter_brush.hpp.
|
inline |
Sets the brush to have a linear gradient.
cs | color stops for gradient. If handle is invalid, then sets brush to not have a gradient. |
start_p | start position of gradient |
end_p | end position of gradient. |
spread | specifies the gradient spread type |
Definition at line 412 of file painter_brush.hpp.
|
inline |
Sets the brush to not have a gradient.
Definition at line 547 of file painter_brush.hpp.
|
inline |
Sets the brush to not have an image.
Definition at line 398 of file painter_brush.hpp.
|
inline |
Sets the brush to not have a repeat window
Definition at line 783 of file painter_brush.hpp.
|
inline |
Sets the brush to have no transformation.
Definition at line 704 of file painter_brush.hpp.
|
inline |
Sets the brush to have no matrix in its transformation.
Definition at line 693 of file painter_brush.hpp.
|
inline |
Sets the brush to have no translation in its transformation.
Definition at line 682 of file painter_brush.hpp.
|
inlineoverridevirtual |
To be optionally implemented by a derived class to return the number of resources that need to be resident after packing. Default implementation returns 0.
Reimplemented from fastuidraw::PainterBrushShaderData.
Definition at line 851 of file painter_brush.hpp.
|
inline |
Assignment operator.
obj | value from which to copy |
Definition at line 327 of file painter_brush.hpp.
To be implemented by a derived class to pack the data.
dst | location to which to pack the data |
Implements fastuidraw::PainterBrushShaderData.
|
inline |
Sets the brush to have a radial gradient.
cs | color stops for gradient. If handle is invalid, then sets brush to not have a gradient. |
start_p | start position of gradient |
start_r | starting radius of radial gradient |
end_p | end position of gradient. |
end_r | ending radius of radial gradient |
spread | specifies the gradient spread type |
Definition at line 432 of file painter_brush.hpp.
|
inline |
Sets the brush to have a radial gradient. Provided as a conveniance, equivalent to
cs | color stops for gradient. If handle is invalid, then sets brush to not have a gradient. |
p | start and end position of gradient |
r | ending radius of radial gradient |
spread | specifies the gradient spread type |
Definition at line 455 of file painter_brush.hpp.
|
inline |
Sets the brush to have a repeat window
pos | location of repeat window |
size | of repeat window |
x_mode | spread mode for x-coordinate |
y_mode | spread mode for y-coordinate |
Definition at line 719 of file painter_brush.hpp.
Returns true if a repeat window is applied to the brush and writes out the position and size of the repeat window as well.
Definition at line 742 of file painter_brush.hpp.
|
inline |
Returns the x-coordinate spread type. Return value is undefined if the repeat_window() is not active.
Definition at line 755 of file painter_brush.hpp.
|
inline |
Returns the y-coordinate spread type. Return value is undefined if the repeat_window() is not active.
Definition at line 770 of file painter_brush.hpp.
PainterBrush& fastuidraw::PainterBrush::reset | ( | void | ) |
Reset the brush to initial conditions.
|
inlineoverridevirtual |
To be optionally implemented by a derived class to save references to resources that need to be resident after packing. Default implementation does nothing.
dst | location to which to save resources. |
Reimplemented from fastuidraw::PainterBrushShaderData.
Definition at line 844 of file painter_brush.hpp.
PainterBrush& fastuidraw::PainterBrush::sub_image | ( | const reference_counted_ptr< const Image > & | im, |
uvec2 | xy, | ||
uvec2 | wh, | ||
enum filter_t | f = filter_linear , |
||
enum mipmap_t | mipmap_filtering = apply_mipmapping |
||
) |
Set the brush to source from a sub-rectangle of an image
im | handle to image to use |
xy | min-corner of sub-rectangle of image to use |
wh | width and height of sub-rectangle of image to use |
f | filter to apply to image, only has effect if im is non-nullptr |
mipmap_filtering | specifies if to apply mipmap filtering |
|
inline |
Sets the brush to have a sweep gradient (directly).
cs | color stops for gradient. If handle is invalid, then sets brush to not have a gradient. |
p | position of gradient |
theta | start angle of the sweep gradient, this value should be in the range [-PI, PI] |
F | the repeat factor applied to the interpolate, the sign of F is used to determine the sign of the sweep gradient. |
spread | specifies the gradient spread type |
Definition at line 476 of file painter_brush.hpp.
|
inline |
Sets the brush to have a sweep gradient where the sign is determined by a PainterEnums::screen_orientation and a PainterEnums::rotation_orientation_t.
cs | color stops for gradient. If handle is invalid, then sets brush to not have a gradient. |
p | position of gradient |
theta | angle of the sweep gradient, this value should be in the range [-PI, PI] |
F | the repeat factor applied to the interpolate, a negative reverses the orientation of the sweep. |
orientation | orientation of the screen |
rotation_orientation | orientation of the sweep |
spread | specifies the gradient spread type |
Definition at line 501 of file painter_brush.hpp.
|
inline |
Sets the brush to have a sweep gradient with a repeat factor of 1.0 and where the sign is determined by a PainterEnums::screen_orientation and a PainterEnums::rotation_orientation_t. Equivalent to
cs | color stops for gradient. If handle is invalid, then sets brush to not have a gradient. |
p | position of gradient |
theta | angle of the sweep gradient, this value should be in the range [-PI, PI] |
orientation | orientation of the screen |
rotation_orientation | orientation of the sweep |
spread | specifies the gradient spread type |
Definition at line 531 of file painter_brush.hpp.
|
inline |
Sets the brush to have a matrix and translation in its transformation
p | translation value for brush transformation |
m | matrix value for brush transformation |
Definition at line 671 of file painter_brush.hpp.
|
inline |
Sets the brush to have a matrix in its transformation.
m | matrix value for brush transformation |
Definition at line 589 of file painter_brush.hpp.
|
inline |
Returns the matrix of the transformation of the brush.
Definition at line 600 of file painter_brush.hpp.
|
inline |
Sets the brush to have a translation in its transformation.
p | translation value for brush transformation |
Definition at line 568 of file painter_brush.hpp.
|
inline |
Returns the translation of the transformation of the brush.
Definition at line 579 of file painter_brush.hpp.