mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 02:40:11 +00:00
gpu: Make linear gradients use variations
This commit is contained in:
parent
2e81e4d452
commit
8032e30a76
@ -8,6 +8,8 @@
|
||||
|
||||
#include "gpu/shaders/gskgpulineargradientinstance.h"
|
||||
|
||||
#define VARIATION_REPEATING 1
|
||||
|
||||
typedef struct _GskGpuLinearGradientOp GskGpuLinearGradientOp;
|
||||
|
||||
struct _GskGpuLinearGradientOp
|
||||
@ -26,7 +28,7 @@ gsk_gpu_linear_gradient_op_print (GskGpuOp *op,
|
||||
|
||||
instance = (GskGpuLineargradientInstance *) gsk_gpu_frame_get_vertex_data (frame, shader->vertex_offset);
|
||||
|
||||
if (instance->repeating)
|
||||
if (shader->variation & VARIATION_REPEATING)
|
||||
gsk_gpu_print_op (string, indent, "repeating-linear-gradient");
|
||||
else
|
||||
gsk_gpu_print_op (string, indent, "linear-gradient");
|
||||
@ -71,7 +73,7 @@ gsk_gpu_linear_gradient_op (GskGpuFrame *frame,
|
||||
|
||||
gsk_gpu_shader_op_alloc (frame,
|
||||
&GSK_GPU_LINEAR_GRADIENT_OP_CLASS,
|
||||
0,
|
||||
repeating ? VARIATION_REPEATING : 0,
|
||||
clip,
|
||||
NULL,
|
||||
&instance);
|
||||
@ -93,5 +95,4 @@ gsk_gpu_linear_gradient_op (GskGpuFrame *frame,
|
||||
instance->offsets0[1] = stops[1].offset;
|
||||
gsk_gpu_rgba_to_float (&stops[0].color, instance->color0);
|
||||
instance->offsets0[0] = stops[0].offset;
|
||||
instance->repeating = repeating;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "common.glsl"
|
||||
|
||||
#define VARIATION_REPEATING ((GSK_VARIATION & 1u) == 1u)
|
||||
|
||||
PASS(0) vec2 _pos;
|
||||
PASS_FLAT(1) Rect _rect;
|
||||
PASS_FLAT(2) vec4 _color0;
|
||||
@ -12,7 +14,6 @@ PASS_FLAT(8) vec4 _color6;
|
||||
PASS_FLAT(9) vec4 _offsets0;
|
||||
PASS_FLAT(10) vec3 _offsets1;
|
||||
PASS(11) float _offset;
|
||||
PASS_FLAT(12) uint _repeating;
|
||||
|
||||
|
||||
#ifdef GSK_VERTEX_SHADER
|
||||
@ -28,7 +29,6 @@ IN(7) vec4 in_color5;
|
||||
IN(8) vec4 in_color6;
|
||||
IN(9) vec4 in_offsets0;
|
||||
IN(10) vec3 in_offsets1;
|
||||
IN(11) uint in_repeating;
|
||||
|
||||
void
|
||||
run (out vec2 pos)
|
||||
@ -54,7 +54,6 @@ run (out vec2 pos)
|
||||
_color6 = in_color6;
|
||||
_offsets0 = in_offsets0;
|
||||
_offsets1 = in_offsets1;
|
||||
_repeating = in_repeating;
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -111,7 +110,7 @@ run (out vec4 color,
|
||||
{
|
||||
float alpha = rect_coverage (_rect, _pos);
|
||||
float offset;
|
||||
if (_repeating != 0u)
|
||||
if (VARIATION_REPEATING)
|
||||
offset = fract (_offset);
|
||||
else
|
||||
offset = clamp (_offset, 0.0, 1.0);
|
||||
|
Loading…
Reference in New Issue
Block a user