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

A PainterImageBrushShader represents a single PainterBrushShader together with sub-shaders of it that can be used to apply an Image. The sub-shader ID is used to describe the Image::type(), Image::format(), what filtering and mipmapping to apply to the image data. More...

#include <painter_image_brush_shader.hpp>

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

Public Types

enum  sub_shader_bits {
  filter_num_bits = 2, mipmap_num_bits = 7, type_num_bits = 4, format_num_bits = 1,
  filter_bit0 = 0, mipmap_bit0 = filter_bit0 + filter_num_bits, type_bit0 = mipmap_bit0 + mipmap_num_bits, format_bit0 = type_bit0 + type_num_bits,
  number_bits = format_bit0 + format_num_bits, number_sub_shaders = 1u << number_bits
}
 Enumeration describing the roles of the bits for the sub-shader ID's. More...
 
enum  sub_shader_masks { filter_mask = FASTUIDRAW_MASK(filter_bit0, filter_num_bits), mipmap_mask = FASTUIDRAW_MASK(mipmap_bit0, mipmap_num_bits), type_mask = FASTUIDRAW_MASK(type_bit0, type_num_bits), format_mask = FASTUIDRAW_MASK(format_bit0, format_num_bits) }
 
- 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

 PainterImageBrushShader (const reference_counted_ptr< PainterBrushShader > &parent_shader)
 
PainterCustomBrush create_brush (PainterPackedValuePool &pool, const reference_counted_ptr< const Image > &image, uvec2 xy, uvec2 wh, enum filter_t image_filter=filter_linear, enum mipmap_t mip_mapping=apply_mipmapping) const
 
PainterCustomBrush create_brush (PainterPackedValuePool &pool, const reference_counted_ptr< const Image > &image, enum filter_t image_filter=filter_linear, enum mipmap_t mip_mapping=apply_mipmapping) const
 
const reference_counted_ptr< PainterBrushShader > & sub_shader (const Image *image, enum filter_t image_filter, enum mipmap_t mip_mapping) const
 
c_array< const reference_counted_ptr< PainterBrushShader > > sub_shaders (void) const
 
- Public Member Functions inherited from fastuidraw::reference_counted_base< T, Counter >
 reference_counted_base (void)
 

Static Public Member Functions

static uint32_t sub_shader_id (const Image *image, enum filter_t image_filter, enum mipmap_t mip_mapping)
 
- Static Public Member Functions inherited from fastuidraw::reference_counted_base< T, Counter >
static void add_reference (const reference_counted_base< T, Counter > *p)
 
static void remove_reference (const reference_counted_base< T, Counter > *p)
 

Detailed Description

A PainterImageBrushShader represents a single PainterBrushShader together with sub-shaders of it that can be used to apply an Image. The sub-shader ID is used to describe the Image::type(), Image::format(), what filtering and mipmapping to apply to the image data.

Definition at line 41 of file painter_image_brush_shader.hpp.

Member Enumeration Documentation

◆ sub_shader_bits

Enumeration describing the roles of the bits for the sub-shader ID's.

Enumerator
filter_num_bits 

Number of bits needed to encode filter for image. A value of 0 indicates no image applied, a non-zero value indicates an image applied and the value specifies what filter via the enumeration PainterBrushEnums::filter_t.

mipmap_num_bits 

Number of bits used to encode number of mipmap levels (when an image is present).

type_num_bits 

Number of bits needed to encode the image type (when an image is present). The possible values are given by the enumeration Image::type_t.

format_num_bits 

Number of bits needed to encode the value of Image::format().

filter_bit0 

first bit for if image is present on the brush and if so, what filter

mipmap_bit0 

first bit to indicate maximum mipmap level to use

type_bit0 

First bit to hold the type of image present if an image is present; the value is the enumeration in Image::type_t

format_bit0 

First bit to encode Image::format_t

number_bits 

The total number of bits needed to specify the sub-shader IDs.

number_sub_shaders 

the total number of sub-shaders

Definition at line 51 of file painter_image_brush_shader.hpp.

◆ sub_shader_masks

Various bit-mask values derived from sub_shader_bits

Enumerator
filter_mask 

mask generated from filter_bit0 and filter_num_bits

mipmap_mask 

mask generated from mipmap_bit0 and mipmap_num_bits

type_mask 

mask generated from type_bit0 and type_num_bits

format_mask 

mask generated from format_bit0 and format_num_bits

Definition at line 116 of file painter_image_brush_shader.hpp.

Constructor & Destructor Documentation

◆ PainterImageBrushShader()

fastuidraw::PainterImageBrushShader::PainterImageBrushShader ( const reference_counted_ptr< PainterBrushShader > &  parent_shader)
explicit

Ctor.

Parameters
parent_shaderthe parent PainterBrushShader that implements image-brush shading and has number_sub_shaders that implement brush shading where the I'th sub-shader implement brush shading as described by extracting from the bits of I the values as encoded by sub_shader_bits

Member Function Documentation

◆ create_brush() [1/2]

PainterCustomBrush fastuidraw::PainterImageBrushShader::create_brush ( PainterPackedValuePool pool,
const reference_counted_ptr< const Image > &  image,
uvec2  xy,
uvec2  wh,
enum filter_t  image_filter = filter_linear,
enum mipmap_t  mip_mapping = apply_mipmapping 
) const

Create a PainterCustomBrush with packed data to brush by sourcing from a sub-rectangle of an Image.

Parameters
poolPainterPackedValuePool used to create the packed value
imageImage from which to source
xyminx-miny corner of sub-rectangle
whwidth and height of sub-rectangle
image_filterfiltering to apply to image
mip_mappingmipmapping to apply to image

◆ create_brush() [2/2]

PainterCustomBrush fastuidraw::PainterImageBrushShader::create_brush ( PainterPackedValuePool pool,
const reference_counted_ptr< const Image > &  image,
enum filter_t  image_filter = filter_linear,
enum mipmap_t  mip_mapping = apply_mipmapping 
) const

Create a PainterCustomBrush with packed data to brush by sourcing from the entirity of an Image.

Parameters
poolPainterPackedValuePool used to create the packed value
imageImage from which to source
image_filterfiltering to apply to image
mip_mappingmipmapping to apply to image

◆ sub_shader()

const reference_counted_ptr<PainterBrushShader>& fastuidraw::PainterImageBrushShader::sub_shader ( const Image image,
enum filter_t  image_filter,
enum mipmap_t  mip_mapping 
) const
Parameters
imageImage from which the brush-image will source; a nullptr value indicates no image and the brush-image will emit constant color white fully opaque
image_filterfiltering to apply to image
mip_mappingmipmapping to apply to image

◆ sub_shader_id()

static uint32_t fastuidraw::PainterImageBrushShader::sub_shader_id ( const Image image,
enum filter_t  image_filter,
enum mipmap_t  mip_mapping 
)
static

Produce the sub-shader ID from what Image and how to sample from the image.

Parameters
imageImage from which the brush-image will source; a nullptr value indicates no image and the brush-image will emit constant color white fully opaque
image_filterfiltering to apply to image
mip_mappingmipmapping to apply to image

◆ sub_shaders()

c_array<const reference_counted_ptr<PainterBrushShader> > fastuidraw::PainterImageBrushShader::sub_shaders ( void  ) const

returns all the sub-shaders of the PainterImageBrushShader


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