mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-14 14:20:21 +00:00
Merge branch 'wip/otte/for-main' into 'main'
gpu: Remove the ubershader See merge request GNOME/gtk!7419
This commit is contained in:
commit
fc4c6525e6
@ -290,8 +290,8 @@ are only available when GTK has been configured with `-Ddebug=true`.
|
||||
`fallback`
|
||||
: Information about fallback usage in renderers
|
||||
|
||||
`glyphcache`
|
||||
: Information about glyph caching
|
||||
`cache`
|
||||
: Information about caching
|
||||
|
||||
`verbose`
|
||||
: Print verbose output while rendering
|
||||
|
@ -408,7 +408,7 @@ gsk_gl_glyph_library_add (GskGLGlyphLibrary *self,
|
||||
width = (int) ceil (ink_rect.width * key->scale / 1024.0);
|
||||
height = (int) ceil (ink_rect.height * key->scale / 1024.0);
|
||||
|
||||
GSK_DEBUG (GLYPH_CACHE, "font %p glyph %u: %u x %u pixels", key->font, key->glyph, width, height);
|
||||
GSK_DEBUG (CACHE, "font %p glyph %u: %u x %u pixels", key->font, key->glyph, width, height);
|
||||
|
||||
value = gsk_gl_texture_library_pack (tl,
|
||||
key,
|
||||
|
@ -74,7 +74,7 @@ gsk_gl_texture_library_real_compact (GskGLTextureLibrary *self,
|
||||
|
||||
if (gsk_gl_texture_atlas_get_unused_ratio (atlas) > MAX_OLD_RATIO)
|
||||
{
|
||||
GSK_DEBUG (GLYPH_CACHE,
|
||||
GSK_DEBUG (CACHE,
|
||||
"Dropping atlas %d (%g.2%% old)", i,
|
||||
100.0 * gsk_gl_texture_atlas_get_unused_ratio (atlas));
|
||||
if (removed == NULL)
|
||||
@ -122,10 +122,10 @@ gsk_gl_texture_library_real_compact (GskGLTextureLibrary *self,
|
||||
}
|
||||
}
|
||||
|
||||
GSK_DEBUG (GLYPH_CACHE, "%s: Dropped %d individual items",
|
||||
GSK_DEBUG (CACHE, "%s: Dropped %d individual items",
|
||||
G_OBJECT_TYPE_NAME (self),
|
||||
dropped);
|
||||
GSK_DEBUG (GLYPH_CACHE, "%s: %d items cached (%d atlased, %d individually)",
|
||||
GSK_DEBUG (CACHE, "%s: %d items cached (%d atlased, %d individually)",
|
||||
G_OBJECT_TYPE_NAME (self),
|
||||
g_hash_table_size (self->hash_table),
|
||||
atlased,
|
||||
@ -139,7 +139,7 @@ gsk_gl_texture_library_real_compact (GskGLTextureLibrary *self,
|
||||
g_clear_pointer (&removed, g_ptr_array_unref);
|
||||
}
|
||||
|
||||
if (GSK_DEBUG_CHECK (GLYPH_CACHE))
|
||||
if (GSK_DEBUG_CHECK (CACHE))
|
||||
{
|
||||
static gint64 last_message;
|
||||
gint64 now = g_get_monotonic_time ();
|
||||
|
@ -517,7 +517,7 @@ gsk_gpu_cache_gc (GskGpuCache *self,
|
||||
|
||||
g_atomic_pointer_set (&self->dead_texture_pixels, 0);
|
||||
|
||||
if (GSK_DEBUG_CHECK (GLYPH_CACHE))
|
||||
if (GSK_DEBUG_CHECK (CACHE))
|
||||
print_cache_stats (self);
|
||||
|
||||
gdk_profiler_end_mark (before, "Glyph cache GC", NULL);
|
||||
|
@ -63,7 +63,7 @@ cache_gc_cb (gpointer data)
|
||||
gint64 timestamp;
|
||||
|
||||
timestamp = g_get_monotonic_time ();
|
||||
GSK_DEBUG (GLYPH_CACHE, "Periodic GC (timestamp %lld)", (long long) timestamp);
|
||||
GSK_DEBUG (CACHE, "Periodic GC (timestamp %lld)", (long long) timestamp);
|
||||
|
||||
if (gsk_gpu_device_gc (self, timestamp))
|
||||
{
|
||||
@ -90,7 +90,7 @@ gsk_gpu_device_maybe_gc (GskGpuDevice *self)
|
||||
|
||||
if (priv->cache_timeout == 0 || dead_texture_pixels > 1000000)
|
||||
{
|
||||
GSK_DEBUG (GLYPH_CACHE, "Pre-frame GC (%" G_GSIZE_FORMAT " dead pixels)", dead_texture_pixels);
|
||||
GSK_DEBUG (CACHE, "Pre-frame GC (%" G_GSIZE_FORMAT " dead pixels)", dead_texture_pixels);
|
||||
gsk_gpu_device_gc (self, g_get_monotonic_time ());
|
||||
}
|
||||
}
|
||||
@ -168,7 +168,7 @@ gsk_gpu_device_setup (GskGpuDevice *self,
|
||||
}
|
||||
}
|
||||
|
||||
if (GSK_DEBUG_CHECK (GLYPH_CACHE))
|
||||
if (GSK_DEBUG_CHECK (CACHE))
|
||||
{
|
||||
if (priv->cache_timeout < 0)
|
||||
gdk_debug_message ("Cache GC disabled");
|
||||
|
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
|
@ -8,7 +8,7 @@ static const GdkDebugKey gsk_debug_keys[] = {
|
||||
{ "vulkan", GSK_DEBUG_VULKAN, "Vulkan renderer information" },
|
||||
{ "shaders", GSK_DEBUG_SHADERS, "Information about shaders" },
|
||||
{ "fallback", GSK_DEBUG_FALLBACK, "Information about fallback usage in renderers" },
|
||||
{ "glyphcache", GSK_DEBUG_GLYPH_CACHE, "Information about glyph caching" },
|
||||
{ "cache", GSK_DEBUG_CACHE, "Information about caching" },
|
||||
{ "verbose", GSK_DEBUG_VERBOSE, "Print verbose output while rendering" },
|
||||
{ "geometry", GSK_DEBUG_GEOMETRY, "Show borders (when using cairo)" },
|
||||
{ "full-redraw", GSK_DEBUG_FULL_REDRAW, "Force full redraws" },
|
||||
|
@ -10,7 +10,7 @@ typedef enum {
|
||||
GSK_DEBUG_SHADERS = 1 << 2,
|
||||
GSK_DEBUG_VULKAN = 1 << 3,
|
||||
GSK_DEBUG_FALLBACK = 1 << 4,
|
||||
GSK_DEBUG_GLYPH_CACHE = 1 << 5,
|
||||
GSK_DEBUG_CACHE = 1 << 5,
|
||||
GSK_DEBUG_VERBOSE = 1 << 6,
|
||||
/* flags below may affect behavior */
|
||||
GSK_DEBUG_GEOMETRY = 1 << 7,
|
||||
|
@ -109,7 +109,6 @@ gsk_private_sources = files([
|
||||
'gpu/gskgpuscissorop.c',
|
||||
'gpu/gskgpustraightalphaop.c',
|
||||
'gpu/gskgputextureop.c',
|
||||
'gpu/gskgpuuberop.c',
|
||||
'gpu/gskgpuuploadop.c',
|
||||
])
|
||||
|
||||
|
@ -64,7 +64,7 @@ struct _GtkInspectorLogs
|
||||
GtkWidget *cairo;
|
||||
GtkWidget *vulkan_gsk;
|
||||
GtkWidget *shaders;
|
||||
GtkWidget *glyphcache;
|
||||
GtkWidget *cache;
|
||||
GtkWidget *verbose;
|
||||
|
||||
GtkWidget *actions;
|
||||
@ -143,7 +143,7 @@ flag_toggled (GtkWidget *button,
|
||||
update_flag (logs->cairo, &flags, GSK_DEBUG_CAIRO);
|
||||
update_flag (logs->vulkan_gsk, &flags, GSK_DEBUG_VULKAN);
|
||||
update_flag (logs->shaders, &flags, GSK_DEBUG_SHADERS);
|
||||
update_flag (logs->glyphcache, &flags, GSK_DEBUG_GLYPH_CACHE);
|
||||
update_flag (logs->cache, &flags, GSK_DEBUG_CACHE);
|
||||
update_flag (logs->verbose, &flags, GSK_DEBUG_VERBOSE);
|
||||
gsk_set_debug_flags (flags);
|
||||
|
||||
@ -205,7 +205,7 @@ gtk_inspector_logs_class_init (GtkInspectorLogsClass *klass)
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorLogs, cairo);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorLogs, vulkan_gsk);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorLogs, shaders);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorLogs, glyphcache);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorLogs, cache);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorLogs, verbose);
|
||||
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorLogs, actions);
|
||||
|
@ -141,8 +141,8 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="glyphcache">
|
||||
<property name="label">Glyph Cache</property>
|
||||
<object class="GtkCheckButton" id="cache">
|
||||
<property name="label">Cache</property>
|
||||
<signal name="toggled" handler="flag_toggled"/>
|
||||
</object>
|
||||
</child>
|
||||
|
@ -60,6 +60,7 @@ show_file (const char *filename,
|
||||
graphene_rect_t node_bounds;
|
||||
GdkPaintable *paintable;
|
||||
GtkWidget *sw;
|
||||
GtkWidget *handle;
|
||||
GtkWidget *window;
|
||||
gboolean done = FALSE;
|
||||
GtkSnapshot *snapshot;
|
||||
@ -82,10 +83,16 @@ show_file (const char *filename,
|
||||
gtk_scrolled_window_set_propagate_natural_height (GTK_SCROLLED_WINDOW (sw), TRUE);
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), picture);
|
||||
|
||||
handle = gtk_window_handle_new ();
|
||||
gtk_window_handle_set_child (GTK_WINDOW_HANDLE (handle), sw);
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_decorated (GTK_WINDOW (window), decorated);
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), decorated);
|
||||
if (!decorated)
|
||||
gtk_widget_remove_css_class (window, "background");
|
||||
set_window_title (GTK_WINDOW (window), filename);
|
||||
gtk_window_set_child (GTK_WINDOW (window), sw);
|
||||
gtk_window_set_child (GTK_WINDOW (window), handle);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
|
||||
|
Loading…
Reference in New Issue
Block a user