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

A PainterGradientBrushShaderData defines the PainterBrushShaderData that the shaders of a PainterGradientBrushShader consume. It specifies what ColorStopSequence to use together with the geometric properties of the gradient. More...

#include <painter_gradient_brush_shader_data.hpp>

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

Public Types

enum  color_stop_xy_encoding { color_stop_x_num_bits = 16, color_stop_y_num_bits = 16, color_stop_x_bit0 = 0, color_stop_y_bit0 = color_stop_x_num_bits }
 Bit encoding for packing ColorStopSequence::texel_location() More...
 
enum  gradient_offset_t {
  p0_x_offset = 0, p0_y_offset, p1_x_offset, p1_y_offset,
  color_stop_xy_offset, color_stop_length_offset, linear_data_size, start_radius_offset = linear_data_size,
  end_radius_offset, radial_data_size, sweep_p_x_offset = p0_x_offset, sweep_p_y_offset = p0_y_offset,
  sweep_angle_offset = p1_x_offset, sweep_sign_factor_offset = p1_y_offset, sweep_data_size = linear_data_size
}
 Enumeration that provides offset, in units of uint32_t, of the packing of the gradient 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
}
 

Public Member Functions

 PainterGradientBrushShaderData (void)
 
 PainterGradientBrushShaderData (const PainterGradientBrushShaderData &obj)
 
c_array< const reference_counted_ptr< const Image > > bind_images (void) const override
 
const reference_counted_ptr< const ColorStopSequence > & color_stops (void) const
 
unsigned int data_size (void) const override
 
PainterGradientBrushShaderDatalinear_gradient (const reference_counted_ptr< const ColorStopSequence > &cs, const vec2 &start_p, const vec2 &end_p)
 
unsigned int number_resources (void) const override
 
PainterGradientBrushShaderDataoperator= (const PainterGradientBrushShaderData &obj)
 
void pack_data (c_array< uvec4 > dst) const override
 
PainterGradientBrushShaderDataradial_gradient (const reference_counted_ptr< const ColorStopSequence > &cs, const vec2 &start_p, float start_r, const vec2 &end_p, float end_r)
 
PainterGradientBrushShaderDataradial_gradient (const reference_counted_ptr< const ColorStopSequence > &cs, const vec2 &p, float r)
 
PainterGradientBrushShaderDatareset (void)
 
void save_resources (c_array< reference_counted_ptr< const resource_base > > dst) const override
 
PainterGradientBrushShaderDatasweep_gradient (const reference_counted_ptr< const ColorStopSequence > &cs, const vec2 &p, float theta, float F=1.0f)
 
PainterGradientBrushShaderDatasweep_gradient (const reference_counted_ptr< const ColorStopSequence > &cs, const vec2 &p, float theta, enum PainterEnums::screen_orientation orientation, enum PainterEnums::rotation_orientation_t rotation_orientation, float F)
 
PainterGradientBrushShaderDatasweep_gradient (const reference_counted_ptr< const ColorStopSequence > &cs, const vec2 &p, float theta, enum PainterEnums::screen_orientation orientation, enum PainterEnums::rotation_orientation_t rotation_orientation)
 
enum gradient_type_t type (void) const
 

Detailed Description

A PainterGradientBrushShaderData defines the PainterBrushShaderData that the shaders of a PainterGradientBrushShader consume. It specifies what ColorStopSequence to use together with the geometric properties of the gradient.

Definition at line 42 of file painter_gradient_brush_shader_data.hpp.

Member Enumeration Documentation

◆ color_stop_xy_encoding

Bit encoding for packing ColorStopSequence::texel_location()

Enumerator
color_stop_x_num_bits 

number bits to encode ColorStopSequence::texel_location().x()

color_stop_y_num_bits 

number bits to encode ColorStopSequence::texel_location().y()

color_stop_x_bit0 

where ColorStopSequence::texel_location().x() is encoded

color_stop_y_bit0 

where ColorStopSequence::texel_location().y() is encoded

Definition at line 51 of file painter_gradient_brush_shader_data.hpp.

◆ gradient_offset_t

Enumeration that provides offset, in units of uint32_t, of the packing of the gradient data.

Enumerator
p0_x_offset 

Offset to x-coordinate of starting point of both linear and radial gradients (packed at float)

p0_y_offset 

