Clarisse 4.0 SP5b SDK  4.0.0.0.5.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Member Functions | List of all members
ModuleLayer Class Reference

This class implements a Layer object in Clarisse.
The Layer objects contains two arrays (internally called pyramids) that store the renders of various qualities that have been computed. One array stores the raw image (the source pyramid), the other one the result after filters have been applied.
Dirtiness information is associated with each of theses renders.
The canvas of these images matches the parent image's, or the render region if one is set. More...

Inheritance diagram for ModuleLayer:
ModuleProjectItem ModuleObject OfModule ResourceUser EventObject CoreCustomData CoreBaseObject CoreBaseType ModuleLayer3d

Public Member Functions

virtual void destroy_all ()
 
unsigned int get_width () const
 Returns the width of the layer.
 
unsigned int get_height () const
 Returns the height of the layer.
 
ModuleImageget_parent_image () const
 Returns the ModuleImage containing the layer.
 
const double & get_opacity () const
 Returns the opacity of the layer.
 
const int & get_blending_mode () const
 Returns the blending mode of the layer.
 
bool is_active () const
 Returns whether the current layer is active or not. Inactive layers are not composited in the final image.
 
virtual ImageHandle get_image (const ModuleImage::Quality &quality, const GMathVec4f *region=0) const
 Returns a handle to the image for the specified quality. If the image is not already available, a render is started. The function returns only when the render is finished.
 
virtual bool is_image_dirty (const ModuleImage::Quality &quality, const bool &strict=false) const
 Checks if the specified quality has already been computed.
 
const ImageCanvaspeek_source_image (const ModuleImage::Quality &quality) const
 Just returns a handle to the current image; does not launch evaluation.
 
bool add_image_level_update_callback (void *data, ModuleImage::ImageLevelUpdateCallback on_image_level_update)
 This function registers a new "image level update" callback item. The callback function is called every time a new render is finished (for each quality).
 
void remove_image_level_update_callback (void *data)
 Removes an image level updated receiver.
 
unsigned int get_image_level_update_receivers_count () const
 Removes an image level updated receiver.
 
void start_progress (const ModuleImage::Quality &quality)
 Starts the mechanism allowing the display of a progress image.
 
void stop_progress (ImageHandle *image)
 Stops the mechanism allowing the display of a progress image.
 
void update_region (const GMathVec4i &region, bool set_progress=true) const
 This function indicates that a new region of the image has been computed.
 
void bucket_render_start (const GMathVec4i &region, unsigned int thread_id)
 
 
void bucket_render_end (const GMathVec4i &region, unsigned int thread_id)
 
 
virtual void dirty_layer (const bool &dirty_source)
 Invalidate images, set dirtiness flags for all qualities.
 
virtual void mark_as_dirty ()
 Set the dirtiness flags of all the ImageCanvas stored in the layer.
 
void dirty_layer_border (GMathVec4f &region)
 Dirty all the tiles of the ImageCanvas that intersect the region.
 
void on_update_visible (const GMathBbox2f &old_region, const GMathBbox2f &new_region)
 Updates the image channels after the visible part of the region has been modified.
 
const bool & is_evaluating () const
 Returns true if a render is in progress.
 
ModuleImage::Quality get_nearest_quality (const unsigned int &w, const unsigned int h) const
 Returns the first quality for which the size of the image is greater than the parameters given.
If none is found, QUALITY_FULL is returned.
 
void image_level_update (const ModuleImage::Quality &quality) const
 Call the image level update callbacks for all registered requesters.
 
const int & get_render_region_mode () const
 Returns how render region is used: is it inherited from the parent image, or defined in the layer itself ?
 
const GMathVec4f & get_render_region_bbox () const
 Returns the values of the render region box.
 
GMathVec4i get_overscan (const ModuleImage::Quality &quality) const
 Returns the overscan, in pixel for the current render.
 
GMathVec4f get_overscan () const
 Returns the overscan values (ratio).
 
GMathVec4i get_data_window (const ModuleImage::Quality &quality) const
 Returns the data region [ x0, y0, w, h].
 
bool update_overscan ()
 Updates the overscan variables from the object attribute values.
 
ImageHandleget_pyramid_source_image (const ModuleImage::Quality &quality) const
 Returns the ImageCanvas stored in the source pyramid for the specified quality.
 
void resize_image (const ImageCanvas &source, ImageCanvas &dest, const ModuleImage::Quality &quality, const int &width, const int &height, const GMathVec4f *render_region) const
 Resize an image.
 
char * get_progress_buffer () const
 Returns the pointer to the buffer that will be used to retrive recently computed pixels.
 
void init_progress_buffer (const int &quality)
 
void update_progress (ModuleImage &image, const CoreString &event, void *data)
 
ImageHandleget_highest_quality_image () const
 Returns the pointer to the best image quality that has been computed. Used to initialize the progress image.
 
size_t get_memory_size () const
 Returns the memory used by the current instance.
 
void set_finalize_image (bool _finalize_image=true)
 
bool get_finalize_image () const
 
ModuleImageFilteradd_filter (const CoreString &class_name, const CoreString &filter_name)
 Adds a new filter.
 
bool has_active_filters () const
 
int get_progress_pixel_count () const
 For internal use.
 
int get_progress_pixel_count_max () const
 For internal use.
 
float get_progress_pixel_percent () const
 For internal use.
 
void set_progress_pixel_count (int count)
 For internal use.
 

Protected Member Functions

virtual const ImageCanvasget_source_image (const ModuleImage::Quality &quality, const GMathVec4f *region=0) const
 
