gtkmm 3.24.7
Functions
Gdk::Cairo Namespace Reference

Functions

void set_source_color (const ::Cairo::RefPtr< ::Cairo::Context > & context, const Gdk::Color & color)
 Sets the specified Gdk::Color as the source color of the Cairo context. More...
 
void set_source_rgba (const ::Cairo::RefPtr< ::Cairo::Context > & context, const Gdk::RGBA & color)
 Sets the specified Gdk::RGBA as the source color of the Cairo context. More...
 
void set_source_pixbuf (const ::Cairo::RefPtr< ::Cairo::Context > & context, const Glib::RefPtr< Gdk::Pixbuf > & pixbuf, double pixbuf_x=0, double pixbuf_y=0)
 Sets the given pixbuf as the source pattern for the Cairo context. More...
 
void add_rectangle_to_path (const ::Cairo::RefPtr< ::Cairo::Context > & context, const Gdk::Rectangle & rectangle)
 Adds the given rectangle to the current path of the context. More...
 
void add_region_to_path (const ::Cairo::RefPtr< ::Cairo::Context > & context, const ::Cairo::RefPtr< ::Cairo::Region > & region)
 Adds the given region to the current path of the context. More...
 
bool get_clip_rectangle (const ::Cairo::RefPtr< ::Cairo::Context > & context, Gdk::Rectangle & rectangle)
 This is a convenience function around Cairo::Context::get_clip_extents(). More...
 
bool get_clip_rectangle (const ::Cairo::RefPtr< ::Cairo::Context > & context)
 This is a convenience function around Cairo::Context::get_clip_extents(). More...
 
::Cairo::RefPtr< ::Cairo::Region > create_region_from_surface (const ::Cairo::RefPtr< ::Cairo::Surface > & surface)
 Creates a region that covers the area where the given surface is more than 50% opaque. More...
 
::Cairo::RefPtr< ::Cairo::ImageSurface > create_surface_from_pixbuf (const Glib::RefPtr< const Gdk::Pixbuf > & pixbuf, int scale, const Glib::RefPtr< Gdk::Window > & for_window={})
 Creates an image surface with the same contents as the pixbuf. More...
 
void draw_from_gl (const ::Cairo::RefPtr< ::Cairo::Context > & context, const Glib::RefPtr< Gdk::Window > & window, int source, int source_type, int buffer_scale, int x, int y, int width, int height)
 This is the main way to draw GL content in gtkmm. More...
 

Function Documentation

◆ add_rectangle_to_path()

void Gdk::Cairo::add_rectangle_to_path ( const ::Cairo::RefPtr< ::Cairo::Context > &  context,
const Gdk::Rectangle rectangle 
)

Adds the given rectangle to the current path of the context.

Parameters
contextA cairo context.
rectangleA rectangle to add to the path of the context.
Since gtkmm 2.10:

◆ add_region_to_path()

void Gdk::Cairo::add_region_to_path ( const ::Cairo::RefPtr< ::Cairo::Context > &  context,
const ::Cairo::RefPtr< ::Cairo::Region > &  region 
)

Adds the given region to the current path of the context.

Parameters
contextA cairo context.
regionA region to add to the path of the context.
Since gtkmm 2.10:

◆ create_region_from_surface()

::Cairo::RefPtr< ::Cairo::Region > Gdk::Cairo::create_region_from_surface ( const ::Cairo::RefPtr< ::Cairo::Surface > &  surface)

Creates a region that covers the area where the given surface is more than 50% opaque.

This function takes into account device offsets that might be set with Cairo::Surface::set_device_offset().

Parameters
surfaceA cairo surface.
Returns
A cairo region.
Since gtkmm 3.24:

◆ create_surface_from_pixbuf()

::Cairo::RefPtr< ::Cairo::ImageSurface > Gdk::Cairo::create_surface_from_pixbuf ( const Glib::RefPtr< const Gdk::Pixbuf > &  pixbuf,
int  scale,
const Glib::RefPtr< Gdk::Window > &  for_window = {} 
)

Creates an image surface with the same contents as the pixbuf.