Offset to y-coordinate of starting point of both linear and radial gradients (packed at float)

p1_x_offset 

Offset to x-coordinate of ending point of both linear and radial gradients (packed at float)

p1_y_offset 

Offset to y-coordinate of ending point of both linear and radial gradients (packed at float)

color_stop_xy_offset 

Offset to the x and y-location of the color stops. The offset is stored as a uint32 packed as according in the enumeration color_stop_xy_encoding

color_stop_length_offset 

Offset to the length of the color stop in -texels-, i.e. ColorStopSequence::width(), packed as a uint32

linear_data_size 

Size of the data for linear gradients.

start_radius_offset 

Offset to starting radius of gradient (packed at float) (radial gradient only)

end_radius_offset 

Offset to ending radius of gradient (packed at float) (radial gradient only)

radial_data_size 

Size of the data for radial gradients.

sweep_p_x_offset 

Offset to the x-coordinate of the point of a sweep gradient.

sweep_p_y_offset 

Offset to the y-coordinate of the point of a sweep gradient.

sweep_angle_offset 

Offset to the angle of a sweep gradient.

sweep_sign_factor_offset 

Offset to the sign-factor of the sweep gradient. The sign of the value is the sign of the sweep gradient and the magnitude is the repeat factor of the gradient.

sweep_data_size 

Size of the data for sweep gradients.

Definition at line 65 of file painter_gradient_brush_shader_data.hpp.

Constructor & Destructor Documentation

◆ PainterGradientBrushShaderData() [1/2]

fastuidraw::PainterGradientBrushShaderData::PainterGradientBrushShaderData ( void  )
inline

Ctor. Initializes the brush to have no gradient.

Definition at line 160 of file painter_gradient_brush_shader_data.hpp.

◆ PainterGradientBrushShaderData() [2/2]

fastuidraw::PainterGradientBrushShaderData::PainterGradientBrushShaderData ( const PainterGradientBrushShaderData obj)
inline

Copy ctor.

Definition at line 166 of file painter_gradient_brush_shader_data.hpp.

Member Function Documentation

◆ bind_images()

c_array<const reference_counted_ptr<const Image> > fastuidraw::PainterGradientBrushShaderData::bind_images ( void  ) const
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 360 of file painter_gradient_brush_shader_data.hpp.

◆ color_stops()

const reference_counted_ptr<const ColorStopSequence>& fastuidraw::PainterGradientBrushShaderData::color_stops ( void  ) const
inline

Returns the value of the handle to the ColorStopSequence that the brush is set to use.

Definition at line 207 of file painter_gradient_brush_shader_data.hpp.

◆ data_size()

unsigned int fastuidraw::PainterGradientBrushShaderData::data_size ( void  ) const
overridevirtual

To be implemented by a derived class to return the number of uvec4 blocks needed to pack the data.

Implements fastuidraw::PainterBrushShaderData.

◆ linear_gradient()

PainterGradientBrushShaderData& fastuidraw::PainterGradientBrushShaderData::linear_gradient ( const reference_counted_ptr< const ColorStopSequence > &  cs,
const vec2 start_p,
const vec2 end_p 
)
inline

Sets the brush to have a linear gradient.

Parameters
cscolor stops for gradient. If handle is invalid, then sets brush to not have a gradient.
start_pstart position of gradient
end_pend position of gradient.

Definition at line 220 of file painter_gradient_brush_shader_data.hpp.

◆ number_resources()

unsigned int fastuidraw::PainterGradientBrushShaderData::number_resources ( void  ) const
overridevirtual

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.

◆ operator=()

PainterGradientBrushShaderData& fastuidraw::PainterGradientBrushShaderData::operator= ( const PainterGradientBrushShaderData obj)
inline

Assignment operator.

Parameters
objvalue from which to copy

Definition at line 175 of file painter_gradient_brush_shader_data.hpp.

◆ pack_data()

void fastuidraw::PainterGradientBrushShaderData::pack_data ( c_array< uvec4 dst) const
overridevirtual

To be implemented by a derived class to pack the data.

Parameters
dstlocation to which to pack the data

Implements fastuidraw::PainterBrushShaderData.

◆ radial_gradient() [1/2]

PainterGradientBrushShaderData& fastuidraw::PainterGradientBrushShaderData::radial_gradient ( const reference_counted_ptr< const ColorStopSequence > &  cs,
const vec2 start_p,
float  start_r,
const vec2 end_p,
float  end_r 
)
inline

