wlmaker
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
gfxbuf.c File Reference
#include "gfxbuf.h"
#include <drm_fourcc.h>
#include <libbase/libbase.h>
#include <wlr/interfaces/wlr_buffer.h>
#include <wlr/types/wlr_buffer.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for gfxbuf.c:

Classes

struct  wlmaker_gfxbuf_t
 

Functions

static wlmaker_gfxbuf_twlmaker_gfxbuf_from_wlr_buffer (struct wlr_buffer *wlr_buffer_ptr)
 
static void wlmaker_gfxbuf_impl_destroy (struct wlr_buffer *wlr_buffer_ptr)
 
static bool wlmaker_gfxbuf_impl_begin_data_ptr_access (struct wlr_buffer *wlr_buffer_ptr, uint32_t flags, void **data_ptr_ptr, uint32_t *format_ptr, size_t *stride_ptr)
 
static void wlmaker_gfxbuf_impl_end_data_ptr_access (struct wlr_buffer *wlr_buffer_ptr)
 
struct wlr_buffer * bs_gfxbuf_create_wlr_buffer (unsigned width, unsigned height)
 
void wlr_buffer_drop_nullify (struct wlr_buffer **wlr_buffer_ptr_ptr)
 
bs_gfxbuf_t * bs_gfxbuf_from_wlr_buffer (struct wlr_buffer *wlr_buffer_ptr)
 
cairo_t * cairo_create_from_wlr_buffer (struct wlr_buffer *wlr_buffer_ptr)
 

Variables

static const struct wlr_buffer_impl wlmaker_gfxbuf_impl
 

Detailed Description

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ bs_gfxbuf_create_wlr_buffer()

struct wlr_buffer * bs_gfxbuf_create_wlr_buffer ( unsigned  width,
unsigned  height 
)

Creates a wlroots buffer tied to a libbase graphics buffer.

This creates a libbase graphics buffer, and wraps it as struct wlr_buffer.

Parameters
width
height
Returns
A struct wlr_buffer. Must be released using wlr_buffer_drop().

◆ bs_gfxbuf_from_wlr_buffer()

bs_gfxbuf_t * bs_gfxbuf_from_wlr_buffer ( struct wlr_buffer *  wlr_buffer_ptr)

Returns the libbase graphics buffer for the struct wlr_buffer.

Parameters
wlr_buffer_ptrPointer to a struct wlr_buffer. Must be a wlr_buffer that was previously created by bs_gfxbuf_create_wlr_buffer.
Returns
Pointer to the libbase graphics buffer. The wlr_buffer_ptr must outlive the bs_gfxbuf_t*. Must not be destroyed.

◆ cairo_create_from_wlr_buffer()

cairo_t * cairo_create_from_wlr_buffer ( struct wlr_buffer *  wlr_buffer_ptr)

Returns a cairo_t for the WLR buffer backed by a libbase graphics buffer.

Parameters
wlr_buffer_ptrPointer to a struct wlr_buffer. Must be a wlr_buffer that was previously created by bs_gfxbuf_create_wlr_buffer.
Returns
Pointer to the the cairo. The wlr_buffer_ptr must outlive the cairo_t*. It must be destroyed using cairo_destroy.

◆ wlmaker_gfxbuf_from_wlr_buffer()

wlmaker_gfxbuf_t * wlmaker_gfxbuf_from_wlr_buffer ( struct wlr_buffer *  wlr_buffer_ptr)
static

Returns the wlmaker_gfxbuf_t for wlr_buffer_ptr.

Parameters
wlr_buffer_ptrPointer to a struct wlr_buffer. Must be a wlr_buffer that was previously created by bs_gfxbuf_create_wlr_buffer.
Returns
A pointer to the wlmaker_gfxbuf_t.

◆ wlmaker_gfxbuf_impl_begin_data_ptr_access()

bool wlmaker_gfxbuf_impl_begin_data_ptr_access ( struct wlr_buffer *  wlr_buffer_ptr,
uint32_t  flags,
void **  data_ptr_ptr,
uint32_t *  format_ptr,
size_t *  stride_ptr 
)
static

struct wlr_buffer_impl callback: Set up for data access.

Parameters
wlr_buffer_ptr
flagsunused.
data_ptr_ptrOutput argument, point to the surface data.
format_ptrOutput argument, set to the surface's format.
stride_ptrOutput argument, set to the surface's stride.

◆ wlmaker_gfxbuf_impl_destroy()

void wlmaker_gfxbuf_impl_destroy ( struct wlr_buffer *  wlr_buffer_ptr)
static

struct wlr_buffer_impl callback: Destroys the graphics buffer.

This function Will be called only once producer and all consumers of the corresponding wlr_buffer have lifted their locks (references).

Parameters
wlr_buffer_ptr

◆ wlmaker_gfxbuf_impl_end_data_ptr_access()

void wlmaker_gfxbuf_impl_end_data_ptr_access ( struct wlr_buffer *  wlr_buffer_ptr)
static

struct wlr_buffer_impl callback: End data access. Here, a no-op.

◆ wlr_buffer_drop_nullify()

void wlr_buffer_drop_nullify ( struct wlr_buffer **  wlr_buffer_ptr_ptr)

Drops a WLR buffer, and sets the pointer to NULL.

Parameters
wlr_buffer_ptr_ptrPoints to a pointer to a WLR buffer. The pointer to the WLR buffer may be NULL; in that case, the call is a no-op.

Variable Documentation

◆ wlmaker_gfxbuf_impl

const struct wlr_buffer_impl wlmaker_gfxbuf_impl
static
Initial value:
= {
}
static void wlmaker_gfxbuf_impl_destroy(struct wlr_buffer *wlr_buffer_ptr)
Definition gfxbuf.c:148
static bool wlmaker_gfxbuf_impl_begin_data_ptr_access(struct wlr_buffer *wlr_buffer_ptr, uint32_t flags, void **data_ptr_ptr, uint32_t *format_ptr, size_t *stride_ptr)
Definition gfxbuf.c:172
static void wlmaker_gfxbuf_impl_end_data_ptr_access(struct wlr_buffer *wlr_buffer_ptr)
Definition gfxbuf.c:189

Implementation callbacks for wlroots' struct wlr_buffer.