Compare commits
111 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f6532288bc | |||
| d64f782b28 | |||
| 1e2c03beee | |||
| b24e10fa30 | |||
| 173952cbc8 | |||
| b31f4f2bae | |||
| df9d9c1f8a | |||
| 7dcb25bd46 | |||
| d131c8d0e7 | |||
| 0582a4ef1b | |||
| a9b1d4a389 | |||
| ea810f176b | |||
| 262ac4247a | |||
| 8e4f0b9484 | |||
| 7669e6e42e | |||
| a3f14a3395 | |||
| 73b8212bf3 | |||
| 6ba6f361be | |||
| 726909d735 | |||
| 04899e3707 | |||
| 7a27122dab | |||
| 73ce437459 | |||
| ca4ae81170 | |||
| 21a7dfae96 | |||
| 6c188f7c93 | |||
| c30e0f78ad | |||
| 76795ffba9 | |||
| c38c5c4ce1 | |||
| 108aac9ee3 | |||
| c427c2b22a | |||
| 59111d100f | |||
| cee8f78c6e | |||
| 0fc35b2124 | |||
| eebe67cf0a | |||
| b9726901a5 | |||
| df1d2b8417 | |||
| 8b1af398a0 | |||
| 982d73df0b | |||
| 1e55e01692 | |||
| 412fcb0330 | |||
| b8d1c3ab55 | |||
| 4fb519f04d | |||
| 054d69aaf9 | |||
| 1dea6d4fc7 | |||
| 022d19a4c6 | |||
| ef7276c398 | |||
| 0a8ca49b5e | |||
| 74f18f71d3 | |||
| c0d4a6fc81 | |||
| 1dd31d58fb | |||
| 766d4dff76 | |||
| e62f135c6a | |||
| 4788f88840 | |||
| 587bc82c37 | |||
| 750dc8dbe2 | |||
| d490d8f1f3 | |||
| cb2f523994 | |||
| 075a0ccb5e | |||
| db91b6dc61 | |||
| 44ac2d5abb | |||
| d7df56b6cb | |||
| 6a9bc5daef | |||
| b8aa51d522 | |||
| f79c807645 | |||
| d0d2ad9f5b | |||
| 0b8298038a | |||
| 6ef0bb8bea | |||
| 91472b2ecd | |||
| 80ddcf38d4 | |||
| 1477882b31 | |||
| 73f2167fe4 | |||
| 2079c898e7 | |||
| c79c18f39c | |||
| cef7f7f87d | |||
| fdce30d3f8 | |||
| f07397f4dd | |||
| f1751f514c | |||
| 2cbfb0e980 | |||
| 8dd7f5aefe | |||
| 398f49ad31 | |||
| 3d260a950e | |||
| f31667f437 | |||
| 219493c818 | |||
| 06f63764fb | |||
| 1243174e53 | |||
| cc909b160f | |||
| d12dde07c3 | |||
| 5191b6fccd | |||
| 2e6e6c1779 | |||
| a29b8fbef4 | |||
| 5b072e716c | |||
| 49845795d9 | |||
| ab04c74ec9 | |||
| 4744bb9099 | |||
| 91522dda63 | |||
| 095a378dbc | |||
| 0956c30ee5 | |||
| f85448ffbf | |||
| d3852ca33a | |||
| 9d9a730659 | |||
| 3f4cd4190f | |||
| 448a402353 | |||
| 2ee9752822 | |||
| f8a1f796b5 | |||
| 3b5a4cf215 | |||
| 759d53cfa0 | |||
| 814d20d61a | |||
| 6cef520804 | |||
| 8c77491150 | |||
| 709ebcedd4 | |||
| 47e6b88555 |
+1
-1
@@ -174,7 +174,7 @@ maintainers review your contribution.
|
||||
|
||||
Each contribution is reviewed by the core developers of the GTK project.
|
||||
|
||||
The [CODE-OWNERS](./docs/CODE-OWNERS) document contains the list of core
|
||||
The [CODEOWNERS](./docs/CODEOWNERS) document contains the list of core
|
||||
contributors to GTK and the areas for which they are responsible; you
|
||||
should ensure to receive their review and signoff on your changes.
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ GskRenderNodeType
|
||||
gsk_render_node_get_node_type
|
||||
gsk_render_node_draw
|
||||
GskSerializationError
|
||||
GskParseErrorFunc
|
||||
gsk_render_node_serialize
|
||||
gsk_render_node_deserialize
|
||||
gsk_render_node_write_to_file
|
||||
|
||||
+4
-1
@@ -448,7 +448,10 @@ gdk_drop_get_surface (GdkDrop *self)
|
||||
* Returns the possible actions for this #GdkDrop. If this value
|
||||
* contains multiple actions - ie gdk_drag_action_is_unique()
|
||||
* returns %FALSE for the result - gdk_drag_finish() must choose
|
||||
* the action to use when accepting the drop.
|
||||
* the action to use when accepting the drop. This will only
|
||||
* happen if you passed %GDK_ACTION_ASK as one of the possible
|
||||
* actions in gdk_drag_status(). %GDK_ACTION_ASK itself will not
|
||||
* be included in the actions returned by this function.
|
||||
*
|
||||
* This value may change over the lifetime of the #GdkDrop both
|
||||
* as a response to source side actions as well as to calls to
|
||||
|
||||
+2
-1
@@ -955,7 +955,8 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
|
||||
if (priv->use_es < 0)
|
||||
priv->use_es = !epoxy_is_desktop_gl ();
|
||||
|
||||
priv->has_debug_output = epoxy_has_gl_extension ("GL_ARB_debug_output");
|
||||
priv->has_debug_output = epoxy_has_gl_extension ("GL_ARB_debug_output") ||
|
||||
epoxy_has_gl_extension ("GL_KHR_debug");
|
||||
|
||||
#ifdef G_ENABLE_CONSISTENCY_CHECKS
|
||||
if (priv->has_debug_output)
|
||||
|
||||
+12
-9
@@ -100,7 +100,7 @@ gdk_rgba_free (GdkRGBA *rgba)
|
||||
gboolean
|
||||
gdk_rgba_is_clear (const GdkRGBA *rgba)
|
||||
{
|
||||
return rgba->alpha < ((double) 0x00ff / (double) 0xffff);
|
||||
return rgba->alpha < ((float) 0x00ff / (float) 0xffff);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ gdk_rgba_is_clear (const GdkRGBA *rgba)
|
||||
gboolean
|
||||
gdk_rgba_is_opaque (const GdkRGBA *rgba)
|
||||
{
|
||||
return rgba->alpha > ((double)0xff00 / (double)0xffff);
|
||||
return rgba->alpha > ((float)0xff00 / (float)0xffff);
|
||||
}
|
||||
|
||||
#define SKIP_WHITESPACES(s) while (*(s) == ' ') (s)++;
|
||||
@@ -398,23 +398,25 @@ gdk_rgba_to_string (const GdkRGBA *rgba)
|
||||
|
||||
static gboolean
|
||||
parse_color_channel_value (GtkCssParser *parser,
|
||||
double *value,
|
||||
float *value,
|
||||
gboolean is_percentage)
|
||||
{
|
||||
double dvalue;
|
||||
|
||||
if (is_percentage)
|
||||
{
|
||||
if (!gtk_css_parser_consume_percentage (parser, value))
|
||||
if (!gtk_css_parser_consume_percentage (parser, &dvalue))
|
||||
return FALSE;
|
||||
|
||||
*value = CLAMP (*value, 0.0, 100.0) / 100.0;
|
||||
*value = CLAMP (dvalue, 0.0, 100.0) / 100.0;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gtk_css_parser_consume_number (parser, value))
|
||||
if (!gtk_css_parser_consume_number (parser, &dvalue))
|
||||
return FALSE;
|
||||
|
||||
*value = CLAMP (*value, 0.0, 255.0) / 255.0;
|
||||
*value = CLAMP (dvalue, 0.0, 255.0) / 255.0;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -425,6 +427,7 @@ parse_color_channel (GtkCssParser *parser,
|
||||
gpointer data)
|
||||
{
|
||||
GdkRGBA *rgba = data;
|
||||
double dvalue;
|
||||
|
||||
switch (arg)
|
||||
{
|
||||
@@ -450,10 +453,10 @@ parse_color_channel (GtkCssParser *parser,
|
||||
return 1;
|
||||
|
||||
case 3:
|
||||
if (!gtk_css_parser_consume_number (parser, &rgba->alpha))
|
||||
if (!gtk_css_parser_consume_number (parser, &dvalue))
|
||||
return 0;
|
||||
|
||||
rgba->alpha = CLAMP (rgba->alpha, 0.0, 1.0);
|
||||
rgba->alpha = CLAMP (dvalue, 0.0, 1.0);
|
||||
return 1;
|
||||
|
||||
default:
|
||||
|
||||
+4
-4
@@ -36,10 +36,10 @@ G_BEGIN_DECLS
|
||||
|
||||
struct _GdkRGBA
|
||||
{
|
||||
gdouble red;
|
||||
gdouble green;
|
||||
gdouble blue;
|
||||
gdouble alpha;
|
||||
float red;
|
||||
float green;
|
||||
float blue;
|
||||
float alpha;
|
||||
};
|
||||
|
||||
#define GDK_TYPE_RGBA (gdk_rgba_get_type ())
|
||||
|
||||
+4
-3
@@ -568,11 +568,12 @@ typedef enum
|
||||
* @GDK_ACTION_MOVE: Move the data, i.e. first copy it, then delete
|
||||
* it from the source using the DELETE target of the X selection protocol.
|
||||
* @GDK_ACTION_LINK: Add a link to the data. Note that this is only
|
||||
* useful if source and destination agree on what it means.
|
||||
* useful if source and destination agree on what it means, and is not
|
||||
* supported on all platforms.
|
||||
* @GDK_ACTION_ASK: Ask the user what to do with the data.
|
||||
*
|
||||
* Used in #GdkDrag to indicate what the destination
|
||||
* should do with the dropped data.
|
||||
* Used in #GdkDrop and #GdkDrag to indicate the actions that the
|
||||
* destination can and should do with the dropped data.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
|
||||
@@ -55,9 +55,6 @@ _gdk_quartz_display_open (const gchar *display_name)
|
||||
if (_gdk_display != NULL)
|
||||
return NULL;
|
||||
|
||||
/* Initialize application */
|
||||
[NSApplication sharedApplication];
|
||||
|
||||
_gdk_display = g_object_new (gdk_quartz_display_get_type (), NULL);
|
||||
_gdk_device_manager = _gdk_device_manager_new (_gdk_display);
|
||||
|
||||
@@ -67,6 +64,8 @@ _gdk_quartz_display_open (const gchar *display_name)
|
||||
|
||||
_gdk_quartz_events_init ();
|
||||
|
||||
/* Initialize application */
|
||||
[NSApplication sharedApplication];
|
||||
#if 0
|
||||
/* FIXME: Remove the #if 0 when we have these functions */
|
||||
_gdk_quartz_dnd_init ();
|
||||
|
||||
@@ -795,8 +795,7 @@ _gdk_quartz_display_create_surface_impl (GdkDisplay *display,
|
||||
|
||||
if (window->surface_type == GDK_SURFACE_TEMP)
|
||||
{
|
||||
/* without NSMiniaturizableWindowMask window will not minimize */
|
||||
style_mask = NSBorderlessWindowMask | NSMiniaturizableWindowMask;
|
||||
style_mask = NSBorderlessWindowMask;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2711,7 +2710,6 @@ gdk_surface_impl_quartz_class_init (GdkSurfaceImplQuartzClass *klass)
|
||||
impl_class->set_decorations = gdk_quartz_surface_set_decorations;
|
||||
impl_class->get_decorations = gdk_quartz_surface_get_decorations;
|
||||
impl_class->set_functions = gdk_quartz_surface_set_functions;
|
||||
impl_class->set_functions = gdk_quartz_surface_set_functions;
|
||||
impl_class->begin_resize_drag = gdk_quartz_surface_begin_resize_drag;
|
||||
impl_class->begin_move_drag = gdk_quartz_surface_begin_move_drag;
|
||||
impl_class->set_opacity = gdk_quartz_surface_set_opacity;
|
||||
|
||||
@@ -1258,6 +1258,8 @@ data_device_enter (void *data,
|
||||
seat->pending_offer = NULL;
|
||||
|
||||
seat->drop = gdk_wayland_drop_new (device, seat->drag, formats, dest_surface, offer, serial);
|
||||
gdk_wayland_drop_set_source_actions (seat->drop, seat->pending_source_actions);
|
||||
gdk_wayland_drop_set_action (seat->drop, seat->pending_action);
|
||||
|
||||
gdk_wayland_seat_discard_pending_offer (seat);
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ gdk_wayland_drag_drop_done (GdkDrag *drag,
|
||||
GdkWaylandDrag *drag_wayland = GDK_WAYLAND_DRAG (drag);
|
||||
GdkDevice *device = gdk_drag_get_device (drag);
|
||||
|
||||
gdk_wayland_seat_set_drag (gdk_device_get_seat (device), drag);
|
||||
gdk_wayland_seat_set_drag (gdk_device_get_seat (device), NULL);
|
||||
|
||||
if (success)
|
||||
{
|
||||
|
||||
@@ -51,7 +51,6 @@ struct _GdkWaylandDrop
|
||||
struct wl_data_offer *offer;
|
||||
uint32_t source_actions;
|
||||
uint32_t action;
|
||||
GdkDragAction selected_action;
|
||||
uint32_t serial;
|
||||
};
|
||||
|
||||
@@ -116,43 +115,43 @@ gdk_wayland_drop_drop_set_status (GdkWaylandDrop *drop_wayland,
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drop_commit_status (GdkWaylandDrop *wayland_drop)
|
||||
gdk_wayland_drop_commit_status (GdkWaylandDrop *wayland_drop,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
uint32_t dnd_actions;
|
||||
|
||||
display = gdk_drop_get_display (GDK_DROP (wayland_drop));
|
||||
|
||||
dnd_actions = gdk_to_wl_actions (wayland_drop->selected_action);
|
||||
|
||||
if (GDK_WAYLAND_DISPLAY (display)->data_device_manager_version >=
|
||||
WL_DATA_OFFER_SET_ACTIONS_SINCE_VERSION)
|
||||
{
|
||||
if (gdk_drag_action_is_unique (wayland_drop->selected_action))
|
||||
{
|
||||
wl_data_offer_set_actions (wayland_drop->offer, dnd_actions, dnd_actions);
|
||||
}
|
||||
uint32_t dnd_actions;
|
||||
uint32_t preferred_action;
|
||||
|
||||
dnd_actions = gdk_to_wl_actions (actions);
|
||||
|
||||
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
|
||||
preferred_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
|
||||
else if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
|
||||
preferred_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
|
||||
else if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
|
||||
preferred_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK;
|
||||
else
|
||||
{
|
||||
wl_data_offer_set_actions (wayland_drop->offer,
|
||||
dnd_actions | WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK,
|
||||
WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK);
|
||||
}
|
||||
preferred_action = 0;
|
||||
|
||||
wl_data_offer_set_actions (wayland_drop->offer, dnd_actions, preferred_action);
|
||||
}
|
||||
|
||||
gdk_wayland_drop_drop_set_status (wayland_drop, wayland_drop->selected_action != 0);
|
||||
gdk_wayland_drop_drop_set_status (wayland_drop, actions != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drop_status (GdkDrop *drop,
|
||||
GdkDragAction action)
|
||||
GdkDragAction actions)
|
||||
{
|
||||
GdkWaylandDrop *wayland_drop;
|
||||
GdkWaylandDrop *wayland_drop = GDK_WAYLAND_DROP (drop);
|
||||
|
||||
wayland_drop = GDK_WAYLAND_DROP (drop);
|
||||
wayland_drop->selected_action = action;
|
||||
|
||||
gdk_wayland_drop_commit_status (wayland_drop);
|
||||
gdk_wayland_drop_commit_status (wayland_drop, actions);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -163,11 +162,9 @@ gdk_wayland_drop_finish (GdkDrop *drop,
|
||||
GdkDisplay *display = gdk_drop_get_display (drop);
|
||||
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
||||
|
||||
wayland_drop->selected_action = action;
|
||||
|
||||
if (action)
|
||||
{
|
||||
gdk_wayland_drop_commit_status (wayland_drop);
|
||||
gdk_wayland_drop_commit_status (wayland_drop, action);
|
||||
|
||||
if (display_wayland->data_device_manager_version >=
|
||||
WL_DATA_OFFER_FINISH_SINCE_VERSION)
|
||||
@@ -288,7 +285,8 @@ gdk_wayland_drop_update_actions (GdkWaylandDrop *drop)
|
||||
GdkDragAction gdk_actions = 0;
|
||||
uint32_t wl_actions;
|
||||
|
||||
if (drop->action & WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
|
||||
if (drop->action == 0 ||
|
||||
drop->action & WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
|
||||
wl_actions = drop->source_actions;
|
||||
else
|
||||
wl_actions = drop->action;
|
||||
|
||||
+20
-38
@@ -590,29 +590,27 @@ gsk_gl_driver_create_texture (GskGLDriver *self,
|
||||
return t->texture_id;
|
||||
}
|
||||
|
||||
static int
|
||||
create_render_target (GskGLDriver *self,
|
||||
int texture_id,
|
||||
gboolean add_depth_buffer,
|
||||
gboolean add_stencil_buffer)
|
||||
void
|
||||
gsk_gl_driver_create_render_target (GskGLDriver *self,
|
||||
int width,
|
||||
int height,
|
||||
int *out_texture_id,
|
||||
int *out_render_target_id)
|
||||
{
|
||||
GLuint fbo_id, depth_stencil_buffer_id;
|
||||
Texture *t;
|
||||
GLuint fbo_id;
|
||||
Texture *texture;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_GL_DRIVER (self), -1);
|
||||
g_return_val_if_fail (self->in_frame, -1);
|
||||
g_return_if_fail (self->in_frame);
|
||||
|
||||
t = gsk_gl_driver_get_texture (self, texture_id);
|
||||
if (t == NULL)
|
||||
return -1;
|
||||
|
||||
if (t->fbo.fbo_id != 0)
|
||||
fbo_clear (&t->fbo);
|
||||
texture = create_texture (self, width, height);
|
||||
gsk_gl_driver_bind_source_texture (self, texture->texture_id);
|
||||
gsk_gl_driver_init_texture_empty (self, texture->texture_id, GL_NEAREST, GL_NEAREST);
|
||||
|
||||
glGenFramebuffers (1, &fbo_id);
|
||||
glBindFramebuffer (GL_FRAMEBUFFER, fbo_id);
|
||||
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, t->texture_id, 0);
|
||||
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->texture_id, 0);
|
||||
|
||||
#if 0
|
||||
if (add_depth_buffer || add_stencil_buffer)
|
||||
{
|
||||
glGenRenderbuffersEXT (1, &depth_stencil_buffer_id);
|
||||
@@ -638,34 +636,18 @@ create_render_target (GskGLDriver *self,
|
||||
if (add_stencil_buffer)
|
||||
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
|
||||
GL_RENDERBUFFER, depth_stencil_buffer_id);
|
||||
texture->fbo.depth_stencil_id = depth_stencil_buffer_id;
|
||||
}
|
||||
#endif
|
||||
|
||||
t->fbo.fbo_id = fbo_id;
|
||||
t->fbo.depth_stencil_id = depth_stencil_buffer_id;
|
||||
texture->fbo.fbo_id = fbo_id;
|
||||
|
||||
g_assert_cmphex (glCheckFramebufferStatus (GL_FRAMEBUFFER), ==, GL_FRAMEBUFFER_COMPLETE);
|
||||
|
||||
glBindFramebuffer (GL_FRAMEBUFFER, self->default_fbo.fbo_id);
|
||||
|
||||
return fbo_id;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_gl_driver_create_render_target (GskGLDriver *self,
|
||||
int width,
|
||||
int height,
|
||||
int *out_texture_id,
|
||||
int *out_render_target_id)
|
||||
{
|
||||
int texture_id, render_target;
|
||||
|
||||
texture_id = gsk_gl_driver_create_texture (self, width, height);
|
||||
gsk_gl_driver_bind_source_texture (self, texture_id);
|
||||
gsk_gl_driver_init_texture_empty (self, texture_id, GL_NEAREST, GL_NEAREST);
|
||||
|
||||
render_target = create_render_target (self, texture_id, FALSE, FALSE);
|
||||
|
||||
*out_texture_id = texture_id;
|
||||
*out_render_target_id = render_target;
|
||||
*out_texture_id = texture->texture_id;
|
||||
*out_render_target_id = fbo_id;
|
||||
}
|
||||
|
||||
/* Mark the texture permanent, meaning it won'e be reused by the GLDriver.
|
||||
|
||||
@@ -195,10 +195,15 @@ upload_glyph (GlyphCacheKey *key,
|
||||
{
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, r.stride / 4);
|
||||
glBindTexture (GL_TEXTURE_2D, value->texture_id);
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
r.x, r.y, r.width, r.height,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
r.data);
|
||||
|
||||
if (gdk_gl_context_get_use_es (gdk_gl_context_get_current ()))
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0, r.x, r.y, r.width, r.height,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
r.data);
|
||||
else
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0, r.x, r.y, r.width, r.height,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
r.data);
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
|
||||
g_free (r.data);
|
||||
}
|
||||
|
||||
+19
-12
@@ -83,7 +83,7 @@ gsk_gl_icon_cache_begin_frame (GskGLIconCache *self,
|
||||
}
|
||||
|
||||
if (self->timestamp % MAX_FRAME_AGE == 0)
|
||||
{
|
||||
{
|
||||
g_hash_table_iter_init (&iter, self->icons);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer *)&texture, (gpointer *)&icon_data))
|
||||
{
|
||||
@@ -134,6 +134,7 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
|
||||
int packed_y = 0;
|
||||
cairo_surface_t *surface;
|
||||
unsigned char *surface_data;
|
||||
guint gl_format;
|
||||
|
||||
gsk_gl_texture_atlases_pack (self->atlases, width + 2, height + 2, &atlas, &packed_x, &packed_y);
|
||||
|
||||
@@ -155,30 +156,37 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
|
||||
surface_data = cairo_image_surface_get_data (surface);
|
||||
gdk_gl_context_push_debug_group_printf (gdk_gl_context_get_current (),
|
||||
"Uploading texture");
|
||||
|
||||
if (gdk_gl_context_get_use_es (gdk_gl_context_get_current ()))
|
||||
gl_format = GL_RGBA;
|
||||
else
|
||||
gl_format = GL_BGRA;
|
||||
|
||||
glBindTexture (GL_TEXTURE_2D, atlas->texture_id);
|
||||
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x + 1, packed_y + 1,
|
||||
width, height,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
gl_format,
|
||||
GL_UNSIGNED_BYTE,
|
||||
surface_data);
|
||||
/* Padding top */
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x + 1, packed_y,
|
||||
width, 1,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
gl_format, GL_UNSIGNED_BYTE,
|
||||
surface_data);
|
||||
/* Padding left */
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x, packed_y + 1,
|
||||
1, height,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
gl_format, GL_UNSIGNED_BYTE,
|
||||
surface_data);
|
||||
/* Padding top left */
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x, packed_y,
|
||||
1, 1,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
gl_format, GL_UNSIGNED_BYTE,
|
||||
surface_data);
|
||||
|
||||
/* Padding right */
|
||||
@@ -187,13 +195,13 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x + width + 1, packed_y + 1,
|
||||
1, height,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
gl_format, GL_UNSIGNED_BYTE,
|
||||
surface_data);
|
||||
/* Padding top right */
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x + width + 1, packed_y,
|
||||
1, 1,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
gl_format, GL_UNSIGNED_BYTE,
|
||||
surface_data);
|
||||
/* Padding bottom */
|
||||
glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
|
||||
@@ -202,13 +210,13 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x + 1, packed_y + 1 + height,
|
||||
width, 1,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
gl_format, GL_UNSIGNED_BYTE,
|
||||
surface_data);
|
||||
/* Padding bottom left */
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x, packed_y + 1 + height,
|
||||
1, 1,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
gl_format, GL_UNSIGNED_BYTE,
|
||||
surface_data);
|
||||
/* Padding bottom right */
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, width);
|
||||
@@ -216,9 +224,8 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
packed_x + 1 + width, packed_y + 1 + height,
|
||||
1, 1,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
gl_format, GL_UNSIGNED_BYTE,
|
||||
surface_data);
|
||||
|
||||
/* Reset this */
|
||||
glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
|
||||
@@ -239,7 +246,7 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
|
||||
char *filename = g_strdup_printf ("atlas_%u_%d.png", atlas->texture_id, k++);
|
||||
|
||||
glBindTexture (GL_TEXTURE_2D, atlas->texture_id);
|
||||
glGetTexImage (GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
|
||||
glGetTexImage (GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, data);
|
||||
s = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_ARGB32, atlas->width, atlas->height, stride);
|
||||
cairo_surface_write_to_png (s, filename);
|
||||
|
||||
|
||||
+308
-543
File diff suppressed because it is too large
Load Diff
+79
-55
@@ -8,6 +8,46 @@ rect_equal (const graphene_rect_t *a,
|
||||
return memcmp (a, b, sizeof (graphene_rect_t)) == 0;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
rounded_rect_equal (const GskRoundedRect *r1,
|
||||
const GskRoundedRect *r2)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!r1)
|
||||
return FALSE;
|
||||
|
||||
if (r1->bounds.origin.x != r2->bounds.origin.x ||
|
||||
r1->bounds.origin.y != r2->bounds.origin.y ||
|
||||
r1->bounds.size.width != r2->bounds.size.width ||
|
||||
r1->bounds.size.height != r2->bounds.size.height)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < 4; i ++)
|
||||
if (r1->corner[i].width != r2->corner[i].width ||
|
||||
r1->corner[i].height != r2->corner[i].height)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
rounded_rect_corners_equal (const GskRoundedRect *r1,
|
||||
const GskRoundedRect *r2)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!r1)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < 4; i ++)
|
||||
if (r1->corner[i].width != r2->corner[i].width ||
|
||||
r1->corner[i].height != r2->corner[i].height)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline ProgramState *
|
||||
get_current_program_state (RenderOpBuilder *builder)
|
||||
{
|
||||
@@ -41,16 +81,6 @@ ops_finish (RenderOpBuilder *builder)
|
||||
builder->current_viewport = GRAPHENE_RECT_INIT (0, 0, 0, 0);
|
||||
}
|
||||
|
||||
static inline void
|
||||
rgba_to_float (const GdkRGBA *c,
|
||||
float *f)
|
||||
{
|
||||
f[0] = c->red;
|
||||
f[1] = c->green;
|
||||
f[2] = c->blue;
|
||||
f[3] = c->alpha;
|
||||
}
|
||||
|
||||
/* Debugging only! */
|
||||
void
|
||||
ops_dump_framebuffer (RenderOpBuilder *builder,
|
||||
@@ -97,15 +127,12 @@ static void
|
||||
extract_matrix_metadata (GskTransform *transform,
|
||||
OpsMatrixMetadata *md)
|
||||
{
|
||||
float dummy;
|
||||
|
||||
switch (gsk_transform_get_category (transform))
|
||||
{
|
||||
case GSK_TRANSFORM_CATEGORY_IDENTITY:
|
||||
md->scale_x = 1;
|
||||
md->scale_y = 1;
|
||||
break;
|
||||
|
||||
case GSK_TRANSFORM_CATEGORY_2D_TRANSLATE:
|
||||
gsk_transform_to_translate (transform, &md->translate_x, &md->translate_y);
|
||||
md->scale_x = 1;
|
||||
md->scale_y = 1;
|
||||
break;
|
||||
@@ -113,7 +140,7 @@ extract_matrix_metadata (GskTransform *transform,
|
||||
case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
|
||||
gsk_transform_to_affine (transform,
|
||||
&md->scale_x, &md->scale_y,
|
||||
&md->translate_x, &md->translate_y);
|
||||
&dummy, &dummy);
|
||||
break;
|
||||
|
||||
case GSK_TRANSFORM_CATEGORY_UNKNOWN:
|
||||
@@ -129,9 +156,6 @@ extract_matrix_metadata (GskTransform *transform,
|
||||
|
||||
/* TODO: 90% sure this is incorrect. But we should never hit this code
|
||||
* path anyway. */
|
||||
md->translate_x = graphene_matrix_get_value (&m, 3, 0);
|
||||
md->translate_y = graphene_matrix_get_value (&m, 3, 1);
|
||||
|
||||
graphene_vec3_init (&col1,
|
||||
graphene_matrix_get_value (&m, 0, 0),
|
||||
graphene_matrix_get_value (&m, 1, 0),
|
||||
@@ -156,17 +180,13 @@ ops_transform_bounds_modelview (const RenderOpBuilder *builder,
|
||||
const graphene_rect_t *src,
|
||||
graphene_rect_t *dst)
|
||||
{
|
||||
const MatrixStackEntry *head;
|
||||
|
||||
g_assert (builder->mv_stack != NULL);
|
||||
g_assert (builder->mv_stack->len >= 1);
|
||||
|
||||
head = &g_array_index (builder->mv_stack, MatrixStackEntry, builder->mv_stack->len - 1);
|
||||
|
||||
gsk_transform_transform_bounds (builder->current_modelview, src, dst);
|
||||
|
||||
dst->origin.x += builder->dx * head->metadata.scale_x;
|
||||
dst->origin.y += builder->dy * head->metadata.scale_y;
|
||||
dst->origin.x += builder->dx * builder->scale_x;
|
||||
dst->origin.y += builder->dy * builder->scale_y;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -205,11 +225,6 @@ void
|
||||
ops_set_program (RenderOpBuilder *builder,
|
||||
const Program *program)
|
||||
{
|
||||
/* The tricky part about this is that we want to initialize all uniforms of a program
|
||||
* to the current value from the builder, but only once. */
|
||||
static const GskRoundedRect empty_clip;
|
||||
static const graphene_matrix_t empty_matrix;
|
||||
static const graphene_rect_t empty_rect;
|
||||
OpProgram *op;
|
||||
ProgramState *program_state;
|
||||
|
||||
@@ -223,9 +238,7 @@ ops_set_program (RenderOpBuilder *builder,
|
||||
|
||||
program_state = &builder->program_state[program->index];
|
||||
|
||||
/* If the projection is not yet set for this program, we use the current one. */
|
||||
if (memcmp (&empty_matrix, &program_state->projection, sizeof (graphene_matrix_t)) == 0 ||
|
||||
memcmp (&builder->current_projection, &program_state->projection, sizeof (graphene_matrix_t)) != 0)
|
||||
if (memcmp (&builder->current_projection, &program_state->projection, sizeof (graphene_matrix_t)) != 0)
|
||||
{
|
||||
OpMatrix *opm;
|
||||
|
||||
@@ -245,8 +258,7 @@ ops_set_program (RenderOpBuilder *builder,
|
||||
program_state->modelview = gsk_transform_ref (builder->current_modelview);
|
||||
}
|
||||
|
||||
if (rect_equal (&empty_rect, &program_state->viewport) ||
|
||||
!rect_equal (&builder->current_viewport, &program_state->viewport))
|
||||
if (!rect_equal (&builder->current_viewport, &program_state->viewport))
|
||||
{
|
||||
OpViewport *opv;
|
||||
|
||||
@@ -255,13 +267,13 @@ ops_set_program (RenderOpBuilder *builder,
|
||||
program_state->viewport = builder->current_viewport;
|
||||
}
|
||||
|
||||
if (memcmp (&empty_clip, &program_state->clip, sizeof (GskRoundedRect)) == 0 ||
|
||||
memcmp (&builder->current_clip, &program_state->clip, sizeof (GskRoundedRect)) != 0)
|
||||
if (!rounded_rect_equal (builder->current_clip, &program_state->clip))
|
||||
{
|
||||
OpClip *opc;
|
||||
|
||||
opc = ops_begin (builder, OP_CHANGE_CLIP);
|
||||
opc->clip = *builder->current_clip;
|
||||
opc->send_corners = !rounded_rect_corners_equal (builder->current_clip, &program_state->clip);
|
||||
program_state->clip = *builder->current_clip;
|
||||
}
|
||||
|
||||
@@ -283,15 +295,25 @@ ops_set_clip (RenderOpBuilder *builder,
|
||||
OpClip *op;
|
||||
|
||||
if (current_program_state &&
|
||||
memcmp (¤t_program_state->clip, clip,sizeof (GskRoundedRect)) == 0)
|
||||
rounded_rect_equal (¤t_program_state->clip, clip))
|
||||
return;
|
||||
|
||||
if (!(op = op_buffer_peek_tail_checked (&builder->render_ops, OP_CHANGE_CLIP)))
|
||||
op = op_buffer_add (&builder->render_ops, OP_CHANGE_CLIP);
|
||||
{
|
||||
op = op_buffer_add (&builder->render_ops, OP_CHANGE_CLIP);
|
||||
op->send_corners = !current_program_state ||
|
||||
!rounded_rect_corners_equal (¤t_program_state->clip, clip);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If the op before sent the corners, this one needs, too */
|
||||
op->send_corners |= !current_program_state ||
|
||||
!rounded_rect_corners_equal (¤t_program_state->clip, clip);
|
||||
}
|
||||
|
||||
op->clip = *clip;
|
||||
|
||||
if (builder->current_program != NULL)
|
||||
if (current_program_state)
|
||||
current_program_state->clip = *clip;
|
||||
}
|
||||
|
||||
@@ -343,7 +365,6 @@ ops_set_modelview_internal (RenderOpBuilder *builder,
|
||||
GskTransform *transform)
|
||||
{
|
||||
ProgramState *current_program_state = get_current_program_state (builder);
|
||||
graphene_matrix_t matrix;
|
||||
OpMatrix *op;
|
||||
|
||||
#if 0
|
||||
@@ -353,12 +374,10 @@ ops_set_modelview_internal (RenderOpBuilder *builder,
|
||||
return;
|
||||
#endif
|
||||
|
||||
gsk_transform_to_matrix (transform, &matrix);
|
||||
|
||||
if (!(op = op_buffer_peek_tail_checked (&builder->render_ops, OP_CHANGE_MODELVIEW)))
|
||||
op = op_buffer_add (&builder->render_ops, OP_CHANGE_MODELVIEW);
|
||||
|
||||
op->matrix = matrix;
|
||||
gsk_transform_to_matrix (transform, &op->matrix);
|
||||
|
||||
if (builder->current_program != NULL)
|
||||
{
|
||||
@@ -597,7 +616,7 @@ ops_set_color (RenderOpBuilder *builder,
|
||||
current_program_state->color = *color;
|
||||
|
||||
op = ops_begin (builder, OP_CHANGE_COLOR);
|
||||
op->rgba = *color;
|
||||
op->rgba = color;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -620,8 +639,8 @@ ops_set_color_matrix (RenderOpBuilder *builder,
|
||||
current_program_state->color_matrix.offset = *offset;
|
||||
|
||||
op = ops_begin (builder, OP_CHANGE_COLOR_MATRIX);
|
||||
op->matrix = *matrix;
|
||||
op->offset = *offset;
|
||||
op->matrix = matrix;
|
||||
op->offset = offset;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -668,19 +687,17 @@ ops_set_border_color (RenderOpBuilder *builder,
|
||||
{
|
||||
ProgramState *current_program_state = get_current_program_state (builder);
|
||||
OpBorder *op;
|
||||
float fcolor[4];
|
||||
|
||||
rgba_to_float (color, fcolor);
|
||||
|
||||
if (memcmp (fcolor, ¤t_program_state->border.color, sizeof fcolor) == 0)
|
||||
if (gdk_rgba_equal (color, ¤t_program_state->border.color))
|
||||
return;
|
||||
|
||||
op = op_buffer_add (&builder->render_ops, OP_CHANGE_BORDER_COLOR);
|
||||
memcpy (op->color, fcolor, sizeof (float[4]));
|
||||
memcpy (current_program_state->border.color, fcolor, sizeof (float[4]));
|
||||
op->color = color;
|
||||
|
||||
current_program_state->border.color = *color;
|
||||
}
|
||||
|
||||
void
|
||||
GskQuadVertex *
|
||||
ops_draw (RenderOpBuilder *builder,
|
||||
const GskQuadVertex vertex_data[GL_N_VERTICES])
|
||||
{
|
||||
@@ -697,7 +714,14 @@ ops_draw (RenderOpBuilder *builder,
|
||||
op->vao_size = GL_N_VERTICES;
|
||||
}
|
||||
|
||||
g_array_append_vals (builder->vertices, vertex_data, GL_N_VERTICES);
|
||||
if (vertex_data)
|
||||
{
|
||||
g_array_append_vals (builder->vertices, vertex_data, GL_N_VERTICES);
|
||||
return NULL; /* Better not use this on the caller side */
|
||||
}
|
||||
|
||||
g_array_set_size (builder->vertices, builder->vertices->len + GL_N_VERTICES);
|
||||
return &g_array_index (builder->vertices, GskQuadVertex, builder->vertices->len - GL_N_VERTICES);
|
||||
}
|
||||
|
||||
/* The offset is only valid for the current modelview.
|
||||
|
||||
@@ -15,12 +15,8 @@
|
||||
#define GL_N_VERTICES 6
|
||||
#define GL_N_PROGRAMS 13
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float translate_x;
|
||||
float translate_y;
|
||||
float scale_x;
|
||||
float scale_y;
|
||||
|
||||
@@ -44,14 +40,10 @@ struct _Program
|
||||
int position_location;
|
||||
int uv_location;
|
||||
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;
|
||||
|
||||
int clip_rect_location;
|
||||
union {
|
||||
struct {
|
||||
int color_location;
|
||||
@@ -66,7 +58,6 @@ struct _Program
|
||||
struct {
|
||||
int num_color_stops_location;
|
||||
int color_stops_location;
|
||||
int color_offsets_location;
|
||||
int start_point_location;
|
||||
int end_point_location;
|
||||
} linear_gradient;
|
||||
@@ -79,19 +70,13 @@ struct _Program
|
||||
int color_location;
|
||||
int spread_location;
|
||||
int offset_location;
|
||||
int outline_location;
|
||||
int corner_widths_location;
|
||||
int corner_heights_location;
|
||||
int outline_rect_location;
|
||||
} inset_shadow;
|
||||
struct {
|
||||
int outline_location;
|
||||
int corner_widths_location;
|
||||
int corner_heights_location;
|
||||
int outline_rect_location;
|
||||
} outset_shadow;
|
||||
struct {
|
||||
int outline_location;
|
||||
int corner_widths_location;
|
||||
int corner_heights_location;
|
||||
int outline_rect_location;
|
||||
int color_location;
|
||||
int spread_location;
|
||||
int offset_location;
|
||||
@@ -99,9 +84,7 @@ struct _Program
|
||||
struct {
|
||||
int color_location;
|
||||
int widths_location;
|
||||
int outline_location;
|
||||
int corner_widths_location;
|
||||
int corner_heights_location;
|
||||
int outline_rect_location;
|
||||
} border;
|
||||
struct {
|
||||
int source2_location;
|
||||
@@ -135,7 +118,7 @@ typedef struct
|
||||
} color_matrix;
|
||||
struct {
|
||||
float widths[4];
|
||||
float color[4];
|
||||
GdkRGBA color;
|
||||
GskRoundedRect outline;
|
||||
} border;
|
||||
};
|
||||
@@ -230,7 +213,7 @@ void ops_set_border_width (RenderOpBuilder *builder,
|
||||
void ops_set_border_color (RenderOpBuilder *builder,
|
||||
const GdkRGBA *color);
|
||||
|
||||
void ops_draw (RenderOpBuilder *builder,
|
||||
GskQuadVertex * ops_draw (RenderOpBuilder *builder,
|
||||
const GskQuadVertex vertex_data[GL_N_VERTICES]);
|
||||
|
||||
void ops_offset (RenderOpBuilder *builder,
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gskglshaderbuilderprivate.h"
|
||||
|
||||
#include "gskdebugprivate.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <epoxy/gl.h>
|
||||
|
||||
void
|
||||
gsk_gl_shader_builder_init (GskGLShaderBuilder *self,
|
||||
const char *vs_preamble_resource_path,
|
||||
const char *fs_preamble_resource_path)
|
||||
{
|
||||
memset (self, 0, sizeof (*self));
|
||||
|
||||
self->vs_preamble = g_resources_lookup_data (vs_preamble_resource_path, 0, NULL);
|
||||
self->fs_preamble = g_resources_lookup_data (fs_preamble_resource_path, 0, NULL);
|
||||
|
||||
g_assert (self->vs_preamble);
|
||||
g_assert (self->fs_preamble);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_gl_shader_builder_finish (GskGLShaderBuilder *self)
|
||||
{
|
||||
g_bytes_unref (self->vs_preamble);
|
||||
g_bytes_unref (self->fs_preamble);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_gl_shader_builder_set_glsl_version (GskGLShaderBuilder *self,
|
||||
int version)
|
||||
{
|
||||
self->version = version;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_shader_error (int shader_id,
|
||||
GError **error)
|
||||
{
|
||||
int status;
|
||||
int log_len;
|
||||
char *buffer;
|
||||
int code_len;
|
||||
char *code;
|
||||
|
||||
glGetShaderiv (shader_id, GL_COMPILE_STATUS, &status);
|
||||
|
||||
if (G_LIKELY (status == GL_TRUE))
|
||||
return TRUE;
|
||||
|
||||
glGetShaderiv (shader_id, GL_INFO_LOG_LENGTH, &log_len);
|
||||
buffer = g_malloc0 (log_len + 1);
|
||||
glGetShaderInfoLog (shader_id, log_len, NULL, buffer);
|
||||
|
||||
glGetShaderiv (shader_id, GL_SHADER_SOURCE_LENGTH, &code_len);
|
||||
code = g_malloc0 (code_len + 1);
|
||||
glGetShaderSource (shader_id, code_len, NULL, code);
|
||||
|
||||
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_COMPILATION_FAILED,
|
||||
"Compilation failure in shader.\nError message: %s\n\nSource code:\n%s\n\n",
|
||||
buffer,
|
||||
code);
|
||||
|
||||
g_free (buffer);
|
||||
g_free (code);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
gsk_gl_shader_builder_create_program (GskGLShaderBuilder *self,
|
||||
const char *resource_path,
|
||||
GError **error)
|
||||
{
|
||||
|
||||
GBytes *source_bytes = g_resources_lookup_data (resource_path, 0, NULL);
|
||||
char version_buffer[64];
|
||||
const char *source;
|
||||
const char *vertex_shader_start;
|
||||
const char *fragment_shader_start;
|
||||
int vertex_id;
|
||||
int fragment_id;
|
||||
int program_id = -1;
|
||||
int status;
|
||||
|
||||
g_assert (source_bytes);
|
||||
|
||||
source = g_bytes_get_data (source_bytes, NULL);
|
||||
vertex_shader_start = strstr (source, "VERTEX_SHADER");
|
||||
fragment_shader_start = strstr (source, "FRAGMENT_SHADER");
|
||||
|
||||
g_assert (vertex_shader_start);
|
||||
g_assert (fragment_shader_start);
|
||||
|
||||
/* They both start at the next newline */
|
||||
vertex_shader_start = strstr (vertex_shader_start, "\n");
|
||||
fragment_shader_start = strstr (fragment_shader_start, "\n");
|
||||
|
||||
g_snprintf (version_buffer, sizeof (version_buffer),
|
||||
"#version %d\n", self->version);
|
||||
|
||||
vertex_id = glCreateShader (GL_VERTEX_SHADER);
|
||||
glShaderSource (vertex_id, 7,
|
||||
(const char *[]) {
|
||||
version_buffer,
|
||||
self->debugging ? "#define GSK_DEBUG 1\n" : "",
|
||||
self->legacy ? "#define GSK_LEGACY 1\n" : "",
|
||||
self->gl3 ? "#define GSK_GL3 1\n" : "",
|
||||
self->gles ? "#define GSK_GLES 1\n" : "",
|
||||
g_bytes_get_data (self->vs_preamble, NULL),
|
||||
vertex_shader_start
|
||||
},
|
||||
(int[]) {
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
fragment_shader_start - vertex_shader_start
|
||||
});
|
||||
glCompileShader (vertex_id);
|
||||
|
||||
if (!check_shader_error (vertex_id, error))
|
||||
{
|
||||
glDeleteShader (vertex_id);
|
||||
goto out;
|
||||
}
|
||||
|
||||
fragment_id = glCreateShader (GL_FRAGMENT_SHADER);
|
||||
glShaderSource (fragment_id, 7,
|
||||
(const char *[]) {
|
||||
version_buffer,
|
||||
self->debugging ? "#define GSK_DEBUG 1\n" : "",
|
||||
self->legacy ? "#define GSK_LEGACY 1\n" : "",
|
||||
self->gl3 ? "#define GSK_GL3 1\n" : "",
|
||||
self->gles ? "#define GSK_GLES 1\n" : "",
|
||||
g_bytes_get_data (self->fs_preamble, NULL),
|
||||
fragment_shader_start
|
||||
},
|
||||
(int[]) {
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
});
|
||||
glCompileShader (fragment_id);
|
||||
|
||||
if (!check_shader_error (fragment_id, error))
|
||||
{
|
||||
glDeleteShader (fragment_id);
|
||||
goto out;
|
||||
}
|
||||
|
||||
program_id = glCreateProgram ();
|
||||
glAttachShader (program_id, vertex_id);
|
||||
glAttachShader (program_id, fragment_id);
|
||||
glLinkProgram (program_id);
|
||||
|
||||
glGetProgramiv (program_id, GL_LINK_STATUS, &status);
|
||||
if (status == GL_FALSE)
|
||||
{
|
||||
char *buffer = NULL;
|
||||
int log_len = 0;
|
||||
|
||||
glGetProgramiv (program_id, GL_INFO_LOG_LENGTH, &log_len);
|
||||
|
||||
buffer = g_malloc0 (log_len + 1);
|
||||
glGetProgramInfoLog (program_id, log_len, NULL, buffer);
|
||||
|
||||
g_warning ("Linking failure in shader:\n%s", buffer);
|
||||
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_LINK_FAILED,
|
||||
"Linking failure in shader: %s", buffer);
|
||||
|
||||
g_free (buffer);
|
||||
|
||||
glDeleteProgram (program_id);
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
glDetachShader (program_id, vertex_id);
|
||||
glDeleteShader (vertex_id);
|
||||
|
||||
glDetachShader (program_id, fragment_id);
|
||||
glDeleteShader (fragment_id);
|
||||
|
||||
out:
|
||||
g_bytes_unref (source_bytes);
|
||||
|
||||
return program_id;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef __GSK_SHADER_BUILDER_PRIVATE_H__
|
||||
#define __GSK_SHADER_BUILDER_PRIVATE_H__
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <graphene.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GBytes *vs_preamble;
|
||||
GBytes *fs_preamble;
|
||||
|
||||
int version;
|
||||
|
||||
guint debugging: 1;
|
||||
guint gles: 1;
|
||||
guint gl3: 1;
|
||||
guint legacy: 1;
|
||||
|
||||
} GskGLShaderBuilder;
|
||||
|
||||
|
||||
void gsk_gl_shader_builder_init (GskGLShaderBuilder *self,
|
||||
const char *vs_preamble_resource_path,
|
||||
const char *fs_preamble_resource_path);
|
||||
void gsk_gl_shader_builder_finish (GskGLShaderBuilder *self);
|
||||
|
||||
void gsk_gl_shader_builder_set_glsl_version (GskGLShaderBuilder *self,
|
||||
int version);
|
||||
|
||||
int gsk_gl_shader_builder_create_program (GskGLShaderBuilder *self,
|
||||
const char *resource_path,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_SHADER_BUILDER_PRIVATE_H__ */
|
||||
@@ -166,7 +166,8 @@ gsk_gl_texture_atlases_pack (GskGLTextureAtlases *self,
|
||||
g_ptr_array_add (self->atlases, atlas);
|
||||
|
||||
/* Pack it onto that one, which surely has enough space... */
|
||||
gsk_gl_texture_atlas_pack (atlas, width, height, &x, &y);
|
||||
if (!gsk_gl_texture_atlas_pack (atlas, width, height, &x, &y))
|
||||
g_assert_not_reached ();
|
||||
|
||||
GSK_NOTE(GLYPH_CACHE, g_message ("adding new atlas"));
|
||||
}
|
||||
@@ -304,5 +305,5 @@ gsk_gl_texture_atlas_realize (GskGLTextureAtlas *atlas)
|
||||
atlas->texture_id = create_shared_texture (atlas->width, atlas->height);
|
||||
gdk_gl_context_label_object_printf (gdk_gl_context_get_current (),
|
||||
GL_TEXTURE, atlas->texture_id,
|
||||
"Glyph atlas %d", atlas->texture_id);
|
||||
"Texture atlas %d", atlas->texture_id);
|
||||
}
|
||||
|
||||
@@ -1,332 +0,0 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gskshaderbuilderprivate.h"
|
||||
|
||||
#include "gskdebugprivate.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <epoxy/gl.h>
|
||||
|
||||
struct _GskShaderBuilder
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
char *resource_base_path;
|
||||
char *vertex_preamble;
|
||||
char *fragment_preamble;
|
||||
|
||||
|
||||
int common_vertex_shader_id;
|
||||
|
||||
int version;
|
||||
|
||||
GPtrArray *defines;
|
||||
|
||||
/* We reuse this one for all the shaders */
|
||||
GString *shader_code;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GskShaderBuilder, gsk_shader_builder, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gsk_shader_builder_finalize (GObject *gobject)
|
||||
{
|
||||
GskShaderBuilder *self = GSK_SHADER_BUILDER (gobject);
|
||||
|
||||
g_free (self->resource_base_path);
|
||||
g_free (self->vertex_preamble);
|
||||
g_free (self->fragment_preamble);
|
||||
g_string_free (self->shader_code, TRUE);
|
||||
|
||||
g_clear_pointer (&self->defines, g_ptr_array_unref);
|
||||
|
||||
if (self->common_vertex_shader_id > 0)
|
||||
glDeleteShader (self->common_vertex_shader_id);
|
||||
|
||||
G_OBJECT_CLASS (gsk_shader_builder_parent_class)->finalize (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_shader_builder_class_init (GskShaderBuilderClass *klass)
|
||||
{
|
||||
G_OBJECT_CLASS (klass)->finalize = gsk_shader_builder_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_shader_builder_init (GskShaderBuilder *self)
|
||||
{
|
||||
self->defines = g_ptr_array_new_with_free_func (g_free);
|
||||
self->shader_code = g_string_new (NULL);
|
||||
}
|
||||
|
||||
GskShaderBuilder *
|
||||
gsk_shader_builder_new (void)
|
||||
{
|
||||
return g_object_new (GSK_TYPE_SHADER_BUILDER, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_shader_builder_set_resource_base_path (GskShaderBuilder *builder,
|
||||
const char *base_path)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_SHADER_BUILDER (builder));
|
||||
|
||||
g_free (builder->resource_base_path);
|
||||
builder->resource_base_path = g_strdup (base_path);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_shader_builder_set_vertex_preamble (GskShaderBuilder *builder,
|
||||
const char *vertex_preamble)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_SHADER_BUILDER (builder));
|
||||
|
||||
g_free (builder->vertex_preamble);
|
||||
builder->vertex_preamble = g_strdup (vertex_preamble);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_shader_builder_set_fragment_preamble (GskShaderBuilder *builder,
|
||||
const char *fragment_preamble)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_SHADER_BUILDER (builder));
|
||||
|
||||
g_free (builder->fragment_preamble);
|
||||
builder->fragment_preamble = g_strdup (fragment_preamble);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_shader_builder_set_version (GskShaderBuilder *builder,
|
||||
int version)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_SHADER_BUILDER (builder));
|
||||
|
||||
builder->version = version;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_shader_builder_add_define (GskShaderBuilder *builder,
|
||||
const char *define_name,
|
||||
const char *define_value)
|
||||
{
|
||||
g_return_if_fail (GSK_IS_SHADER_BUILDER (builder));
|
||||
g_return_if_fail (define_name != NULL && *define_name != '\0');
|
||||
g_return_if_fail (define_value != NULL && *define_value != '\0');
|
||||
|
||||
g_ptr_array_add (builder->defines, g_strdup (define_name));
|
||||
g_ptr_array_add (builder->defines, g_strdup (define_value));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
lookup_shader_code (GString *code,
|
||||
const char *base_path,
|
||||
const char *shader_file,
|
||||
GError **error)
|
||||
{
|
||||
GBytes *source;
|
||||
char *path;
|
||||
|
||||
if (base_path != NULL)
|
||||
path = g_build_filename (base_path, shader_file, NULL);
|
||||
else
|
||||
path = g_strdup (shader_file);
|
||||
|
||||
source = g_resources_lookup_data (path, 0, error);
|
||||
g_free (path);
|
||||
|
||||
if (source == NULL)
|
||||
return FALSE;
|
||||
|
||||
g_string_append (code, g_bytes_get_data (source, NULL));
|
||||
|
||||
g_bytes_unref (source);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
gsk_shader_builder_compile_shader (GskShaderBuilder *builder,
|
||||
int shader_type,
|
||||
const char *shader_preamble,
|
||||
const char *shader_source,
|
||||
GError **error)
|
||||
{
|
||||
GString *code;
|
||||
const char *source;
|
||||
int shader_id;
|
||||
int status;
|
||||
int i;
|
||||
|
||||
/* Clear possibly previously set shader code */
|
||||
g_string_erase (builder->shader_code, 0, -1);
|
||||
code = builder->shader_code;
|
||||
|
||||
if (builder->version > 0)
|
||||
{
|
||||
g_string_append_printf (code, "#version %d\n", builder->version);
|
||||
g_string_append_c (code, '\n');
|
||||
}
|
||||
|
||||
for (i = 0; i < builder->defines->len; i += 2)
|
||||
{
|
||||
const char *name = g_ptr_array_index (builder->defines, i);
|
||||
const char *value = g_ptr_array_index (builder->defines, i + 1);
|
||||
|
||||
g_string_append (code, "#define");
|
||||
g_string_append_c (code, ' ');
|
||||
g_string_append (code, name);
|
||||
g_string_append_c (code, ' ');
|
||||
g_string_append (code, value);
|
||||
g_string_append_c (code, '\n');
|
||||
}
|
||||
|
||||
g_string_append_c (code, '\n');
|
||||
|
||||
if (!lookup_shader_code (code, builder->resource_base_path, shader_preamble, error))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_string_append_c (code, '\n');
|
||||
|
||||
if (!lookup_shader_code (code, builder->resource_base_path, shader_source, error))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
source = code->str;
|
||||
|
||||
shader_id = glCreateShader (shader_type);
|
||||
glShaderSource (shader_id, 1, (const GLchar **) &source, NULL);
|
||||
glCompileShader (shader_id);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GSK_DEBUG_CHECK (SHADERS))
|
||||
{
|
||||
g_print ("*** Compiling %s shader from '%s' + '%s' ***\n"
|
||||
"%s\n",
|
||||
shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment",
|
||||
shader_preamble, shader_source,
|
||||
source);
|
||||
}
|
||||
#endif
|
||||
|
||||
glGetShaderiv (shader_id, GL_COMPILE_STATUS, &status);
|
||||
if (status == GL_FALSE)
|
||||
{
|
||||
int log_len;
|
||||
char *buffer;
|
||||
|
||||
glGetShaderiv (shader_id, GL_INFO_LOG_LENGTH, &log_len);
|
||||
|
||||
buffer = g_malloc0 (log_len + 1);
|
||||
glGetShaderInfoLog (shader_id, log_len, NULL, buffer);
|
||||
|
||||
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_COMPILATION_FAILED,
|
||||
"Compilation failure in %s shader:\n%s",
|
||||
shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment",
|
||||
buffer);
|
||||
g_free (buffer);
|
||||
|
||||
glDeleteShader (shader_id);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return shader_id;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_shader_builder_set_common_vertex_shader (GskShaderBuilder *self,
|
||||
const char *vertex_shader,
|
||||
GError **error)
|
||||
{
|
||||
int shader_id;
|
||||
|
||||
|
||||
shader_id = gsk_shader_builder_compile_shader (self,
|
||||
GL_VERTEX_SHADER,
|
||||
self->vertex_preamble,
|
||||
vertex_shader,
|
||||
error);
|
||||
|
||||
g_assert (shader_id > 0);
|
||||
self->common_vertex_shader_id = shader_id;
|
||||
}
|
||||
|
||||
int
|
||||
gsk_shader_builder_create_program (GskShaderBuilder *builder,
|
||||
const char *fragment_shader,
|
||||
const char *vertex_shader,
|
||||
GError **error)
|
||||
{
|
||||
int vertex_id;
|
||||
int fragment_id;
|
||||
int program_id;
|
||||
int status;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_SHADER_BUILDER (builder), -1);
|
||||
g_return_val_if_fail (fragment_shader != NULL, -1);
|
||||
g_return_val_if_fail (builder->common_vertex_shader_id != 0, -1);
|
||||
|
||||
if (vertex_shader == NULL)
|
||||
vertex_id = builder->common_vertex_shader_id;
|
||||
else
|
||||
vertex_id = gsk_shader_builder_compile_shader (builder, GL_VERTEX_SHADER,
|
||||
builder->vertex_preamble,
|
||||
vertex_shader,
|
||||
error);
|
||||
if (vertex_id < 0)
|
||||
return -1;
|
||||
|
||||
fragment_id = gsk_shader_builder_compile_shader (builder, GL_FRAGMENT_SHADER,
|
||||
builder->fragment_preamble,
|
||||
fragment_shader,
|
||||
error);
|
||||
if (fragment_id < 0)
|
||||
{
|
||||
glDeleteShader (vertex_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
program_id = glCreateProgram ();
|
||||
glAttachShader (program_id, vertex_id);
|
||||
glAttachShader (program_id, fragment_id);
|
||||
glLinkProgram (program_id);
|
||||
|
||||
glGetProgramiv (program_id, GL_LINK_STATUS, &status);
|
||||
if (status == GL_FALSE)
|
||||
{
|
||||
char *buffer = NULL;
|
||||
int log_len = 0;
|
||||
|
||||
glGetProgramiv (program_id, GL_INFO_LOG_LENGTH, &log_len);
|
||||
|
||||
buffer = g_malloc0 (log_len + 1);
|
||||
glGetProgramInfoLog (program_id, log_len, NULL, buffer);
|
||||
|
||||
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_LINK_FAILED,
|
||||
"Linking failure in shader:\n%s", buffer);
|
||||
g_free (buffer);
|
||||
|
||||
glDeleteProgram (program_id);
|
||||
program_id = -1;
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
if (vertex_id > 0)
|
||||
{
|
||||
/* We delete the common vertex shader when destroying the shader builder */
|
||||
glDetachShader (program_id, vertex_id);
|
||||
}
|
||||
|
||||
if (fragment_id > 0)
|
||||
{
|
||||
glDetachShader (program_id, fragment_id);
|
||||
glDeleteShader (fragment_id);
|
||||
}
|
||||
|
||||
return program_id;
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
#ifndef __GSK_SHADER_BUILDER_PRIVATE_H__
|
||||
#define __GSK_SHADER_BUILDER_PRIVATE_H__
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <graphene.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GSK_TYPE_SHADER_BUILDER (gsk_shader_builder_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskShaderBuilder, gsk_shader_builder, GSK, SHADER_BUILDER, GObject)
|
||||
|
||||
GskShaderBuilder * gsk_shader_builder_new (void);
|
||||
|
||||
void gsk_shader_builder_set_version (GskShaderBuilder *builder,
|
||||
int version);
|
||||
void gsk_shader_builder_set_resource_base_path (GskShaderBuilder *builder,
|
||||
const char *base_path);
|
||||
void gsk_shader_builder_set_vertex_preamble (GskShaderBuilder *builder,
|
||||
const char *shader_preamble);
|
||||
void gsk_shader_builder_set_fragment_preamble (GskShaderBuilder *builder,
|
||||
const char *shader_preamble);
|
||||
|
||||
void gsk_shader_builder_add_define (GskShaderBuilder *builder,
|
||||
const char *define_name,
|
||||
const char *define_value);
|
||||
|
||||
void gsk_shader_builder_set_common_vertex_shader (GskShaderBuilder *self,
|
||||
const char *vertex_shader,
|
||||
GError **error);
|
||||
|
||||
int gsk_shader_builder_create_program (GskShaderBuilder *builder,
|
||||
const char *fragment_shader,
|
||||
const char *vertex_shader,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GSK_SHADER_BUILDER_PRIVATE_H__ */
|
||||
+8
-10
@@ -77,7 +77,7 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GdkRGBA rgba;
|
||||
const GdkRGBA *rgba;
|
||||
} OpColor;
|
||||
|
||||
typedef struct
|
||||
@@ -88,6 +88,7 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
GskRoundedRect clip;
|
||||
guint send_corners: 1;
|
||||
} OpClip;
|
||||
|
||||
typedef struct
|
||||
@@ -108,8 +109,7 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float color_offsets[8];
|
||||
float color_stops[4 * 8];
|
||||
const GskColorStop *color_stops;
|
||||
graphene_point_t start_point;
|
||||
graphene_point_t end_point;
|
||||
int n_color_stops;
|
||||
@@ -117,8 +117,8 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
graphene_matrix_t matrix;
|
||||
graphene_vec4_t offset;
|
||||
const graphene_matrix_t *matrix;
|
||||
const graphene_vec4_t *offset;
|
||||
} OpColorMatrix;
|
||||
|
||||
typedef struct
|
||||
@@ -130,18 +130,16 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float outline[4];
|
||||
float corner_widths[4];
|
||||
float corner_heights[4];
|
||||
GskRoundedRect outline;
|
||||
float spread;
|
||||
float offset[2];
|
||||
float color[4];
|
||||
const GdkRGBA *color;
|
||||
} OpShadow;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float widths[4];
|
||||
float color[4];
|
||||
const GdkRGBA *color;
|
||||
GskRoundedRect outline;
|
||||
} OpBorder;
|
||||
|
||||
|
||||
+7
-7
@@ -41,7 +41,7 @@ typedef struct _GskShadow GskShadow;
|
||||
|
||||
struct _GskColorStop
|
||||
{
|
||||
double offset;
|
||||
float offset;
|
||||
GdkRGBA color;
|
||||
};
|
||||
|
||||
@@ -210,11 +210,11 @@ GskTransform * gsk_transform_node_get_transform (GskRenderNode
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_opacity_node_new (GskRenderNode *child,
|
||||
double opacity);
|
||||
float opacity);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_opacity_node_get_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
double gsk_opacity_node_get_opacity (GskRenderNode *node);
|
||||
float gsk_opacity_node_get_opacity (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_color_matrix_node_new (GskRenderNode *child,
|
||||
@@ -280,13 +280,13 @@ GskBlendMode gsk_blend_node_get_blend_mode (GskRenderNode
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_cross_fade_node_new (GskRenderNode *start,
|
||||
GskRenderNode *end,
|
||||
double progress);
|
||||
float progress);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_cross_fade_node_get_start_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_cross_fade_node_get_end_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
double gsk_cross_fade_node_get_progress (GskRenderNode *node);
|
||||
float gsk_cross_fade_node_get_progress (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_text_node_new (PangoFont *font,
|
||||
@@ -307,11 +307,11 @@ const graphene_point_t *gsk_text_node_get_offset (GskRenderNode
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_blur_node_new (GskRenderNode *child,
|
||||
double radius);
|
||||
float radius);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_blur_node_get_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
double gsk_blur_node_get_radius (GskRenderNode *node);
|
||||
float gsk_blur_node_get_radius (GskRenderNode *node);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -2197,7 +2197,7 @@ struct _GskOpacityNode
|
||||
GskRenderNode render_node;
|
||||
|
||||
GskRenderNode *child;
|
||||
double opacity;
|
||||
float opacity;
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -2267,7 +2267,7 @@ static const GskRenderNodeClass GSK_OPACITY_NODE_CLASS = {
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_opacity_node_new (GskRenderNode *child,
|
||||
double opacity)
|
||||
float opacity)
|
||||
{
|
||||
GskOpacityNode *self;
|
||||
|
||||
@@ -2301,7 +2301,7 @@ gsk_opacity_node_get_child (GskRenderNode *node)
|
||||
return self->child;
|
||||
}
|
||||
|
||||
double
|
||||
float
|
||||
gsk_opacity_node_get_opacity (GskRenderNode *node)
|
||||
{
|
||||
GskOpacityNode *self = (GskOpacityNode *) node;
|
||||
@@ -3278,7 +3278,7 @@ struct _GskCrossFadeNode
|
||||
|
||||
GskRenderNode *start;
|
||||
GskRenderNode *end;
|
||||
double progress;
|
||||
float progress;
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -3352,7 +3352,7 @@ static const GskRenderNodeClass GSK_CROSS_FADE_NODE_CLASS = {
|
||||
GskRenderNode *
|
||||
gsk_cross_fade_node_new (GskRenderNode *start,
|
||||
GskRenderNode *end,
|
||||
double progress)
|
||||
float progress)
|
||||
{
|
||||
GskCrossFadeNode *self;
|
||||
|
||||
@@ -3390,7 +3390,7 @@ gsk_cross_fade_node_get_end_child (GskRenderNode *node)
|
||||
return self->end;
|
||||
}
|
||||
|
||||
double
|
||||
float
|
||||
gsk_cross_fade_node_get_progress (GskRenderNode *node)
|
||||
{
|
||||
GskCrossFadeNode *self = (GskCrossFadeNode *) node;
|
||||
@@ -3634,7 +3634,7 @@ struct _GskBlurNode
|
||||
GskRenderNode render_node;
|
||||
|
||||
GskRenderNode *child;
|
||||
double radius;
|
||||
float radius;
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -3882,7 +3882,7 @@ static const GskRenderNodeClass GSK_BLUR_NODE_CLASS = {
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_blur_node_new (GskRenderNode *child,
|
||||
double radius)
|
||||
float radius)
|
||||
{
|
||||
GskBlurNode *self;
|
||||
float clip_radius = gsk_cairo_blur_compute_pixels (radius);
|
||||
@@ -3911,7 +3911,7 @@ gsk_blur_node_get_child (GskRenderNode *node)
|
||||
return self->child;
|
||||
}
|
||||
|
||||
double
|
||||
float
|
||||
gsk_blur_node_get_radius (GskRenderNode *node)
|
||||
{
|
||||
GskBlurNode *self = (GskBlurNode *) node;
|
||||
|
||||
@@ -433,9 +433,13 @@ parse_stops (GtkCssParser *parser,
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (!gtk_css_parser_consume_number (parser, &stop.offset))
|
||||
double dval;
|
||||
|
||||
if (!gtk_css_parser_consume_number (parser, &dval))
|
||||
goto error;
|
||||
|
||||
stop.offset = dval;
|
||||
|
||||
if (!gdk_rgba_parser_parse (parser, &stop.color))
|
||||
goto error;
|
||||
|
||||
|
||||
+75
-23
@@ -685,16 +685,54 @@ gsk_rotate_transform_finalize (GskTransform *self)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void
|
||||
_sincos (float deg,
|
||||
float *out_s,
|
||||
float *out_c)
|
||||
{
|
||||
if (deg == 90.0)
|
||||
{
|
||||
*out_c = 0.0;
|
||||
*out_s = 1.0;
|
||||
}
|
||||
else if (deg == 180.0)
|
||||
{
|
||||
*out_c = -1.0;
|
||||
*out_s = 0.0;
|
||||
}
|
||||
else if (deg == 270.0)
|
||||
{
|
||||
*out_c = 0.0;
|
||||
*out_s = -1.0;
|
||||
}
|
||||
else if (deg == 0.0)
|
||||
{
|
||||
*out_c = 1.0;
|
||||
*out_s = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
float angle = deg * M_PI / 180.0;
|
||||
|
||||
#ifdef HAVE_SINCOSF
|
||||
sincosf (angle, out_s, out_c);
|
||||
#else
|
||||
*out_s = sinf (angle);
|
||||
*out_c = cosf (angle);
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_rotate_transform_to_matrix (GskTransform *transform,
|
||||
graphene_matrix_t *out_matrix)
|
||||
{
|
||||
GskRotateTransform *self = (GskRotateTransform *) transform;
|
||||
float rad, c, s;
|
||||
float c, s;
|
||||
|
||||
_sincos (self->angle, &s, &c);
|
||||
|
||||
rad = self->angle * M_PI / 180.f;
|
||||
c = cosf (rad);
|
||||
s = sinf (rad);
|
||||
graphene_matrix_init_from_2d (out_matrix,
|
||||
c, s,
|
||||
-s, c,
|
||||
@@ -711,14 +749,12 @@ gsk_rotate_transform_apply_2d (GskTransform *transform,
|
||||
float *out_dy)
|
||||
{
|
||||
GskRotateTransform *self = (GskRotateTransform *) transform;
|
||||
float s, c, rad, xx, xy, yx, yy;
|
||||
float s, c, xx, xy, yx, yy;
|
||||
|
||||
if (fmodf (self->angle, 360.0f) == 0.0)
|
||||
return;
|
||||
|
||||
rad = self->angle * G_PI / 180.0f;
|
||||
s = sinf (rad);
|
||||
c = cosf (rad);
|
||||
_sincos (self->angle, &s, &c);
|
||||
|
||||
xx = c * *out_xx + s * *out_xy;
|
||||
yx = c * *out_yx + s * *out_yy;
|
||||
@@ -785,6 +821,22 @@ static const GskTransformClass GSK_ROTATE_TRANSFORM_CLASS =
|
||||
gsk_rotate_transform_equal,
|
||||
};
|
||||
|
||||
static inline float
|
||||
normalize_angle (float angle)
|
||||
{
|
||||
float f;
|
||||
|
||||
if (angle >= 0 && angle < 360)
|
||||
return angle;
|
||||
|
||||
f = angle - (360 * ((int)(angle / 360.0)));
|
||||
|
||||
if (f < 0)
|
||||
f = 360 + f;
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_transform_rotate:
|
||||
* @next: (allow-none) (transfer full): the next transform
|
||||
@@ -815,7 +867,7 @@ gsk_transform_rotate (GskTransform *next,
|
||||
GSK_TRANSFORM_CATEGORY_2D,
|
||||
next);
|
||||
|
||||
result->angle = angle;
|
||||
result->angle = normalize_angle (angle);
|
||||
|
||||
return &result->parent;
|
||||
}
|
||||
@@ -938,7 +990,7 @@ gsk_transform_rotate_3d (GskTransform *next,
|
||||
GSK_TRANSFORM_CATEGORY_3D,
|
||||
next);
|
||||
|
||||
result->angle = angle;
|
||||
result->angle = normalize_angle (angle);
|
||||
graphene_vec3_init_from_vec3 (&result->axis, axis);
|
||||
|
||||
return &result->parent;
|
||||
@@ -1033,9 +1085,9 @@ gsk_scale_transform_equal (GskTransform *first_transform,
|
||||
GskScaleTransform *first = (GskScaleTransform *) first_transform;
|
||||
GskScaleTransform *second = (GskScaleTransform *) second_transform;
|
||||
|
||||
return G_APPROX_VALUE (first->factor_x, second->factor_x, 0.01f) &&
|
||||
G_APPROX_VALUE (first->factor_y, second->factor_y, 0.01f) &&
|
||||
G_APPROX_VALUE (first->factor_z, second->factor_z, 0.01f);
|
||||
return G_APPROX_VALUE (first->factor_x, second->factor_x, FLT_EPSILON) &&
|
||||
G_APPROX_VALUE (first->factor_y, second->factor_y, FLT_EPSILON) &&
|
||||
G_APPROX_VALUE (first->factor_z, second->factor_z, FLT_EPSILON);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1620,10 +1672,10 @@ gsk_transform_equal (GskTransform *first,
|
||||
if (first == NULL || second == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!gsk_transform_equal (first->next, second->next))
|
||||
if (first->transform_class != second->transform_class)
|
||||
return FALSE;
|
||||
|
||||
if (first->transform_class != second->transform_class)
|
||||
if (!gsk_transform_equal (first->next, second->next))
|
||||
return FALSE;
|
||||
|
||||
return first->transform_class->equal (first, second);
|
||||
@@ -1686,7 +1738,10 @@ gsk_transform_transform_bounds (GskTransform *self,
|
||||
float dx, dy;
|
||||
|
||||
gsk_transform_to_translate (self, &dx, &dy);
|
||||
graphene_rect_offset_r (rect, dx, dy, out_rect);
|
||||
out_rect->origin.x = rect->origin.x + dx;
|
||||
out_rect->origin.y = rect->origin.y + dy;
|
||||
out_rect->size.width = rect->size.width;
|
||||
out_rect->size.height = rect->size.height;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1696,13 +1751,10 @@ gsk_transform_transform_bounds (GskTransform *self,
|
||||
|
||||
gsk_transform_to_affine (self, &scale_x, &scale_y, &dx, &dy);
|
||||
|
||||
*out_rect = *rect;
|
||||
out_rect->origin.x *= scale_x;
|
||||
out_rect->origin.y *= scale_y;
|
||||
out_rect->size.width *= scale_x;
|
||||
out_rect->size.height *= scale_y;
|
||||
out_rect->origin.x += dx;
|
||||
out_rect->origin.y += dy;
|
||||
out_rect->origin.x = (rect->origin.x * scale_x) + dx;
|
||||
out_rect->origin.y = (rect->origin.y * scale_y) + dy;
|
||||
out_rect->size.width = rect->size.width * scale_x;
|
||||
out_rect->size.height = rect->size.height * scale_y;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
+16
-21
@@ -1,24 +1,19 @@
|
||||
gsk_private_gl_shaders = [
|
||||
'resources/glsl/blit.fs.glsl',
|
||||
'resources/glsl/blit.vs.glsl',
|
||||
'resources/glsl/color.fs.glsl',
|
||||
'resources/glsl/coloring.fs.glsl',
|
||||
'resources/glsl/color_matrix.fs.glsl',
|
||||
'resources/glsl/linear_gradient.fs.glsl',
|
||||
'resources/glsl/blur.fs.glsl',
|
||||
'resources/glsl/inset_shadow.fs.glsl',
|
||||
'resources/glsl/outset_shadow.fs.glsl',
|
||||
'resources/glsl/unblurred_outset_shadow.fs.glsl',
|
||||
'resources/glsl/border.fs.glsl',
|
||||
'resources/glsl/cross_fade.fs.glsl',
|
||||
'resources/glsl/blend.fs.glsl',
|
||||
'resources/glsl/repeat.fs.glsl',
|
||||
'resources/glsl/es2_common.fs.glsl',
|
||||
'resources/glsl/es2_common.vs.glsl',
|
||||
'resources/glsl/gl3_common.fs.glsl',
|
||||
'resources/glsl/gl3_common.vs.glsl',
|
||||
'resources/glsl/gl_common.fs.glsl',
|
||||
'resources/glsl/gl_common.vs.glsl',
|
||||
'resources/glsl/preamble.fs.glsl',
|
||||
'resources/glsl/preamble.vs.glsl',
|
||||
'resources/glsl/border.glsl',
|
||||
'resources/glsl/blit.glsl',
|
||||
'resources/glsl/coloring.glsl',
|
||||
'resources/glsl/color.glsl',
|
||||
'resources/glsl/linear_gradient.glsl',
|
||||
'resources/glsl/color_matrix.glsl',
|
||||
'resources/glsl/blur.glsl',
|
||||
'resources/glsl/inset_shadow.glsl',
|
||||
'resources/glsl/outset_shadow.glsl',
|
||||
'resources/glsl/unblurred_outset_shadow.glsl',
|
||||
'resources/glsl/cross_fade.glsl',
|
||||
'resources/glsl/blend.glsl',
|
||||
'resources/glsl/repeat.glsl',
|
||||
]
|
||||
|
||||
gsk_public_sources = files([
|
||||
@@ -38,7 +33,7 @@ gsk_private_sources = files([
|
||||
'gskdebug.c',
|
||||
'gskprivate.c',
|
||||
'gskprofiler.c',
|
||||
'gl/gskshaderbuilder.c',
|
||||
'gl/gskglshaderbuilder.c',
|
||||
'gl/gskglprofiler.c',
|
||||
'gl/gskglglyphcache.c',
|
||||
'gl/gskglimage.c',
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
// VERTEX_SHADER:
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
vUv = vec2(aUv.x, aUv.y);
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
uniform int u_mode;
|
||||
uniform sampler2D u_source2;
|
||||
|
||||
@@ -264,73 +272,39 @@ void main() {
|
||||
|
||||
vec4 result;
|
||||
if (u_mode == 0)
|
||||
{
|
||||
result = normal(top_color, bottom_color);
|
||||
}
|
||||
result = normal(top_color, bottom_color);
|
||||
else if (u_mode == 1)
|
||||
{
|
||||
result = multiply(top_color, bottom_color);
|
||||
}
|
||||
result = multiply(top_color, bottom_color);
|
||||
else if (u_mode == 2)
|
||||
{
|
||||
result = screen(top_color, bottom_color);
|
||||
}
|
||||
result = screen(top_color, bottom_color);
|
||||
else if (u_mode == 3)
|
||||
{
|
||||
result = overlay(top_color, bottom_color);
|
||||
}
|
||||
result = overlay(top_color, bottom_color);
|
||||
else if (u_mode == 4)
|
||||
{
|
||||
result = darken(top_color, bottom_color);
|
||||
}
|
||||
result = darken(top_color, bottom_color);
|
||||
else if (u_mode == 5)
|
||||
{
|
||||
result = lighten(top_color, bottom_color);
|
||||
}
|
||||
result = lighten(top_color, bottom_color);
|
||||
else if (u_mode == 6)
|
||||
{
|
||||
result = color_dodge(top_color, bottom_color);
|
||||
}
|
||||
result = color_dodge(top_color, bottom_color);
|
||||
else if (u_mode == 7)
|
||||
{
|
||||
result = color_burn(top_color, bottom_color);
|
||||
}
|
||||
result = color_burn(top_color, bottom_color);
|
||||
else if (u_mode == 8)
|
||||
{
|
||||
result = hard_light(top_color, bottom_color);
|
||||
}
|
||||
result = hard_light(top_color, bottom_color);
|
||||
else if (u_mode == 9)
|
||||
{
|
||||
result = soft_light(top_color, bottom_color);
|
||||
}
|
||||
result = soft_light(top_color, bottom_color);
|
||||
else if (u_mode == 10)
|
||||
{
|
||||
result = difference(top_color, bottom_color);
|
||||
}
|
||||
result = difference(top_color, bottom_color);
|
||||
else if (u_mode == 11)
|
||||
{
|
||||
result = exclusion(top_color, bottom_color);
|
||||
}
|
||||
result = exclusion(top_color, bottom_color);
|
||||
else if (u_mode == 12)
|
||||
{
|
||||
result = color(top_color, bottom_color);
|
||||
}
|
||||
result = color(top_color, bottom_color);
|
||||
else if (u_mode == 13)
|
||||
{
|
||||
result = hue(top_color, bottom_color);
|
||||
}
|
||||
result = hue(top_color, bottom_color);
|
||||
else if (u_mode == 14)
|
||||
{
|
||||
result = saturation(top_color, bottom_color);
|
||||
}
|
||||
result = saturation(top_color, bottom_color);
|
||||
else if (u_mode == 15)
|
||||
{
|
||||
result = luminosity(top_color, bottom_color);
|
||||
}
|
||||
result = luminosity(top_color, bottom_color);
|
||||
else
|
||||
{
|
||||
discard;
|
||||
}
|
||||
discard;
|
||||
|
||||
setOutputColor(result * u_alpha);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
void main() {
|
||||
vec4 diffuse = Texture(u_source, vUv);
|
||||
|
||||
setOutputColor(diffuse * u_alpha);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// VERTEX_SHADER:
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
vUv = vec2(aUv.x, aUv.y);
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
void main() {
|
||||
vec4 diffuse = Texture(u_source, vUv);
|
||||
|
||||
setOutputColor(diffuse * u_alpha);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
vUv = vec2(aUv.x, aUv.y);
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
uniform float u_blur_radius;
|
||||
uniform vec2 u_blur_size;
|
||||
uniform vec2 u_blur_dir;
|
||||
|
||||
const float PI = 3.14159265;
|
||||
const float RADIUS_MULTIPLIER = 3.0;
|
||||
|
||||
// blur_radius 0 is NOT supported and MUST be caught before.
|
||||
|
||||
// Partially from http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html
|
||||
void main() {
|
||||
float sigma = u_blur_radius; // *shrug*
|
||||
float blur_radius = u_blur_radius * RADIUS_MULTIPLIER;
|
||||
vec3 incrementalGaussian;
|
||||
incrementalGaussian.x = 1.0 / (sqrt(2.0 * PI) * sigma);
|
||||
incrementalGaussian.y = exp(-0.5 / (sigma * sigma));
|
||||
incrementalGaussian.z = incrementalGaussian.y * incrementalGaussian.y;
|
||||
|
||||
vec2 pixel_step = vec2(1.0) / u_blur_size;
|
||||
|
||||
float coefficientSum = 0;
|
||||
vec4 sum = Texture(u_source, vUv) * incrementalGaussian.x;
|
||||
coefficientSum += incrementalGaussian.x;
|
||||
incrementalGaussian.xy *= incrementalGaussian.yz;
|
||||
|
||||
int pixels_per_side = int(floor(blur_radius / 2.0));
|
||||
for (int i = 1; i <= pixels_per_side; i++) {
|
||||
vec2 p = i * pixel_step * u_blur_dir;
|
||||
|
||||
sum += Texture(u_source, vUv - p) * incrementalGaussian.x;
|
||||
sum += Texture(u_source, vUv + p) * incrementalGaussian.x;
|
||||
|
||||
coefficientSum += 2.0 * incrementalGaussian.x;
|
||||
incrementalGaussian.xy *= incrementalGaussian.yz;
|
||||
}
|
||||
|
||||
setOutputColor(sum / coefficientSum);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// VERTEX_SHADER:
|
||||
uniform float u_blur_radius;
|
||||
uniform vec2 u_blur_size;
|
||||
uniform vec2 u_blur_dir;
|
||||
|
||||
_OUT_ vec2 pixel_step;
|
||||
_OUT_ float pixels_per_side;
|
||||
_OUT_ vec3 initial_gaussian;
|
||||
|
||||
const float PI = 3.14159265;
|
||||
const float RADIUS_MULTIPLIER = 3.0;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
vUv = vec2(aUv.x, aUv.y);
|
||||
|
||||
pixel_step = (vec2(1.0) / u_blur_size) * u_blur_dir;
|
||||
pixels_per_side = floor(u_blur_radius * RADIUS_MULTIPLIER / 2.0);
|
||||
|
||||
float sigma = u_blur_radius; // *shrug*
|
||||
initial_gaussian.x = 1.0 / (sqrt(2.0 * PI) * sigma);
|
||||
initial_gaussian.y = exp(-0.5 / (sigma * sigma));
|
||||
initial_gaussian.z = initial_gaussian.y * initial_gaussian.y;
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
uniform float u_blur_radius;
|
||||
uniform vec2 u_blur_size;
|
||||
|
||||
_IN_ vec2 pixel_step;
|
||||
_IN_ float pixels_per_side;
|
||||
_IN_ vec3 initial_gaussian;
|
||||
|
||||
// blur_radius 0 is NOT supported and MUST be caught before.
|
||||
|
||||
// Partially from http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html
|
||||
void main() {
|
||||
vec3 incrementalGaussian = initial_gaussian;
|
||||
|
||||
float coefficientSum = 0.0;
|
||||
vec4 sum = Texture(u_source, vUv) * incrementalGaussian.x;
|
||||
coefficientSum += incrementalGaussian.x;
|
||||
incrementalGaussian.xy *= incrementalGaussian.yz;
|
||||
|
||||
vec2 p = pixel_step;
|
||||
for (int i = 1; i <= int(pixels_per_side); i++) {
|
||||
sum += Texture(u_source, vUv - p) * incrementalGaussian.x;
|
||||
sum += Texture(u_source, vUv + p) * incrementalGaussian.x;
|
||||
|
||||
coefficientSum += 2.0 * incrementalGaussian.x;
|
||||
incrementalGaussian.xy *= incrementalGaussian.yz;
|
||||
|
||||
p += pixel_step;
|
||||
}
|
||||
|
||||
setOutputColor(sum / coefficientSum);
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
uniform vec4 u_color;
|
||||
uniform vec4 u_widths;
|
||||
|
||||
uniform vec4 u_outline;
|
||||
uniform vec4 u_corner_widths;
|
||||
uniform vec4 u_corner_heights;
|
||||
|
||||
void main() {
|
||||
vec4 bounds = u_outline;
|
||||
|
||||
bounds.z = bounds.x + bounds.z;
|
||||
bounds.w = bounds.y + bounds.w;
|
||||
|
||||
vec4 f = gl_FragCoord;
|
||||
f.x += u_viewport.x;
|
||||
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
||||
|
||||
RoundedRect routside = RoundedRect (bounds, u_corner_widths, u_corner_heights);
|
||||
RoundedRect rinside = rounded_rect_shrink (routside, u_widths);
|
||||
|
||||
float alpha = clamp (rounded_rect_coverage (routside, f.xy) -
|
||||
rounded_rect_coverage (rinside, f.xy),
|
||||
0.0, 1.0);
|
||||
|
||||
/* Pre-multiply */
|
||||
vec4 color = u_color;
|
||||
color.rgb *= color.a;
|
||||
|
||||
setOutputColor (color * alpha * u_alpha);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// VERTEX_SHADER:
|
||||
uniform vec4 u_color;
|
||||
|
||||
_OUT_ vec4 final_color;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
final_color = u_color;
|
||||
final_color.rgb *= final_color.a; // pre-multiply
|
||||
final_color *= u_alpha;
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
uniform vec4 u_widths;
|
||||
uniform vec4[3] u_outline_rect;
|
||||
|
||||
_IN_ vec4 final_color;
|
||||
|
||||
void main() {
|
||||
vec4 f = gl_FragCoord;
|
||||
f.x += u_viewport.x;
|
||||
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
||||
|
||||
RoundedRect outside = create_rect(u_outline_rect);
|
||||
RoundedRect inside = rounded_rect_shrink (outside, u_widths);
|
||||
|
||||
float alpha = clamp (rounded_rect_coverage (outside, f.xy) -
|
||||
rounded_rect_coverage (inside, f.xy),
|
||||
0.0, 1.0);
|
||||
|
||||
setOutputColor(final_color * alpha);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
uniform vec4 u_color;
|
||||
|
||||
void main() {
|
||||
vec4 color = u_color;
|
||||
|
||||
// Pre-multiply alpha
|
||||
color.rgb *= color.a;
|
||||
setOutputColor(color * u_alpha);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// VERTEX_SHADER:
|
||||
uniform vec4 u_color;
|
||||
|
||||
_OUT_ vec4 final_color;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
final_color = u_color;
|
||||
// Pre-multiply alpha
|
||||
final_color.rgb *= final_color.a;
|
||||
final_color *= u_alpha;
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
_IN_ vec4 final_color;
|
||||
|
||||
void main() {
|
||||
setOutputColor(final_color);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,23 @@
|
||||
// VERTEX_SHADER:
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
vUv = vec2(aUv.x, aUv.y);
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
uniform mat4 u_color_matrix;
|
||||
uniform vec4 u_color_offset;
|
||||
|
||||
void main() {
|
||||
vec4 diffuse = Texture(u_source, vUv);
|
||||
vec4 color;
|
||||
|
||||
color = diffuse;
|
||||
vec4 color = Texture(u_source, vUv);
|
||||
|
||||
// Un-premultilpy
|
||||
if (color.a != 0.0)
|
||||
color.rgb /= color.a;
|
||||
|
||||
color = u_color_matrix * color + u_color_offset;
|
||||
color = clamp(color, 0.0f, 1.0f);
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
|
||||
color.rgb *= color.a;
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
uniform vec4 u_color;
|
||||
|
||||
void main() {
|
||||
vec4 diffuse = Texture(u_source, vUv);
|
||||
vec4 color = u_color;
|
||||
|
||||
// pre-multiply
|
||||
color.rgb *= color.a;
|
||||
|
||||
// u_source is drawn using cairo, so already pre-multiplied.
|
||||
color = vec4(color.rgb * diffuse.a * u_alpha,
|
||||
color.a * diffuse.a * u_alpha);
|
||||
|
||||
setOutputColor(color);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// VERTEX_SHADER:
|
||||
uniform vec4 u_color;
|
||||
|
||||
_OUT_ vec4 final_color;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
vUv = vec2(aUv.x, aUv.y);
|
||||
|
||||
final_color = u_color;
|
||||
// pre-multiply
|
||||
final_color.rgb *= final_color.a;
|
||||
final_color *= u_alpha;
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
|
||||
_IN_ vec4 final_color;
|
||||
|
||||
void main() {
|
||||
vec4 diffuse = Texture(u_source, vUv);
|
||||
|
||||
setOutputColor(final_color * diffuse.a);
|
||||
}
|
||||
@@ -1,4 +1,11 @@
|
||||
// VERTEX_SHADER:
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
vUv = vec2(aUv.x, aUv.y);
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
uniform float u_progress;
|
||||
uniform sampler2D u_source2;
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
precision mediump float;
|
||||
|
||||
uniform sampler2D u_source;
|
||||
uniform sampler2D u_mask;
|
||||
uniform mat4 u_projection;
|
||||
uniform mat4 u_modelview;
|
||||
uniform float u_alpha;
|
||||
uniform int uBlendMode;
|
||||
uniform vec4 u_viewport;
|
||||
|
||||
// In GtkSnapshot coordinates
|
||||
uniform vec4 u_clip;
|
||||
uniform vec4 u_clip_corner_widths;
|
||||
uniform vec4 u_clip_corner_heights;
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
|
||||
struct RoundedRect
|
||||
{
|
||||
vec4 bounds;
|
||||
vec4 corner_widths;
|
||||
vec4 corner_heights;
|
||||
};
|
||||
|
||||
float
|
||||
ellipsis_dist (vec2 p, vec2 radius)
|
||||
{
|
||||
if (radius == vec2(0, 0))
|
||||
return 0.0;
|
||||
|
||||
vec2 p0 = p / radius;
|
||||
vec2 p1 = 2.0 * p0 / radius;
|
||||
|
||||
return (dot(p0, p0) - 1.0) / length (p1);
|
||||
}
|
||||
|
||||
float
|
||||
ellipsis_coverage (vec2 point, vec2 center, vec2 radius)
|
||||
{
|
||||
float d = ellipsis_dist (point - center, radius);
|
||||
return clamp (0.5 - d, 0.0, 1.0);
|
||||
}
|
||||
|
||||
float
|
||||
rounded_rect_coverage (RoundedRect r, vec2 p)
|
||||
{
|
||||
if (p.x < r.bounds.x || p.y < r.bounds.y ||
|
||||
p.x >= r.bounds.z || p.y >= r.bounds.w)
|
||||
return 0.0;
|
||||
|
||||
vec2 rad_tl = vec2(r.corner_widths.x, r.corner_heights.x);
|
||||
vec2 rad_tr = vec2(r.corner_widths.y, r.corner_heights.y);
|
||||
vec2 rad_br = vec2(r.corner_widths.z, r.corner_heights.z);
|
||||
vec2 rad_bl = vec2(r.corner_widths.w, r.corner_heights.w);
|
||||
|
||||
vec2 ref_tl = r.bounds.xy + vec2( r.corner_widths.x, r.corner_heights.x);
|
||||
vec2 ref_tr = r.bounds.zy + vec2(-r.corner_widths.y, r.corner_heights.y);
|
||||
vec2 ref_br = r.bounds.zw + vec2(-r.corner_widths.z, -r.corner_heights.z);
|
||||
vec2 ref_bl = r.bounds.xw + vec2( r.corner_widths.w, -r.corner_heights.w);
|
||||
|
||||
float d_tl = ellipsis_coverage(p, ref_tl, rad_tl);
|
||||
float d_tr = ellipsis_coverage(p, ref_tr, rad_tr);
|
||||
float d_br = ellipsis_coverage(p, ref_br, rad_br);
|
||||
float d_bl = ellipsis_coverage(p, ref_bl, rad_bl);
|
||||
|
||||
vec4 corner_coverages = 1.0 - vec4(d_tl, d_tr, d_br, d_bl);
|
||||
|
||||
bvec4 is_out = bvec4(p.x < ref_tl.x && p.y < ref_tl.y,
|
||||
p.x > ref_tr.x && p.y < ref_tr.y,
|
||||
p.x > ref_br.x && p.y > ref_br.y,
|
||||
p.x < ref_bl.x && p.y > ref_bl.y);
|
||||
|
||||
return 1.0 - dot(vec4(is_out), corner_coverages);
|
||||
}
|
||||
|
||||
RoundedRect
|
||||
rounded_rect_shrink (RoundedRect r, vec4 amount)
|
||||
{
|
||||
vec4 new_bounds = r.bounds + vec4(1.0,1.0,-1.0,-1.0) * amount.wxyz;
|
||||
vec4 new_widths = max (r.corner_widths - amount.wyyw, 0.0);
|
||||
vec4 new_heights = max (r.corner_heights - amount.xxzz, 0.0);
|
||||
|
||||
return RoundedRect (new_bounds, new_widths, new_heights);
|
||||
}
|
||||
|
||||
vec4 Texture(sampler2D sampler, vec2 texCoords) {
|
||||
return texture2D(sampler, texCoords);
|
||||
}
|
||||
|
||||
void setOutputColor(vec4 color) {
|
||||
vec4 clipBounds = u_clip;
|
||||
vec4 f = gl_FragCoord;
|
||||
|
||||
f.x += u_viewport.x;
|
||||
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
||||
|
||||
clipBounds.z = clipBounds.x + clipBounds.z;
|
||||
clipBounds.w = clipBounds.y + clipBounds.w;
|
||||
|
||||
RoundedRect r = RoundedRect(clipBounds, u_clip_corner_widths, u_clip_corner_heights);
|
||||
|
||||
gl_FragColor = color * rounded_rect_coverage(r, f.xy);
|
||||
/*gl_FragColor = color;*/
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
precision mediump float;
|
||||
|
||||
uniform mat4 u_projection;
|
||||
uniform mat4 u_modelview;
|
||||
|
||||
attribute vec2 aPosition;
|
||||
attribute vec2 aUv;
|
||||
|
||||
varying vec2 vUv;
|
||||
@@ -1,7 +0,0 @@
|
||||
uniform mat4 u_projection;
|
||||
uniform mat4 u_modelview;
|
||||
|
||||
in vec2 aPosition;
|
||||
in vec2 aUv;
|
||||
|
||||
out vec2 vUv;
|
||||
@@ -1,102 +0,0 @@
|
||||
uniform sampler2D u_source;
|
||||
uniform sampler2D u_mask;
|
||||
uniform mat4 u_projection;
|
||||
uniform mat4 u_modelview;
|
||||
uniform float u_alpha;
|
||||
uniform int uBlendMode;
|
||||
uniform vec4 u_viewport;
|
||||
|
||||
// In GtkSnapshot coordinates
|
||||
uniform vec4 u_clip;
|
||||
uniform vec4 u_clip_corner_widths;
|
||||
uniform vec4 u_clip_corner_heights;
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
|
||||
struct RoundedRect
|
||||
{
|
||||
vec4 bounds;
|
||||
vec4 corner_widths;
|
||||
vec4 corner_heights;
|
||||
};
|
||||
|
||||
float
|
||||
ellipsis_dist (vec2 p, vec2 radius)
|
||||
{
|
||||
if (radius == vec2(0, 0))
|
||||
return 0.0;
|
||||
|
||||
vec2 p0 = p / radius;
|
||||
vec2 p1 = 2.0 * p0 / radius;
|
||||
|
||||
return (dot(p0, p0) - 1.0) / length (p1);
|
||||
}
|
||||
|
||||
float
|
||||
ellipsis_coverage (vec2 point, vec2 center, vec2 radius)
|
||||
{
|
||||
float d = ellipsis_dist (point - center, radius);
|
||||
return clamp (0.5 - d, 0.0, 1.0);
|
||||
}
|
||||
|
||||
float
|
||||
rounded_rect_coverage (RoundedRect r, vec2 p)
|
||||
{
|
||||
if (p.x < r.bounds.x || p.y < r.bounds.y ||
|
||||
p.x >= r.bounds.z || p.y >= r.bounds.w)
|
||||
return 0.0;
|
||||
|
||||
vec2 rad_tl = vec2(r.corner_widths.x, r.corner_heights.x);
|
||||
vec2 rad_tr = vec2(r.corner_widths.y, r.corner_heights.y);
|
||||
vec2 rad_br = vec2(r.corner_widths.z, r.corner_heights.z);
|
||||
vec2 rad_bl = vec2(r.corner_widths.w, r.corner_heights.w);
|
||||
|
||||
vec2 ref_tl = r.bounds.xy + vec2( r.corner_widths.x, r.corner_heights.x);
|
||||
vec2 ref_tr = r.bounds.zy + vec2(-r.corner_widths.y, r.corner_heights.y);
|
||||
vec2 ref_br = r.bounds.zw + vec2(-r.corner_widths.z, -r.corner_heights.z);
|
||||
vec2 ref_bl = r.bounds.xw + vec2( r.corner_widths.w, -r.corner_heights.w);
|
||||
|
||||
float d_tl = ellipsis_coverage(p, ref_tl, rad_tl);
|
||||
float d_tr = ellipsis_coverage(p, ref_tr, rad_tr);
|
||||
float d_br = ellipsis_coverage(p, ref_br, rad_br);
|
||||
float d_bl = ellipsis_coverage(p, ref_bl, rad_bl);
|
||||
|
||||
vec4 corner_coverages = 1.0 - vec4(d_tl, d_tr, d_br, d_bl);
|
||||
|
||||
bvec4 is_out = bvec4(p.x < ref_tl.x && p.y < ref_tl.y,
|
||||
p.x > ref_tr.x && p.y < ref_tr.y,
|
||||
p.x > ref_br.x && p.y > ref_br.y,
|
||||
p.x < ref_bl.x && p.y > ref_bl.y);
|
||||
|
||||
return 1.0 - dot(vec4(is_out), corner_coverages);
|
||||
}
|
||||
|
||||
RoundedRect
|
||||
rounded_rect_shrink (RoundedRect r, vec4 amount)
|
||||
{
|
||||
vec4 new_bounds = r.bounds + vec4(1.0,1.0,-1.0,-1.0) * amount.wxyz;
|
||||
vec4 new_widths = max (r.corner_widths - amount.wyyw, 0.0);
|
||||
vec4 new_heights = max (r.corner_heights - amount.xxzz, 0.0);
|
||||
|
||||
return RoundedRect (new_bounds, new_widths, new_heights);
|
||||
}
|
||||
|
||||
vec4 Texture(sampler2D sampler, vec2 texCoords) {
|
||||
return texture2D(sampler, texCoords);
|
||||
}
|
||||
|
||||
void setOutputColor(vec4 color) {
|
||||
vec4 clipBounds = u_clip;
|
||||
vec4 f = gl_FragCoord;
|
||||
|
||||
f.x += u_viewport.x;
|
||||
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
||||
|
||||
clipBounds.z = clipBounds.x + clipBounds.z;
|
||||
clipBounds.w = clipBounds.y + clipBounds.w;
|
||||
|
||||
RoundedRect r = RoundedRect(clipBounds, u_clip_corner_widths, u_clip_corner_heights);
|
||||
|
||||
gl_FragColor = color * rounded_rect_coverage(r, f.xy);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
uniform mat4 u_projection;
|
||||
uniform mat4 u_modelview;
|
||||
|
||||
attribute vec2 aPosition;
|
||||
attribute vec2 aUv;
|
||||
|
||||
varying vec2 vUv;
|
||||
@@ -1,26 +0,0 @@
|
||||
uniform float u_spread;
|
||||
uniform vec4 u_color;
|
||||
uniform vec2 u_offset;
|
||||
uniform vec4 u_outline;
|
||||
uniform vec4 u_corner_widths;
|
||||
uniform vec4 u_corner_heights;
|
||||
|
||||
|
||||
void main() {
|
||||
vec4 f = gl_FragCoord;
|
||||
|
||||
f.x += u_viewport.x;
|
||||
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
||||
|
||||
RoundedRect outline = RoundedRect(vec4(u_outline.xy, u_outline.xy + u_outline.zw),
|
||||
u_corner_widths, u_corner_heights);
|
||||
RoundedRect inside = rounded_rect_shrink(outline, vec4(u_spread));
|
||||
|
||||
|
||||
vec2 offset = vec2(u_offset.x, - u_offset.y);
|
||||
vec4 color = vec4(u_color.rgb * u_color.a, u_color.a);
|
||||
color = color * clamp (rounded_rect_coverage (outline, f.xy) -
|
||||
rounded_rect_coverage (inside, f.xy - offset),
|
||||
0.0, 1.0);
|
||||
setOutputColor(color * u_alpha);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// VERTEX_SHADER:
|
||||
uniform vec4 u_color;
|
||||
|
||||
_OUT_ vec4 final_color;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
final_color = u_color;
|
||||
final_color.rgb *= final_color.a;
|
||||
final_color *= u_alpha;
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
uniform float u_spread;
|
||||
uniform vec2 u_offset;
|
||||
uniform vec4[3] u_outline_rect;
|
||||
|
||||
_IN_ vec4 final_color;
|
||||
|
||||
void main() {
|
||||
vec4 f = gl_FragCoord;
|
||||
vec4 color;
|
||||
|
||||
f.x += u_viewport.x;
|
||||
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
||||
|
||||
RoundedRect outside = create_rect(u_outline_rect);
|
||||
RoundedRect inside = rounded_rect_shrink(outside, vec4(u_spread));
|
||||
color = final_color * clamp (rounded_rect_coverage (outside, f.xy) -
|
||||
rounded_rect_coverage (inside, f.xy - u_offset),
|
||||
0.0, 1.0);
|
||||
setOutputColor(color);
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
uniform vec4 u_color_stops[8];
|
||||
uniform float u_color_offsets[8];
|
||||
uniform int u_num_color_stops;
|
||||
uniform vec2 u_start_point;
|
||||
uniform vec2 u_end_point;
|
||||
|
||||
vec4 fragCoord() {
|
||||
vec4 f = gl_FragCoord;
|
||||
f.x += u_viewport.x;
|
||||
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
||||
return f;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 startPoint = (u_modelview * vec4(u_start_point, 0, 1)).xy;
|
||||
vec2 endPoint = (u_modelview * vec4(u_end_point, 0, 1)).xy;
|
||||
float maxDist = length(endPoint - startPoint);
|
||||
|
||||
// Position relative to startPoint
|
||||
vec2 pos = fragCoord().xy - startPoint;
|
||||
|
||||
// Gradient direction
|
||||
vec2 gradient = endPoint - startPoint;
|
||||
float gradientLength = length(gradient);
|
||||
|
||||
// Current pixel, projected onto the line between the start point and the end point
|
||||
// The projection will be relative to the start point!
|
||||
vec2 proj = (dot(gradient, pos) / (gradientLength * gradientLength)) * gradient;
|
||||
|
||||
// Offset of the current pixel
|
||||
float offset = length(proj) / maxDist;
|
||||
|
||||
vec4 color = u_color_stops[0];
|
||||
for (int i = 1; i < u_num_color_stops; i ++) {
|
||||
if (offset >= u_color_offsets[i - 1]) {
|
||||
float o = (offset - u_color_offsets[i - 1]) / (u_color_offsets[i] - u_color_offsets[i - 1]);
|
||||
color = mix(u_color_stops[i - 1], u_color_stops[i], clamp(o, 0.0, 1.0));
|
||||
}
|
||||
}
|
||||
|
||||
/* Pre-multiply */
|
||||
color.rgb *= color.a;
|
||||
|
||||
setOutputColor(color * u_alpha);
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
// VERTEX_SHADER
|
||||
uniform vec2 u_start_point;
|
||||
uniform vec2 u_end_point;
|
||||
uniform float u_color_stops[8 * 5];
|
||||
uniform int u_num_color_stops;
|
||||
|
||||
_OUT_ vec2 startPoint;
|
||||
_OUT_ vec2 endPoint;
|
||||
_OUT_ float maxDist;
|
||||
_OUT_ vec2 gradient;
|
||||
_OUT_ float gradientLength;
|
||||
_OUT_ vec4 color_stops[8];
|
||||
_OUT_ float color_offsets[8];
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
startPoint = (u_modelview * vec4(u_start_point, 0, 1)).xy;
|
||||
endPoint = (u_modelview * vec4(u_end_point, 0, 1)).xy;
|
||||
maxDist = length(endPoint - startPoint);
|
||||
|
||||
// Gradient direction
|
||||
gradient = endPoint - startPoint;
|
||||
gradientLength = length(gradient);
|
||||
|
||||
for (int i = 0; i < u_num_color_stops; i ++) {
|
||||
color_offsets[i] = u_color_stops[(i * 5) + 0];
|
||||
color_stops[i].r = u_color_stops[(i * 5) + 1];
|
||||
color_stops[i].g = u_color_stops[(i * 5) + 2];
|
||||
color_stops[i].b = u_color_stops[(i * 5) + 3];
|
||||
color_stops[i].a = u_color_stops[(i * 5) + 4];
|
||||
}
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
#ifdef GSK_LEGACY
|
||||
uniform int u_num_color_stops;
|
||||
#else
|
||||
uniform highp int u_num_color_stops; // Why? Because it works like this.
|
||||
#endif
|
||||
|
||||
_IN_ vec2 startPoint;
|
||||
_IN_ vec2 endPoint;
|
||||
_IN_ float maxDist;
|
||||
_IN_ vec2 gradient;
|
||||
_IN_ float gradientLength;
|
||||
_IN_ vec4 color_stops[8];
|
||||
_IN_ float color_offsets[8];
|
||||
|
||||
|
||||
vec4 fragCoord() {
|
||||
vec4 f = gl_FragCoord;
|
||||
f.x += u_viewport.x;
|
||||
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
||||
return f;
|
||||
}
|
||||
|
||||
void main() {
|
||||
// Position relative to startPoint
|
||||
vec2 pos = fragCoord().xy - startPoint;
|
||||
|
||||
// Current pixel, projected onto the line between the start point and the end point
|
||||
// The projection will be relative to the start point!
|
||||
vec2 proj = (dot(gradient, pos) / (gradientLength * gradientLength)) * gradient;
|
||||
|
||||
// Offset of the current pixel
|
||||
float offset = length(proj) / maxDist;
|
||||
|
||||
vec4 color = color_stops[0];
|
||||
for (int i = 1; i < u_num_color_stops; i ++) {
|
||||
if (offset >= color_offsets[i - 1]) {
|
||||
float o = (offset - color_offsets[i - 1]) / (color_offsets[i] - color_offsets[i - 1]);
|
||||
color = mix(color_stops[i - 1], color_stops[i], clamp(o, 0.0, 1.0));
|
||||
}
|
||||
}
|
||||
|
||||
/* Pre-multiply */
|
||||
color.rgb *= color.a;
|
||||
|
||||
setOutputColor(color * u_alpha);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
uniform vec4 u_outline;
|
||||
uniform vec4 u_corner_widths;//= vec4(0, 0, 0, 0);
|
||||
uniform vec4 u_corner_heights;// = vec4(0, 0, 0, 0);
|
||||
|
||||
void main() {
|
||||
vec4 f = gl_FragCoord;
|
||||
|
||||
f.x += u_viewport.x;
|
||||
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
||||
|
||||
RoundedRect outline = RoundedRect(vec4(u_outline.xy, u_outline.xy + u_outline.zw), u_corner_widths, u_corner_heights);
|
||||
|
||||
vec4 color = Texture(u_source, vUv);
|
||||
color = color * (1.0 - clamp(rounded_rect_coverage (outline, f.xy), 0.0, 1.0));
|
||||
setOutputColor(color * u_alpha);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// VERTEX_SHADER:
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
vUv = vec2(aUv.x, aUv.y);
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
uniform vec4[3] u_outline_rect;
|
||||
|
||||
void main() {
|
||||
vec4 f = gl_FragCoord;
|
||||
|
||||
f.x += u_viewport.x;
|
||||
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
||||
|
||||
RoundedRect outline = create_rect(u_outline_rect);
|
||||
vec4 color = Texture(u_source, vUv);
|
||||
color = color * (1.0 - clamp(rounded_rect_coverage(outline, f.xy), 0.0, 1.0));
|
||||
setOutputColor(color * u_alpha);
|
||||
}
|
||||
@@ -1,21 +1,33 @@
|
||||
#ifdef GSK_GL3
|
||||
precision highp float;
|
||||
#endif
|
||||
|
||||
#ifdef GSK_GLES
|
||||
precision highp float;
|
||||
#endif
|
||||
|
||||
|
||||
uniform sampler2D u_source;
|
||||
uniform sampler2D u_mask;
|
||||
uniform mat4 u_projection = mat4(1.0);
|
||||
uniform mat4 u_modelview = mat4(1.0);
|
||||
uniform float u_alpha = 1.0;
|
||||
uniform int uBlendMode;
|
||||
uniform mat4 u_projection;
|
||||
uniform mat4 u_modelview;
|
||||
uniform float u_alpha;// = 1.0;
|
||||
uniform vec4 u_viewport;
|
||||
uniform vec4[3] u_clip_rect;
|
||||
|
||||
// In GtkSnapshot coordinates
|
||||
uniform vec4 u_clip;
|
||||
uniform vec4 u_clip_corner_widths = vec4(0, 0, 0, 0);
|
||||
uniform vec4 u_clip_corner_heights = vec4(0, 0, 0, 0);
|
||||
#if GSK_GLES
|
||||
#define _OUT_ varying
|
||||
#define _IN_ varying
|
||||
#elif GSK_LEGACY
|
||||
#define _OUT_ varying
|
||||
#define _IN_ varying
|
||||
_OUT_ vec4 outputColor;
|
||||
#else
|
||||
#define _OUT_ out
|
||||
#define _IN_ in
|
||||
_OUT_ vec4 outputColor;
|
||||
#endif
|
||||
_IN_ vec2 vUv;
|
||||
|
||||
in vec2 vUv;
|
||||
|
||||
out vec4 outputColor;
|
||||
|
||||
|
||||
struct RoundedRect
|
||||
@@ -25,6 +37,16 @@ struct RoundedRect
|
||||
vec4 corner_heights;
|
||||
};
|
||||
|
||||
// Transform from a GskRoundedRect to a RoundedRect as we need it.
|
||||
RoundedRect
|
||||
create_rect(vec4 data[3])
|
||||
{
|
||||
vec4 bounds = vec4(data[0].xy, data[0].xy + data[0].zw);
|
||||
vec4 widths = vec4(data[1].x, data[1].z, data[2].x, data[2].z);
|
||||
vec4 heights = vec4(data[1].y, data[1].w, data[2].y, data[2].w);
|
||||
return RoundedRect(bounds, widths, heights);
|
||||
}
|
||||
|
||||
float
|
||||
ellipsis_dist (vec2 p, vec2 radius)
|
||||
{
|
||||
@@ -76,6 +98,7 @@ rounded_rect_coverage (RoundedRect r, vec2 p)
|
||||
return 1.0 - dot(vec4(is_out), corner_coverages);
|
||||
}
|
||||
|
||||
// amount is: top, right, bottom, left
|
||||
RoundedRect
|
||||
rounded_rect_shrink (RoundedRect r, vec4 amount)
|
||||
{
|
||||
@@ -84,40 +107,46 @@ rounded_rect_shrink (RoundedRect r, vec4 amount)
|
||||
vec4 new_heights = vec4(0);
|
||||
|
||||
// Left top
|
||||
if (r.corner_widths.x > 0) new_widths.x = r.corner_widths.x - amount.w;
|
||||
if (r.corner_heights.x > 0) new_heights.x = r.corner_heights.x - amount.x;
|
||||
if (r.corner_widths.x > 0.0) new_widths.x = r.corner_widths.x - amount.w;
|
||||
if (r.corner_heights.x > 0.0) new_heights.x = r.corner_heights.x - amount.x;
|
||||
|
||||
// Top right
|
||||
if (r.corner_widths.y > 0) new_widths.y = r.corner_widths.y - amount.y;
|
||||
if (r.corner_heights.y > 0) new_heights.y = r.corner_heights.y - amount.x;
|
||||
if (r.corner_widths.y > 0.0) new_widths.y = r.corner_widths.y - amount.y;
|
||||
if (r.corner_heights.y > 0.0) new_heights.y = r.corner_heights.y - amount.x;
|
||||
|
||||
// Bottom right
|
||||
if (r.corner_widths.z > 0) new_widths.z = r.corner_widths.z - amount.y;
|
||||
if (r.corner_heights.z > 0) new_heights.z = r.corner_heights.z - amount.z;
|
||||
if (r.corner_widths.z > 0.0) new_widths.z = r.corner_widths.z - amount.y;
|
||||
if (r.corner_heights.z > 0.0) new_heights.z = r.corner_heights.z - amount.z;
|
||||
|
||||
// Bottom left
|
||||
if (r.corner_widths.w > 0) new_widths.w = r.corner_widths.w - amount.w;
|
||||
if (r.corner_heights.w > 0) new_heights.w = r.corner_heights.w - amount.z;
|
||||
if (r.corner_widths.w > 0.0) new_widths.w = r.corner_widths.w - amount.w;
|
||||
if (r.corner_heights.w > 0.0) new_heights.w = r.corner_heights.w - amount.z;
|
||||
|
||||
return RoundedRect (new_bounds, new_widths, new_heights);
|
||||
}
|
||||
|
||||
vec4 Texture(sampler2D sampler, vec2 texCoords) {
|
||||
#if GSK_GLES
|
||||
return texture2D(sampler, texCoords);
|
||||
#elif GSK_LEGACY
|
||||
return texture2D(sampler, texCoords);
|
||||
#else
|
||||
return texture(sampler, texCoords);
|
||||
#endif
|
||||
}
|
||||
|
||||
void setOutputColor(vec4 color) {
|
||||
vec4 clipBounds = u_clip;
|
||||
vec4 f = gl_FragCoord;
|
||||
|
||||
f.x += u_viewport.x;
|
||||
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
||||
|
||||
clipBounds.z = clipBounds.x + clipBounds.z;
|
||||
clipBounds.w = clipBounds.y + clipBounds.w;
|
||||
|
||||
RoundedRect r = RoundedRect(clipBounds, u_clip_corner_widths, u_clip_corner_heights);
|
||||
|
||||
outputColor = color * rounded_rect_coverage(r, f.xy);
|
||||
#if GSK_GLES
|
||||
gl_FragColor = color * rounded_rect_coverage(create_rect(u_clip_rect), f.xy);
|
||||
#elif GSK_LEGACY
|
||||
gl_FragColor = color * rounded_rect_coverage(create_rect(u_clip_rect), f.xy);
|
||||
#else
|
||||
outputColor = color * rounded_rect_coverage(create_rect(u_clip_rect), f.xy);
|
||||
#endif
|
||||
/*outputColor = color;*/
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
uniform mat4 u_projection;
|
||||
uniform mat4 u_modelview;
|
||||
uniform float u_alpha;
|
||||
|
||||
#ifdef GSK_GLES
|
||||
precision highp float;
|
||||
#endif
|
||||
|
||||
#if GSK_GLES
|
||||
#define _OUT_ varying
|
||||
#define _IN_ varying
|
||||
attribute vec2 aPosition;
|
||||
attribute vec2 aUv;
|
||||
_OUT_ vec2 vUv;
|
||||
#elif GSK_LEGACY
|
||||
#define _OUT_ varying
|
||||
#define _IN_ varying
|
||||
attribute vec2 aPosition;
|
||||
attribute vec2 aUv;
|
||||
_OUT_ vec2 vUv;
|
||||
#else
|
||||
#define _OUT_ out
|
||||
#define _IN_ in
|
||||
_IN_ vec2 aPosition;
|
||||
_IN_ vec2 aUv;
|
||||
_OUT_ vec2 vUv;
|
||||
#endif
|
||||
@@ -1,3 +1,11 @@
|
||||
// VERTEX_SHADER:
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
vUv = vec2(aUv.x, aUv.y);
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
uniform vec4 u_child_bounds;
|
||||
uniform vec4 u_texture_rect;
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
uniform float u_spread;
|
||||
uniform vec4 u_color;
|
||||
uniform vec2 u_offset;
|
||||
uniform vec4 u_outline;
|
||||
uniform vec4 u_corner_widths;
|
||||
uniform vec4 u_corner_heights;
|
||||
|
||||
|
||||
void main() {
|
||||
vec4 f = gl_FragCoord;
|
||||
|
||||
f.x += u_viewport.x;
|
||||
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
||||
|
||||
RoundedRect inside = RoundedRect(vec4(u_outline.xy, u_outline.xy + u_outline.zw),
|
||||
u_corner_widths, u_corner_heights);
|
||||
|
||||
RoundedRect outline = rounded_rect_shrink(inside, vec4(- u_spread));
|
||||
|
||||
vec2 offset = vec2(u_offset.x, - u_offset.y);
|
||||
vec4 color = vec4(u_color.rgb * u_color.a, u_color.a);
|
||||
color = color * clamp (rounded_rect_coverage (outline, f.xy - offset) -
|
||||
rounded_rect_coverage (inside, f.xy),
|
||||
0.0, 1.0);
|
||||
setOutputColor(color * u_alpha);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// VERTEX_SHADER:
|
||||
uniform vec4 u_color;
|
||||
|
||||
_OUT_ vec4 final_color;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
||||
|
||||
final_color = u_color;
|
||||
final_color.rgb *= final_color.a;
|
||||
final_color *= u_alpha;
|
||||
}
|
||||
|
||||
// FRAGMENT_SHADER:
|
||||
uniform float u_spread;
|
||||
uniform vec2 u_offset;
|
||||
uniform vec4[3] u_outline_rect;
|
||||
|
||||
_IN_ vec4 final_color;
|
||||
|
||||
void main() {
|
||||
vec4 f = gl_FragCoord;
|
||||
vec4 color;
|
||||
|
||||
f.x += u_viewport.x;
|
||||
f.y = (u_viewport.y + u_viewport.w) - f.y;
|
||||
|
||||
RoundedRect inside = create_rect(u_outline_rect);
|
||||
RoundedRect outside = rounded_rect_shrink(inside, vec4(- u_spread));
|
||||
color = final_color * clamp (rounded_rect_coverage (outside, f.xy - u_offset) -
|
||||
rounded_rect_coverage (inside, f.xy),
|
||||
0.0, 1.0);
|
||||
setOutputColor(color);
|
||||
}
|
||||
@@ -27,6 +27,15 @@
|
||||
fun:gtk_media_file_extension_init
|
||||
}
|
||||
|
||||
# AMD driver
|
||||
{
|
||||
radeonsi_dri general
|
||||
Memcheck:Leak
|
||||
fun:calloc
|
||||
...
|
||||
obj:/usr/lib/dri/radeonsi_dri.so
|
||||
}
|
||||
|
||||
# mesa driver stuff
|
||||
{
|
||||
i965 addr4
|
||||
|
||||
+23
-39
@@ -36,6 +36,7 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkbin.h"
|
||||
|
||||
|
||||
@@ -44,23 +45,6 @@ typedef struct
|
||||
GtkWidget *child;
|
||||
} GtkBinPrivate;
|
||||
|
||||
static void gtk_bin_add (GtkContainer *container,
|
||||
GtkWidget *widget);
|
||||
static void gtk_bin_remove (GtkContainer *container,
|
||||
GtkWidget *widget);
|
||||
static void gtk_bin_forall (GtkContainer *container,
|
||||
GtkCallback callback,
|
||||
gpointer callback_data);
|
||||
static GType gtk_bin_child_type (GtkContainer *container);
|
||||
|
||||
static void gtk_bin_measure (GtkWidget *widget,
|
||||
GtkOrientation orientation,
|
||||
int for_size,
|
||||
int *minimum,
|
||||
int *natural,
|
||||
int *minimum_baseline,
|
||||
int *natural_baseline);
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GtkBin, gtk_bin, GTK_TYPE_CONTAINER)
|
||||
|
||||
static void
|
||||
@@ -72,7 +56,7 @@ gtk_bin_size_allocate (GtkWidget *widget,
|
||||
GtkBin *bin = GTK_BIN (widget);
|
||||
GtkBinPrivate *priv = gtk_bin_get_instance_private (bin);
|
||||
|
||||
if (priv->child && gtk_widget_get_visible (priv->child))
|
||||
if (priv->child && _gtk_widget_get_visible (priv->child))
|
||||
gtk_widget_size_allocate (priv->child,
|
||||
&(GtkAllocation) {
|
||||
0, 0,
|
||||
@@ -80,26 +64,6 @@ gtk_bin_size_allocate (GtkWidget *widget,
|
||||
}, baseline);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_bin_class_init (GtkBinClass *class)
|
||||
{
|
||||
GtkWidgetClass *widget_class = (GtkWidgetClass*) class;
|
||||
GtkContainerClass *container_class = (GtkContainerClass*) class;
|
||||
|
||||
widget_class->measure = gtk_bin_measure;
|
||||
widget_class->size_allocate = gtk_bin_size_allocate;
|
||||
|
||||
container_class->add = gtk_bin_add;
|
||||
container_class->remove = gtk_bin_remove;
|
||||
container_class->forall = gtk_bin_forall;
|
||||
container_class->child_type = gtk_bin_child_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_bin_init (GtkBin *bin)
|
||||
{
|
||||
}
|
||||
|
||||
static GType
|
||||
gtk_bin_child_type (GtkContainer *container)
|
||||
{
|
||||
@@ -179,7 +143,7 @@ gtk_bin_measure (GtkWidget *widget,
|
||||
{
|
||||
GtkBinPrivate *priv = gtk_bin_get_instance_private (GTK_BIN (widget));
|
||||
|
||||
if (priv->child != NULL && gtk_widget_get_visible (priv->child))
|
||||
if (priv->child != NULL && _gtk_widget_get_visible (priv->child))
|
||||
{
|
||||
gtk_widget_measure (priv->child,
|
||||
orientation,
|
||||
@@ -194,6 +158,26 @@ gtk_bin_measure (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_bin_class_init (GtkBinClass *class)
|
||||
{
|
||||
GtkWidgetClass *widget_class = (GtkWidgetClass*) class;
|
||||
GtkContainerClass *container_class = (GtkContainerClass*) class;
|
||||
|
||||
widget_class->measure = gtk_bin_measure;
|
||||
widget_class->size_allocate = gtk_bin_size_allocate;
|
||||
|
||||
container_class->add = gtk_bin_add;
|
||||
container_class->remove = gtk_bin_remove;
|
||||
container_class->forall = gtk_bin_forall;
|
||||
container_class->child_type = gtk_bin_child_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_bin_init (GtkBin *bin)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_bin_get_child:
|
||||
* @bin: a #GtkBin
|
||||
|
||||
@@ -530,7 +530,8 @@ gtk_color_chooser_widget_init (GtkColorChooserWidget *cc)
|
||||
GtkWidget *button;
|
||||
GtkWidget *label;
|
||||
gint i;
|
||||
GdkRGBA color;
|
||||
double color[4];
|
||||
GdkRGBA rgba;
|
||||
GVariant *variant;
|
||||
GVariantIter iter;
|
||||
gboolean selected;
|
||||
@@ -568,14 +569,20 @@ gtk_color_chooser_widget_init (GtkColorChooserWidget *cc)
|
||||
g_variant_iter_init (&iter, variant);
|
||||
i = 0;
|
||||
p = NULL;
|
||||
while (g_variant_iter_loop (&iter, "(dddd)", &color.red, &color.green, &color.blue, &color.alpha))
|
||||
while (g_variant_iter_loop (&iter, "(dddd)", &color[0], &color[1], &color[2], &color[3]))
|
||||
{
|
||||
i++;
|
||||
p = gtk_color_swatch_new ();
|
||||
gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (p), &color);
|
||||
|
||||
rgba.red = color[0];
|
||||
rgba.green = color[1];
|
||||
rgba.blue = color[2];
|
||||
rgba.alpha = color[3];
|
||||
|
||||
gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (p), &rgba);
|
||||
gtk_color_swatch_set_can_drop (GTK_COLOR_SWATCH (p), TRUE);
|
||||
atk_obj = gtk_widget_get_accessible (p);
|
||||
name = accessible_color_name (&color);
|
||||
name = accessible_color_name (&rgba);
|
||||
text = g_strdup_printf (_("Custom color %d: %s"), i, name);
|
||||
atk_object_set_name (atk_obj, text);
|
||||
g_free (text);
|
||||
@@ -598,9 +605,15 @@ gtk_color_chooser_widget_init (GtkColorChooserWidget *cc)
|
||||
|
||||
g_settings_get (priv->settings, I_("selected-color"), "(bdddd)",
|
||||
&selected,
|
||||
&color.red, &color.green, &color.blue, &color.alpha);
|
||||
&color[0], &color[1], &color[2], &color[3]);
|
||||
if (selected)
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (cc), &color);
|
||||
{
|
||||
rgba.red = color[0];
|
||||
rgba.green = color[1];
|
||||
rgba.blue = color[2];
|
||||
rgba.alpha = color[3];
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (cc), &rgba);
|
||||
}
|
||||
|
||||
gtk_widget_hide (GTK_WIDGET (priv->editor));
|
||||
}
|
||||
|
||||
@@ -555,7 +555,7 @@ gtk_color_editor_get_rgba (GtkColorChooser *chooser,
|
||||
GdkRGBA *color)
|
||||
{
|
||||
GtkColorEditor *editor = GTK_COLOR_EDITOR (chooser);
|
||||
gdouble h, s, v;
|
||||
float h, s, v;
|
||||
|
||||
h = gtk_adjustment_get_value (editor->priv->h_adj);
|
||||
s = gtk_adjustment_get_value (editor->priv->s_adj);
|
||||
@@ -569,7 +569,7 @@ gtk_color_editor_set_rgba (GtkColorChooser *chooser,
|
||||
const GdkRGBA *color)
|
||||
{
|
||||
GtkColorEditor *editor = GTK_COLOR_EDITOR (chooser);
|
||||
gdouble h, s, v;
|
||||
float h, s, v;
|
||||
|
||||
gtk_rgb_to_hsv (color->red, color->green, color->blue, &h, &s, &v);
|
||||
|
||||
|
||||
@@ -149,11 +149,11 @@ portal_response_received (GDBusConnection *connection,
|
||||
|
||||
if (response == 0)
|
||||
{
|
||||
GdkRGBA c;
|
||||
double d1, d2, d3;
|
||||
|
||||
c.alpha = 1.0;
|
||||
if (g_variant_lookup (ret, "color", "(ddd)", &c.red, &c.green, &c.blue))
|
||||
g_task_return_pointer (picker->task, gdk_rgba_copy (&c), (GDestroyNotify)gdk_rgba_free);
|
||||
if (g_variant_lookup (ret, "color", "(ddd)", &d1, &d2, &d3))
|
||||
g_task_return_pointer (picker->task,
|
||||
gdk_rgba_copy (&(GdkRGBA){d1, d2, d3, 1.0f}), (GDestroyNotify)gdk_rgba_free);
|
||||
else
|
||||
g_task_return_new_error (picker->task,
|
||||
G_IO_ERROR,
|
||||
|
||||
@@ -129,15 +129,15 @@ color_picked (GObject *source,
|
||||
}
|
||||
else
|
||||
{
|
||||
GdkRGBA c;
|
||||
double d1, d2, d3;
|
||||
|
||||
g_variant_get (ret, "(@a{sv})", &dict);
|
||||
|
||||
c.alpha = 1;
|
||||
if (!g_variant_lookup (dict, "color", "(ddd)", &c.red, &c.green, &c.blue))
|
||||
if (!g_variant_lookup (dict, "color", "(ddd)", &d1, &d2, &d3))
|
||||
g_task_return_new_error (picker->task, G_IO_ERROR, G_IO_ERROR_FAILED, "No color received");
|
||||
else
|
||||
g_task_return_pointer (picker->task, gdk_rgba_copy (&c), (GDestroyNotify)gdk_rgba_free);
|
||||
g_task_return_pointer (picker->task,
|
||||
gdk_rgba_copy (&(GdkRGBA){d1, d2, d3, 1.0f}), (GDestroyNotify)gdk_rgba_free);
|
||||
|
||||
g_variant_unref (dict);
|
||||
g_variant_unref (ret);
|
||||
|
||||
+2
-2
@@ -118,8 +118,8 @@ create_texture (GtkColorPlane *plane)
|
||||
gint width, height, stride;
|
||||
guint red, green, blue;
|
||||
guint32 *data, *p;
|
||||
gdouble h, s, v;
|
||||
gdouble r, g, b;
|
||||
float h, s, v;
|
||||
float r, g, b;
|
||||
gdouble sf, vf;
|
||||
gint x, y;
|
||||
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ gtk_color_scale_snapshot_trough (GtkColorScale *scale,
|
||||
GBytes *bytes;
|
||||
guchar *data, *p;
|
||||
gdouble h;
|
||||
gdouble r, g, b;
|
||||
float r, g, b;
|
||||
gdouble f;
|
||||
int hue_x, hue_y;
|
||||
|
||||
|
||||
@@ -551,7 +551,6 @@ gtk_color_swatch_init (GtkColorSwatch *swatch)
|
||||
GtkEventController *controller;
|
||||
GtkGesture *gesture;
|
||||
|
||||
priv = gtk_color_swatch_get_instance_private (swatch);
|
||||
priv->use_alpha = TRUE;
|
||||
priv->selectable = TRUE;
|
||||
priv->has_menu = TRUE;
|
||||
|
||||
+16
-16
@@ -39,12 +39,12 @@
|
||||
|
||||
/* Converts from HSV to RGB */
|
||||
static void
|
||||
hsv_to_rgb (gdouble *h,
|
||||
gdouble *s,
|
||||
gdouble *v)
|
||||
hsv_to_rgb (float *h,
|
||||
float *s,
|
||||
float *v)
|
||||
{
|
||||
gdouble hue, saturation, value;
|
||||
gdouble f, p, q, t;
|
||||
float hue, saturation, value;
|
||||
float f, p, q, t;
|
||||
|
||||
if (*s == 0.0)
|
||||
{
|
||||
@@ -112,14 +112,14 @@ hsv_to_rgb (gdouble *h,
|
||||
|
||||
/* Converts from RGB to HSV */
|
||||
static void
|
||||
rgb_to_hsv (gdouble *r,
|
||||
gdouble *g,
|
||||
gdouble *b)
|
||||
rgb_to_hsv (float *r,
|
||||
float *g,
|
||||
float *b)
|
||||
{
|
||||
gdouble red, green, blue;
|
||||
gdouble h, s, v;
|
||||
gdouble min, max;
|
||||
gdouble delta;
|
||||
float red, green, blue;
|
||||
float h, s, v;
|
||||
float min, max;
|
||||
float delta;
|
||||
|
||||
red = *r;
|
||||
green = *g;
|
||||
@@ -200,8 +200,8 @@ rgb_to_hsv (gdouble *r,
|
||||
* output values will be in the same range.
|
||||
*/
|
||||
void
|
||||
gtk_hsv_to_rgb (gdouble h, gdouble s, gdouble v,
|
||||
gdouble *r, gdouble *g, gdouble *b)
|
||||
gtk_hsv_to_rgb (float h, float s, float v,
|
||||
float *r, float *g, float *b)
|
||||
{
|
||||
g_return_if_fail (h >= 0.0 && h <= 1.0);
|
||||
g_return_if_fail (s >= 0.0 && s <= 1.0);
|
||||
@@ -234,8 +234,8 @@ gtk_hsv_to_rgb (gdouble h, gdouble s, gdouble v,
|
||||
* output values will be in the same range.
|
||||
*/
|
||||
void
|
||||
gtk_rgb_to_hsv (gdouble r, gdouble g, gdouble b,
|
||||
gdouble *h, gdouble *s, gdouble *v)
|
||||
gtk_rgb_to_hsv (float r, float g, float b,
|
||||
float *h, float *s, float *v)
|
||||
{
|
||||
g_return_if_fail (r >= 0.0 && r <= 1.0);
|
||||
g_return_if_fail (g >= 0.0 && g <= 1.0);
|
||||
|
||||
+4
-4
@@ -40,11 +40,11 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_hsv_to_rgb (gdouble h, gdouble s, gdouble v,
|
||||
gdouble *r, gdouble *g, gdouble *b);
|
||||
void gtk_hsv_to_rgb (float h, float s, float v,
|
||||
float *r, float *g, float *b);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_rgb_to_hsv (gdouble r, gdouble g, gdouble b,
|
||||
gdouble *h, gdouble *s, gdouble *v);
|
||||
void gtk_rgb_to_hsv (float r, float g, float b,
|
||||
float *h, float *s, float *v);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+72
-57
@@ -31,82 +31,82 @@
|
||||
G_DEFINE_TYPE (GtkCssImageLinear, _gtk_css_image_linear, GTK_TYPE_CSS_IMAGE)
|
||||
|
||||
static void
|
||||
gtk_css_image_linear_get_start_end (GtkCssImageLinear *linear,
|
||||
double length,
|
||||
double *start,
|
||||
double *end)
|
||||
gtk_css_image_linear_get_repeating_start_end (GtkCssImageLinear *linear,
|
||||
double length,
|
||||
double *start,
|
||||
double *end)
|
||||
{
|
||||
GtkCssImageLinearColorStop *stop;
|
||||
double pos;
|
||||
guint i;
|
||||
|
||||
if (linear->repeating)
|
||||
{
|
||||
stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, 0);
|
||||
if (stop->offset == NULL)
|
||||
*start = 0;
|
||||
else
|
||||
*start = _gtk_css_number_value_get (stop->offset, length) / length;
|
||||
|
||||
*end = *start;
|
||||
g_assert (linear->repeating);
|
||||
|
||||
for (i = 0; i < linear->stops->len; i++)
|
||||
{
|
||||
stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, i);
|
||||
|
||||
if (stop->offset == NULL)
|
||||
continue;
|
||||
|
||||
pos = _gtk_css_number_value_get (stop->offset, length) / length;
|
||||
|
||||
*end = MAX (pos, *end);
|
||||
}
|
||||
|
||||
if (stop->offset == NULL)
|
||||
*end = MAX (*end, 1.0);
|
||||
}
|
||||
stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, 0);
|
||||
if (stop->offset == NULL)
|
||||
*start = 0;
|
||||
else
|
||||
*start = _gtk_css_number_value_get (stop->offset, length) / length;
|
||||
|
||||
*end = *start;
|
||||
|
||||
for (i = 0; i < linear->stops->len; i++)
|
||||
{
|
||||
*start = 0;
|
||||
*end = 1;
|
||||
stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, i);
|
||||
|
||||
if (stop->offset == NULL)
|
||||
continue;
|
||||
|
||||
pos = _gtk_css_number_value_get (stop->offset, length) / length;
|
||||
|
||||
*end = MAX (pos, *end);
|
||||
}
|
||||
|
||||
if (stop->offset == NULL)
|
||||
*end = MAX (*end, 1.0);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_image_linear_compute_start_point (double angle_in_degrees,
|
||||
double width,
|
||||
double height,
|
||||
double *x,
|
||||
double *y)
|
||||
double *out_x,
|
||||
double *out_y,
|
||||
double *out_length)
|
||||
{
|
||||
double angle, c, slope, perpendicular;
|
||||
|
||||
double x, y, length;
|
||||
|
||||
angle = fmod (angle_in_degrees, 360);
|
||||
if (angle < 0)
|
||||
angle += 360;
|
||||
|
||||
if (angle == 0)
|
||||
{
|
||||
*x = 0;
|
||||
*y = -height;
|
||||
*out_x = 0;
|
||||
*out_y = -height;
|
||||
*out_length = height;
|
||||
return;
|
||||
}
|
||||
else if (angle == 90)
|
||||
{
|
||||
*x = width;
|
||||
*y = 0;
|
||||
*out_x = width;
|
||||
*out_y = 0;
|
||||
*out_length = width;
|
||||
return;
|
||||
}
|
||||
else if (angle == 180)
|
||||
{
|
||||
*x = 0;
|
||||
*y = height;
|
||||
*out_x = 0;
|
||||
*out_y = height;
|
||||
*out_length = height;
|
||||
return;
|
||||
}
|
||||
else if (angle == 270)
|
||||
{
|
||||
*x = -width;
|
||||
*y = 0;
|
||||
*out_x = -width;
|
||||
*out_y = 0;
|
||||
*out_length = width;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -119,14 +119,20 @@ gtk_css_image_linear_compute_start_point (double angle_in_degrees,
|
||||
width = - width;
|
||||
if (angle < 90 || angle > 270)
|
||||
height = - height;
|
||||
|
||||
|
||||
/* Compute c (of y = mx + c) of perpendicular */
|
||||
c = height - perpendicular * width;
|
||||
|
||||
*x = c / (slope - perpendicular);
|
||||
*y = perpendicular * *x + c;
|
||||
x = c / (slope - perpendicular);
|
||||
y = perpendicular * x + c;
|
||||
|
||||
length = sqrt (x * x + y * y);
|
||||
|
||||
*out_x = x;
|
||||
*out_y = y;
|
||||
*out_length = length;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_css_image_linear_snapshot (GtkCssImage *image,
|
||||
GtkSnapshot *snapshot,
|
||||
@@ -173,21 +179,30 @@ gtk_css_image_linear_snapshot (GtkCssImage *image,
|
||||
|
||||
gtk_css_image_linear_compute_start_point (angle,
|
||||
width, height,
|
||||
&x, &y);
|
||||
&x, &y,
|
||||
&length);
|
||||
|
||||
length = sqrt (x * x + y * y);
|
||||
gtk_css_image_linear_get_start_end (linear, length, &start, &end);
|
||||
|
||||
if (start == end)
|
||||
if (linear->repeating)
|
||||
{
|
||||
/* repeating gradients with all color stops sharing the same offset
|
||||
* get the color of the last color stop */
|
||||
GtkCssImageLinearColorStop *stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop, linear->stops->len - 1);
|
||||
gtk_css_image_linear_get_repeating_start_end (linear, length, &start, &end);
|
||||
|
||||
gtk_snapshot_append_color (snapshot,
|
||||
_gtk_css_rgba_value_get_rgba (stop->color),
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
return;
|
||||
if (start == end)
|
||||
{
|
||||
/* repeating gradients with all color stops sharing the same offset
|
||||
* get the color of the last color stop */
|
||||
GtkCssImageLinearColorStop *stop = &g_array_index (linear->stops, GtkCssImageLinearColorStop,
|
||||
linear->stops->len - 1);
|
||||
|
||||
gtk_snapshot_append_color (snapshot,
|
||||
_gtk_css_rgba_value_get_rgba (stop->color),
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
start = 0;
|
||||
end = 1;
|
||||
}
|
||||
|
||||
offset = start;
|
||||
|
||||
@@ -182,7 +182,8 @@ gtk_fixed_layout_child_set_transform (GtkFixedLayoutChild *child,
|
||||
|
||||
g_return_if_fail (GTK_IS_FIXED_LAYOUT_CHILD (child));
|
||||
|
||||
child->transform = gsk_transform_transform (child->transform, transform);
|
||||
gsk_transform_unref (child->transform);
|
||||
child->transform = gsk_transform_ref (transform);
|
||||
|
||||
layout = gtk_layout_child_get_layout_manager (GTK_LAYOUT_CHILD (child));
|
||||
gtk_layout_manager_layout_changed (layout);
|
||||
|
||||
+11
-4
@@ -1136,10 +1136,17 @@ gtk_image_snapshot (GtkWidget *widget,
|
||||
else
|
||||
y = CLAMP (baseline - h * gtk_image_get_baseline_align (image), 0, height - ceil (h));
|
||||
|
||||
gtk_snapshot_save (snapshot);
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
|
||||
gdk_paintable_snapshot (GDK_PAINTABLE (priv->icon_helper), snapshot, w, h);
|
||||
gtk_snapshot_restore (snapshot);
|
||||
if (x != 0 || y != 0)
|
||||
{
|
||||
gtk_snapshot_save (snapshot);
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
|
||||
gdk_paintable_snapshot (GDK_PAINTABLE (priv->icon_helper), snapshot, w, h);
|
||||
gtk_snapshot_restore (snapshot);
|
||||
}
|
||||
else
|
||||
{
|
||||
gdk_paintable_snapshot (GDK_PAINTABLE (priv->icon_helper), snapshot, w, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkbinlayout.h"
|
||||
#include "gtkgestureclick.h"
|
||||
|
||||
/**
|
||||
* SECTION:gtkinfobar
|
||||
@@ -162,6 +163,8 @@ typedef struct
|
||||
|
||||
gboolean show_close_button;
|
||||
GtkMessageType message_type;
|
||||
int default_response;
|
||||
gboolean default_response_sensitive;
|
||||
} GtkInfoBarPrivate;
|
||||
|
||||
typedef struct _ResponseData ResponseData;
|
||||
@@ -468,12 +471,26 @@ close_button_clicked_cb (GtkWidget *button,
|
||||
GTK_RESPONSE_CLOSE);
|
||||
}
|
||||
|
||||
static void
|
||||
click_released_cb (GtkGestureClick *gesture,
|
||||
guint n_press,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
GtkInfoBar *info_bar)
|
||||
{
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
|
||||
if (priv->default_response && priv->default_response_sensitive)
|
||||
gtk_info_bar_response (info_bar, priv->default_response);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_info_bar_init (GtkInfoBar *info_bar)
|
||||
{
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
GtkWidget *widget = GTK_WIDGET (info_bar);
|
||||
GtkWidget *main_box;
|
||||
GtkGesture *gesture;
|
||||
|
||||
/* message-type is a CONSTRUCT property, so we init to a value
|
||||
* different from its default to trigger its property setter
|
||||
@@ -503,6 +520,11 @@ gtk_info_bar_init (GtkInfoBar *info_bar)
|
||||
gtk_container_add (GTK_CONTAINER (main_box), priv->close_button);
|
||||
g_signal_connect (priv->close_button, "clicked",
|
||||
G_CALLBACK (close_button_clicked_cb), info_bar);
|
||||
|
||||
gesture = gtk_gesture_click_new ();
|
||||
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_PRIMARY);
|
||||
g_signal_connect (gesture, "released", G_CALLBACK (click_released_cb), widget);
|
||||
gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (gesture));
|
||||
}
|
||||
|
||||
static GtkBuildableIface *parent_buildable_iface;
|
||||
@@ -754,6 +776,22 @@ gtk_info_bar_new_with_buttons (const gchar *first_button_text,
|
||||
return GTK_WIDGET (info_bar);
|
||||
}
|
||||
|
||||
static void
|
||||
update_default_response (GtkInfoBar *info_bar,
|
||||
int response_id,
|
||||
gboolean sensitive)
|
||||
{
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
|
||||
priv->default_response = response_id;
|
||||
priv->default_response_sensitive = sensitive;
|
||||
|
||||
if (response_id && sensitive)
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (info_bar)), "action");
|
||||
else
|
||||
gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (info_bar)), "action");
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_info_bar_set_response_sensitive:
|
||||
* @info_bar: a #GtkInfoBar
|
||||
@@ -786,6 +824,9 @@ gtk_info_bar_set_response_sensitive (GtkInfoBar *info_bar,
|
||||
}
|
||||
|
||||
g_list_free (children);
|
||||
|
||||
if (response_id == priv->default_response)
|
||||
update_default_response (info_bar, response_id, setting);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -806,6 +847,7 @@ gtk_info_bar_set_default_response (GtkInfoBar *info_bar,
|
||||
{
|
||||
GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (info_bar);
|
||||
GList *children, *list;
|
||||
gboolean sensitive = TRUE;
|
||||
|
||||
g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
|
||||
|
||||
@@ -822,10 +864,13 @@ gtk_info_bar_set_default_response (GtkInfoBar *info_bar,
|
||||
|
||||
window = gtk_widget_get_ancestor (GTK_WIDGET (info_bar), GTK_TYPE_WINDOW);
|
||||
gtk_window_set_default_widget (GTK_WINDOW (window), widget);
|
||||
sensitive = gtk_widget_get_sensitive (widget);
|
||||
}
|
||||
}
|
||||
|
||||
g_list_free (children);
|
||||
|
||||
update_default_response (info_bar, response_id, sensitive);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+8
-7
@@ -6032,14 +6032,15 @@ gtk_label_update_actions (GtkLabel *label)
|
||||
GtkLabelLink *link;
|
||||
|
||||
if (priv->select_info)
|
||||
has_selection = priv->select_info->selection_anchor != priv->select_info->selection_end;
|
||||
{
|
||||
has_selection = priv->select_info->selection_anchor != priv->select_info->selection_end;
|
||||
link = priv->select_info->active_link;
|
||||
}
|
||||
else
|
||||
has_selection = FALSE;
|
||||
|
||||
if (priv->select_info->link_clicked)
|
||||
link = priv->select_info->active_link;
|
||||
else
|
||||
link = gtk_label_get_focus_link (label);
|
||||
{
|
||||
has_selection = FALSE;
|
||||
link = gtk_label_get_focus_link (label);
|
||||
}
|
||||
|
||||
gtk_widget_action_set_enabled (widget, "clipboard.copy", has_selection);
|
||||
gtk_widget_action_set_enabled (widget, "selection.select-all",
|
||||
|
||||
+1
-12
@@ -446,17 +446,6 @@ allocate_trough (GtkGizmo *gizmo,
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
snapshot_trough (GtkGizmo *gizmo,
|
||||
GtkSnapshot *snapshot)
|
||||
|
||||
{
|
||||
GtkProgressBar *pbar = GTK_PROGRESS_BAR (gtk_widget_get_parent (GTK_WIDGET (gizmo)));
|
||||
GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar);
|
||||
|
||||
gtk_widget_snapshot_child (GTK_WIDGET (gizmo), priv->progress_widget, snapshot);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_progress_bar_init (GtkProgressBar *pbar)
|
||||
{
|
||||
@@ -476,7 +465,7 @@ gtk_progress_bar_init (GtkProgressBar *pbar)
|
||||
priv->trough_widget = gtk_gizmo_new ("trough",
|
||||
NULL,
|
||||
allocate_trough,
|
||||
snapshot_trough,
|
||||
NULL,
|
||||
NULL);
|
||||
gtk_widget_set_parent (priv->trough_widget, GTK_WIDGET (pbar));
|
||||
|
||||
|
||||
+18
-21
@@ -92,6 +92,7 @@ gtk_theming_background_snapshot_layer (GtkCssBoxes *bg,
|
||||
const GskRoundedRect *origin, *clip;
|
||||
double image_width, image_height;
|
||||
double width, height;
|
||||
double x, y;
|
||||
|
||||
image = _gtk_css_image_value_get_image (
|
||||
_gtk_css_array_value_get_nth (
|
||||
@@ -144,27 +145,26 @@ gtk_theming_background_snapshot_layer (GtkCssBoxes *bg,
|
||||
gtk_snapshot_push_debug (snapshot, "Layer %u", idx);
|
||||
gtk_snapshot_push_rounded_clip (snapshot, clip);
|
||||
|
||||
gtk_snapshot_translate (snapshot, &origin->bounds.origin);
|
||||
|
||||
x = _gtk_css_position_value_get_x (pos, width - image_width) + origin->bounds.origin.x;
|
||||
y = _gtk_css_position_value_get_y (pos, height - image_height) + origin->bounds.origin.y;
|
||||
if (hrepeat == GTK_CSS_REPEAT_STYLE_NO_REPEAT && vrepeat == GTK_CSS_REPEAT_STYLE_NO_REPEAT)
|
||||
{
|
||||
/* shortcut for normal case */
|
||||
double x, y;
|
||||
|
||||
x = _gtk_css_position_value_get_x (pos, width - image_width);
|
||||
y = _gtk_css_position_value_get_y (pos, height - image_height);
|
||||
|
||||
gtk_snapshot_save (snapshot);
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
|
||||
|
||||
gtk_css_image_snapshot (image, snapshot, image_width, image_height);
|
||||
|
||||
gtk_snapshot_restore (snapshot);
|
||||
if (x != 0 || y != 0)
|
||||
{
|
||||
gtk_snapshot_save (snapshot);
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
|
||||
gtk_css_image_snapshot (image, snapshot, image_width, image_height);
|
||||
gtk_snapshot_restore (snapshot);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_css_image_snapshot (image, snapshot, image_width, image_height);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float repeat_width, repeat_height;
|
||||
float position_x, position_y;
|
||||
graphene_rect_t fill_rect;
|
||||
|
||||
/* If ‘background-repeat’ is ‘round’ for one (or both) dimensions,
|
||||
@@ -246,19 +246,16 @@ gtk_theming_background_snapshot_layer (GtkCssBoxes *bg,
|
||||
fill_rect.size.height = height;
|
||||
}
|
||||
|
||||
position_x = _gtk_css_position_value_get_x (pos, width - image_width);
|
||||
position_y = _gtk_css_position_value_get_y (pos, height - image_height);
|
||||
|
||||
gtk_snapshot_push_repeat (snapshot,
|
||||
&fill_rect,
|
||||
&GRAPHENE_RECT_INIT (
|
||||
position_x, position_y,
|
||||
x, y,
|
||||
repeat_width, repeat_height
|
||||
));
|
||||
|
||||
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (
|
||||
position_x + 0.5 * (repeat_width - image_width),
|
||||
position_y + 0.5 * (repeat_height - image_height)));
|
||||
x + 0.5 * (repeat_width - image_width),
|
||||
y + 0.5 * (repeat_height - image_height)));
|
||||
gtk_css_image_snapshot (image, snapshot, image_width, image_height);
|
||||
|
||||
gtk_snapshot_pop (snapshot);
|
||||
|
||||
+10
-5
@@ -654,16 +654,16 @@ gtk_css_style_snapshot_border (GtkCssBoxes *boxes,
|
||||
GtkBorderImage border_image;
|
||||
float border_width[4];
|
||||
|
||||
border_width[0] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
|
||||
border_width[1] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
|
||||
border_width[2] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
|
||||
border_width[3] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
|
||||
|
||||
if (gtk_border_image_init (&border_image, boxes->style))
|
||||
{
|
||||
cairo_t *cr;
|
||||
const graphene_rect_t *bounds;
|
||||
|
||||
border_width[0] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
|
||||
border_width[1] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
|
||||
border_width[2] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
|
||||
border_width[3] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
|
||||
|
||||
bounds = gtk_css_boxes_get_border_rect (boxes);
|
||||
|
||||
gtk_snapshot_push_debug (snapshot, "CSS border image");
|
||||
@@ -697,6 +697,11 @@ gtk_css_style_snapshot_border (GtkCssBoxes *boxes,
|
||||
border_style[2] = _gtk_css_border_style_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE));
|
||||
border_style[3] = _gtk_css_border_style_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_LEFT_STYLE));
|
||||
|
||||
border_width[0] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
|
||||
border_width[1] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
|
||||
border_width[2] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
|
||||
border_width[3] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
|
||||
|
||||
gtk_snapshot_push_debug (snapshot, "CSS border");
|
||||
snapshot_border (snapshot,
|
||||
gtk_css_boxes_get_border_box (boxes),
|
||||
|
||||
@@ -76,7 +76,7 @@ gtk_render_node_paintable_paintable_get_intrinsic_width (GdkPaintable *paintable
|
||||
{
|
||||
GtkRenderNodePaintable *self = GTK_RENDER_NODE_PAINTABLE (paintable);
|
||||
|
||||
return self->bounds.size.width;
|
||||
return ceilf (self->bounds.size.width);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -84,7 +84,7 @@ gtk_render_node_paintable_paintable_get_intrinsic_height (GdkPaintable *paintabl
|
||||
{
|
||||
GtkRenderNodePaintable *self = GTK_RENDER_NODE_PAINTABLE (paintable);
|
||||
|
||||
return self->bounds.size.height;
|
||||
return ceilf (self->bounds.size.height);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+32
-17
@@ -1660,12 +1660,11 @@ gtk_scrolled_window_measure (GtkWidget *widget,
|
||||
{
|
||||
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
|
||||
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
|
||||
GtkBin *bin = GTK_BIN (scrolled_window);
|
||||
int minimum_req = 0, natural_req = 0;
|
||||
GtkWidget *child;
|
||||
GtkBorder sborder = { 0 };
|
||||
|
||||
child = gtk_bin_get_child (bin);
|
||||
child = gtk_bin_get_child (GTK_BIN (scrolled_window));
|
||||
|
||||
if (child)
|
||||
gtk_scrollable_get_border (GTK_SCROLLABLE (child), &sborder);
|
||||
@@ -1728,35 +1727,50 @@ gtk_scrolled_window_measure (GtkWidget *widget,
|
||||
*/
|
||||
if (policy_may_be_visible (priv->hscrollbar_policy))
|
||||
{
|
||||
GtkRequisition hscrollbar_requisition;
|
||||
gtk_widget_get_preferred_size (priv->hscrollbar, &hscrollbar_requisition, NULL);
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
minimum_req = MAX (minimum_req, hscrollbar_requisition.width + sborder.left + sborder.right);
|
||||
natural_req = MAX (natural_req, hscrollbar_requisition.width + sborder.left + sborder.right);
|
||||
int min_scrollbar_width, nat_scrollbar_width;
|
||||
|
||||
gtk_widget_measure (priv->hscrollbar, GTK_ORIENTATION_HORIZONTAL, -1,
|
||||
&min_scrollbar_width, &nat_scrollbar_width,
|
||||
NULL, NULL);
|
||||
minimum_req = MAX (minimum_req, min_scrollbar_width + sborder.left + sborder.right);
|
||||
natural_req = MAX (natural_req, nat_scrollbar_width + sborder.left + sborder.right);
|
||||
}
|
||||
else if (!priv->use_indicators && priv->hscrollbar_policy == GTK_POLICY_ALWAYS)
|
||||
{
|
||||
minimum_req += hscrollbar_requisition.height;
|
||||
natural_req += hscrollbar_requisition.height;
|
||||
int min_scrollbar_height, nat_scrollbar_height;
|
||||
|
||||
gtk_widget_measure (priv->hscrollbar, GTK_ORIENTATION_VERTICAL, -1,
|
||||
&min_scrollbar_height, &nat_scrollbar_height,
|
||||
NULL, NULL);
|
||||
|
||||
minimum_req += min_scrollbar_height;
|
||||
natural_req += nat_scrollbar_height;
|
||||
}
|
||||
}
|
||||
|
||||
if (policy_may_be_visible (priv->vscrollbar_policy))
|
||||
{
|
||||
GtkRequisition vscrollbar_requisition;
|
||||
gtk_widget_get_preferred_size (priv->vscrollbar, &vscrollbar_requisition, NULL);
|
||||
|
||||
if (orientation == GTK_ORIENTATION_VERTICAL)
|
||||
{
|
||||
minimum_req = MAX (minimum_req, vscrollbar_requisition.height + sborder.top + sborder.bottom);
|
||||
natural_req = MAX (natural_req, vscrollbar_requisition.height + sborder.top + sborder.bottom);
|
||||
int min_scrollbar_height, nat_scrollbar_height;
|
||||
|
||||
gtk_widget_measure (priv->vscrollbar, GTK_ORIENTATION_VERTICAL, -1,
|
||||
&min_scrollbar_height, &nat_scrollbar_height,
|
||||
NULL, NULL);
|
||||
minimum_req = MAX (minimum_req, min_scrollbar_height + sborder.top + sborder.bottom);
|
||||
natural_req = MAX (natural_req, nat_scrollbar_height + sborder.top + sborder.bottom);
|
||||
}
|
||||
else if (!priv->use_indicators && priv->vscrollbar_policy == GTK_POLICY_ALWAYS)
|
||||
{
|
||||
minimum_req += vscrollbar_requisition.width;
|
||||
natural_req += vscrollbar_requisition.width;
|
||||
int min_scrollbar_width, nat_scrollbar_width;
|
||||
|
||||
gtk_widget_measure (priv->vscrollbar, GTK_ORIENTATION_HORIZONTAL, -1,
|
||||
&min_scrollbar_width, &nat_scrollbar_width,
|
||||
NULL, NULL);
|
||||
minimum_req += min_scrollbar_width;
|
||||
natural_req += nat_scrollbar_width;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2787,7 +2801,8 @@ gtk_scrolled_window_snapshot (GtkWidget *widget,
|
||||
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
|
||||
|
||||
if (priv->hscrollbar_visible &&
|
||||
priv->vscrollbar_visible)
|
||||
priv->vscrollbar_visible &&
|
||||
!priv->use_indicators)
|
||||
gtk_scrolled_window_snapshot_scrollbars_junction (scrolled_window, snapshot);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_scrolled_window_parent_class)->snapshot (widget, snapshot);
|
||||
|
||||
+45
-76
@@ -580,80 +580,6 @@ gtk_widget_get_request_mode (GtkWidget *widget)
|
||||
return cache->request_mode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _gtk_widget_get_preferred_size_and_baseline:
|
||||
* @widget: a #GtkWidget instance
|
||||
* @minimum_size: (out) (allow-none): location for storing the minimum size, or %NULL
|
||||
* @natural_size: (out) (allow-none): location for storing the natural size, or %NULL
|
||||
*
|
||||
* Retrieves the minimum and natural size and the corresponding baselines of a widget, taking
|
||||
* into account the widget’s preference for height-for-width management. The baselines may
|
||||
* be -1 which means that no baseline is requested for this widget.
|
||||
*
|
||||
* This is used to retrieve a suitable size by container widgets which do
|
||||
* not impose any restrictions on the child placement. It can be used
|
||||
* to deduce toplevel window and menu sizes as well as child widgets in
|
||||
* free-form containers such as GtkLayout.
|
||||
*
|
||||
* Handle with care. Note that the natural height of a height-for-width
|
||||
* widget will generally be a smaller size than the minimum height, since the required
|
||||
* height for the natural width is generally smaller than the required height for
|
||||
* the minimum width.
|
||||
*/
|
||||
void
|
||||
_gtk_widget_get_preferred_size_and_baseline (GtkWidget *widget,
|
||||
GtkRequisition *minimum_size,
|
||||
GtkRequisition *natural_size,
|
||||
gint *minimum_baseline,
|
||||
gint *natural_baseline)
|
||||
{
|
||||
gint min_width, nat_width;
|
||||
gint min_height, nat_height;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
|
||||
{
|
||||
gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, -1,
|
||||
&min_width, &nat_width, NULL, NULL);
|
||||
|
||||
if (minimum_size)
|
||||
{
|
||||
minimum_size->width = min_width;
|
||||
gtk_widget_measure (widget,
|
||||
GTK_ORIENTATION_VERTICAL, min_width,
|
||||
&minimum_size->height, NULL, minimum_baseline, NULL);
|
||||
}
|
||||
|
||||
if (natural_size)
|
||||
{
|
||||
natural_size->width = nat_width;
|
||||
gtk_widget_measure (widget,
|
||||
GTK_ORIENTATION_VERTICAL, nat_width,
|
||||
NULL, &natural_size->height, NULL, natural_baseline);
|
||||
}
|
||||
}
|
||||
else /* GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT or CONSTANT_SIZE */
|
||||
{
|
||||
gtk_widget_measure (widget, GTK_ORIENTATION_VERTICAL,
|
||||
-1, &min_height, &nat_height, minimum_baseline, natural_baseline);
|
||||
|
||||
if (minimum_size)
|
||||
{
|
||||
minimum_size->height = min_height;
|
||||
gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, min_height,
|
||||
&minimum_size->width, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
if (natural_size)
|
||||
{
|
||||
natural_size->height = nat_height;
|
||||
gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, nat_height,
|
||||
NULL, &natural_size->width, NULL, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_get_preferred_size:
|
||||
* @widget: a #GtkWidget instance
|
||||
@@ -681,8 +607,51 @@ gtk_widget_get_preferred_size (GtkWidget *widget,
|
||||
GtkRequisition *minimum_size,
|
||||
GtkRequisition *natural_size)
|
||||
{
|
||||
_gtk_widget_get_preferred_size_and_baseline (widget, minimum_size, natural_size,
|
||||
NULL, NULL);
|
||||
int min_width, nat_width;
|
||||
int min_height, nat_height;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
|
||||
{
|
||||
gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, -1,
|
||||
&min_width, &nat_width, NULL, NULL);
|
||||
|
||||
if (minimum_size)
|
||||
{
|
||||
minimum_size->width = min_width;
|
||||
gtk_widget_measure (widget,
|
||||
GTK_ORIENTATION_VERTICAL, min_width,
|
||||
&minimum_size->height, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
if (natural_size)
|
||||
{
|
||||
natural_size->width = nat_width;
|
||||
gtk_widget_measure (widget,
|
||||
GTK_ORIENTATION_VERTICAL, nat_width,
|
||||
NULL, &natural_size->height, NULL, NULL);
|
||||
}
|
||||
}
|
||||
else /* GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT or CONSTANT_SIZE */
|
||||
{
|
||||
gtk_widget_measure (widget, GTK_ORIENTATION_VERTICAL,
|
||||
-1, &min_height, &nat_height, NULL, NULL);
|
||||
|
||||
if (minimum_size)
|
||||
{
|
||||
minimum_size->height = min_height;
|
||||
gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, min_height,
|
||||
&minimum_size->width, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
if (natural_size)
|
||||
{
|
||||
natural_size->height = nat_height;
|
||||
gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, nat_height,
|
||||
NULL, &natural_size->width, NULL, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
|
||||
+17
-4
@@ -547,13 +547,25 @@ gtk_snapshot_collect_repeat (GtkSnapshot *snapshot,
|
||||
guint n_nodes)
|
||||
{
|
||||
GskRenderNode *node, *repeat_node;
|
||||
graphene_rect_t *bounds = &state->data.repeat.bounds;
|
||||
graphene_rect_t *child_bounds = &state->data.repeat.child_bounds;
|
||||
const graphene_rect_t *bounds = &state->data.repeat.bounds;
|
||||
const graphene_rect_t *child_bounds = &state->data.repeat.child_bounds;
|
||||
|
||||
node = gtk_snapshot_collect_default (snapshot, state, nodes, n_nodes);
|
||||
if (node == NULL)
|
||||
return NULL;
|
||||
|
||||
if (gsk_render_node_get_node_type (node) == GSK_COLOR_NODE &&
|
||||
graphene_rect_equal (child_bounds, &node->bounds))
|
||||
{
|
||||
/* Repeating a color node entirely is pretty easy by just increasing
|
||||
* the size of the color node. */
|
||||
GskRenderNode *color_node = gsk_color_node_new (gsk_color_node_peek_color (node), bounds);
|
||||
|
||||
gsk_render_node_unref (node);
|
||||
|
||||
return color_node;
|
||||
}
|
||||
|
||||
repeat_node = gsk_repeat_node_new (bounds,
|
||||
node,
|
||||
child_bounds->size.width > 0 ? child_bounds : NULL);
|
||||
@@ -575,8 +587,9 @@ gtk_graphene_rect_scale_affine (const graphene_rect_t *rect,
|
||||
res->origin.y = scale_y * rect->origin.y + dy;
|
||||
res->size.width = scale_x * rect->size.width;
|
||||
res->size.height = scale_y * rect->size.height;
|
||||
/* necessary when scale_x or scale_y are < 0 */
|
||||
graphene_rect_normalize (res);
|
||||
|
||||
if (scale_x < 0 || scale_y < 0)
|
||||
graphene_rect_normalize (res);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -2062,6 +2062,8 @@ gtk_text_unmap (GtkWidget *widget)
|
||||
_gtk_text_handle_set_mode (priv->text_handle,
|
||||
GTK_TEXT_HANDLE_MODE_NONE);
|
||||
|
||||
priv->cursor_alpha = 1.0;
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_text_parent_class)->unmap (widget);
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -75,9 +75,6 @@ enum {
|
||||
|
||||
struct _GtkToolItemPrivate
|
||||
{
|
||||
gchar *tip_text;
|
||||
gchar *tip_private;
|
||||
|
||||
guint visible_horizontal : 1;
|
||||
guint visible_vertical : 1;
|
||||
guint homogeneous : 1;
|
||||
@@ -214,6 +211,10 @@ gtk_tool_item_init (GtkToolItem *toolitem)
|
||||
static void
|
||||
gtk_tool_item_finalize (GObject *object)
|
||||
{
|
||||
GtkToolItemPrivate *priv = gtk_tool_item_get_instance_private (GTK_TOOL_ITEM (object));
|
||||
|
||||
g_clear_pointer (&priv->overflow_text, g_free);
|
||||
|
||||
G_OBJECT_CLASS (gtk_tool_item_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
+14
-7
@@ -511,7 +511,6 @@ enum {
|
||||
UNREALIZE,
|
||||
SIZE_ALLOCATE,
|
||||
STATE_FLAGS_CHANGED,
|
||||
HIERARCHY_CHANGED,
|
||||
DIRECTION_CHANGED,
|
||||
GRAB_NOTIFY,
|
||||
CHILD_NOTIFY,
|
||||
@@ -12671,8 +12670,9 @@ gtk_widget_create_render_node (GtkWidget *widget,
|
||||
"RenderNode for %s %p",
|
||||
G_OBJECT_TYPE_NAME (widget), widget);
|
||||
|
||||
filter_value = _gtk_style_context_peek_property (_gtk_widget_get_style_context (widget), GTK_CSS_PROPERTY_FILTER);
|
||||
gtk_css_filter_value_push_snapshot (filter_value, snapshot);
|
||||
filter_value = gtk_css_style_get_value (gtk_css_node_get_style (priv->cssnode), GTK_CSS_PROPERTY_FILTER);
|
||||
if (filter_value)
|
||||
gtk_css_filter_value_push_snapshot (filter_value, snapshot);
|
||||
|
||||
if (opacity < 1.0)
|
||||
gtk_snapshot_push_opacity (snapshot, opacity);
|
||||
@@ -13086,12 +13086,19 @@ gtk_widget_snapshot_child (GtkWidget *widget,
|
||||
if (GTK_IS_NATIVE (child))
|
||||
return;
|
||||
|
||||
gtk_snapshot_save (snapshot);
|
||||
gtk_snapshot_transform (snapshot, priv->transform);
|
||||
if (priv->transform)
|
||||
{
|
||||
gtk_snapshot_save (snapshot);
|
||||
gtk_snapshot_transform (snapshot, priv->transform);
|
||||
|
||||
gtk_widget_snapshot (child, snapshot);
|
||||
gtk_widget_snapshot (child, snapshot);
|
||||
|
||||
gtk_snapshot_restore (snapshot);
|
||||
gtk_snapshot_restore (snapshot);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_snapshot (child, snapshot);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -236,12 +236,6 @@ void _gtk_widget_add_attached_window (GtkWidget *widget,
|
||||
void _gtk_widget_remove_attached_window (GtkWidget *widget,
|
||||
GtkWindow *window);
|
||||
|
||||
void _gtk_widget_get_preferred_size_and_baseline(GtkWidget *widget,
|
||||
GtkRequisition *minimum_size,
|
||||
GtkRequisition *natural_size,
|
||||
gint *minimum_baseline,
|
||||
gint *natural_baseline);
|
||||
|
||||
const gchar* _gtk_widget_get_accel_path (GtkWidget *widget,
|
||||
gboolean *locked);
|
||||
|
||||
|
||||
+16
-15
@@ -1570,21 +1570,22 @@ device_removed_cb (GdkSeat *seat,
|
||||
{
|
||||
GtkWindow *window = user_data;
|
||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
||||
GList *l = priv->foci, *cur;
|
||||
GList *l = priv->foci;
|
||||
|
||||
while (l)
|
||||
{
|
||||
GList *next;
|
||||
GtkPointerFocus *focus = l->data;
|
||||
|
||||
cur = l;
|
||||
focus = cur->data;
|
||||
l = cur->next;
|
||||
next = l->next;
|
||||
|
||||
if (focus->device == device)
|
||||
{
|
||||
priv->foci = g_list_delete_link (priv->foci, cur);
|
||||
priv->foci = g_list_delete_link (priv->foci, l);
|
||||
gtk_pointer_focus_unref (focus);
|
||||
}
|
||||
|
||||
l = next;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9294,15 +9295,15 @@ gtk_window_update_pointer_focus_on_state_change (GtkWindow *window,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
||||
GList *l = priv->foci, *cur;
|
||||
GList *l = priv->foci;
|
||||
|
||||
while (l)
|
||||
{
|
||||
GList *next;
|
||||
|
||||
GtkPointerFocus *focus = l->data;
|
||||
|
||||
cur = l;
|
||||
focus = cur->data;
|
||||
l = cur->next;
|
||||
next = l->next;
|
||||
|
||||
gtk_pointer_focus_ref (focus);
|
||||
|
||||
@@ -9314,9 +9315,9 @@ gtk_window_update_pointer_focus_on_state_change (GtkWindow *window,
|
||||
if (GTK_WIDGET (focus->toplevel) == widget)
|
||||
{
|
||||
/* Unmapping the toplevel, remove pointer focus */
|
||||
priv->foci = g_list_remove_link (priv->foci, cur);
|
||||
priv->foci = g_list_remove_link (priv->foci, l);
|
||||
gtk_pointer_focus_unref (focus);
|
||||
g_list_free (cur);
|
||||
g_list_free (l);
|
||||
}
|
||||
else if (focus->target == widget ||
|
||||
gtk_widget_is_ancestor (focus->target, widget))
|
||||
@@ -9325,6 +9326,8 @@ gtk_window_update_pointer_focus_on_state_change (GtkWindow *window,
|
||||
}
|
||||
|
||||
gtk_pointer_focus_unref (focus);
|
||||
|
||||
l = next;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9334,15 +9337,13 @@ gtk_window_maybe_revoke_implicit_grab (GtkWindow *window,
|
||||
GtkWidget *grab_widget)
|
||||
{
|
||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
||||
GList *l = priv->foci, *cur;
|
||||
GList *l = priv->foci;
|
||||
|
||||
while (l)
|
||||
{
|
||||
GtkPointerFocus *focus = l->data;
|
||||
|
||||
cur = l;
|
||||
focus = cur->data;
|
||||
l = cur->next;
|
||||
l = l->next;
|
||||
|
||||
if (focus->toplevel != window)
|
||||
continue;
|
||||
|
||||
@@ -3760,17 +3760,30 @@ scrolledwindow {
|
||||
|
||||
|
||||
junction { // the small square between two scrollbars
|
||||
border-color: transparent;
|
||||
// the border image is used to add the missing dot between the borders, details, details, details...
|
||||
border-image: linear-gradient(to bottom, $borders_color 1px, transparent 1px) 0 0 0 1 / 0 1px stretch;
|
||||
background-color: $scrollbar_bg_color;
|
||||
// Only color the top-left (or top right in RTL) pixel, to visually connect
|
||||
// the borders of the two scrollbars.
|
||||
|
||||
&:dir(rtl) { border-image-slice: 0 1 0 0; }
|
||||
background: $borders_color,
|
||||
linear-gradient(to bottom, transparent 1px, $scrollbar_bg_color 1px),
|
||||
linear-gradient(to right, transparent 1px, $scrollbar_bg_color 1px);
|
||||
|
||||
&:dir(rtl) {
|
||||
background: $borders_color,
|
||||
linear-gradient(to bottom, transparent 1px, $scrollbar_bg_color 1px),
|
||||
linear-gradient(to left, transparent 1px, $scrollbar_bg_color 1px);
|
||||
}
|
||||
|
||||
&:backdrop {
|
||||
border-image-source: linear-gradient(to bottom, $backdrop_borders_color 1px, transparent 1px);
|
||||
background-color: $backdrop_scrollbar_bg_color;
|
||||
transition: $backdrop_transition;
|
||||
background: $backdrop_borders_color,
|
||||
linear-gradient(to bottom, transparent 1px, $backdrop_scrollbar_bg_color 1px),
|
||||
linear-gradient(to right, transparent 1px, $backdrop_scrollbar_bg_color 1px);
|
||||
|
||||
&:dir(rtl) {
|
||||
background: $backdrop_borders_color,
|
||||
linear-gradient(to bottom, transparent 1px, $backdrop_scrollbar_bg_color 1px),
|
||||
linear-gradient(to left, transparent 1px, $backdrop_scrollbar_bg_color 1px);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4257,6 +4270,11 @@ video {
|
||||
infobar {
|
||||
border-style: none;
|
||||
|
||||
&.action:hover {
|
||||
background-color: if($variant == 'light', desaturate(lighten(invert($selected_bg_color), 47%), 30%),
|
||||
desaturate(darken(invert($selected_bg_color), 42%), 70%));
|
||||
border-color: lighten($borders_color, 10%);
|
||||
}
|
||||
&.info,
|
||||
&.question,
|
||||
&.warning,
|
||||
@@ -4271,7 +4289,6 @@ infobar {
|
||||
text-shadow: none;
|
||||
|
||||
&:backdrop { text-shadow: none; }
|
||||
|
||||
> revealer > box {
|
||||
padding-top: 8px; padding-bottom: 8px;
|
||||
border-bottom: 1px solid lighten($borders_color, 5%);
|
||||
|
||||
@@ -41,6 +41,8 @@ image.drag-icon { -gtk-icon-size: 32px; }
|
||||
|
||||
textview { outline: none; }
|
||||
|
||||
textview:drop(active) { caret-color: #4e9a06; }
|
||||
|
||||
textview border { background-color: #313131; }
|
||||
|
||||
.rubberband, rubberband, flowbox rubberband, treeview.view rubberband, .content-view rubberband, .content-view .rubberband { border: 1px solid #0f3b71; background-color: rgba(15, 59, 113, 0.2); }
|
||||
@@ -1541,11 +1543,13 @@ scrolledwindow overshoot.right { background-image: radial-gradient(farthest-side
|
||||
|
||||
scrolledwindow overshoot.right:backdrop { background-image: radial-gradient(farthest-side at right, #202020 85%, rgba(32, 32, 32, 0)); background-size: 3% 100%; background-repeat: no-repeat; background-position: right; background-color: transparent; border: none; box-shadow: none; }
|
||||
|
||||
scrolledwindow junction { border-color: transparent; border-image: linear-gradient(to bottom, #1b1b1b 1px, transparent 1px) 0 0 0 1/0 1px stretch; background-color: #313131; }
|
||||
scrolledwindow junction { background: #1b1b1b, linear-gradient(to bottom, transparent 1px, #313131 1px), linear-gradient(to right, transparent 1px, #313131 1px); }
|
||||
|
||||
scrolledwindow junction:dir(rtl) { border-image-slice: 0 1 0 0; }
|
||||
scrolledwindow junction:dir(rtl) { background: #1b1b1b, linear-gradient(to bottom, transparent 1px, #313131 1px), linear-gradient(to left, transparent 1px, #313131 1px); }
|
||||
|
||||
scrolledwindow junction:backdrop { border-image-source: linear-gradient(to bottom, #202020 1px, transparent 1px); background-color: #2d2d2d; transition: 200ms ease-out; }
|
||||
scrolledwindow junction:backdrop { transition: 200ms ease-out; background: #202020, linear-gradient(to bottom, transparent 1px, #2d2d2d 1px), linear-gradient(to right, transparent 1px, #2d2d2d 1px); }
|
||||
|
||||
scrolledwindow junction:backdrop:dir(rtl) { background: #202020, linear-gradient(to bottom, transparent 1px, #2d2d2d 1px), linear-gradient(to left, transparent 1px, #2d2d2d 1px); }
|
||||
|
||||
separator { background: #282828; min-width: 1px; min-height: 1px; }
|
||||
|
||||
@@ -1755,6 +1759,8 @@ video image.osd { min-width: 64px; min-height: 64px; border-radius: 32px; }
|
||||
/************** GtkInfoBar * */
|
||||
infobar { border-style: none; }
|
||||
|
||||
infobar.action:hover { background-color: #3e3b37; border-color: #353535; }
|
||||
|
||||
infobar.info, infobar.question, infobar.warning, infobar.error { text-shadow: none; }
|
||||
|
||||
infobar.info:backdrop, infobar.info, infobar.question:backdrop, infobar.question, infobar.warning:backdrop, infobar.warning, infobar.error:backdrop, infobar.error { background-color: #44403b; border-color: #353535; }
|
||||
|
||||
@@ -41,6 +41,8 @@ image.drag-icon { -gtk-icon-size: 32px; }
|
||||
|
||||
textview { outline: none; }
|
||||
|
||||
textview:drop(active) { caret-color: #4e9a06; }
|
||||
|
||||
textview border { background-color: #fbfafa; }
|
||||
|
||||
.rubberband, rubberband, flowbox rubberband, treeview.view rubberband, .content-view rubberband, .content-view .rubberband { border: 1px solid #1b6acb; background-color: rgba(27, 106, 203, 0.2); }
|
||||
@@ -1557,11 +1559,13 @@ scrolledwindow overshoot.right { background-image: radial-gradient(farthest-side
|
||||
|
||||
scrolledwindow overshoot.right:backdrop { background-image: radial-gradient(farthest-side at right, #d5d0cc 85%, rgba(213, 208, 204, 0)); background-size: 3% 100%; background-repeat: no-repeat; background-position: right; background-color: transparent; border: none; box-shadow: none; }
|
||||
|
||||
scrolledwindow junction { border-color: transparent; border-image: linear-gradient(to bottom, #cdc7c2 1px, transparent 1px) 0 0 0 1/0 1px stretch; background-color: #cecece; }
|
||||
scrolledwindow junction { background: #cdc7c2, linear-gradient(to bottom, transparent 1px, #cecece 1px), linear-gradient(to right, transparent 1px, #cecece 1px); }
|
||||
|
||||
scrolledwindow junction:dir(rtl) { border-image-slice: 0 1 0 0; }
|
||||
scrolledwindow junction:dir(rtl) { background: #cdc7c2, linear-gradient(to bottom, transparent 1px, #cecece 1px), linear-gradient(to left, transparent 1px, #cecece 1px); }
|
||||
|
||||
scrolledwindow junction:backdrop { border-image-source: linear-gradient(to bottom, #d5d0cc 1px, transparent 1px); background-color: #efedec; transition: 200ms ease-out; }
|
||||
scrolledwindow junction:backdrop { transition: 200ms ease-out; background: #d5d0cc, linear-gradient(to bottom, transparent 1px, #efedec 1px), linear-gradient(to right, transparent 1px, #efedec 1px); }
|
||||
|
||||
scrolledwindow junction:backdrop:dir(rtl) { background: #d5d0cc, linear-gradient(to bottom, transparent 1px, #efedec 1px), linear-gradient(to left, transparent 1px, #efedec 1px); }
|
||||
|
||||
separator { background: #d8d4d0; min-width: 1px; min-height: 1px; }
|
||||
|
||||
@@ -1771,6 +1775,8 @@ video image.osd { min-width: 64px; min-height: 64px; border-radius: 32px; }
|
||||
/************** GtkInfoBar * */
|
||||
infobar { border-style: none; }
|
||||
|
||||
infobar.action:hover { background-color: #f4ebe1; border-color: #e4e1de; }
|
||||
|
||||
infobar.info, infobar.question, infobar.warning, infobar.error { text-shadow: none; }
|
||||
|
||||
infobar.info:backdrop, infobar.info, infobar.question:backdrop, infobar.question, infobar.warning:backdrop, infobar.warning, infobar.error:backdrop, infobar.error { background-color: #f1e6d9; border-color: #e4e1de; }
|
||||
|
||||
@@ -198,6 +198,7 @@ check_functions = [
|
||||
'log2',
|
||||
'exp2',
|
||||
'sincos',
|
||||
'sincosf',
|
||||
]
|
||||
|
||||
foreach func : check_functions
|
||||
|
||||
+2589
-2105
File diff suppressed because it is too large
Load Diff
+512
-661
File diff suppressed because it is too large
Load Diff
@@ -159,8 +159,9 @@ main (int argc, char **argv)
|
||||
g_themed_icon_append_name (G_THEMED_ICON (icon), "folder-symbolic");
|
||||
|
||||
gtk_entry_set_icon_from_gicon (GTK_ENTRY (entry),
|
||||
GTK_ENTRY_ICON_PRIMARY,
|
||||
icon);
|
||||
GTK_ENTRY_ICON_PRIMARY,
|
||||
icon);
|
||||
g_object_unref (icon);
|
||||
gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
|
||||
GTK_ENTRY_ICON_PRIMARY,
|
||||
FALSE);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
blend {
|
||||
top: color {
|
||||
bounds: 0 0 50 50;
|
||||
color: red;
|
||||
}
|
||||
bottom: color {
|
||||
bounds: 25 25 0 10;
|
||||
color: blue;
|
||||
}
|
||||
mode: multiply;
|
||||
}
|
||||
|
||||
|
||||
blend {
|
||||
top: color {
|
||||
bounds: 25 85 0 10;
|
||||
color: blue;
|
||||
}
|
||||
bottom: color {
|
||||
bounds: 0 60 50 50;
|
||||
color: red;
|
||||
}
|
||||
|
||||
mode: multiply;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 221 B |
@@ -0,0 +1,13 @@
|
||||
transform {
|
||||
child: container {
|
||||
border {
|
||||
outline: 5 5 100 100;
|
||||
}
|
||||
color {
|
||||
color: rgba(0, 0, 0, 0);
|
||||
bounds: 0 0 110 110;
|
||||
}
|
||||
}
|
||||
|
||||
transform: translate(110, 0) rotate(90);
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 356 B |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user