2017-11-22 20:02:50 +00:00
|
|
|
#ifndef __GSK_GL_RENDER_OPS_H__
|
|
|
|
#define __GSK_GL_RENDER_OPS_H__
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <graphene.h>
|
|
|
|
#include <gdk/gdk.h>
|
|
|
|
|
|
|
|
#include "gskgldriverprivate.h"
|
|
|
|
#include "gskroundedrectprivate.h"
|
2019-05-02 00:13:16 +00:00
|
|
|
#include "gskglrenderer.h"
|
2019-02-23 06:50:51 +00:00
|
|
|
#include "gskrendernodeprivate.h"
|
2017-11-22 20:02:50 +00:00
|
|
|
|
2019-10-11 14:23:33 +00:00
|
|
|
#include "opbuffer.h"
|
|
|
|
|
2017-11-22 20:02:50 +00:00
|
|
|
#define GL_N_VERTICES 6
|
2019-08-10 12:45:45 +00:00
|
|
|
#define GL_N_PROGRAMS 13
|
2020-07-24 18:45:22 +00:00
|
|
|
#define MAX_GRADIENT_STOPS 8
|
2017-11-22 20:02:50 +00:00
|
|
|
|
2018-11-26 16:52:35 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2018-11-28 08:30:27 +00:00
|
|
|
float scale_x;
|
|
|
|
float scale_y;
|
|
|
|
|
2019-02-23 06:50:51 +00:00
|
|
|
float dx_before;
|
|
|
|
float dy_before;
|
2018-11-26 16:52:35 +00:00
|
|
|
} OpsMatrixMetadata;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2019-06-02 07:55:11 +00:00
|
|
|
GskTransform *transform;
|
2018-11-26 16:52:35 +00:00
|
|
|
OpsMatrixMetadata metadata;
|
|
|
|
} MatrixStackEntry;
|
|
|
|
|
2019-10-11 14:23:33 +00:00
|
|
|
struct _Program
|
2017-11-22 20:02:50 +00:00
|
|
|
{
|
|
|
|
int index; /* Into the renderer's program array */
|
|
|
|
|
|
|
|
int id;
|
|
|
|
/* Common locations (gl_common)*/
|
|
|
|
int source_location;
|
|
|
|
int position_location;
|
2017-11-30 17:47:55 +00:00
|
|
|
int uv_location;
|
2017-11-22 20:02:50 +00:00
|
|
|
int alpha_location;
|
|
|
|
int viewport_location;
|
|
|
|
int projection_location;
|
|
|
|
int modelview_location;
|
2019-12-16 05:16:26 +00:00
|
|
|
int clip_rect_location;
|
2017-11-22 20:02:50 +00:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
int color_location;
|
2017-11-30 17:47:55 +00:00
|
|
|
} color;
|
|
|
|
struct {
|
|
|
|
int color_location;
|
|
|
|
} coloring;
|
2017-11-22 20:02:50 +00:00
|
|
|
struct {
|
|
|
|
int color_matrix_location;
|
|
|
|
int color_offset_location;
|
2017-11-30 17:47:55 +00:00
|
|
|
} color_matrix;
|
2017-11-22 20:02:50 +00:00
|
|
|
struct {
|
2017-11-30 17:47:55 +00:00
|
|
|
int num_color_stops_location;
|
2017-11-22 20:02:50 +00:00
|
|
|
int color_stops_location;
|
|
|
|
int start_point_location;
|
|
|
|
int end_point_location;
|
2017-11-30 17:47:55 +00:00
|
|
|
} linear_gradient;
|
2017-11-25 07:56:50 +00:00
|
|
|
struct {
|
|
|
|
int blur_radius_location;
|
|
|
|
int blur_size_location;
|
2019-11-26 08:38:53 +00:00
|
|
|
int blur_dir_location;
|
2017-11-30 17:47:55 +00:00
|
|
|
} blur;
|
2017-11-30 15:48:03 +00:00
|
|
|
struct {
|
2017-11-30 17:47:55 +00:00
|
|
|
int color_location;
|
|
|
|
int spread_location;
|
|
|
|
int offset_location;
|
2019-12-16 05:16:26 +00:00
|
|
|
int outline_rect_location;
|
2017-11-30 17:47:55 +00:00
|
|
|
} inset_shadow;
|
2017-12-01 07:30:11 +00:00
|
|
|
struct {
|
2020-01-16 07:02:48 +00:00
|
|
|
int color_location;
|
2019-12-16 05:16:26 +00:00
|
|
|
int outline_rect_location;
|
2017-12-01 07:30:11 +00:00
|
|
|
} outset_shadow;
|
2018-01-15 09:55:40 +00:00
|
|
|
struct {
|
2019-12-16 05:16:26 +00:00
|
|
|
int outline_rect_location;
|
2018-01-15 09:55:40 +00:00
|
|
|
int color_location;
|
|
|
|
int spread_location;
|
|
|
|
int offset_location;
|
|
|
|
} unblurred_outset_shadow;
|
2017-12-01 10:55:10 +00:00
|
|
|
struct {
|
|
|
|
int color_location;
|
|
|
|
int widths_location;
|
2019-12-16 05:16:26 +00:00
|
|
|
int outline_rect_location;
|
2017-12-01 10:55:10 +00:00
|
|
|
} border;
|
2017-12-11 07:22:28 +00:00
|
|
|
struct {
|
|
|
|
int source2_location;
|
|
|
|
int progress_location;
|
|
|
|
} cross_fade;
|
2019-04-28 05:46:17 +00:00
|
|
|
struct {
|
|
|
|
int source2_location;
|
|
|
|
int mode_location;
|
|
|
|
} blend;
|
2019-08-10 12:45:45 +00:00
|
|
|
struct {
|
|
|
|
int child_bounds_location;
|
|
|
|
int texture_rect_location;
|
|
|
|
} repeat;
|
2017-11-22 20:02:50 +00:00
|
|
|
};
|
2019-10-11 14:23:33 +00:00
|
|
|
};
|
2017-11-22 20:02:50 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2019-06-02 07:55:11 +00:00
|
|
|
GskTransform *modelview;
|
2018-12-02 13:17:18 +00:00
|
|
|
GskRoundedRect clip;
|
|
|
|
graphene_matrix_t projection;
|
|
|
|
int source_texture;
|
|
|
|
graphene_rect_t viewport;
|
|
|
|
float opacity;
|
|
|
|
/* Per-program state */
|
|
|
|
union {
|
2019-12-17 12:06:02 +00:00
|
|
|
GdkRGBA color;
|
2018-12-02 13:17:18 +00:00
|
|
|
struct {
|
|
|
|
graphene_matrix_t matrix;
|
|
|
|
graphene_vec4_t offset;
|
|
|
|
} color_matrix;
|
|
|
|
struct {
|
|
|
|
float widths[4];
|
2019-12-17 12:06:02 +00:00
|
|
|
GdkRGBA color;
|
2018-12-02 13:17:18 +00:00
|
|
|
GskRoundedRect outline;
|
|
|
|
} border;
|
2020-07-24 06:49:24 +00:00
|
|
|
struct {
|
|
|
|
GskRoundedRect outline;
|
|
|
|
float dx;
|
|
|
|
float dy;
|
|
|
|
float spread;
|
|
|
|
GdkRGBA color;
|
|
|
|
} inset_shadow;
|
|
|
|
struct {
|
|
|
|
GskRoundedRect outline;
|
|
|
|
float dx;
|
|
|
|
float dy;
|
|
|
|
float spread;
|
|
|
|
GdkRGBA color;
|
|
|
|
} unblurred_outset_shadow;
|
2020-07-24 18:45:22 +00:00
|
|
|
struct {
|
|
|
|
int n_color_stops;
|
|
|
|
GskColorStop color_stops[MAX_GRADIENT_STOPS];
|
|
|
|
float start_point[2];
|
|
|
|
float end_point[2];
|
|
|
|
} linear_gradient;
|
2018-12-02 13:17:18 +00:00
|
|
|
};
|
|
|
|
} ProgramState;
|
2017-11-22 20:02:50 +00:00
|
|
|
|
2020-02-11 15:56:24 +00:00
|
|
|
typedef struct {
|
|
|
|
int ref_count;
|
|
|
|
union {
|
|
|
|
Program programs[GL_N_PROGRAMS];
|
|
|
|
struct {
|
|
|
|
Program blend_program;
|
|
|
|
Program blit_program;
|
|
|
|
Program blur_program;
|
|
|
|
Program border_program;
|
|
|
|
Program color_matrix_program;
|
|
|
|
Program color_program;
|
|
|
|
Program coloring_program;
|
|
|
|
Program cross_fade_program;
|
|
|
|
Program inset_shadow_program;
|
|
|
|
Program linear_gradient_program;
|
|
|
|
Program outset_shadow_program;
|
|
|
|
Program repeat_program;
|
|
|
|
Program unblurred_outset_shadow_program;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
ProgramState state[GL_N_PROGRAMS];
|
|
|
|
} GskGLRendererPrograms;
|
|
|
|
|
2018-12-02 13:17:18 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2020-02-11 15:56:24 +00:00
|
|
|
GskGLRendererPrograms *programs;
|
2017-11-22 20:02:50 +00:00
|
|
|
const Program *current_program;
|
|
|
|
int current_render_target;
|
|
|
|
int current_texture;
|
2018-10-06 07:23:26 +00:00
|
|
|
|
2017-11-22 20:02:50 +00:00
|
|
|
graphene_matrix_t current_projection;
|
|
|
|
graphene_rect_t current_viewport;
|
|
|
|
float current_opacity;
|
2017-12-09 17:26:29 +00:00
|
|
|
float dx, dy;
|
2019-11-29 13:40:20 +00:00
|
|
|
float scale_x, scale_y;
|
2017-11-22 20:02:50 +00:00
|
|
|
|
2019-10-11 14:23:33 +00:00
|
|
|
OpBuffer render_ops;
|
2019-10-11 17:59:58 +00:00
|
|
|
GArray *vertices;
|
2019-10-11 14:23:33 +00:00
|
|
|
|
2017-11-22 20:02:50 +00:00
|
|
|
GskGLRenderer *renderer;
|
2018-11-26 16:52:35 +00:00
|
|
|
|
|
|
|
/* Stack of modelview matrices */
|
|
|
|
GArray *mv_stack;
|
2019-06-02 07:55:11 +00:00
|
|
|
GskTransform *current_modelview;
|
2018-12-30 14:25:01 +00:00
|
|
|
|
|
|
|
/* Same thing */
|
|
|
|
GArray *clip_stack;
|
2019-06-02 07:55:11 +00:00
|
|
|
/* Pointer into clip_stack */
|
2018-12-30 14:25:01 +00:00
|
|
|
const GskRoundedRect *current_clip;
|
2020-07-24 16:30:36 +00:00
|
|
|
bool clip_is_rectilinear;
|
2017-11-22 20:02:50 +00:00
|
|
|
} RenderOpBuilder;
|
|
|
|
|
|
|
|
|
2018-12-02 07:12:09 +00:00
|
|
|
void ops_dump_framebuffer (RenderOpBuilder *builder,
|
|
|
|
const char *filename,
|
|
|
|
int width,
|
|
|
|
int height);
|
2019-04-24 10:56:44 +00:00
|
|
|
void ops_init (RenderOpBuilder *builder);
|
2019-07-06 11:38:55 +00:00
|
|
|
void ops_free (RenderOpBuilder *builder);
|
2019-10-11 14:23:33 +00:00
|
|
|
void ops_reset (RenderOpBuilder *builder);
|
2019-04-24 11:28:11 +00:00
|
|
|
void ops_push_debug_group (RenderOpBuilder *builder,
|
|
|
|
const char *text);
|
|
|
|
void ops_pop_debug_group (RenderOpBuilder *builder);
|
|
|
|
|
2018-11-26 16:52:35 +00:00
|
|
|
void ops_finish (RenderOpBuilder *builder);
|
|
|
|
void ops_push_modelview (RenderOpBuilder *builder,
|
2019-06-02 07:55:11 +00:00
|
|
|
GskTransform *transform);
|
2019-02-23 06:50:51 +00:00
|
|
|
void ops_set_modelview (RenderOpBuilder *builder,
|
2019-06-02 07:55:11 +00:00
|
|
|
GskTransform *transform);
|
2018-11-26 16:52:35 +00:00
|
|
|
void ops_pop_modelview (RenderOpBuilder *builder);
|
2018-04-11 09:20:50 +00:00
|
|
|
float ops_get_scale (const RenderOpBuilder *builder);
|
|
|
|
|
2017-12-03 18:15:33 +00:00
|
|
|
void ops_set_program (RenderOpBuilder *builder,
|
|
|
|
const Program *program);
|
2017-11-22 20:02:50 +00:00
|
|
|
|
2018-12-30 14:25:01 +00:00
|
|
|
void ops_push_clip (RenderOpBuilder *builder,
|
2017-12-03 18:15:33 +00:00
|
|
|
const GskRoundedRect *clip);
|
2018-12-30 14:25:01 +00:00
|
|
|
void ops_pop_clip (RenderOpBuilder *builder);
|
|
|
|
gboolean ops_has_clip (RenderOpBuilder *builder);
|
2017-11-22 20:02:50 +00:00
|
|
|
|
2018-10-06 07:23:26 +00:00
|
|
|
void ops_transform_bounds_modelview (const RenderOpBuilder *builder,
|
|
|
|
const graphene_rect_t *src,
|
|
|
|
graphene_rect_t *dst);
|
|
|
|
|
2017-12-03 18:15:33 +00:00
|
|
|
graphene_matrix_t ops_set_projection (RenderOpBuilder *builder,
|
|
|
|
const graphene_matrix_t *projection);
|
2017-11-22 20:02:50 +00:00
|
|
|
|
2017-12-03 18:15:33 +00:00
|
|
|
graphene_rect_t ops_set_viewport (RenderOpBuilder *builder,
|
|
|
|
const graphene_rect_t *viewport);
|
2017-11-22 20:02:50 +00:00
|
|
|
|
2017-12-03 18:15:33 +00:00
|
|
|
void ops_set_texture (RenderOpBuilder *builder,
|
|
|
|
int texture_id);
|
2017-11-22 20:02:50 +00:00
|
|
|
|
2017-12-03 18:15:33 +00:00
|
|
|
int ops_set_render_target (RenderOpBuilder *builder,
|
|
|
|
int render_target_id);
|
2017-11-22 20:02:50 +00:00
|
|
|
|
2017-12-03 18:15:33 +00:00
|
|
|
float ops_set_opacity (RenderOpBuilder *builder,
|
|
|
|
float opacity);
|
|
|
|
void ops_set_color (RenderOpBuilder *builder,
|
|
|
|
const GdkRGBA *color);
|
|
|
|
|
|
|
|
void ops_set_color_matrix (RenderOpBuilder *builder,
|
|
|
|
const graphene_matrix_t *matrix,
|
|
|
|
const graphene_vec4_t *offset);
|
2017-11-22 20:02:50 +00:00
|
|
|
|
2017-12-05 07:38:42 +00:00
|
|
|
void ops_set_border (RenderOpBuilder *builder,
|
2018-03-15 16:27:19 +00:00
|
|
|
const GskRoundedRect *outline);
|
2018-12-05 09:44:11 +00:00
|
|
|
void ops_set_border_width (RenderOpBuilder *builder,
|
|
|
|
const float *widths);
|
2017-12-05 07:38:42 +00:00
|
|
|
|
|
|
|
void ops_set_border_color (RenderOpBuilder *builder,
|
|
|
|
const GdkRGBA *color);
|
2020-07-24 06:49:24 +00:00
|
|
|
void ops_set_inset_shadow (RenderOpBuilder *self,
|
|
|
|
const GskRoundedRect outline,
|
|
|
|
float spread,
|
|
|
|
const GdkRGBA *color,
|
|
|
|
float dx,
|
|
|
|
float dy);
|
|
|
|
void ops_set_unblurred_outset_shadow (RenderOpBuilder *self,
|
|
|
|
const GskRoundedRect outline,
|
|
|
|
float spread,
|
|
|
|
const GdkRGBA *color,
|
|
|
|
float dx,
|
|
|
|
float dy);
|
2017-12-05 07:38:42 +00:00
|
|
|
|
2020-07-24 18:45:22 +00:00
|
|
|
void ops_set_linear_gradient (RenderOpBuilder *self,
|
|
|
|
guint n_color_stops,
|
|
|
|
const GskColorStop *color_stops,
|
|
|
|
float start_x,
|
|
|
|
float start_y,
|
|
|
|
float end_x,
|
|
|
|
float end_y);
|
|
|
|
|
2019-12-18 08:06:16 +00:00
|
|
|
GskQuadVertex * ops_draw (RenderOpBuilder *builder,
|
2017-11-22 20:02:50 +00:00
|
|
|
const GskQuadVertex vertex_data[GL_N_VERTICES]);
|
|
|
|
|
2017-12-09 17:26:29 +00:00
|
|
|
void ops_offset (RenderOpBuilder *builder,
|
|
|
|
float x,
|
|
|
|
float y);
|
|
|
|
|
2019-10-11 14:23:33 +00:00
|
|
|
gpointer ops_begin (RenderOpBuilder *builder,
|
|
|
|
OpKind kind);
|
|
|
|
OpBuffer *ops_get_buffer (RenderOpBuilder *builder);
|
2017-11-22 20:02:50 +00:00
|
|
|
|
|
|
|
#endif
|