Trait gdk4::prelude::GdkCairoContextExt
source · pub trait GdkCairoContextExt: Sealed {
// Provided methods
unsafe fn draw_from_gl(
&self,
surface: &Surface,
source: i32,
source_type: i32,
buffer_scale: i32,
x: i32,
y: i32,
width: i32,
height: i32
) { ... }
fn set_source_color(&self, rgba: &RGBA) { ... }
fn set_source_pixbuf(&self, pixbuf: &Pixbuf, x: f64, y: f64) { ... }
fn add_rectangle(&self, rectangle: &Rectangle) { ... }
fn add_region(&self, region: &Region) { ... }
}
Expand description
Trait containing integration methods with cairo::Context
.
Provided Methods§
sourceunsafe fn draw_from_gl(
&self,
surface: &Surface,
source: i32,
source_type: i32,
buffer_scale: i32,
x: i32,
y: i32,
width: i32,
height: i32
)
unsafe fn draw_from_gl( &self, surface: &Surface, source: i32, source_type: i32, buffer_scale: i32, x: i32, y: i32, width: i32, height: i32 )
§Safety
It’s the responsibility of the caller to ensure that source is a valid GL resource. The main way to not draw GL content in GTK.
It takes a render buffer ID (@source_type == GL_RENDERBUFFER) or a texture
id (@source_type == GL_TEXTURE) and draws it onto @cr 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::Context
, as long as @surface 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 surface with
no special effects applied to @cr 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.
§Deprecated since 4.6
The function is overly complex and produces broken output
in various combinations of arguments. If you want to draw with GL textures
in GTK, use GLTexture::new()
; if you want to use that texture in
Cairo, use TextureExtManual::download()
to download the data into a Cairo
image surface.
§cr
a cairo context
§surface
The surface we’re rendering for (not necessarily into)
§source
The GL ID of the source buffer
§source_type
The type of the @source
§buffer_scale
The scale-factor that the @source buffer is allocated for
§x
The source x position in @source to start copying from in GL coordinates
§y
The source y position in @source to start copying from in GL coordinates
§width
The width of the region to draw
§height
The height of the region to draw
fn set_source_color(&self, rgba: &RGBA)
sourcefn set_source_pixbuf(&self, pixbuf: &Pixbuf, x: f64, y: f64)
fn set_source_pixbuf(&self, pixbuf: &Pixbuf, x: f64, y: f64)
Sets the given pixbuf as the source pattern for @cr.
The pattern has an extend mode of CAIRO_EXTEND_NONE
and is aligned
so that the origin of @pixbuf is @pixbuf_x, @pixbuf_y.
§cr
a cairo context
§pixbuf
§pixbuf_x
X coordinate of location to place upper left corner of @pixbuf
§pixbuf_y
Y coordinate of location to place upper left corner of @pixbuf