mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 02:40:11 +00:00
gpu: Remove the ubershader
It didn't bring any noticable benefits and it isn't compatible with the way we intend to do colorstate support. And nobody seems to want to spend time on it, so let's get rid of it. We can bring it back later if someone wants to work on it.
This commit is contained in:
parent
be8fef9811
commit
012c4b9425
File diff suppressed because it is too large
Load Diff
@ -24,7 +24,6 @@
|
||||
#define GSK_GPU_MAX_FRAMES 4
|
||||
|
||||
static const GdkDebugKey gsk_gpu_optimization_keys[] = {
|
||||
{ "uber", GSK_GPU_OPTIMIZE_UBER, "Don't use the uber shader" },
|
||||
{ "clear", GSK_GPU_OPTIMIZE_CLEAR, "Use shaders instead of vkCmdClearAttachment()/glClear()" },
|
||||
{ "merge", GSK_GPU_OPTIMIZE_MERGE, "Use one vkCmdDraw()/glDrawArrays() per operation" },
|
||||
{ "blit", GSK_GPU_OPTIMIZE_BLIT, "Use shaders instead of vkCmdBlit()/glBlitFramebuffer()" },
|
||||
|
@ -113,11 +113,10 @@ G_STATIC_ASSERT (GSK_GPU_PATTERN_BLEND_SATURATION == GSK_GPU_PATTERN_BLEND_DEFAU
|
||||
G_STATIC_ASSERT (GSK_GPU_PATTERN_BLEND_LUMINOSITY == GSK_GPU_PATTERN_BLEND_DEFAULT + GSK_BLEND_MODE_LUMINOSITY);
|
||||
|
||||
typedef enum {
|
||||
GSK_GPU_OPTIMIZE_UBER = 1 << 0,
|
||||
GSK_GPU_OPTIMIZE_CLEAR = 1 << 1,
|
||||
GSK_GPU_OPTIMIZE_MERGE = 1 << 2,
|
||||
GSK_GPU_OPTIMIZE_BLIT = 1 << 3,
|
||||
GSK_GPU_OPTIMIZE_GRADIENTS = 1 << 4,
|
||||
GSK_GPU_OPTIMIZE_MIPMAP = 1 << 5,
|
||||
GSK_GPU_OPTIMIZE_CLEAR = 1 << 0,
|
||||
GSK_GPU_OPTIMIZE_MERGE = 1 << 1,
|
||||
GSK_GPU_OPTIMIZE_BLIT = 1 << 2,
|
||||
GSK_GPU_OPTIMIZE_GRADIENTS = 1 << 3,
|
||||
GSK_GPU_OPTIMIZE_MIPMAP = 1 << 4,
|
||||
} GskGpuOptimizations;
|
||||
|
||||
|
@ -1,69 +0,0 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gskgpuuberopprivate.h"
|
||||
|
||||
#include "gskgpuframeprivate.h"
|
||||
#include "gskgpuprintprivate.h"
|
||||
#include "gskgpushaderopprivate.h"
|
||||
#include "gskrectprivate.h"
|
||||
|
||||
#include "gpu/shaders/gskgpuuberinstance.h"
|
||||
|
||||
typedef struct _GskGpuUberOp GskGpuUberOp;
|
||||
|
||||
struct _GskGpuUberOp
|
||||
{
|
||||
GskGpuShaderOp op;
|
||||
};
|
||||
|
||||
static void
|
||||
gsk_gpu_uber_op_print_instance (GskGpuShaderOp *shader,
|
||||
gpointer instance_,
|
||||
GString *string)
|
||||
{
|
||||
GskGpuUberInstance *instance = instance_;
|
||||
|
||||
gsk_gpu_print_rect (string, instance->rect);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_UBER_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuUberOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
gsk_gpu_shader_op_finish,
|
||||
gsk_gpu_shader_op_print,
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
gsk_gpu_shader_op_vk_command,
|
||||
#endif
|
||||
gsk_gpu_shader_op_gl_command
|
||||
},
|
||||
"gskgpuuber",
|
||||
sizeof (GskGpuUberInstance),
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
&gsk_gpu_uber_info,
|
||||
#endif
|
||||
gsk_gpu_uber_op_print_instance,
|
||||
gsk_gpu_uber_setup_attrib_locations,
|
||||
gsk_gpu_uber_setup_vao,
|
||||
};
|
||||
|
||||
void
|
||||
gsk_gpu_uber_op (GskGpuFrame *frame,
|
||||
GskGpuShaderClip clip,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_point_t *offset,
|
||||
GskGpuDescriptors *desc,
|
||||
guint32 pattern_id)
|
||||
{
|
||||
GskGpuUberInstance *instance;
|
||||
|
||||
gsk_gpu_shader_op_alloc (frame,
|
||||
&GSK_GPU_UBER_OP_CLASS,
|
||||
0,
|
||||
clip,
|
||||
desc,
|
||||
&instance);
|
||||
|
||||
gsk_gpu_rect_to_float (rect, offset, instance->rect);
|
||||
instance->pattern_id = pattern_id;
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "gskgpushaderopprivate.h"
|
||||
|
||||
#include <graphene.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void gsk_gpu_uber_op (GskGpuFrame *frame,
|
||||
GskGpuShaderClip clip,
|
||||
const graphene_rect_t *rect,
|
||||
const graphene_point_t *offset,
|
||||
GskGpuDescriptors *desc,
|
||||
guint32 pattern_id);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -75,12 +75,6 @@ gsk_ngl_renderer_create_context (GskGpuRenderer *renderer,
|
||||
|
||||
*supported = -1;
|
||||
|
||||
/* Shader compilation takes too long when texture() and get_float() calls
|
||||
* use if/else ladders to avoid non-uniform indexing.
|
||||
* And that is always true with GL.
|
||||
*/
|
||||
*supported &= ~GSK_GPU_OPTIMIZE_UBER;
|
||||
|
||||
return GDK_DRAW_CONTEXT (context);
|
||||
}
|
||||
|
||||
|
@ -102,15 +102,6 @@ gsk_vulkan_renderer_create_context (GskGpuRenderer *renderer,
|
||||
|
||||
*supported = -1;
|
||||
|
||||
/* Shader compilation takes too long when texture() and get_float() calls
|
||||
* use if/else ladders to avoid non-uniform indexing.
|
||||
* This is true when we use the Vulkan 1.0 shaders, but works with the Vulkan 1.2
|
||||
* shaders.
|
||||
*/
|
||||
if (!gdk_display_has_vulkan_feature (display, GDK_VULKAN_FEATURE_DYNAMIC_INDEXING) ||
|
||||
!gdk_display_has_vulkan_feature (display, GDK_VULKAN_FEATURE_NONUNIFORM_INDEXING))
|
||||
*supported &= ~GSK_GPU_OPTIMIZE_UBER;
|
||||
|
||||
return GDK_DRAW_CONTEXT (context);
|
||||
}
|
||||
|
||||
|
@ -1,147 +0,0 @@
|
||||
#ifndef _GRADIENT_
|
||||
#define _GRADIENT_
|
||||
|
||||
#ifdef GSK_FRAGMENT_SHADER
|
||||
|
||||
#include "common.glsl"
|
||||
|
||||
struct Gradient
|
||||
{
|
||||
int n_stops;
|
||||
uint offset;
|
||||
};
|
||||
|
||||
float
|
||||
gradient_read_offset (Gradient self,
|
||||
int i)
|
||||
{
|
||||
return gsk_get_float (self.offset + uint(i) * 5u);
|
||||
}
|
||||
|
||||
vec4
|
||||
gradient_read_color (Gradient self,
|
||||
int i)
|
||||
{
|
||||
uint u = uint (clamp (i, 0, self.n_stops - 1));
|
||||
return vec4 (gsk_get_float (self.offset + u * 5u + 1u),
|
||||
gsk_get_float (self.offset + u * 5u + 2u),
|
||||
gsk_get_float (self.offset + u * 5u + 3u),
|
||||
gsk_get_float (self.offset + u * 5u + 4u));
|
||||
}
|
||||
|
||||
vec4
|
||||
gradient_get_color_for_range_unscaled (Gradient self,
|
||||
float start,
|
||||
float end)
|
||||
{
|
||||
vec4 result = vec4 (0.0);
|
||||
float offset;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < self.n_stops; i++)
|
||||
{
|
||||
offset = gradient_read_offset (self, i);
|
||||
if (offset >= start)
|
||||
break;
|
||||
}
|
||||
if (i == self.n_stops)
|
||||
offset = 1.0;
|
||||
|
||||
float last_offset = i > 0 ? gradient_read_offset (self, i - 1) : 0.0;
|
||||
vec4 last_color = gradient_read_color (self, i - 1);
|
||||
vec4 color = gradient_read_color (self, i);
|
||||
if (last_offset < start)
|
||||
{
|
||||
last_color = mix (last_color, color, (start - last_offset) / (offset - last_offset));
|
||||
last_offset = start;
|
||||
}
|
||||
if (end <= start)
|
||||
return last_color;
|
||||
|
||||
for (; i < self.n_stops; i++)
|
||||
{
|
||||
offset = gradient_read_offset (self, i);
|
||||
color = gradient_read_color (self, i);
|
||||
if (offset >= end)
|
||||
break;
|
||||
result += 0.5 * (color + last_color) * (offset - last_offset);
|
||||
last_offset = offset;
|
||||
last_color = color;
|
||||
}
|
||||
if (i == self.n_stops)
|
||||
{
|
||||
offset = 1.0;
|
||||
color = gradient_read_color (self, i);
|
||||
}
|
||||
if (offset > end)
|
||||
{
|
||||
color = mix (last_color, color, (end - last_offset) / (offset - last_offset));
|
||||
offset = end;
|
||||
}
|
||||
result += 0.5 * (color + last_color) * (offset - last_offset);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
vec4
|
||||
gradient_get_color_repeating (Gradient self,
|
||||
float start,
|
||||
float end)
|
||||
{
|
||||
vec4 c;
|
||||
|
||||
if (floor (end) > floor (start))
|
||||
{
|
||||
float fract_end = fract(end);
|
||||
float fract_start = fract(start);
|
||||
float n = floor (end) - floor (start);
|
||||
if (fract_end > fract_start + 0.01)
|
||||
c = gradient_get_color_for_range_unscaled (self, fract_start, fract_end);
|
||||
else if (fract_start > fract_end + 0.01)
|
||||
c = - gradient_get_color_for_range_unscaled (self, fract_end, fract_start);
|
||||
c += gradient_get_color_for_range_unscaled (self, 0.0, 1.0) * n;
|
||||
}
|
||||
else
|
||||
{
|
||||
start = fract (start);
|
||||
end = fract (end);
|
||||
c = gradient_get_color_for_range_unscaled (self, start, end);
|
||||
}
|
||||
c /= end - start;
|
||||
|
||||
return color_premultiply (c);
|
||||
}
|
||||
|
||||
vec4
|
||||
gradient_get_color (Gradient self,
|
||||
float start,
|
||||
float end)
|
||||
{
|
||||
vec4 c;
|
||||
|
||||
start = clamp (start, 0.0, 1.0);
|
||||
end = clamp (end, 0.0, 1.0);
|
||||
c = gradient_get_color_for_range_unscaled (self, start, end);
|
||||
if (end > start)
|
||||
c /= end - start;
|
||||
|
||||
return color_premultiply (c);
|
||||
}
|
||||
|
||||
uint
|
||||
gradient_get_size (Gradient self)
|
||||
{
|
||||
return uint (self.n_stops) * 5u + 1u;
|
||||
}
|
||||
|
||||
Gradient
|
||||
gradient_new (uint offset)
|
||||
{
|
||||
Gradient self = Gradient (gsk_get_int (offset),
|
||||
offset + 1u);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
#endif /* GSK_FRAGMENT_SHADER */
|
||||
#endif /* __GRADIENT__ */
|
@ -1,41 +0,0 @@
|
||||
#include "common.glsl"
|
||||
#include "pattern.glsl"
|
||||
|
||||
PASS(0) vec2 _pos;
|
||||
PASS_FLAT(1) Rect _rect;
|
||||
PASS_FLAT(2) uint _pattern_id;
|
||||
|
||||
|
||||
#ifdef GSK_VERTEX_SHADER
|
||||
|
||||
IN(0) vec4 in_rect;
|
||||
IN(1) uint in_pattern_id;
|
||||
|
||||
void
|
||||
run (out vec2 pos)
|
||||
{
|
||||
Rect r = rect_from_gsk (in_rect);
|
||||
|
||||
pos = rect_get_position (r);
|
||||
|
||||
_pos = pos;
|
||||
_rect = r;
|
||||
_pattern_id = in_pattern_id;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef GSK_FRAGMENT_SHADER
|
||||
|
||||
void
|
||||
run (out vec4 color,
|
||||
out vec2 position)
|
||||
{
|
||||
color = pattern (_pattern_id, _pos);
|
||||
color.a *= rect_coverage (_rect, _pos);
|
||||
position = _pos;
|
||||
}
|
||||
|
||||
#endif
|
@ -6,8 +6,6 @@ gsk_private_gpu_include_shaders = files([
|
||||
'common-vulkan.glsl',
|
||||
'ellipse.glsl',
|
||||
'enums.glsl',
|
||||
'gradient.glsl',
|
||||
'pattern.glsl',
|
||||
'rect.glsl',
|
||||
'roundedrect.glsl',
|
||||
])
|
||||
@ -28,7 +26,6 @@ gsk_private_gpu_shaders = files([
|
||||
'gskgpuroundedcolor.glsl',
|
||||
'gskgpustraightalpha.glsl',
|
||||
'gskgputexture.glsl',
|
||||
'gskgpuuber.glsl',
|
||||
])
|
||||
|
||||
gsk_private_gpu_shader_headers = []
|
||||
|
@ -1,459 +0,0 @@
|
||||
#ifndef _PATTERN_
|
||||
#define _PATTERN_
|
||||
|
||||
#include "common.glsl"
|
||||
#include "blendmode.glsl"
|
||||
#include "gradient.glsl"
|
||||
#include "rect.glsl"
|
||||
|
||||
#ifdef GSK_FRAGMENT_SHADER
|
||||
|
||||
vec4 stack[GSK_GPU_PATTERN_STACK_SIZE];
|
||||
uint stack_size = 0u;
|
||||
|
||||
void
|
||||
stack_push (vec4 data)
|
||||
{
|
||||
stack[stack_size] = data;
|
||||
stack_size++;
|
||||
}
|
||||
|
||||
vec4
|
||||
stack_pop (void)
|
||||
{
|
||||
stack_size--;
|
||||
return stack[stack_size];
|
||||
}
|
||||
|
||||
struct Position
|
||||
{
|
||||
/* pos.xy is the actual position
|
||||
pos.zw is the fwidth() of it
|
||||
*/
|
||||
vec4 pos;
|
||||
};
|
||||
|
||||
vec2
|
||||
position (Position pos)
|
||||
{
|
||||
return pos.pos.xy;
|
||||
}
|
||||
|
||||
vec2
|
||||
position_fwidth (Position pos)
|
||||
{
|
||||
return pos.pos.zw;
|
||||
}
|
||||
|
||||
Position
|
||||
position_new (vec2 pos)
|
||||
{
|
||||
return Position (vec4 (pos, fwidth (pos)));
|
||||
}
|
||||
|
||||
uint
|
||||
read_uint (inout uint reader)
|
||||
{
|
||||
uint result = gsk_get_uint (reader);
|
||||
reader++;
|
||||
return result;
|
||||
}
|
||||
|
||||
float
|
||||
read_float (inout uint reader)
|
||||
{
|
||||
float result = gsk_get_float (reader);
|
||||
reader++;
|
||||
return result;
|
||||
}
|
||||
|
||||
vec2
|
||||
read_vec2 (inout uint reader)
|
||||
{
|
||||
return vec2 (read_float (reader), read_float (reader));
|
||||
}
|
||||
|
||||
vec4
|
||||
read_vec4 (inout uint reader)
|
||||
{
|
||||
return vec4 (read_float (reader), read_float (reader), read_float (reader), read_float (reader));
|
||||
}
|
||||
|
||||
Rect
|
||||
read_rect (inout uint reader)
|
||||
{
|
||||
return rect_new_size (read_vec4 (reader));
|
||||
}
|
||||
|
||||
mat4
|
||||
read_mat4 (inout uint reader)
|
||||
{
|
||||
mat4 result = mat4 (gsk_get_float (reader + 0u), gsk_get_float (reader + 1u),
|
||||
gsk_get_float (reader + 2u), gsk_get_float (reader + 3u),
|
||||
gsk_get_float (reader + 4u), gsk_get_float (reader + 5u),
|
||||
gsk_get_float (reader + 6u), gsk_get_float (reader + 7u),
|
||||
gsk_get_float (reader + 8u), gsk_get_float (reader + 9u),
|
||||
gsk_get_float (reader + 10u), gsk_get_float (reader + 11u),
|
||||
gsk_get_float (reader + 12u), gsk_get_float (reader + 13u),
|
||||
gsk_get_float (reader + 14u), gsk_get_float (reader + 15u));
|
||||
reader += 16u;
|
||||
return result;
|
||||
}
|
||||
|
||||
Gradient
|
||||
read_gradient (inout uint reader)
|
||||
{
|
||||
Gradient gradient = gradient_new (reader);
|
||||
reader += gradient_get_size (gradient);
|
||||
|
||||
return gradient;
|
||||
}
|
||||
|
||||
void
|
||||
clip_pattern (inout uint reader,
|
||||
inout vec4 color,
|
||||
Position pos)
|
||||
{
|
||||
Rect clip = read_rect (reader);
|
||||
float alpha = rect_coverage (clip, position (pos), abs (position_fwidth (pos)));
|
||||
|
||||
color *= alpha;
|
||||
}
|
||||
|
||||
void
|
||||
opacity_pattern (inout uint reader,
|
||||
inout vec4 color)
|
||||
{
|
||||
float opacity = read_float (reader);
|
||||
|
||||
color *= opacity;
|
||||
}
|
||||
|
||||
void
|
||||
color_matrix_pattern (inout uint reader,
|
||||
inout vec4 color)
|
||||
{
|
||||
mat4 matrix = read_mat4 (reader);
|
||||
vec4 offset = read_vec4 (reader);
|
||||
|
||||
color = color_unpremultiply (color);
|
||||
|
||||
color = matrix * color + offset;
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
|
||||
color = color_premultiply (color);
|
||||
}
|
||||
|
||||
void
|
||||
repeat_push_pattern (inout uint reader,
|
||||
inout Position pos)
|
||||
{
|
||||
stack_push (pos.pos);
|
||||
Rect bounds = read_rect (reader);
|
||||
|
||||
vec2 size = rect_size (bounds);
|
||||
pos.pos.xy = mod (pos.pos.xy - bounds.bounds.xy, size);
|
||||
/* make sure we have a positive result */
|
||||
pos.pos.xy = mix (pos.pos.xy, pos.pos.xy + size, lessThan (pos.pos.xy, vec2 (0.0)));
|
||||
pos.pos.xy += bounds.bounds.xy;
|
||||
}
|
||||
|
||||
void
|
||||
affine_pattern (inout uint reader,
|
||||
inout Position pos)
|
||||
{
|
||||
stack_push (pos.pos);
|
||||
vec4 transform = read_vec4 (reader);
|
||||
|
||||
pos.pos.zw *= transform.zw;
|
||||
pos.pos.xy -= transform.xy;
|
||||
pos.pos.xy *= transform.zw;
|
||||
}
|
||||
|
||||
void
|
||||
position_pop_pattern (inout uint reader,
|
||||
inout Position pos)
|
||||
{
|
||||
pos = Position (stack_pop ());
|
||||
}
|
||||
|
||||
void
|
||||
cross_fade_pattern (inout uint reader,
|
||||
inout vec4 color)
|
||||
{
|
||||
vec4 start = stack_pop ();
|
||||
float progress = read_float (reader);
|
||||
|
||||
color = mix (start, color, progress);
|
||||
}
|
||||
|
||||
void
|
||||
mask_alpha_pattern (inout uint reader,
|
||||
inout vec4 color)
|
||||
{
|
||||
vec4 source = stack_pop ();
|
||||
|
||||
color = source * color.a;
|
||||
}
|
||||
|
||||
void
|
||||
mask_inverted_alpha_pattern (inout uint reader,
|
||||
inout vec4 color)
|
||||
{
|
||||
vec4 source = stack_pop ();
|
||||
|
||||
color = source * (1.0 - color.a);
|
||||
}
|
||||
|
||||
void
|
||||
mask_luminance_pattern (inout uint reader,
|
||||
inout vec4 color)
|
||||
{
|
||||
vec4 source = stack_pop ();
|
||||
|
||||
color = source * luminance (color.rgb);
|
||||
}
|
||||
|
||||
void
|
||||
mask_inverted_luminance_pattern (inout uint reader,
|
||||
inout vec4 color)
|
||||
{
|
||||
vec4 source = stack_pop ();
|
||||
|
||||
color = source * (color.a - luminance (color.rgb));
|
||||
}
|
||||
|
||||
void
|
||||
blend_mode_pattern (inout vec4 color,
|
||||
uint mode)
|
||||
{
|
||||
vec4 bottom = stack_pop ();
|
||||
|
||||
color = blend_mode (bottom, color, mode);
|
||||
}
|
||||
|
||||
vec4
|
||||
glyphs_pattern (inout uint reader,
|
||||
Position pos)
|
||||
{
|
||||
float opacity = 0.0;
|
||||
vec4 color = color_premultiply (read_vec4 (reader));
|
||||
uint num_glyphs = read_uint (reader);
|
||||
uint i;
|
||||
|
||||
vec2 p = position (pos);
|
||||
vec2 dFdp = abs (position_fwidth (pos));
|
||||
for (i = 0u; i < num_glyphs; i++)
|
||||
{
|
||||
uint tex_id = read_uint (reader);
|
||||
Rect glyph_bounds = read_rect (reader);
|
||||
vec4 tex_rect = read_vec4 (reader);
|
||||
|
||||
float coverage = rect_coverage (glyph_bounds, p, dFdp);
|
||||
if (coverage > 0.0)
|
||||
opacity += coverage * gsk_texture (tex_id, (p - tex_rect.xy) / tex_rect.zw).a;
|
||||
}
|
||||
|
||||
return color * opacity;
|
||||
}
|
||||
|
||||
vec4
|
||||
texture_pattern (inout uint reader,
|
||||
Position pos)
|
||||
{
|
||||
uint tex_id = read_uint (reader);
|
||||
vec4 tex_rect = read_vec4 (reader);
|
||||
|
||||
return gsk_texture (tex_id, (position (pos) - tex_rect.xy) / tex_rect.zw);
|
||||
}
|
||||
|
||||
vec4
|
||||
straight_alpha_pattern (inout uint reader,
|
||||
Position pos)
|
||||
{
|
||||
uint tex_id = read_uint (reader);
|
||||
vec4 tex_rect = read_vec4 (reader);
|
||||
|
||||
return gsk_texture_straight_alpha (tex_id, (position (pos) - tex_rect.xy) / tex_rect.zw);
|
||||
}
|
||||
|
||||
vec4
|
||||
linear_gradient_pattern (inout uint reader,
|
||||
Position pos,
|
||||
bool repeating)
|
||||
{
|
||||
vec2 start = read_vec2 (reader);
|
||||
vec2 end = read_vec2 (reader);
|
||||
Gradient gradient = read_gradient (reader);
|
||||
|
||||
vec2 line = end - start;
|
||||
float line_length = dot (line, line);
|
||||
float offset = dot (position (pos) - start, line) / line_length;
|
||||
float other_offset = dot (position (pos) + position_fwidth (pos) - start, line) / line_length;
|
||||
float d_offset = 0.5 * abs (offset - other_offset);
|
||||
|
||||
if (repeating)
|
||||
return gradient_get_color_repeating (gradient, offset - d_offset, offset + d_offset);
|
||||
else
|
||||
return gradient_get_color (gradient, offset - d_offset, offset + d_offset);
|
||||
}
|
||||
|
||||
vec4
|
||||
radial_gradient_pattern (inout uint reader,
|
||||
Position pos,
|
||||
bool repeating)
|
||||
{
|
||||
vec2 center = read_vec2 (reader);
|
||||
vec2 radius = read_vec2 (reader);
|
||||
float start = read_float (reader);
|
||||
float end = read_float (reader);
|
||||
Gradient gradient = read_gradient (reader);
|
||||
|
||||
float offset = length ((position (pos) - center) / radius);
|
||||
float other_offset = length ((position (pos) + position_fwidth (pos) - center) / radius);
|
||||
offset = (offset - start) / (end - start);
|
||||
other_offset = (other_offset - start) / (end - start);
|
||||
float d_offset = abs (0.5 * (offset - other_offset));
|
||||
|
||||
if (repeating)
|
||||
return gradient_get_color_repeating (gradient, offset - d_offset, offset + d_offset);
|
||||
else
|
||||
return gradient_get_color (gradient, offset - d_offset, offset + d_offset);
|
||||
}
|
||||
|
||||
vec4
|
||||
conic_gradient_pattern (inout uint reader,
|
||||
Position pos)
|
||||
{
|
||||
vec2 center = read_vec2 (reader);
|
||||
float angle = read_float (reader);
|
||||
Gradient gradient = read_gradient (reader);
|
||||
|
||||
/* scaling modifies angles, so be sure to use right coordinate system */
|
||||
vec2 dpos = position (pos) - center;
|
||||
vec2 dpos2 = (position (pos) + position_fwidth (pos)) - center;
|
||||
float offset = atan (dpos.y, dpos.x);
|
||||
float offset2 = atan (dpos2.y, dpos2.x);
|
||||
offset = degrees (offset + angle) / 360.0;
|
||||
offset2 = degrees (offset2 + angle) / 360.0;
|
||||
float overflow = fract (offset + 0.5);
|
||||
float overflow2 = fract (offset2 + 0.5);
|
||||
offset = fract (offset);
|
||||
offset2 = fract (offset2);
|
||||
float d_offset = max (0.00001, 0.5 * min (abs (offset - offset2), abs (overflow - overflow2)));
|
||||
|
||||
return gradient_get_color_repeating (gradient, offset - d_offset, offset + d_offset);
|
||||
}
|
||||
|
||||
vec4
|
||||
color_pattern (inout uint reader)
|
||||
{
|
||||
vec4 color = read_vec4 (reader);
|
||||
|
||||
return color_premultiply (color);
|
||||
}
|
||||
|
||||
vec4
|
||||
pattern (uint reader,
|
||||
vec2 pos_)
|
||||
{
|
||||
vec4 color = vec4 (1.0, 0.0, 0.8, 1.0); /* pink */
|
||||
Position pos = position_new (pos_ / GSK_GLOBAL_SCALE);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
uint type = read_uint (reader);
|
||||
switch (type)
|
||||
{
|
||||
default:
|
||||
case GSK_GPU_PATTERN_DONE:
|
||||
return color;
|
||||
case GSK_GPU_PATTERN_COLOR:
|
||||
color = color_pattern (reader);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_TEXTURE:
|
||||
color = texture_pattern (reader, pos);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_STRAIGHT_ALPHA:
|
||||
color = straight_alpha_pattern (reader, pos);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_GLYPHS:
|
||||
color = glyphs_pattern (reader, pos);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_COLOR_MATRIX:
|
||||
color_matrix_pattern (reader, color);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_OPACITY:
|
||||
opacity_pattern (reader, color);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_LINEAR_GRADIENT:
|
||||
color = linear_gradient_pattern (reader, pos, false);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_REPEATING_LINEAR_GRADIENT:
|
||||
color = linear_gradient_pattern (reader, pos, true);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_RADIAL_GRADIENT:
|
||||
color = radial_gradient_pattern (reader, pos, false);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_REPEATING_RADIAL_GRADIENT:
|
||||
color = radial_gradient_pattern (reader, pos, true);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_CONIC_GRADIENT:
|
||||
color = conic_gradient_pattern (reader, pos);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_CLIP:
|
||||
clip_pattern (reader, color, pos);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_REPEAT_PUSH:
|
||||
repeat_push_pattern (reader, pos);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_POSITION_POP:
|
||||
position_pop_pattern (reader, pos);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_PUSH_COLOR:
|
||||
stack_push (color);
|
||||
color = vec4 (0.0);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_POP_CROSS_FADE:
|
||||
cross_fade_pattern (reader, color);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_POP_MASK_ALPHA:
|
||||
mask_alpha_pattern (reader, color);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_POP_MASK_INVERTED_ALPHA:
|
||||
mask_inverted_alpha_pattern (reader, color);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_POP_MASK_LUMINANCE:
|
||||
mask_luminance_pattern (reader, color);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_POP_MASK_INVERTED_LUMINANCE:
|
||||
mask_inverted_luminance_pattern (reader, color);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_AFFINE:
|
||||
affine_pattern (reader, pos);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_BLEND_DEFAULT:
|
||||
case GSK_GPU_PATTERN_BLEND_MULTIPLY:
|
||||
case GSK_GPU_PATTERN_BLEND_SCREEN:
|
||||
case GSK_GPU_PATTERN_BLEND_OVERLAY:
|
||||
case GSK_GPU_PATTERN_BLEND_DARKEN:
|
||||
case GSK_GPU_PATTERN_BLEND_LIGHTEN:
|
||||
case GSK_GPU_PATTERN_BLEND_COLOR_DODGE:
|
||||
case GSK_GPU_PATTERN_BLEND_COLOR_BURN:
|
||||
case GSK_GPU_PATTERN_BLEND_HARD_LIGHT:
|
||||
case GSK_GPU_PATTERN_BLEND_SOFT_LIGHT:
|
||||
case GSK_GPU_PATTERN_BLEND_DIFFERENCE:
|
||||
case GSK_GPU_PATTERN_BLEND_EXCLUSION:
|
||||
case GSK_GPU_PATTERN_BLEND_COLOR:
|
||||
case GSK_GPU_PATTERN_BLEND_HUE:
|
||||
case GSK_GPU_PATTERN_BLEND_SATURATION:
|
||||
case GSK_GPU_PATTERN_BLEND_LUMINOSITY:
|
||||
blend_mode_pattern (color, type - GSK_GPU_PATTERN_BLEND_DEFAULT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -109,7 +109,6 @@ gsk_private_sources = files([
|
||||
'gpu/gskgpuscissorop.c',
|
||||
'gpu/gskgpustraightalphaop.c',
|
||||
'gpu/gskgputextureop.c',
|
||||
'gpu/gskgpuuberop.c',
|
||||
'gpu/gskgpuuploadop.c',
|
||||
])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user