render: add get native paint target of renderer

Add wlr_pixman_buffer_get_current_image for wlr_pixman_renderer.
Add wlr_gles2_buffer_get_current_fbo for wlr_gles2_renderer.

Allow get the FBO/pixman_image_t, the compositor can be add some
action for FBO(for eg, attach a depth buffer), or without pixman
render to pixman_image_t(for eg, use QPainter of Qt instead of pixman).
This commit is contained in:
zccrs 2021-05-28 13:53:24 +08:00 committed by Simon Ser
parent dc17ecd236
commit 3c03639cd5
4 changed files with 22 additions and 0 deletions

View File

@ -21,6 +21,10 @@ struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_egl *egl);
struct wlr_egl *wlr_gles2_renderer_get_egl(struct wlr_renderer *renderer); struct wlr_egl *wlr_gles2_renderer_get_egl(struct wlr_renderer *renderer);
bool wlr_gles2_renderer_check_ext(struct wlr_renderer *renderer, bool wlr_gles2_renderer_check_ext(struct wlr_renderer *renderer,
const char *ext); const char *ext);
/**
* Returns the OpenGL FBO of current buffer.
*/
GLuint wlr_gles2_renderer_get_current_fbo(struct wlr_renderer *wlr_renderer);
struct wlr_gles2_texture_attribs { struct wlr_gles2_texture_attribs {
GLenum target; /* either GL_TEXTURE_2D or GL_TEXTURE_EXTERNAL_OES */ GLenum target; /* either GL_TEXTURE_2D or GL_TEXTURE_EXTERNAL_OES */

View File

@ -14,6 +14,11 @@
#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);
/**
* Returns the image of current buffer.
*/
pixman_image_t *wlr_pixman_renderer_get_current_image(
struct wlr_renderer *wlr_renderer);
bool wlr_renderer_is_pixman(struct wlr_renderer *wlr_renderer); bool wlr_renderer_is_pixman(struct wlr_renderer *wlr_renderer);
bool wlr_texture_is_pixman(struct wlr_texture *texture); bool wlr_texture_is_pixman(struct wlr_texture *texture);

View File

@ -919,3 +919,9 @@ bool wlr_gles2_renderer_check_ext(struct wlr_renderer *wlr_renderer,
struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer); struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
return check_gl_ext(renderer->exts_str, ext); return check_gl_ext(renderer->exts_str, ext);
} }
GLuint wlr_gles2_renderer_get_current_fbo(struct wlr_renderer *wlr_renderer) {
struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
assert(renderer->current_buffer);
return renderer->current_buffer->fbo;
}

View File

@ -567,3 +567,10 @@ pixman_image_t *wlr_pixman_texture_get_image(struct wlr_texture *wlr_texture) {
struct wlr_pixman_texture *texture = get_texture(wlr_texture); struct wlr_pixman_texture *texture = get_texture(wlr_texture);
return texture->image; return texture->image;
} }
pixman_image_t *wlr_pixman_renderer_get_current_image(
struct wlr_renderer *wlr_renderer) {
struct wlr_pixman_renderer *renderer = get_renderer(wlr_renderer);
assert(renderer->current_buffer);
return renderer->current_buffer->image;
}