Parameters
pixbufA Gdk::Pixbuf.
scaleThe scale of the new surface, or 0 to use same as for_window.
for_windowThe window this will be drawn to, or an empty Glib::RefPtr<Gdk::Window> if none.
Returns
A new cairo surface.
Since gtkmm 3.24:

◆ draw_from_gl()

void Gdk::Cairo::draw_from_gl ( const ::Cairo::RefPtr< ::Cairo::Context > &  context,
const Glib::RefPtr< Gdk::Window > &  window,
int  source,
int  source_type,
int  buffer_scale,
int  x,
int  y,
int  width,
int  height 
)

This is the main way to draw GL content in gtkmm.

It takes a render buffer ID (source_type == GL_RENDERBUFFER) or a texture id (source_type == GL_TEXTURE) and draws it onto context with an OVER operation, respecting the current clip. The top left corner of the rectangle specified by x, y, width and height will be drawn at the current (0,0) position of the cairo context.

This will work for all cairo contexts, as long as window is realized, but the fallback implementation that reads back the pixels from the buffer may be used in the general case. In the case of direct drawing to a window with no special effects applied to context it will however use a more efficient approach.

For GL_RENDERBUFFER the code will always fall back to software for buffers with alpha components, so make sure you use GL_TEXTURE if using alpha.

Calling this may change the current GL context.

Parameters
contextA cairo context.
windowThe window we're rendering for (not necessarily into).
sourceThe GL ID of the source buffer.
source_typeThe type of the source.
buffer_scaleThe scale-factor that the source buffer is allocated for.
xThe source x position in source to start copying from in GL coordinates.
yThe source y position in source to start copying from in GL coordinates.
widthThe width of the region to draw.
heightThe height of the region to draw.
Since gtkmm 3.24:

◆ get_clip_rectangle() [1/2]

bool Gdk::Cairo::get_clip_rectangle ( const ::Cairo::RefPtr< ::Cairo::Context > &  context)

This is a convenience function around Cairo::Context::get_clip_extents().

Parameters
contextA cairo context.
Returns
true if a clip rectangle exists, false if all of context is clipped and all drawing can be skipped.
Since gtkmm 3.24:

◆ get_clip_rectangle() [2/2]

bool Gdk::Cairo::get_clip_rectangle ( const ::Cairo::RefPtr< ::Cairo::Context > &  context,
Gdk::Rectangle rectangle 
)

This is a convenience function around Cairo::Context::get_clip_extents().

It rounds the clip extents to integer coordinates and returns a boolean indicating if a clip area exists.

Parameters
contextA cairo context.
[out]rectangleReturn location for the clip rectangle.
Returns
true if a clip rectangle exists, false if all of context is clipped and all drawing can be skipped.
Since gtkmm 3.24:

◆ set_source_color()

void Gdk::Cairo::set_source_color ( const ::Cairo::RefPtr< ::Cairo::Context > &  context,
const Gdk::Color color 
)

Sets the specified Gdk::Color as the source color of the Cairo context.

Parameters
contextThe cairo context.
colorThe color to use as the source color.
Since gtkmm 2.10:
Deprecated:
Use set_source_rgba() instead.

◆ set_source_pixbuf()

void Gdk::Cairo::set_source_pixbuf ( const ::Cairo::RefPtr< ::Cairo::Context > &  context,
const Glib::RefPtr< Gdk::Pixbuf > &  pixbuf,
double  pixbuf_x = 0,
double  pixbuf_y = 0 
)

Sets the given pixbuf as the source pattern for the Cairo context.

The pattern has an extend mode of Cairo::EXTEND_NONE and is aligned so that the origin of pixbuf is pixbuf_x, pixbuf_y.

Parameters
contextThe cairo context.
pixbufA Gdk::Pixbuf
pixbuf_xX coordinate of location to place upper left corner of pixbuf.
pixbuf_yY coordinate of location to place upper left corner of pixbuf.
Since gtkmm 2.10:

◆ set_source_rgba()

void Gdk::Cairo::set_source_rgba ( const ::Cairo::RefPtr< ::Cairo::Context > &  context,
const Gdk::RGBA color 
)

Sets the specified Gdk::RGBA as the source color of the Cairo context.

Parameters
contextThe cairo context.
colorThe color to use as the source color.
Since gtkmm 3.0: