Class: Gegl::Buffer

Inherits:
TileHandler show all
Defined in:
(unknown)

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TileHandler

#create_tile, #damage_rect, #damage_tile, #dup_tile, #get_source_tile, #lock, #source, #source=, #unlock

Constructor Details

#initialize(extent, backend) ⇒ Gegl::Buffer

Create a new GeglBuffer from a backend, if NULL is passed in the extent of the buffer will be inherited from the extent of the backend.

returns a GeglBuffer, that holds a reference to the provided backend. GeglRectangle.

Parameters:

  • extent (Gegl::Rectangle)

    the geometry of the buffer (origin, width and height) a

  • backend (Gegl::TileBackend)

    an instance of a GeglTileBackend subclass.

Class Method Details

.load(path) ⇒ Gegl::Buffer

Loads an existing GeglBuffer from disk, if it has previously been saved with gegl_buffer_save it should be possible to open through any GIO transport, buffers that have been used as swap needs random access to be opened.

Parameters:

  • path (String)

    the path to a gegl buffer on disk.

Returns:

.open(path) ⇒ Gegl::Buffer

Open an existing on-disk GeglBuffer, this buffer is opened in a monitored state so multiple instances of gegl can share the same buffer. Sets on one buffer are reflected in the other.

Parameters:

  • path (String)

    the path to a gegl buffer on disk.

Returns:

.swap_create_file(suffix) ⇒ Gegl::filename

Generates a unique filename in the GEGL swap directory, suitable for using as swap space. When the file is no longer needed, it may be removed with gegl_buffer_swap_remove_file(); otherwise, it will be removed when gegl_exit() is called. file path, or nil is the swap is disabled. The returned string should be freed with g_free() when no longer needed.

Parameters:

  • suffix (String)

    a string to suffix the filename with, for identification purposes, or nil.

Returns:

  • (Gegl::filename)

    a string containing the full

.swap_has_file(path) ⇒ Boolean

Tests if path is a swap file, that is, if it has been created with gegl_buffer_swap_create_file(), and hasn't been removed yet.

Parameters:

  • path (Gegl::filename)

    a filename

Returns:

  • (Boolean)

.swap_remove_file(path) ⇒ nil

Removes a swap file, generated using gegl_buffer_swap_create_file(), unlinking the file, if exists.

Parameters:

  • path (Gegl::filename)

    the swap file to remove, as returned by gegl_buffer_swap_create_file()

Returns:

  • (nil)

Instance Method Details

#abyssGegl::Rectangle

Return the abyss extent of a buffer, this expands out to the parents extent in subbuffers.

Returns:

  • (Gegl::Rectangle)

#abyss=(abyss) ⇒ Boolean

Changes the size and position of the abyss rectangle of a buffer.

Returns TRUE if the change of abyss was successful.

Parameters:

  • abyss (Gegl::Rectangle)

    new abyss.

Returns:

  • (Boolean)

#abyss_heightInteger

Returns abyss-height.

Returns:

  • (Integer)

    abyss-height

#abyss_height=(abyss_height) ⇒ Integer

Parameters:

  • abyss_height (Integer)

Returns:

  • (Integer)

    abyss-height

  • (Integer)

    abyss-height

#abyss_widthInteger

Returns abyss-width.

Returns:

  • (Integer)

    abyss-width

#abyss_width=(abyss_width) ⇒ Integer

Parameters:

  • abyss_width (Integer)

Returns:

  • (Integer)

    abyss-width

  • (Integer)

    abyss-width

#abyss_xInteger

Returns abyss-x.

Returns:

  • (Integer)

    abyss-x

#abyss_x=(abyss_x) ⇒ Integer

Parameters:

  • abyss_x (Integer)

Returns:

  • (Integer)

    abyss-x

  • (Integer)

    abyss-x

#abyss_yInteger

Returns abyss-y.

Returns:

  • (Integer)

    abyss-y

#abyss_y=(abyss_y) ⇒ Integer

Parameters:

  • abyss_y (Integer)

Returns:

  • (Integer)

    abyss-y

  • (Integer)

    abyss-y

#add_handler(handler) ⇒ nil

Add a new tile handler in the existing chain of tile handler of a GeglBuffer.

Parameters:

  • handler (GObject)

    a Gegl::TileHandler

Returns:

  • (nil)

#backendGegl::TileBackend

Returns backend.

Returns:

#backend=(backend) ⇒ Gegl::TileBackend

Parameters:

Returns:

#clear(roi) ⇒ nil

Clears the provided rectangular region by setting all the associated memory to 0.

Parameters:

  • roi (Gegl::Rectangle)

    a rectangular region

Returns:

  • (nil)

#copy(src_rect, repeat_mode, dst, dst_rect) ⇒ nil

Copy a region from source buffer to destination buffer.

If the babl_formats of the buffers are the same, and the tile boundaries align, this will create copy-on-write tiles in the destination buffer.

This function never does any scaling. When src_rect and dst_rect do not have the same width and height, the size of src_rect is used.

Parameters:

  • src_rect (Gegl::Rectangle)

    source rectangle (or NULL to copy entire source buffer)

  • repeat_mode (Gegl::AbyssPolicy)

    the abyss policy to be using if src_rect is outside src's extent.

  • dst (Gegl::Buffer)

    destination buffer.

  • dst_rect (Gegl::Rectangle)

    position of upper left destination pixel (or NULL to match src_rect)

Returns:

  • (nil)

#create_sub_buffer(extent) ⇒ Gegl::Buffer

Create a new sub GeglBuffer, that is a view on a larger buffer.

Parameters:

  • extent (Gegl::Rectangle)

    coordinates of new buffer.

Returns:

#dupGegl::Buffer

Duplicate a buffer (internally uses gegl_buffer_copy). Aligned tiles will create copy-on-write clones in the new buffer.

Returns:

#extentGegl::Rectangle

Returns a pointer to a GeglRectangle structure defining the geometry of a specific GeglBuffer, this is also the default width/height of buffers passed in to gegl_buffer_set and gegl_buffer_get (with a scale of 1.0 at least).

Returns:

  • (Gegl::Rectangle)

#extent=(extent) ⇒ Boolean

Changes the size and position that is considered active in a buffer, this operation is valid on any buffer, reads on subbuffers outside the master buffer's extent are at the moment undefined.

Returns TRUE if the change of extent was successful.

Parameters:

  • extent (Gegl::Rectangle)

    new extent.

Returns:

  • (Boolean)

#flushnil

Flushes all unsaved data to disk, this is not necessary for shared geglbuffers opened with gegl_buffer_open since they auto-sync on writes.

Returns:

  • (nil)

#flush_ext(rect) ⇒ nil

Invokes the external flush function, if any is set on the provided buffer - this ensures that data pending - in the current implementation only OpenCL - externally to be synchronized with the buffer. Multi threaded code should call such a synchronization before branching out to avoid each of the threads having an implicit synchronization of its own.

Parameters:

  • rect (Gegl::Rectangle)

    rectangle

Returns:

  • (nil)

#formatGObject

Returns format.

Returns:

  • (GObject)

    format

#format=(format) ⇒ GObject

Parameters:

  • format (GObject)

Returns:

  • (GObject)

    format

  • (GObject)

    format

#freeze_changednil

Blocks emission of the "changed" signal for buffer.

While the signal is blocked, changes to buffer are accumulated, and will be emitted once the signal is unblocked, using gegl_buffer_thaw_changed().

Returns:

  • (nil)

#get(rect, scale, format, dest, rowstride, repeat_mode) ⇒ nil

Fetch a rectangular linear buffer of pixel data from the GeglBuffer, the data is converted to the desired BablFormat, if the BablFormat stored and fetched is the same this amounts to a series of memcpy's aligned to demux the tile structure into a linear buffer. destination buffer, if NULL equal to the extent of the buffer. The coordinates and dimensions are after scale has been applied. depends on the requested BablFormat. rowstride based on the width and bytes per pixel for the specified format. Valid values: GEGL_ABYSS_NONE (abyss pixels are zeroed), GEGL_ABYSS_WHITE (abyss pixels are white), GEGL_ABYSS_BLACK (abyss pixels are black), GEGL_ABYSS_CLAMP (coordinates are clamped to the abyss rectangle), GEGL_ABYSS_LOOP (buffer contents are tiled if outside of the abyss rectangle) this argument also takes a GEGL_BUFFER_FILTER value or'ed into it, allowing to specify trade-off of performance/quality, valid values are: GEGL_BUFFER_FILTER_NEAREST, GEGL_BUFFER_FILTER_BILINEAR, GEGL_BUFFER_FILTER_BOX and GEGL_BUFFER_FILTER_AUTO.

Parameters:

  • rect (Gegl::Rectangle)

    the coordinates we want to retrieve data from, and width/height of

  • scale (Float)

    sampling scale, 1.0 = pixel for pixel 2.0 = magnify, 0.5 scale down.

  • format (Babl::Object)

    the BablFormat to store in the linear buffer dest.

  • dest (GObject)

    the memory destination for a linear buffer for the pixels, the size needed

  • rowstride (Integer)

    rowstride in bytes, or GEGL_AUTO_ROWSTRIDE to compute the

  • repeat_mode (Gegl::AbyssPolicy)

    how requests outside the buffer extent are handled.

Returns:

  • (nil)

#get_tile(x, y, z) ⇒ Gegl::Tile

Parameters:

  • x (Integer)
  • y (Integer)
  • z (Integer)

Returns:

  • (Gegl::Tile)

#heightInteger

Returns height.

Returns:

  • (Integer)

    height

#height=(height) ⇒ Integer

Parameters:

  • height (Integer)

Returns:

  • (Integer)

    height

  • (Integer)

    height

#initialized=(initialized) ⇒ Boolean

Parameters:

  • initialized (Boolean)

Returns:

  • (Boolean)

    initialized

  • (Boolean)

    initialized

#initialized?Boolean

Returns initialized.

Returns:

  • (Boolean)

    initialized

#introspectable_get(rect, scale, format_name, repeat_mode, data_length) ⇒ Array<Integer>

Fetch a rectangular linear buffer of pixel data from the GeglBuffer. Valid values: GEGL_ABYSS_NONE (abyss pixels are zeroed), GEGL_ABYSS_WHITE (abyss pixels are white), GEGL_ABYSS_BLACK (abyss pixels are black), GEGL_ABYSS_CLAMP (coordinates are clamped to the abyss rectangle), GEGL_ABYSS_LOOP (buffer contents are tiled if outside of the abyss rectangle).

Parameters:

  • rect (Gegl::Rectangle)

    the coordinates we want to retrieve data from.

  • scale (Float)

    sampling scale, 1.0 = pixel for pixel 2.0 = magnify, 0.5 scale down.

  • format_name (String)

    the format to store data in, if NULL the format of the buffer is used.

  • repeat_mode (Gegl::AbyssPolicy)

    how requests outside the buffer extent are handled.

  • data_length (Integer)

    The length of the returned buffer

Returns:

  • (Array<Integer>)

    A copy of the requested data

#introspectable_set(rect, format_name, src, src_length) ⇒ nil

Store a linear raster buffer into the GeglBuffer.

Parameters:

  • rect (Gegl::Rectangle)

    the rectangle to write.

  • format_name (String)

    the format of the input data.

  • src (Array<Integer>)

    pixel data to write to buffer.

  • src_length (Integer)

    the lenght of src in bytes

Returns:

  • (nil)

#iterator_new(roi, level, format, access_mode, abyss_policy, max_slots) ⇒ Gegl::BufferIterator

Create a new buffer iterator, this buffer will be iterated through in linear chunks, some chunks might be full tiles the coordinates, see the documentation of gegl_buffer_iterator_next for how to use it and destroy it. extent at 1:1, x,y,width and height are/(2^level) buffers pixels.

