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"
|
|
|
|
#include "gskglrendererprivate.h"
|
2019-02-23 06:50:51 +00:00
|
|
|
#include "gskrendernodeprivate.h"
|
2017-11-22 20:02:50 +00:00
|
|
|
|
|
|
|
#define GL_N_VERTICES 6
|
2018-12-02 15:04:40 +00:00
|
|
|
#define GL_N_PROGRAMS 11
|
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 translate_x;
|
|
|
|
float translate_y;
|
|
|
|
float scale_x;
|
|
|
|
float scale_y;
|
|
|
|
|
2019-02-23 06:50:51 +00:00
|
|
|
float dx_before;
|
|
|
|
float dy_before;
|
|
|
|
|
|
|
|
GskMatrixCategory category;
|
2018-11-26 16:52:35 +00:00
|
|
|
} OpsMatrixMetadata;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
graphene_matrix_t matrix;
|
|
|
|
OpsMatrixMetadata metadata;
|
|
|
|
} MatrixStackEntry;
|
|
|
|
|
2017-11-22 20:02:50 +00:00
|
|
|
enum {
|
|
|
|
OP_NONE,
|
|
|
|
OP_CHANGE_OPACITY = 1,
|
|
|
|
OP_CHANGE_COLOR = 2,
|
|
|
|
OP_CHANGE_PROJECTION = 3,
|
|
|
|
OP_CHANGE_MODELVIEW = 4,
|
|
|
|
OP_CHANGE_PROGRAM = 5,
|
|
|
|
OP_CHANGE_RENDER_TARGET = 6,
|
|
|
|
OP_CHANGE_CLIP = 7,
|
|
|
|
OP_CHANGE_VIEWPORT = 8,
|
|
|
|
OP_CHANGE_SOURCE_TEXTURE = 9,
|
|
|
|
OP_CHANGE_VAO = 10,
|
|
|
|
OP_CHANGE_LINEAR_GRADIENT = 11,
|
2017-11-24 09:32:08 +00:00
|
|
|
OP_CHANGE_COLOR_MATRIX = 12,
|
2017-11-25 07:56:50 +00:00
|
|
|
OP_CHANGE_BLUR = 13,
|
2017-11-30 15:48:03 +00:00
|
|
|
OP_CHANGE_INSET_SHADOW = 14,
|
2017-12-01 07:30:11 +00:00
|
|
|
OP_CHANGE_OUTSET_SHADOW = 15,
|
2017-12-01 10:55:10 +00:00
|
|
|
OP_CHANGE_BORDER = 16,
|
2017-12-05 07:38:42 +00:00
|
|
|
OP_CHANGE_BORDER_COLOR = 17,
|
2018-12-05 09:44:11 +00:00
|
|
|
OP_CHANGE_BORDER_WIDTH = 18,
|
|
|
|
OP_CHANGE_CROSS_FADE = 19,
|
|
|
|
OP_CHANGE_UNBLURRED_OUTSET_SHADOW = 20,
|
|
|
|
OP_CLEAR = 21,
|
|
|
|
OP_DRAW = 22,
|
|
|
|
OP_DUMP_FRAMEBUFFER = 23,
|
2017-11-22 20:02:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
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 blend_mode_location;
|
|
|
|
int viewport_location;
|
|
|
|
int projection_location;
|
|
|
|
int modelview_location;
|
|
|
|
int clip_location;
|
|
|
|
int clip_corner_widths_location;
|
|
|
|
int clip_corner_heights_location;
|
|
|
|
|
|
|
|
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 color_offsets_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;
|
2017-12-28 15:41:32 +00:00
|
|
|
int 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;
|
|
|
|
int outline_location;
|
|
|
|
int corner_widths_location;
|
|
|
|
int corner_heights_location;
|
|
|
|
} inset_shadow;
|
2017-12-01 07:30:11 +00:00
|
|
|
struct {
|
|
|
|
int outline_location;
|
|
|
|
int corner_widths_location;
|
|
|
|
int corner_heights_location;
|
|
|
|
} outset_shadow;
|
2018-01-15 09:55:40 +00:00
|
|
|
struct {
|
|
|
|
int outline_location;
|
|
|
|
int corner_widths_location;
|
|
|
|
int corner_heights_location;
|
|
|
|
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;
|
2018-03-15 16:27:19 +00:00
|
|
|
int outline_location;
|
|
|
|
int corner_widths_location;
|
|
|
|
int corner_heights_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;
|
2017-11-22 20:02:50 +00:00
|
|
|
};
|
2017-11-30 17:47:55 +00:00
|
|
|
|
2017-11-22 20:02:50 +00:00
|
|
|
} Program;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
guint op;
|
|
|
|
|
|
|
|
union {
|
|
|
|
float opacity;
|
|
|
|
graphene_matrix_t modelview; /* TODO: Make both matrix members just "matrix" */
|
|
|
|
graphene_matrix_t projection;
|
|
|
|
const Program *program;
|
|
|
|
int texture_id;
|
|
|
|
int render_target_id;
|
|
|
|
GdkRGBA color;
|
|
|
|
GskQuadVertex vertex_data[6];
|
|
|
|
GskRoundedRect clip;
|
|
|
|
graphene_rect_t viewport;
|
|
|
|
struct {
|
|
|
|
int n_color_stops;
|
|
|
|
float color_offsets[8];
|
|
|
|
float color_stops[4 * 8];
|
|
|
|
graphene_point_t start_point;
|
|
|
|
graphene_point_t end_point;
|
|
|
|
} linear_gradient;
|
2017-11-23 18:49:41 +00:00
|
|
|
struct {
|
|
|
|
gsize vao_offset;
|
2017-11-24 09:24:49 +00:00
|
|
|
gsize vao_size;
|
2017-11-23 18:49:41 +00:00
|
|
|
} draw;
|
2017-11-24 09:32:08 +00:00
|
|
|
struct {
|
|
|
|
graphene_matrix_t matrix;
|
|
|
|
graphene_vec4_t offset;
|
|
|
|
} color_matrix;
|
2017-11-25 07:56:50 +00:00
|
|
|
struct {
|
|
|
|
float radius;
|
|
|
|
graphene_size_t size;
|
2017-12-28 15:41:32 +00:00
|
|
|
float dir[2];
|
2017-11-25 07:56:50 +00:00
|
|
|
} blur;
|
2017-11-30 15:48:03 +00:00
|
|
|
struct {
|
|
|
|
float outline[4];
|
|
|
|
float corner_widths[4];
|
|
|
|
float corner_heights[4];
|
|
|
|
float radius;
|
|
|
|
float spread;
|
2017-11-30 17:47:55 +00:00
|
|
|
float offset[2];
|
2017-11-30 15:48:03 +00:00
|
|
|
float color[4];
|
|
|
|
} inset_shadow;
|
2017-12-01 07:30:11 +00:00
|
|
|
struct {
|
|
|
|
float outline[4];
|
|
|
|
float corner_widths[4];
|
|
|
|
float corner_heights[4];
|
|
|
|
float radius;
|
|
|
|
float spread;
|
|
|
|
float offset[2];
|
|
|
|
float color[4];
|
|
|
|
} outset_shadow;
|
2018-01-15 09:55:40 +00:00
|
|
|
struct {
|
|
|
|
float outline[4];
|
|
|
|
float corner_widths[4];
|
|
|
|
float corner_heights[4];
|
|
|
|
float radius;
|
|
|
|
float spread;
|
|
|
|
float offset[2];
|
|
|
|
float color[4];
|
|
|
|
} unblurred_outset_shadow;
|
2017-12-01 09:27:31 +00:00
|
|
|
struct {
|
|
|
|
float color[4];
|
|
|
|
} shadow;
|
2017-12-01 10:55:10 +00:00
|
|
|
struct {
|
|
|
|
float widths[4];
|
2017-12-05 07:38:42 +00:00
|
|
|
float color[4];
|
2018-03-15 16:27:19 +00:00
|
|
|
GskRoundedRect outline;
|
2017-12-01 10:55:10 +00:00
|
|
|
} border;
|
2017-12-11 07:22:28 +00:00
|
|
|
struct {
|
|
|
|
float progress;
|
|
|
|
int source2;
|
|
|
|
} cross_fade;
|
2018-12-02 07:12:09 +00:00
|
|
|
struct {
|
|
|
|
char *filename;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
} dump;
|
2017-11-22 20:02:50 +00:00
|
|
|
};
|
|
|
|
} RenderOp;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2018-12-02 13:17:18 +00:00
|
|
|
GskRoundedRect clip;
|
|
|
|
graphene_matrix_t modelview;
|
|
|
|
graphene_matrix_t projection;
|
|
|
|
int source_texture;
|
|
|
|
graphene_rect_t viewport;
|
|
|
|
float opacity;
|
|
|
|
/* Per-program state */
|
|
|
|
union {
|
|
|
|
GdkRGBA color;
|
|
|
|
struct {
|
|
|
|
graphene_matrix_t matrix;
|
|
|
|
graphene_vec4_t offset;
|
|
|
|
} color_matrix;
|
|
|
|
struct {
|
|
|
|
float widths[4];
|
|
|
|
float color[4];
|
|
|
|
GskRoundedRect outline;
|
|
|
|
} border;
|
|
|
|
};
|
|
|
|
} ProgramState;
|
2017-11-22 20:02:50 +00:00
|
|
|
|
2018-12-02 13:17:18 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
ProgramState program_state[GL_N_PROGRAMS];
|
2017-11-22 20:02:50 +00:00
|
|
|
/* Current global state */
|
2018-12-02 13:17:18 +00:00
|
|
|
ProgramState *current_program_state;
|
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;
|
2017-11-22 20:02:50 +00:00
|
|
|
|
|
|
|
gsize buffer_size;
|
|
|
|
|
|
|
|
GArray *render_ops;
|
|
|
|
GskGLRenderer *renderer;
|
2018-11-26 16:52:35 +00:00
|
|
|
|
|
|
|
/* Stack of modelview matrices */
|
|
|
|
GArray *mv_stack;
|
|
|
|
/* Pointer into mv_stack */
|
|
|
|
const graphene_matrix_t *current_modelview;
|
2018-12-30 14:25:01 +00:00
|
|
|
|
|
|
|
/* Same thing */
|
|
|
|
GArray *clip_stack;
|
|
|
|
const GskRoundedRect *current_clip;
|
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);
|
2017-11-22 20:02:50 +00:00
|
|
|
|
2018-11-26 16:52:35 +00:00
|
|
|
void ops_finish (RenderOpBuilder *builder);
|
|
|
|
void ops_push_modelview (RenderOpBuilder *builder,
|
2019-02-23 06:50:51 +00:00
|
|
|
const graphene_matrix_t *mv,
|
|
|
|
GskMatrixCategory mv_category);
|
|
|
|
void ops_set_modelview (RenderOpBuilder *builder,
|
|
|
|
const graphene_matrix_t *mv,
|
|
|
|
GskMatrixCategory mv_category);
|
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);
|
|
|
|
|
2017-11-22 20:02:50 +00:00
|
|
|
void ops_draw (RenderOpBuilder *builder,
|
|
|
|
const GskQuadVertex vertex_data[GL_N_VERTICES]);
|
|
|
|
|
2017-12-09 17:26:29 +00:00
|
|
|
void ops_offset (RenderOpBuilder *builder,
|
|
|
|
float x,
|
|
|
|
float y);
|
|
|
|
|
2017-11-22 20:02:50 +00:00
|
|
|
void ops_add (RenderOpBuilder *builder,
|
|
|
|
const RenderOp *op);
|
|
|
|
|
|
|
|
#endif
|