virtual ImageHandlecreate_pyramid_image (const ModuleImage::Quality &quality) const
 
virtual void update_channels (const ModuleImage::Quality &quality) const
 
virtual void on_attribute_change (const OfAttr &attr, int &dirtiness, const int &dirtiness_flags)
 
virtual void module_constructor (OfObject &object)
 
void build_image (const ModuleImage::Quality &quality, const GMathVec4f *region=0) const
 
void dirty_image_channels (const CoreVector< CoreString > &channel_names)
 
void update_image_channels (const CoreVector< CoreString > &remove_channels, const CoreVector< CoreString > &add_channels)
 
void dirty_layer_position ()
 
void image_level_update (const ModuleImage::Quality &quality, ImageHandle image) const
 

Additional Inherited Members

- Public Types inherited from EventObject
typedef void(* EventInfoFunction )(EventObject &, const EventInfo &, void *)
 
typedef void(EventObject::* EventInfoMethod )(EventObject &, const EventInfo &, void *)
 
typedef void(* EventFunction )(EventObject &, const CoreString &, void *)
 
typedef void(EventObject::* EventMethod )(EventObject &, const CoreString &, void *)
 
- Static Public Member Functions inherited from ModuleObject
static ResourceID declare_resource (const char *tag)
 
static ResourceID declare_resource (const CoreString &tag)
 
static bool declare_resource (ResourceID id, const char *tag)
 
static bool declare_resource (ResourceID id, const CoreString &tag)
 
static ResourceID get_resource_id (const char *tag)
 
static ResourceID get_resource_id (const CoreString &tag)
 
static const char * get_resource_tag (ResourceID id)
 

Detailed Description

This class implements a Layer object in Clarisse.
The Layer objects contains two arrays (internally called pyramids) that store the renders of various qualities that have been computed. One array stores the raw image (the source pyramid), the other one the result after filters have been applied.
Dirtiness information is associated with each of theses renders.
The canvas of these images matches the parent image's, or the render region if one is set.

Member Function Documentation

bool ModuleLayer::add_image_level_update_callback ( void *  data,
ModuleImage::ImageLevelUpdateCallback  on_image_level_update 
)

This function registers a new "image level update" callback item. The callback function is called every time a new render is finished (for each quality).

Parameters
dataPointer used to identify the callback. The pointer is passed to the callbacks as first parameter. We usually use the pointer to the requester. The same pointer need to be given to use the remove the callback function.
See Also
remove_image_level_update_callback.
Parameters
on_image_level_updateFunction called when a render is done.

void ModuleLayer::bucket_render_end ( const GMathVec4i &  region,
unsigned int  thread_id 
)

void ModuleLayer::bucket_render_start ( const GMathVec4i &  region,
unsigned int  thread_id 
)

void ModuleLayer::dirty_layer ( const bool &  dirty_source)
virtual

Invalidate images, set dirtiness flags for all qualities.

Parameters
Ifnot set, the source pyramid will not be affected. Typical case: modifying a filter, as it will not have an effect on the source images.

Reimplemented in ModuleLayer3d.

void ModuleLayer::dirty_layer_border ( GMathVec4f &  region)

Dirty all the tiles of the ImageCanvas that intersect the region.

Note
Only the ImageCanvas in the source pyramid are modified.
Deprecated:
ImageHandle ModuleLayer::get_image ( const ModuleImage::Quality quality,
const GMathVec4f *  region = 0 
) const
virtual

Returns a handle to the image for the specified quality. If the image is not already available, a render is started. The function returns only when the render is finished.

Parameters
qualityImage quality to evaluate
regionRegion to render
Returns
a handle to the evaluated image
Note
Do not call from the mainloop if the requested quality is not already computed.
unsigned int ModuleLayer::get_image_level_update_receivers_count ( ) const

Removes an image level updated receiver.

ModuleImage::Quality ModuleLayer::get_nearest_quality ( const unsigned int &  w,
const unsigned int  h 
) const

Returns the first quality for which the size of the image is greater than the parameters given.
If none is found, QUALITY_FULL is returned.

Note
This function is mainly used when a resized version of the image is created.

bool ModuleLayer::has_active_filters ( ) const
Returns
true if layer has active filters.
void ModuleLayer::image_level_update ( const ModuleImage::Quality quality) const

Call the image level update callbacks for all registered requesters.

bool ModuleLayer::is_image_dirty ( const ModuleImage::Quality quality,
const bool &  strict = false 
) const
virtual

Checks if the specified quality has already been computed.

Parameters
qualityQuality to check
strictIf set to true, the function will return true only the requested quality is computed. If set to false, the function will return true if the requested quality or a better one is available.
void ModuleLayer::on_update_visible ( const GMathBbox2f &  old_region,
const GMathBbox2f &  new_region 
)

Updates the image channels after the visible part of the region has been modified.

Note
This function is used by the render region feature to make sure that the parts of the image are correctly set before rendering. Tiles outside the region are cleared and set to clean, tiles inside or cutting the region are set to dirty, so they are recomputed in the next render.

Note
Only the ImageCanvas in the source pyramid are modified.
void ModuleLayer::remove_image_level_update_callback ( void *  data)

Removes an image level updated receiver.

void ModuleLayer::update_region ( const GMathVec4i &  region,
bool  set_progress = true 
) const

This function indicates that a new region of the image has been computed.

Parameters
regionRegion of the image to update.
set_progressIf set, the progress value is updated using the number of pixels in the region.