Parameters:

  • roi (Gegl::Rectangle)

    the rectangle to iterate over

  • level (Integer)

    the level at which we are iterating, the roi will indicate the

  • format (Babl::Object)

    the format we want to process this buffers data in, pass 0 to use the buffers format.

  • access_mode (Gegl::AccessMode)

    whether we need reading or writing to this buffer one of GEGL_BUFFER_READ, GEGL_BUFFER_WRITE and GEGL_BUFFER_READWRITE.

  • abyss_policy (Gegl::AbyssPolicy)

    how request outside the buffer extent are handled.

  • max_slots (Integer)

Returns:

  • (Gegl::BufferIterator)

    a new buffer iterator that can be used to iterate through the

#linear_close(linear) ⇒ nil

This function makes sure GeglBuffer and underlying code is aware of changes being made to the linear buffer. If the request was not a compatible one it is written back to the buffer. Multiple concurrent users can be handed the same buffer (both raw access and converted).

Parameters:

  • linear (GObject)

    a previously returned buffer.

Returns:

  • (nil)

#linear_open(extent, rowstride, format) ⇒ GObject

Raw direct random access to the full data of a buffer in linear memory. request is compatible with the underlying data storage direct access to the underlying data is provided. Otherwise, it returns a copy of the data.

Parameters:

  • extent (Gegl::Rectangle)

    region to open, pass NULL for entire buffer.

  • rowstride (Integer)

    return location for rowstride.

  • format (Babl::Object)

    desired format or NULL to use buffers format.

Returns:

  • (GObject)

    a pointer to a linear memory region describing the buffer, if the

#pathString

Returns path.

Returns:

  • (String)

    path

#path=(path) ⇒ String

Parameters:

  • path (String)

Returns:

  • (String)

    path

  • (String)

    path

#pixelsInteger

Returns pixels.

Returns:

  • (Integer)

    pixels

#pixels=(pixels) ⇒ Integer

Parameters:

  • pixels (Integer)

Returns:

  • (Integer)

    pixels

  • (Integer)

    pixels

#px_sizeInteger

Returns px-size.

Returns:

  • (Integer)

    px-size

#px_size=(px_size) ⇒ Integer

Parameters:

  • px_size (Integer)

Returns:

  • (Integer)

    px-size

  • (Integer)

    px-size

#remove_handler(handler) ⇒ nil

Remove the provided tile handler in the existing chain of tile handler of a GeglBuffer.

Parameters:

  • handler (GObject)

    a Gegl::TileHandler

Returns:

  • (nil)

#sample(x, y, scale, dest, format, sampler_type, repeat_mode) ⇒ nil

Query interpolate pixel values at a given coordinate using a specified form of interpolation.

If you intend to take multiple samples, consider using gegl_buffer_sampler_new() to create a sampler object instead, which is more efficient. gegl_sampler_compute_scale the same. to be ported from working code. Valid values: GEGL_SAMPLER_NEAREST, GEGL_SAMPLER_LINEAR, GEGL_SAMPLER_CUBIC, GEGL_SAMPLER_NOHALO and GEGL_SAMPLER_LOHALO Valid values: GEGL_ABYSS_NONE (abyss pixels are zeroed), GEGL_ABYSS_WHITE (abyss pixels are white), GEGL_ABYSS_BLACK (abyss pixels are black), GEGL_ABYSS_CLAMP (coordinates are clamped to the abyss rectangle), GEGL_ABYSS_LOOP (buffer contents are tiled if outside of the abyss rectangle).

Parameters:

  • x (Float)

    x coordinate to sample in buffer coordinates

  • y (Float)

    y coordinate to sample in buffer coordinates

  • scale (Gegl::BufferMatrix2)

    a matrix that indicates scaling factors, see

  • dest (GObject)

    buffer capable of storing one pixel in format.

  • format (Babl::Object)

    the format to store the sampled color in.

  • sampler_type (Gegl::SamplerType)

    the sampler type to use,

  • repeat_mode (Gegl::AbyssPolicy)

    how requests outside the buffer extent are handled.

Returns:

  • (nil)

#sample_at_level(x, y, scale, dest, format, level, sampler_type, repeat_mode) ⇒ nil

Query interpolate pixel values at a given coordinate using a specified form of interpolation.

