Clutter::CairoTexture(3) Texture with Cairo integration


my $texture = Clutter::CairoTexture->new(64, 64);
my $cr = $texture->create_context();
# use Cairo API to draw on the Cairo::Context
# destroys the Context and uploads the contents to the
# CairoTexture; alternatively, you can let $cr go out
# of scope
$cr = undef;


Clutter::CairoTexture is a Clutter::Texture that displays the contents of a Cairo::Context. The Clutter::CairoTexture actor will create a Cairo image surface which will then be uploaded to a GL texture when needed.

Clutter::CairoTexture will provide a Cairo::Context by using the Clutter::CairoTexture::create_context() and the Clutter::CairoTexture::create_context_for_region() methods; you can use the Cairo API to draw on the context and then destroy the context when done.

As soon as the context is destroyed, the contents of the surface will be uploaded into the Clutter::CairoTexture actor.

Although a new Cairo::Context is created each time you call the create_context() or the create_context_for_region() methods, the CairoTexture will use the same image surface. You can call Clutter::CairoTexturr::clear() to erase the contents between calls.

Warning: Note that you should never use the code above inside the Clutter::Actor::PAINT or Clutter::Actor::PICK virtual functions or signal handlers because it will lead to performance degradation.






actor = Clutter::CairoTexture->new ($width, $height)

  • $width (integer)
  • $height (integer)


scalar = $texture->create_context

scalar = $texture->create_context_for_region ($x_offset, $y_offset, $width, $height)

  • $x_offset (integer)
  • $y_offset (integer)
  • $width (integer)
  • $height (integer)

list = $texture->get_surface_size

$texture->set_surface_size ($width, $height)

  • $width (integer)
  • $height (integer)


'surface-height' (Glib::UInt : readable / writable / private)
Surface Height
'surface-width' (Glib::UInt : readable / writable / private)
Surface Width

Clutter::Texture, Cairo


Copyright (C) 2006, 2007, 2008 OpenedHand Ltd

Copyright (C) 2009 Intel Corporation

This module is free software; you can redistribute it and/or modify it under the terms of either:

  • the GNU Lesser General Public Library version 2.1; or
  • the Artistic License, version 2.0.

See Clutter for the full copyright notice.