Merge pull request #346 from mighty9245/unify-gd-definition

gl_common: unify gd definition
This commit is contained in:
yshui 2020-03-22 02:24:26 +00:00 committed by GitHub
commit 2523829f4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 12 deletions

View File

@ -264,8 +264,7 @@ _gl_average_texture_color(backend_t *base, GLuint source_texture, GLuint destina
* deleted when the gl_image is released. * deleted when the gl_image is released.
*/ */
static GLuint gl_average_texture_color(backend_t *base, struct gl_image *img) { static GLuint gl_average_texture_color(backend_t *base, struct gl_image *img) {
auto gd = (struct gl_data *)base;
struct gl_data *gd = (void *)base;
// Prepare textures which will be used for destination and source of rendering // Prepare textures which will be used for destination and source of rendering
// during downscaling. // during downscaling.
@ -360,8 +359,7 @@ static GLuint gl_average_texture_color(backend_t *base, struct gl_image *img) {
*/ */
static void _gl_compose(backend_t *base, struct gl_image *img, GLuint target, static void _gl_compose(backend_t *base, struct gl_image *img, GLuint target,
GLint *coord, GLuint *indices, int nrects) { GLint *coord, GLuint *indices, int nrects) {
auto gd = (struct gl_data *)base;
struct gl_data *gd = (void *)base;
if (!img || !img->inner->texture) { if (!img || !img->inner->texture) {
log_error("Missing texture."); log_error("Missing texture.");
return; return;
@ -508,7 +506,7 @@ x_rect_to_coords(int nrects, const rect_t *rects, int dst_x, int dst_y, int text
// TODO: make use of reg_visible // TODO: make use of reg_visible
void gl_compose(backend_t *base, void *image_data, int dst_x, int dst_y, void gl_compose(backend_t *base, void *image_data, int dst_x, int dst_y,
const region_t *reg_tgt, const region_t *reg_visible attr_unused) { const region_t *reg_tgt, const region_t *reg_visible attr_unused) {
struct gl_data *gd = (void *)base; auto gd = (struct gl_data *)base;
struct gl_image *img = image_data; struct gl_image *img = image_data;
// Painting // Painting
@ -543,7 +541,7 @@ void gl_compose(backend_t *base, void *image_data, int dst_x, int dst_y,
bool gl_blur(backend_t *base, double opacity, void *ctx, const region_t *reg_blur, bool gl_blur(backend_t *base, double opacity, void *ctx, const region_t *reg_blur,
const region_t *reg_visible attr_unused) { const region_t *reg_visible attr_unused) {
struct gl_blur_context *bctx = ctx; struct gl_blur_context *bctx = ctx;
struct gl_data *gd = (void *)base; auto gd = (struct gl_data *)base;
if (gd->width + bctx->resize_width * 2 != bctx->texture_width || if (gd->width + bctx->resize_width * 2 != bctx->texture_width ||
gd->height + bctx->resize_height * 2 != bctx->texture_height) { gd->height + bctx->resize_height * 2 != bctx->texture_height) {
@ -867,7 +865,7 @@ static void _gl_fill(backend_t *base, struct color c, const region_t *clip, GLui
static const GLuint fill_vert_in_coord_loc = 0; static const GLuint fill_vert_in_coord_loc = 0;
int nrects; int nrects;
const rect_t *rect = pixman_region32_rectangles((region_t *)clip, &nrects); const rect_t *rect = pixman_region32_rectangles((region_t *)clip, &nrects);
struct gl_data *gd = (void *)base; auto gd = (struct gl_data *)base;
GLuint vao; GLuint vao;
glGenVertexArrays(1, &vao); glGenVertexArrays(1, &vao);
@ -919,13 +917,13 @@ static void _gl_fill(backend_t *base, struct color c, const region_t *clip, GLui
} }
void gl_fill(backend_t *base, struct color c, const region_t *clip) { void gl_fill(backend_t *base, struct color c, const region_t *clip) {
struct gl_data *gd = (void *)base; auto gd = (struct gl_data *)base;
return _gl_fill(base, c, clip, gd->back_fbo, gd->height, true); return _gl_fill(base, c, clip, gd->back_fbo, gd->height, true);
} }
void gl_release_image(backend_t *base, void *image_data) { void gl_release_image(backend_t *base, void *image_data) {
struct gl_image *wd = image_data; struct gl_image *wd = image_data;
struct gl_data *gl = (void *)base; auto gd = (struct gl_data *)base;
wd->inner->refcount--; wd->inner->refcount--;
assert(wd->inner->refcount >= 0); assert(wd->inner->refcount >= 0);
if (wd->inner->refcount > 0) { if (wd->inner->refcount > 0) {
@ -933,7 +931,7 @@ void gl_release_image(backend_t *base, void *image_data) {
return; return;
} }
gl->release_user_data(base, wd->inner); gd->release_user_data(base, wd->inner);
assert(wd->inner->user_data == NULL); assert(wd->inner->user_data == NULL);
glDeleteTextures(1, &wd->inner->texture); glDeleteTextures(1, &wd->inner->texture);
@ -1303,7 +1301,7 @@ static inline void gl_image_decouple(backend_t *base, struct gl_image *img) {
return; return;
} }
struct gl_data *gl = (void *)base; auto gd = (struct gl_data *)base;
auto new_tex = ccalloc(1, struct gl_texture); auto new_tex = ccalloc(1, struct gl_texture);
new_tex->texture = gl_new_texture(GL_TEXTURE_2D); new_tex->texture = gl_new_texture(GL_TEXTURE_2D);
@ -1314,7 +1312,7 @@ static inline void gl_image_decouple(backend_t *base, struct gl_image *img) {
new_tex->height = img->inner->height; new_tex->height = img->inner->height;
new_tex->width = img->inner->width; new_tex->width = img->inner->width;
new_tex->refcount = 1; new_tex->refcount = 1;
new_tex->user_data = gl->decouple_texture_user_data(base, img->inner->user_data); new_tex->user_data = gd->decouple_texture_user_data(base, img->inner->user_data);
GLuint fbo; GLuint fbo;
glGenFramebuffers(1, &fbo); glGenFramebuffers(1, &fbo);