If you intend to take multiple samples, consider using gegl_buffer_sampler_new_at_level() to create a sampler object instead, which is more efficient. gegl_sampler_compute_scale the same. to be ported from working code. Valid values: GEGL_SAMPLER_NEAREST, GEGL_SAMPLER_LINEAR, GEGL_SAMPLER_CUBIC, GEGL_SAMPLER_NOHALO and GEGL_SAMPLER_LOHALO Valid values: GEGL_ABYSS_NONE (abyss pixels are zeroed), GEGL_ABYSS_WHITE (abyss pixels are white), GEGL_ABYSS_BLACK (abyss pixels are black), GEGL_ABYSS_CLAMP (coordinates are clamped to the abyss rectangle), GEGL_ABYSS_LOOP (buffer contents are tiled if outside of the abyss rectangle).

Parameters:

  • x (Float)

    x coordinate to sample in buffer coordinates

  • y (Float)

    y coordinate to sample in buffer coordinates

  • scale (Gegl::BufferMatrix2)

    a matrix that indicates scaling factors, see

  • dest (GObject)

    buffer capable of storing one pixel in format.

  • format (Babl::Object)

    the format to store the sampled color in.

  • level (Integer)

    mipmap level to sample from (x and y are level 0 coordinates)

  • sampler_type (Gegl::SamplerType)

    the sampler type to use,

  • repeat_mode (Gegl::AbyssPolicy)

    how requests outside the buffer extent are handled.

Returns:

  • (nil)

#sample_cleanupnil

Clean up resources used by sampling framework of buffer.

Returns:

  • (nil)

#sampler_new(format, sampler_type) ⇒ Gegl::Sampler

Create a new sampler, when you are done with the sampler, g_object_unref it.

Samplers only hold weak references to buffers, so if its buffer is freed the sampler will become invalid. to be ported from working code. Valid values: GEGL_SAMPLER_NEAREST, GEGL_SAMPLER_LINEAR, GEGL_SAMPLER_CUBIC, GEGL_SAMPLER_NOHALO and GEGL_SAMPLER_LOHALO

Parameters:

  • format (Babl::Object)

    format we want data back in

  • sampler_type (Gegl::SamplerType)

    the sampler type to use,

Returns:

  • (Gegl::Sampler)

#sampler_new_at_level(format, sampler_type, level) ⇒ Gegl::Sampler

Create a new sampler, when you are done with the sampler, g_object_unref it.

Samplers only hold weak references to buffers, so if its buffer is freed the sampler will become invalid. to be ported from working code. Valid values: GEGL_SAMPLER_NEAREST, GEGL_SAMPLER_LINEAR, GEGL_SAMPLER_CUBIC, GEGL_SAMPLER_NOHALO and GEGL_SAMPLER_LOHALO

Parameters:

  • format (Babl::Object)

    format we want data back in

  • sampler_type (Gegl::SamplerType)

    the sampler type to use,

  • level (Integer)

    the mipmap level to create a sampler for

Returns:

  • (Gegl::Sampler)

#save(path, roi) ⇒ nil

Write a GeglBuffer to a file. written to disk.

Parameters:

  • path (String)

    the path where the gegl buffer will be saved, any writable GIO uri is valid.

  • roi (Gegl::Rectangle)

    the region of interest to write, this is the tiles that will be collected and

Returns:

  • (nil)

#set(rect, mipmap_level, format, src, rowstride) ⇒ nil

Store a linear raster buffer into the GeglBuffer. the linear buffer being set. the data when setting. 1 = 1:2, 2=1:4, 3=1:8 .. rowstride based on the width and bytes per pixel for the specified format.

Parameters:

  • rect (Gegl::Rectangle)

    the coordinates we want to change the data of and the width/height of

  • mipmap_level (Integer)

    the scale level being set, 0 = 1:1 = default = base mipmap level,

  • format (Babl::Object)

    the babl_format the linear buffer src.

  • src (GObject)

    linear buffer of image data to be stored in buffer.

  • rowstride (Integer)

    rowstride in bytes, or GEGL_AUTO_ROWSTRIDE to compute the

Returns:

  • (nil)