Sets the brush to have a radial gradient.

Parameters
cscolor stops for gradient. If handle is invalid, then sets brush to not have a gradient.
start_pstart position of gradient
start_rstarting radius of radial gradient
end_pend position of gradient.
end_rending radius of radial gradient

Definition at line 240 of file painter_gradient_brush_shader_data.hpp.

◆ radial_gradient() [2/2]

PainterGradientBrushShaderData& fastuidraw::PainterGradientBrushShaderData::radial_gradient ( const reference_counted_ptr< const ColorStopSequence > &  cs,
const vec2 p,
float  r 
)
inline

Sets the brush to have a radial gradient. Provided as a conveniance, equivalent to

radial_gradient(cs, p, 0.0f, p, r);
Parameters
cscolor stops for gradient. If handle is invalid, then sets brush to not have a gradient.
pstart and end position of gradient
rending radius of radial gradient

Definition at line 265 of file painter_gradient_brush_shader_data.hpp.

◆ reset()

PainterGradientBrushShaderData& fastuidraw::PainterGradientBrushShaderData::reset ( void  )
inline

Reset the brush to initial conditions.

Definition at line 185 of file painter_gradient_brush_shader_data.hpp.

◆ save_resources()

void fastuidraw::PainterGradientBrushShaderData::save_resources ( c_array< reference_counted_ptr< const resource_base > >  dst) const
overridevirtual

To be optionally implemented by a derived class to save references to resources that need to be resident after packing. Default implementation does nothing.

Parameters
dstlocation to which to save resources.

Reimplemented from fastuidraw::PainterBrushShaderData.

◆ sweep_gradient() [1/3]

PainterGradientBrushShaderData& fastuidraw::PainterGradientBrushShaderData::sweep_gradient ( const reference_counted_ptr< const ColorStopSequence > &  cs,
const vec2 p,
float  theta,
float  F = 1.0f 
)
inline

Sets the brush to have a sweep gradient (directly).

Parameters
cscolor stops for gradient. If handle is invalid, then sets brush to not have a gradient.
pposition of gradient
thetastart angle of the sweep gradient, this value should be in the range [-PI, PI]
Fthe repeat factor applied to the interpolate, the sign of F is used to determine the sign of the sweep gradient.

Definition at line 283 of file painter_gradient_brush_shader_data.hpp.

◆ sweep_gradient() [2/3]

PainterGradientBrushShaderData& fastuidraw::PainterGradientBrushShaderData::sweep_gradient ( const reference_counted_ptr< const ColorStopSequence > &  cs,
const vec2 p,
float  theta,
enum PainterEnums::screen_orientation  orientation,
enum PainterEnums::rotation_orientation_t  rotation_orientation,
float  F 
)
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.

Parameters
cscolor stops for gradient. If handle is invalid, then sets brush to not have a gradient.
pposition of gradient
thetaangle of the sweep gradient, this value should be in the range [-PI, PI]
Fthe repeat factor applied to the interpolate, a negative reverses the orientation of the sweep.
orientationorientation of the screen
rotation_orientationorientation of the sweep

Definition at line 308 of file painter_gradient_brush_shader_data.hpp.

◆ sweep_gradient() [3/3]

PainterGradientBrushShaderData& fastuidraw::PainterGradientBrushShaderData::sweep_gradient ( const reference_counted_ptr< const ColorStopSequence > &  cs,
const vec2 p,
float  theta,
enum PainterEnums::screen_orientation  orientation,
enum PainterEnums::rotation_orientation_t  rotation_orientation 
)
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

sweep_gradient(cs, p, theta, orientation, rotation_orientation, 1.0f, repeat);
Parameters
cscolor stops for gradient. If handle is invalid, then sets brush to not have a gradient.
pposition of gradient
thetaangle of the sweep gradient, this value should be in the range [-PI, PI]
orientationorientation of the screen
rotation_orientationorientation of the sweep

Definition at line 339 of file painter_gradient_brush_shader_data.hpp.

◆ type()

enum gradient_type_t fastuidraw::PainterGradientBrushShaderData::type ( void  ) const
inline

Returns the type of gradient the data specifies.

Definition at line 196 of file painter_gradient_brush_shader_data.hpp.


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