Compare commits

...

12 Commits

Author SHA1 Message Date
Matthias Clasen e74e7766d1 Implement dashed and dotted underlines
This is implementing new support in Pango for
rendering dashed and dotted lines. This is currently
using a linear gradient for dashes and a repeat node
for dots.
2021-03-31 18:57:03 -04:00
Matthias Clasen 3973a14c07 cellrenderertext: Quiet compiler warnings
Handle new values of the PangoUnderline enumeration.
2021-03-31 18:57:03 -04:00
Matthias Clasen 68ab1576ce atspipango: Quiet compiler warnings
Handle new values of the PangoUnderline enum.
2021-03-31 18:57:03 -04:00
Matthias Clasen 8713aa911b Add missing overline color support
This was overlooked when overlines were added.

Without this, overlines will come out in the the
wrong color.
2021-03-31 17:51:16 -04:00
Matthias Clasen b5df1299ec gsk: Add another test
Compare clipped repeat nodes. Must skip cairo here
since it blurred the child by scaling after rendering.

Also skip the gl renderer, since it hasn't been fixed
for this yet. ngl passes this test.
2021-03-31 16:49:31 -04:00
Matthias Clasen 6f62107656 testsuite: Rename next to ngl
Use specific names for renderers in the gsk tests.
Otherwise the tests may use the wrong renderer, or
the same renderer twice.
2021-03-31 14:59:43 -04:00
Matthias Clasen f9457af128 ngl: Fix offscreen rendering with transforms
There was confusion here about the handling of the
modelview transform. The modelview transform we are
getting is already set up for rendering the node
we are given, so keep it - except for possible adding
an extra scale on top when the texture would otherwise
be too big.
2021-03-31 14:36:24 -04:00
Matthias Clasen 94f0a4ef2c ngl: Be explicit about offscreen clipping
Explicitly set all the input arguments.
This makes it clearer what is going on.
2021-03-31 14:34:16 -04:00
Matthias Clasen 53e75936cb ngl: Add sonme comments
The GskNglRenderOffscreen struct is a mix of in and
out arguments. Better annotate that a little bit.
2021-03-31 14:32:47 -04:00
Anders Jonsson 6c95fc7e87 Update Swedish translation 2021-03-30 17:13:11 +00:00
Matthias Clasen f4cc9a47ad Merge branch 'docs' into 'master'
docs: Cover corner-case of @line_number = total lines in buffer