#set_color(rect, color) ⇒ nil

Sets the region covered by rect to the specified color.

Parameters:

  • rect (Gegl::Rectangle)

    a rectangular region to fill with a color.

  • color (Gegl::Color)

    the GeglColor to fill with.

Returns:

  • (nil)

#set_color_from_pixel(rect, pixel, pixel_format) ⇒ nil

Sets the region covered by rect to the the provided pixel.

Parameters:

  • rect (Gegl::Rectangle)

    a rectangular region to fill with a color.

  • pixel (GObject)

    pointer to the data of a single pixel

  • pixel_format (Babl::Object)

    the babl format of the pixel, if missing - the soft format of dst.

Returns:

  • (nil)

#set_pattern(rect, pattern, x_offset, y_offset) ⇒ nil

Fill a region with a repeating pattern. Offsets parameters are relative to the origin (0, 0) and not to the rectangle. So be carefull about the origin of pattern and buffer extents.

Parameters:

  • rect (Gegl::Rectangle)

    the region of buffer to fill

  • pattern (Gegl::Buffer)

    a Gegl::Buffer to be repeated as a pattern

  • x_offset (Integer)

    where the pattern starts horizontally

  • y_offset (Integer)

    where the pattern starts vertical

Returns:

  • (nil)

#share_storage(buffer2) ⇒ Boolean

Checks if a pair of buffers share the same underlying tile storage.

Returns TRUE if buffer1 and buffer2 share the same storage.

Parameters:

Returns:

  • (Boolean)

#shift_xInteger

Returns shift-x.

Returns:

  • (Integer)

    shift-x

#shift_x=(shift_x) ⇒ Integer

Parameters:

  • shift_x (Integer)

Returns:

  • (Integer)

    shift-x

  • (Integer)

    shift-x

#shift_yInteger

Returns shift-y.

Returns:

  • (Integer)

    shift-y

#shift_y=(shift_y) ⇒ Integer

Parameters:

  • shift_y (Integer)

Returns:

  • (Integer)

    shift-y

  • (Integer)

    shift-y

#signal_connect(detailed_signal, c_handler, data) ⇒ Gegl::glong

This function should be used instead of g_signal_connect when connecting to the GeglBuffer::changed signal handler, GeglBuffer contains additional machinery to avoid the overhead of changes when no signal handler have been connected, if regular g_signal_connect is used; then no signals will be emitted.

Parameters:

  • detailed_signal (String)

    only "changed" expected for now

  • c_handler (GObject::Callback)

    c function callback

  • data (GObject)

    user data:

Returns:

  • (Gegl::glong)

    an handle like g_signal_connect.

#thaw_changednil

Unblocks emission of the "changed" signal for buffer.

Once all calls to gegl_buffer_freeze_changed() are matched by corresponding calls to gegl_buffer_freeze_changed(), all accumulated changes are emitted.

Returns:

  • (nil)

#tile_heightInteger

Returns tile-height.

Returns:

  • (Integer)

    tile-height

#tile_height=(tile_height) ⇒ Integer

Parameters:

  • tile_height (Integer)

Returns:

  • (Integer)

    tile-height

  • (Integer)

    tile-height

#tile_widthInteger

Returns tile-width.

Returns:

  • (Integer)

    tile-width

#tile_width=(tile_width) ⇒ Integer

Parameters:

  • tile_width (Integer)

Returns:

  • (Integer)

    tile-width

  • (Integer)

    tile-width

#widthInteger

Returns width.

Returns:

  • (Integer)

    width

#width=(width) ⇒ Integer

Parameters:

  • width (Integer)

Returns:

  • (Integer)

    width

  • (Integer)

    width

#xInteger

Returns x.

Returns:

  • (Integer)

    x

#x=(x) ⇒ Integer

Parameters:

  • x (Integer)

Returns:

  • (Integer)

    x

  • (Integer)

    x

#yInteger

Returns y.

Returns:

  • (Integer)

    y

#y=(y) ⇒ Integer

Parameters:

  • y (Integer)

Returns:

  • (Integer)

    y

  • (Integer)

    y