render/pixman: add wlr_*_is_pixman and wlr_pixman_texture_get_image

Add the following functions:

- wlr_renderer_is_pixman
- wlr_texture_is_pixman
- wlr_pixman_texture_get_image
This commit is contained in:
zccrs 2021-05-28 14:15:40 +08:00 committed by Simon Ser
parent fdc40e071e
commit dc17ecd236
2 changed files with 20 additions and 2 deletions

View File

@ -9,9 +9,14 @@
#ifndef WLR_RENDER_PIXMAN_H #ifndef WLR_RENDER_PIXMAN_H
#define WLR_RENDER_PIXMAN_H #define WLR_RENDER_PIXMAN_H
#include <pixman.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
struct wlr_renderer *wlr_pixman_renderer_create(void); struct wlr_renderer *wlr_pixman_renderer_create(void);
bool wlr_renderer_is_pixman(struct wlr_renderer *wlr_renderer);
bool wlr_texture_is_pixman(struct wlr_texture *texture);
pixman_image_t *wlr_pixman_texture_get_image(struct wlr_texture *wlr_texture);
#endif #endif

View File

@ -12,9 +12,13 @@
static const struct wlr_renderer_impl renderer_impl; static const struct wlr_renderer_impl renderer_impl;
bool wlr_renderer_is_pixman(struct wlr_renderer *wlr_renderer) {
return wlr_renderer->impl == &renderer_impl;
}
static struct wlr_pixman_renderer *get_renderer( static struct wlr_pixman_renderer *get_renderer(
struct wlr_renderer *wlr_renderer) { struct wlr_renderer *wlr_renderer) {
assert(wlr_renderer->impl == &renderer_impl); assert(wlr_renderer_is_pixman(wlr_renderer));
return (struct wlr_pixman_renderer *)wlr_renderer; return (struct wlr_pixman_renderer *)wlr_renderer;
} }
@ -31,9 +35,13 @@ static struct wlr_pixman_buffer *get_buffer(
static const struct wlr_texture_impl texture_impl; static const struct wlr_texture_impl texture_impl;
bool wlr_texture_is_pixman(struct wlr_texture *texture) {
return texture->impl == &texture_impl;
}
static struct wlr_pixman_texture *get_texture( static struct wlr_pixman_texture *get_texture(
struct wlr_texture *wlr_texture) { struct wlr_texture *wlr_texture) {
assert(wlr_texture->impl == &texture_impl); assert(wlr_texture_is_pixman(wlr_texture));
return (struct wlr_pixman_texture *)wlr_texture; return (struct wlr_pixman_texture *)wlr_texture;
} }
@ -554,3 +562,8 @@ struct wlr_renderer *wlr_pixman_renderer_create(void) {
return &renderer->wlr_renderer; return &renderer->wlr_renderer;
} }
pixman_image_t *wlr_pixman_texture_get_image(struct wlr_texture *wlr_texture) {
struct wlr_pixman_texture *texture = get_texture(wlr_texture);
return texture->image;
}