See merge request GNOME/gtk!3373
2021-03-30 16:09:34 +00:00
Avinash Sonawane 622bb9186e docs: Cover corner-case of @line_number = total lines in buffer 2021-03-30 17:00:33 +05:30
10 changed files with 1160 additions and 972 deletions
+22 -10
View File
@@ -163,18 +163,29 @@ struct _GskNglRenderJob
typedef struct _GskNglRenderOffscreen
{
/* The bounds to render */
const graphene_rect_t *bounds;
/* Return location for texture coordinates */
struct {
float x;
float y;
float x2;
float y2;
} area;
/* Return location for texture ID */
guint texture_id;
/* Whether to force creating a new texture, even if the
* input already is a texture
*/
guint force_offscreen : 1;
guint reset_clip : 1;
guint do_not_cache : 1;
guint linear_filter : 1;
/* Return location for whether we created a texture */
guint was_offscreen : 1;
} GskNglRenderOffscreen;
@@ -1594,6 +1605,7 @@ gsk_ngl_render_job_visit_rounded_clip_node (GskNglRenderJob *job,
offscreen.bounds = &node->bounds;
offscreen.force_offscreen = TRUE;
offscreen.reset_clip = FALSE;
gsk_ngl_render_job_push_clip (job, &transformed_clip);
if (!gsk_ngl_render_job_visit_node_with_offscreen (job, child, &offscreen))
@@ -3554,8 +3566,8 @@ gsk_ngl_render_job_visit_node_with_offscreen (GskNglRenderJob *job,
float scaled_width;
float scaled_height;
float scale_x = job->scale_x;
float scale_y = job->scale_y;
float downscale_x = 1;
float downscale_y = 1;
g_assert (job->command_queue->max_texture_size > 0);
@@ -3566,17 +3578,17 @@ gsk_ngl_render_job_visit_node_with_offscreen (GskNglRenderJob *job,
{
int max_texture_size = job->command_queue->max_texture_size;
scaled_width = ceilf (offscreen->bounds->size.width * scale_x);
scaled_width = ceilf (offscreen->bounds->size.width * job->scale_x);
if (scaled_width > max_texture_size)
{
scale_x *= (float)max_texture_size / scaled_width;
downscale_x = (float)max_texture_size / scaled_width;
scaled_width = max_texture_size;
}
scaled_height = ceilf (offscreen->bounds->size.height * scale_y);
scaled_height = ceilf (offscreen->bounds->size.height * job->scale_y);
if (scaled_height > max_texture_size)
{
scale_y *= (float)max_texture_size / scaled_height;
downscale_y = (float)max_texture_size / scaled_height;
scaled_height = max_texture_size;
}
}
@@ -3620,10 +3632,9 @@ gsk_ngl_render_job_visit_node_with_offscreen (GskNglRenderJob *job,
gsk_ngl_render_job_set_viewport (job, &viewport, &prev_viewport);
gsk_ngl_render_job_set_projection_from_rect (job, &job->viewport, &prev_projection);
gsk_ngl_render_job_set_modelview (job, gsk_transform_scale (NULL, scale_x, scale_y));
if (downscale_x != 1 || downscale_y != 1)
gsk_ngl_render_job_push_modelview (job, gsk_transform_scale (NULL, downscale_x, downscale_y));
prev_alpha = gsk_ngl_render_job_set_alpha (job, 1.0f);
job->offset_x = offset_x;
job->offset_y = offset_y;
prev_fbo = gsk_ngl_command_queue_bind_framebuffer (job->command_queue, render_target->framebuffer_id);
gsk_ngl_command_queue_clear (job->command_queue, 0, &job->viewport);
@@ -3636,7 +3647,8 @@ gsk_ngl_render_job_visit_node_with_offscreen (GskNglRenderJob *job,
if (offscreen->reset_clip)
gsk_ngl_render_job_pop_clip (job);
gsk_ngl_render_job_pop_modelview (job);
if (downscale_x != 1 || downscale_y != 1)
gsk_ngl_render_job_pop_modelview (job);
gsk_ngl_render_job_set_viewport (job, &prev_viewport, NULL);
gsk_ngl_render_job_set_projection (job, &prev_projection);
gsk_ngl_render_job_set_alpha (job, prev_alpha);
+17 -1
View File
@@ -86,11 +86,27 @@ pango_underline_to_string (PangoUnderline value)
return "none";
case PANGO_UNDERLINE_SINGLE:
case PANGO_UNDERLINE_SINGLE_LINE:
#if PANGO_VERSION_CHECK(1,49,0)
case PANGO_UNDERLINE_SINGLE_DOTTED:
case PANGO_UNDERLINE_SINGLE_LINE_DOTTED:
case PANGO_UNDERLINE_SINGLE_DASHED:
case PANGO_UNDERLINE_SINGLE_LINE_DASHED:
#endif
return "single";
case PANGO_UNDERLINE_DOUBLE:
case PANGO_UNDERLINE_DOUBLE_LINE:
#if PANGO_VERSION_CHECK(1,49,0)
case PANGO_UNDERLINE_DOUBLE_DOTTED:
case PANGO_UNDERLINE_DOUBLE_LINE_DOTTED:
case PANGO_UNDERLINE_DOUBLE_DASHED:
case PANGO_UNDERLINE_DOUBLE_LINE_DASHED:
#endif
return "double";
case PANGO_UNDERLINE_LOW:
#if PANGO_VERSION_CHECK(1,49,0)
case PANGO_UNDERLINE_LOW_DOTTED:
case PANGO_UNDERLINE_LOW_DASHED:
#endif
return "low";
case PANGO_UNDERLINE_ERROR:
case PANGO_UNDERLINE_ERROR_LINE:
@@ -196,7 +212,7 @@ gtk_pango_get_default_attributes (PangoLayout *layout,
pango_wrap_mode_to_string (mode));
g_variant_builder_add (builder, "{ss}", "strikethrough", "false");
g_variant_builder_add (builder, "{ss}", "underline", "false");
g_variant_builder_add (builder, "{ss}", "underline", "none");
g_variant_builder_add (builder, "{ss}", "rise", "0");
g_variant_builder_add (builder, "{ss}", "scale", "1");
g_variant_builder_add (builder, "{ss}", "bg-full-height", "0");
+87
View File
@@ -127,6 +127,85 @@ gsk_pango_renderer_draw_rectangle (PangoRenderer *renderer,
(double)height / PANGO_SCALE));
}
#if PANGO_VERSION_CHECK(1,49,0)
static void
gsk_pango_renderer_draw_line (PangoRenderer *renderer,
PangoRenderPart part,
PangoRenderLineStyle style,
int x,
int y,
int width,
int height)
{
GskPangoRenderer *crenderer = (GskPangoRenderer *) (renderer);
GdkRGBA rgba;
double xx, yy, ww, hh;
xx = (double)x / PANGO_SCALE;
yy = (double)y / PANGO_SCALE;
ww = (double)width / PANGO_SCALE;
hh = (double)height / PANGO_SCALE;
get_color (crenderer, part, &rgba);
switch (style)
{
case PANGO_RENDER_LINE_SOLID:
gtk_snapshot_append_color (crenderer->snapshot,
&rgba,
&GRAPHENE_RECT_INIT (xx, yy, ww, hh));
break;
case PANGO_RENDER_LINE_DOTTED:
{
GskRoundedRect dot;
double d = MIN (ww, hh);
graphene_rect_t bounds = GRAPHENE_RECT_INIT (xx, yy, d, d);
graphene_size_t rr = GRAPHENE_SIZE_INIT (d/2, d/2);
GdkRGBA transparent = { 0.f, 0.f, 0.f, 0.f };
gsk_rounded_rect_init (&dot, &bounds, &rr, &rr, &rr, &rr);
gtk_snapshot_push_repeat (crenderer->snapshot,
&GRAPHENE_RECT_INIT (xx, yy, ww, hh),
NULL);
gtk_snapshot_push_rounded_clip (crenderer->snapshot, &dot);
gtk_snapshot_append_color (crenderer->snapshot, &rgba, &bounds);
gtk_snapshot_pop (crenderer->snapshot);
gtk_snapshot_append_color (crenderer->snapshot, &transparent, &GRAPHENE_RECT_INIT (xx + d, yy, 0.5 * d, d));
gtk_snapshot_pop (crenderer->snapshot);
}
break;
case PANGO_RENDER_LINE_DASHED:
{
GskColorStop stops[4];
GdkRGBA transparent = { 0.f, 0.f, 0.f, 0.f };
stops[0].offset = 0;
stops[0].color = rgba;
stops[1].offset = 0.66;
stops[1].color = rgba;
stops[2].offset = 0.66;
stops[2].color = transparent;
stops[3].offset = 1;
stops[3].color = transparent;
gtk_snapshot_append_repeating_linear_gradient (
crenderer->snapshot,
&GRAPHENE_RECT_INIT (xx, yy, ww, hh),
&GRAPHENE_POINT_INIT (xx, yy),
&GRAPHENE_POINT_INIT (xx + 9 * MIN (ww, hh), yy),
stops, 4);
}
break;
default:
g_assert_not_reached ();
}
}
#endif
static void
gsk_pango_renderer_draw_trapezoid (PangoRenderer *renderer,
PangoRenderPart part,
@@ -409,6 +488,11 @@ gsk_pango_renderer_prepare_run (PangoRenderer *renderer,
}
else
text_renderer_set_rgba (crenderer, PANGO_RENDER_PART_UNDERLINE, fg_rgba);
if (appearance->overline_rgba)
text_renderer_set_rgba (crenderer, PANGO_RENDER_PART_OVERLINE, appearance->overline_rgba);
else
text_renderer_set_rgba (crenderer, PANGO_RENDER_PART_OVERLINE, fg_rgba);
}
static void
@@ -426,6 +510,9 @@ gsk_pango_renderer_class_init (GskPangoRendererClass *klass)
renderer_class->draw_trapezoid = gsk_pango_renderer_draw_trapezoid;
renderer_class->draw_error_underline = gsk_pango_renderer_draw_error_underline;
renderer_class->draw_shape = gsk_pango_renderer_draw_shape;
#if PANGO_VERSION_CHECK(1,49,0)
renderer_class->draw_line = gsk_pango_renderer_draw_line;
#endif
renderer_class->prepare_run = gsk_pango_renderer_prepare_run;
}
+25 -2
View File
@@ -1527,10 +1527,33 @@ get_layout (GtkCellRendererText *celltext,
uline = PANGO_UNDERLINE_DOUBLE_LINE;
break;
case PANGO_UNDERLINE_DOUBLE_LINE:
case PANGO_UNDERLINE_ERROR_LINE:
#if PANGO_VERSION_CHECK(1,49,0)
case PANGO_UNDERLINE_SINGLE_DASHED:
uline = PANGO_UNDERLINE_DOUBLE_DASHED;
break;
case PANGO_UNDERLINE_SINGLE_LINE_DASHED:
uline = PANGO_UNDERLINE_DOUBLE_LINE_DASHED;
break;
case PANGO_UNDERLINE_SINGLE_DOTTED:
uline = PANGO_UNDERLINE_DOUBLE_DOTTED;
break;
case PANGO_UNDERLINE_SINGLE_LINE_DOTTED:
uline = PANGO_UNDERLINE_DOUBLE_LINE_DOTTED;
break;
case PANGO_UNDERLINE_DOUBLE_DASHED:
case PANGO_UNDERLINE_DOUBLE_LINE_DASHED:
case PANGO_UNDERLINE_DOUBLE_DOTTED:
case PANGO_UNDERLINE_DOUBLE_LINE_DOTTED:
case PANGO_UNDERLINE_LOW_DASHED:
case PANGO_UNDERLINE_LOW_DOTTED:
#endif
case PANGO_UNDERLINE_DOUBLE_LINE:
case PANGO_UNDERLINE_ERROR_LINE:
case PANGO_UNDERLINE_DOUBLE:
case PANGO_UNDERLINE_LOW:
case PANGO_UNDERLINE_ERROR:
+3 -3
View File
@@ -3250,7 +3250,7 @@ gtk_text_buffer_remove_all_tags (GtkTextBuffer *buffer,
* Note characters, not bytes; UTF-8 may encode one character as multiple
* bytes.
*
* If @line_number is greater than the number of lines in the @buffer,
* If @line_number is greater than or equal to the number of lines in the @buffer,
* the end iterator is returned. And if @char_offset is off the
* end of the line, the iterator at the end of the line is returned.
*
@@ -3301,7 +3301,7 @@ gtk_text_buffer_get_iter_at_line_offset (GtkTextBuffer *buffer,
* @byte_index must be the start of a UTF-8 character. Note bytes, not
* characters; UTF-8 may encode one character as multiple bytes.
*
* If @line_number is greater than the number of lines in the @buffer,
* If @line_number is greater than or equal to the number of lines in the @buffer,
* the end iterator is returned. And if @byte_index is off the
* end of the line, the iterator at the end of the line is returned.
*
@@ -3348,7 +3348,7 @@ gtk_text_buffer_get_iter_at_line_index (GtkTextBuffer *buffer,
*
* Initializes @iter to the start of the given line.
*
* If @line_number is greater than the number of lines
* If @line_number is greater than or equal to the number of lines
* in the @buffer, the end iterator is returned.
*
* Returns: whether the exact position has been found
+1 -1
View File
@@ -4052,7 +4052,7 @@ gtk_text_iter_set_visible_line_index (GtkTextIter *iter,
*
* Moves iterator @iter to the start of the line @line_number.
*
* If @line_number is negative or larger than the number of lines
* If @line_number is negative or larger than or equal to the number of lines
* in the buffer, moves @iter to the start of the last line in the buffer.
*/
void
+970 -953
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,32 @@
transform {
child: transform {
child: rounded-clip {
child: container {
repeat {
bounds: 0 0 159 34;
child: container {
color {
bounds: 0 0 10 10;
color: rgb(168,168,168);
}
color {
bounds: 10 0 10 10;
color: rgb(84,84,84);
}
color {
bounds: 0 10 10 10;
color: rgb(84,84,84);
}
color {
bounds: 10 10 10 10;
color: rgb(168,168,168);
}
}
}
}
clip: 0 0 159 34 / 6;
}
transform: scale(4, 4);
}
transform: translate(6, 20);
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

+3 -2
View File
@@ -76,6 +76,7 @@ compare_render_tests = [
'clip-in-rounded-clip2',
'clip-in-rounded-clip3',
'rounded-clip-in-clip-3d', # not really 3d, but cairo fails it
'clipped-repeat-3d-ngl',
'issue-3615'
]
@@ -89,8 +90,8 @@ informative_render_tests = [
renderers = [
# name exclude term
[ 'opengl', '' ],
[ 'next', '' ],
[ 'gl', '-ngl' ],
[ 'ngl', '' ],
[ 'broadway', '-3d' ],
[ 'cairo', '-3d' ],
]