forked from AuroraMiddleware/gtk
css: Pass boxes to the render functions
Instead of style + rect_of_one_box, pass the new GtkCssBoxes object. This has the nice side effect that when drawing background + border + outline, we only compute all the boxes we need once.
This commit is contained in:
parent
7ad0f7fc52
commit
c44c44ee25
@ -270,12 +270,9 @@ gtk_theming_background_snapshot_layer (GtkCssBoxes *bg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gtk_css_style_snapshot_background (GtkCssStyle *style,
|
gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
|
||||||
GtkSnapshot *snapshot,
|
GtkSnapshot *snapshot)
|
||||||
gdouble width,
|
|
||||||
gdouble height)
|
|
||||||
{
|
{
|
||||||
GtkCssBoxes boxes;
|
|
||||||
gint idx;
|
gint idx;
|
||||||
GtkCssValue *background_image;
|
GtkCssValue *background_image;
|
||||||
GtkCssValue *box_shadow;
|
GtkCssValue *box_shadow;
|
||||||
@ -284,9 +281,9 @@ gtk_css_style_snapshot_background (GtkCssStyle *style,
|
|||||||
gint number_of_layers;
|
gint number_of_layers;
|
||||||
GskBlendMode *blend_mode_values;
|
GskBlendMode *blend_mode_values;
|
||||||
|
|
||||||
background_image = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BACKGROUND_IMAGE);
|
background_image = gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BACKGROUND_IMAGE);
|
||||||
bg_color = _gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
|
bg_color = _gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
|
||||||
box_shadow = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BOX_SHADOW);
|
box_shadow = gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BOX_SHADOW);
|
||||||
|
|
||||||
/* This is the common default case of no background */
|
/* This is the common default case of no background */
|
||||||
if (gdk_rgba_is_clear (bg_color) &&
|
if (gdk_rgba_is_clear (bg_color) &&
|
||||||
@ -295,15 +292,13 @@ gtk_css_style_snapshot_background (GtkCssStyle *style,
|
|||||||
_gtk_css_shadows_value_is_none (box_shadow))
|
_gtk_css_shadows_value_is_none (box_shadow))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gtk_css_boxes_init_border_box (&boxes, style, 0, 0, width, height);
|
|
||||||
|
|
||||||
gtk_snapshot_push_debug (snapshot, "CSS background");
|
gtk_snapshot_push_debug (snapshot, "CSS background");
|
||||||
|
|
||||||
gtk_css_shadows_value_snapshot_outset (box_shadow,
|
gtk_css_shadows_value_snapshot_outset (box_shadow,
|
||||||
snapshot,
|
snapshot,
|
||||||
gtk_css_boxes_get_border_box (&boxes));
|
gtk_css_boxes_get_border_box (boxes));
|
||||||
|
|
||||||
blend_modes = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BACKGROUND_BLEND_MODE);
|
blend_modes = gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BACKGROUND_BLEND_MODE);
|
||||||
number_of_layers = _gtk_css_array_value_get_n_values (background_image);
|
number_of_layers = _gtk_css_array_value_get_n_values (background_image);
|
||||||
blend_mode_values = g_alloca (sizeof (GskBlendMode) * number_of_layers);
|
blend_mode_values = g_alloca (sizeof (GskBlendMode) * number_of_layers);
|
||||||
|
|
||||||
@ -316,25 +311,25 @@ gtk_css_style_snapshot_background (GtkCssStyle *style,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gdk_rgba_is_clear (bg_color))
|
if (!gdk_rgba_is_clear (bg_color))
|
||||||
gtk_theming_background_snapshot_color (&boxes, snapshot, bg_color, background_image);
|
gtk_theming_background_snapshot_color (boxes, snapshot, bg_color, background_image);
|
||||||
|
|
||||||
for (idx = number_of_layers - 1; idx >= 0; idx--)
|
for (idx = number_of_layers - 1; idx >= 0; idx--)
|
||||||
{
|
{
|
||||||
if (blend_mode_values[idx] == GSK_BLEND_MODE_DEFAULT)
|
if (blend_mode_values[idx] == GSK_BLEND_MODE_DEFAULT)
|
||||||
{
|
{
|
||||||
gtk_theming_background_snapshot_layer (&boxes, idx, snapshot);
|
gtk_theming_background_snapshot_layer (boxes, idx, snapshot);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gtk_snapshot_pop (snapshot);
|
gtk_snapshot_pop (snapshot);
|
||||||
gtk_theming_background_snapshot_layer (&boxes, idx, snapshot);
|
gtk_theming_background_snapshot_layer (boxes, idx, snapshot);
|
||||||
gtk_snapshot_pop (snapshot);
|
gtk_snapshot_pop (snapshot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_css_shadows_value_snapshot_inset (box_shadow,
|
gtk_css_shadows_value_snapshot_inset (box_shadow,
|
||||||
snapshot,
|
snapshot,
|
||||||
gtk_css_boxes_get_padding_box (&boxes));
|
gtk_css_boxes_get_padding_box (boxes));
|
||||||
|
|
||||||
gtk_snapshot_pop (snapshot);
|
gtk_snapshot_pop (snapshot);
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,13 @@
|
|||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
|
|
||||||
#include "gtkcsstypesprivate.h"
|
#include "gtkcsstypesprivate.h"
|
||||||
|
#include "gtkcssboxesprivate.h"
|
||||||
#include "gtktypes.h"
|
#include "gtktypes.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
void gtk_css_style_snapshot_background (GtkCssStyle *style,
|
void gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
|
||||||
GtkSnapshot *snapshot,
|
GtkSnapshot *snapshot);
|
||||||
gdouble width,
|
|
||||||
gdouble height);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -252,12 +252,9 @@ gtk_border_image_compute_slice_size (GtkBorderImageSliceSize sizes[3],
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_border_image_render (GtkBorderImage *image,
|
gtk_border_image_render (GtkBorderImage *image,
|
||||||
const double border_width[4],
|
const float border_width[4],
|
||||||
cairo_t *cr,
|
cairo_t *cr,
|
||||||
gdouble x,
|
const graphene_rect_t *rect)
|
||||||
gdouble y,
|
|
||||||
gdouble width,
|
|
||||||
gdouble height)
|
|
||||||
{
|
{
|
||||||
cairo_surface_t *surface, *slice;
|
cairo_surface_t *surface, *slice;
|
||||||
GtkBorderImageSliceSize vertical_slice[3], horizontal_slice[3];
|
GtkBorderImageSliceSize vertical_slice[3], horizontal_slice[3];
|
||||||
@ -267,7 +264,7 @@ gtk_border_image_render (GtkBorderImage *image,
|
|||||||
|
|
||||||
_gtk_css_image_get_concrete_size (image->source,
|
_gtk_css_image_get_concrete_size (image->source,
|
||||||
0, 0,
|
0, 0,
|
||||||
width, height,
|
rect->size.width, rect->size.height,
|
||||||
&source_width, &source_height);
|
&source_width, &source_height);
|
||||||
|
|
||||||
/* XXX: Optimize for (source_width == width && source_height == height) */
|
/* XXX: Optimize for (source_width == width && source_height == height) */
|
||||||
@ -285,15 +282,15 @@ gtk_border_image_render (GtkBorderImage *image,
|
|||||||
_gtk_css_number_value_get (_gtk_css_border_value_get_top (image->slice), source_height),
|
_gtk_css_number_value_get (_gtk_css_border_value_get_top (image->slice), source_height),
|
||||||
_gtk_css_number_value_get (_gtk_css_border_value_get_bottom (image->slice), source_height));
|
_gtk_css_number_value_get (_gtk_css_border_value_get_bottom (image->slice), source_height));
|
||||||
gtk_border_image_compute_border_size (horizontal_border,
|
gtk_border_image_compute_border_size (horizontal_border,
|
||||||
x,
|
rect->origin.x,
|
||||||
width,
|
rect->size.width,
|
||||||
border_width[GTK_CSS_LEFT],
|
border_width[GTK_CSS_LEFT],
|
||||||
border_width[GTK_CSS_RIGHT],
|
border_width[GTK_CSS_RIGHT],
|
||||||
_gtk_css_border_value_get_left (image->width),
|
_gtk_css_border_value_get_left (image->width),
|
||||||
_gtk_css_border_value_get_right (image->width));
|
_gtk_css_border_value_get_right (image->width));
|
||||||
gtk_border_image_compute_border_size (vertical_border,
|
gtk_border_image_compute_border_size (vertical_border,
|
||||||
y,
|
rect->origin.y,
|
||||||
height,
|
rect->size.height,
|
||||||
border_width[GTK_CSS_TOP],
|
border_width[GTK_CSS_TOP],
|
||||||
border_width[GTK_CSS_BOTTOM],
|
border_width[GTK_CSS_BOTTOM],
|
||||||
_gtk_css_border_value_get_top (image->width),
|
_gtk_css_border_value_get_top (image->width),
|
||||||
@ -424,7 +421,7 @@ set_stroke_style (cairo_t *cr,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
render_frame_stroke (cairo_t *cr,
|
render_frame_stroke (cairo_t *cr,
|
||||||
GskRoundedRect *border_box,
|
const GskRoundedRect *border_box,
|
||||||
const double border_width[4],
|
const double border_width[4],
|
||||||
GdkRGBA colors[4],
|
GdkRGBA colors[4],
|
||||||
guint hidden_side,
|
guint hidden_side,
|
||||||
@ -511,7 +508,7 @@ render_frame_stroke (cairo_t *cr,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
snapshot_frame_stroke (GtkSnapshot *snapshot,
|
snapshot_frame_stroke (GtkSnapshot *snapshot,
|
||||||
GskRoundedRect *outline,
|
const GskRoundedRect *outline,
|
||||||
const float border_width[4],
|
const float border_width[4],
|
||||||
GdkRGBA colors[4],
|
GdkRGBA colors[4],
|
||||||
guint hidden_side,
|
guint hidden_side,
|
||||||
@ -540,7 +537,7 @@ color_shade (const GdkRGBA *color,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
snapshot_border (GtkSnapshot *snapshot,
|
snapshot_border (GtkSnapshot *snapshot,
|
||||||
GskRoundedRect *border_box,
|
const GskRoundedRect *border_box,
|
||||||
const float border_width[4],
|
const float border_width[4],
|
||||||
GdkRGBA colors[4],
|
GdkRGBA colors[4],
|
||||||
GtkBorderStyle border_style[4])
|
GtkBorderStyle border_style[4])
|
||||||
@ -661,136 +658,86 @@ snapshot_border (GtkSnapshot *snapshot,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gtk_css_style_snapshot_border (GtkCssStyle *style,
|
gtk_css_style_snapshot_border (GtkCssBoxes *boxes,
|
||||||
GtkSnapshot *snapshot,
|
GtkSnapshot *snapshot)
|
||||||
gdouble width,
|
|
||||||
gdouble height)
|
|
||||||
{
|
{
|
||||||
GtkBorderImage border_image;
|
GtkBorderImage border_image;
|
||||||
float border_width[4];
|
float border_width[4];
|
||||||
|
|
||||||
border_width[0] = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
|
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 (style, GTK_CSS_PROPERTY_BORDER_RIGHT_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 (style, GTK_CSS_PROPERTY_BORDER_BOTTOM_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 (style, GTK_CSS_PROPERTY_BORDER_LEFT_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, style))
|
if (gtk_border_image_init (&border_image, boxes->style))
|
||||||
{
|
{
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
graphene_rect_t bounds;
|
const graphene_rect_t *bounds;
|
||||||
double double_width[4] = { border_width[0], border_width[1], border_width[2], border_width[3] };
|
|
||||||
|
|
||||||
graphene_rect_init (&bounds, 0, 0, width, height);
|
bounds = gtk_css_boxes_get_border_rect (boxes);
|
||||||
|
|
||||||
gtk_snapshot_push_debug (snapshot, "CSS border image");
|
gtk_snapshot_push_debug (snapshot, "CSS border image");
|
||||||
cr = gtk_snapshot_append_cairo (snapshot,
|
cr = gtk_snapshot_append_cairo (snapshot, bounds);
|
||||||
&bounds);
|
gtk_border_image_render (&border_image, border_width, cr, bounds);
|
||||||
gtk_border_image_render (&border_image, double_width, cr, 0, 0, width, height);
|
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
gtk_snapshot_pop (snapshot);
|
gtk_snapshot_pop (snapshot);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GtkBorderStyle border_style[4];
|
GtkBorderStyle border_style[4];
|
||||||
GskRoundedRect border_box;
|
|
||||||
GdkRGBA colors[4];
|
GdkRGBA colors[4];
|
||||||
graphene_simd4f_t alpha_test_vector;
|
graphene_simd4f_t alpha_test_vector;
|
||||||
|
|
||||||
/* Optimize the most common case of "This widget has no border" */
|
/* Optimize the most common case of "This widget has no border" */
|
||||||
if (border_width[0] == 0 &&
|
if (graphene_rect_equal (gtk_css_boxes_get_border_rect (boxes),
|
||||||
border_width[1] == 0 &&
|
gtk_css_boxes_get_padding_rect (boxes)))
|
||||||
border_width[2] == 0 &&
|
|
||||||
border_width[3] == 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
colors[0] = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_COLOR));
|
colors[0] = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_TOP_COLOR));
|
||||||
colors[1] = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR));
|
colors[1] = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR));
|
||||||
colors[2] = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR));
|
colors[2] = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR));
|
||||||
colors[3] = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_LEFT_COLOR));
|
colors[3] = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_LEFT_COLOR));
|
||||||
|
|
||||||
alpha_test_vector = graphene_simd4f_init (colors[0].alpha, colors[1].alpha, colors[2].alpha, colors[3].alpha);
|
alpha_test_vector = graphene_simd4f_init (colors[0].alpha, colors[1].alpha, colors[2].alpha, colors[3].alpha);
|
||||||
if (graphene_simd4f_is_zero4 (alpha_test_vector))
|
if (graphene_simd4f_is_zero4 (alpha_test_vector))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
border_style[0] = _gtk_css_border_style_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
|
border_style[0] = _gtk_css_border_style_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
|
||||||
border_style[1] = _gtk_css_border_style_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE));
|
border_style[1] = _gtk_css_border_style_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE));
|
||||||
border_style[2] = _gtk_css_border_style_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE));
|
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 (style, GTK_CSS_PROPERTY_BORDER_LEFT_STYLE));
|
border_style[3] = _gtk_css_border_style_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BORDER_LEFT_STYLE));
|
||||||
|
|
||||||
gtk_rounded_boxes_init_for_style (&border_box, NULL, NULL, style, 0, 0, width, height);
|
|
||||||
|
|
||||||
gtk_snapshot_push_debug (snapshot, "CSS border");
|
gtk_snapshot_push_debug (snapshot, "CSS border");
|
||||||
snapshot_border (snapshot, &border_box, border_width, colors, border_style);
|
snapshot_border (snapshot,
|
||||||
|
gtk_css_boxes_get_border_box (boxes),
|
||||||
|
border_width,
|
||||||
|
colors,
|
||||||
|
border_style);
|
||||||
gtk_snapshot_pop (snapshot);
|
gtk_snapshot_pop (snapshot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
compute_outline_rect (GtkCssStyle *style,
|
|
||||||
gdouble x,
|
|
||||||
gdouble y,
|
|
||||||
gdouble width,
|
|
||||||
gdouble height,
|
|
||||||
cairo_rectangle_t *out_rect)
|
|
||||||
{
|
|
||||||
double offset, owidth;
|
|
||||||
|
|
||||||
owidth = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_OUTLINE_WIDTH), 100);
|
|
||||||
offset = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_OUTLINE_OFFSET), 100);
|
|
||||||
|
|
||||||
if (width <= -2 * offset)
|
|
||||||
{
|
|
||||||
x += width / 2;
|
|
||||||
out_rect->x = x - owidth;
|
|
||||||
out_rect->width = 2 * owidth;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
out_rect->x = x - offset - owidth;
|
|
||||||
out_rect->width = width + 2 * (offset + owidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (height <= -2 * offset)
|
|
||||||
{
|
|
||||||
y += height / 2;
|
|
||||||
out_rect->y = y - owidth;
|
|
||||||
out_rect->height = 2 * owidth;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
out_rect->y = y - offset - owidth;
|
|
||||||
out_rect->height = height + 2 * (offset + owidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gtk_css_style_snapshot_outline (GtkCssStyle *style,
|
gtk_css_style_snapshot_outline (GtkCssBoxes *boxes,
|
||||||
GtkSnapshot *snapshot,
|
GtkSnapshot *snapshot)
|
||||||
gdouble width,
|
|
||||||
gdouble height)
|
|
||||||
{
|
{
|
||||||
GtkBorderStyle border_style[4];
|
GtkBorderStyle border_style[4];
|
||||||
GskRoundedRect border_box;
|
|
||||||
float border_width[4];
|
float border_width[4];
|
||||||
GdkRGBA colors[4];
|
GdkRGBA colors[4];
|
||||||
|
|
||||||
border_style[0] = _gtk_css_border_style_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_OUTLINE_STYLE));
|
border_style[0] = _gtk_css_border_style_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_OUTLINE_STYLE));
|
||||||
if (border_style[0] != GTK_BORDER_STYLE_NONE)
|
if (border_style[0] != GTK_BORDER_STYLE_NONE)
|
||||||
{
|
{
|
||||||
cairo_rectangle_t rect;
|
|
||||||
|
|
||||||
compute_outline_rect (style, 0, 0, width, height, &rect);
|
|
||||||
|
|
||||||
border_style[1] = border_style[2] = border_style[3] = border_style[0];
|
border_style[1] = border_style[2] = border_style[3] = border_style[0];
|
||||||
border_width[0] = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_OUTLINE_WIDTH), 100);
|
border_width[0] = _gtk_css_number_value_get (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_OUTLINE_WIDTH), 100);
|
||||||
border_width[3] = border_width[2] = border_width[1] = border_width[0];
|
border_width[3] = border_width[2] = border_width[1] = border_width[0];
|
||||||
colors[0] = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_OUTLINE_COLOR));
|
colors[0] = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_OUTLINE_COLOR));
|
||||||
colors[3] = colors[2] = colors[1] = colors[0];
|
colors[3] = colors[2] = colors[1] = colors[0];
|
||||||
|
|
||||||
_gtk_rounded_box_init_rect (&border_box, rect.x, rect.y, rect.width, rect.height);
|
snapshot_border (snapshot,
|
||||||
_gtk_rounded_box_apply_outline_radius_for_style (&border_box, style);
|
gtk_css_boxes_get_outline_box (boxes),
|
||||||
|
border_width,
|
||||||
snapshot_border (snapshot, &border_box, border_width, colors, border_style);
|
colors,
|
||||||
|
border_style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,21 +23,16 @@
|
|||||||
#define __GTK_RENDER_BORDER_H__
|
#define __GTK_RENDER_BORDER_H__
|
||||||
|
|
||||||
#include "gtkborder.h"
|
#include "gtkborder.h"
|
||||||
#include "gtkcssimageprivate.h"
|
#include "gtkcssboxesprivate.h"
|
||||||
#include "gtkcssvalueprivate.h"
|
|
||||||
#include "gtktypes.h"
|
#include "gtktypes.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
void gtk_css_style_snapshot_border (GtkCssStyle *style,
|
void gtk_css_style_snapshot_border (GtkCssBoxes *boxes,
|
||||||
GtkSnapshot *snapshot,
|
GtkSnapshot *snapshot);
|
||||||
gdouble width,
|
|
||||||
gdouble height);
|
|
||||||
|
|
||||||
void gtk_css_style_snapshot_outline (GtkCssStyle *style,
|
void gtk_css_style_snapshot_outline (GtkCssBoxes *boxes,
|
||||||
GtkSnapshot *snapshot,
|
GtkSnapshot *snapshot);
|
||||||
gdouble width,
|
|
||||||
gdouble height);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -1263,14 +1263,15 @@ gtk_snapshot_render_background (GtkSnapshot *snapshot,
|
|||||||
gdouble width,
|
gdouble width,
|
||||||
gdouble height)
|
gdouble height)
|
||||||
{
|
{
|
||||||
|
GtkCssBoxes boxes;
|
||||||
|
|
||||||
g_return_if_fail (snapshot != NULL);
|
g_return_if_fail (snapshot != NULL);
|
||||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||||
|
|
||||||
gtk_snapshot_offset (snapshot, x, y);
|
gtk_css_boxes_init_border_box (&boxes,
|
||||||
gtk_css_style_snapshot_background (gtk_style_context_lookup_style (context),
|
gtk_style_context_lookup_style (context),
|
||||||
snapshot,
|
x, y, width, height);
|
||||||
width, height);
|
gtk_css_style_snapshot_background (&boxes, snapshot);
|
||||||
gtk_snapshot_offset (snapshot, -x, -y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1294,14 +1295,15 @@ gtk_snapshot_render_frame (GtkSnapshot *snapshot,
|
|||||||
gdouble width,
|
gdouble width,
|
||||||
gdouble height)
|
gdouble height)
|
||||||
{
|
{
|
||||||
|
GtkCssBoxes boxes;
|
||||||
|
|
||||||
g_return_if_fail (snapshot != NULL);
|
g_return_if_fail (snapshot != NULL);
|
||||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||||
|
|
||||||
gtk_snapshot_offset (snapshot, x, y);
|
gtk_css_boxes_init_border_box (&boxes,
|
||||||
gtk_css_style_snapshot_border (gtk_style_context_lookup_style (context),
|
gtk_style_context_lookup_style (context),
|
||||||
snapshot,
|
x, y, width, height);
|
||||||
width, height);
|
gtk_css_style_snapshot_border (&boxes, snapshot);
|
||||||
gtk_snapshot_offset (snapshot, -x, -y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1325,14 +1327,15 @@ gtk_snapshot_render_focus (GtkSnapshot *snapshot,
|
|||||||
gdouble width,
|
gdouble width,
|
||||||
gdouble height)
|
gdouble height)
|
||||||
{
|
{
|
||||||
|
GtkCssBoxes boxes;
|
||||||
|
|
||||||
g_return_if_fail (snapshot != NULL);
|
g_return_if_fail (snapshot != NULL);
|
||||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||||
|
|
||||||
gtk_snapshot_offset (snapshot, x, y);
|
gtk_css_boxes_init_border_box (&boxes,
|
||||||
gtk_css_style_snapshot_outline (gtk_style_context_lookup_style (context),
|
gtk_style_context_lookup_style (context),
|
||||||
snapshot,
|
x, y, width, height);
|
||||||
width, height);
|
gtk_css_style_snapshot_outline (&boxes, snapshot);
|
||||||
gtk_snapshot_offset (snapshot, -x, -y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13053,72 +13053,43 @@ gtk_widget_create_render_node (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GtkWidgetClass *klass = GTK_WIDGET_GET_CLASS (widget);
|
GtkWidgetClass *klass = GTK_WIDGET_GET_CLASS (widget);
|
||||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||||
|
GtkCssBoxes boxes;
|
||||||
GtkCssValue *filter_value;
|
GtkCssValue *filter_value;
|
||||||
double opacity;
|
double opacity;
|
||||||
GtkCssStyle *style;
|
|
||||||
GtkAllocation allocation;
|
|
||||||
GtkBorder margin, border, padding;
|
|
||||||
GtkSnapshot *snapshot;
|
GtkSnapshot *snapshot;
|
||||||
|
|
||||||
opacity = priv->alpha / 255.0;
|
opacity = priv->alpha / 255.0;
|
||||||
if (opacity <= 0.0)
|
if (opacity <= 0.0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
gtk_css_boxes_init (&boxes, widget);
|
||||||
snapshot = gtk_snapshot_new_with_parent (parent_snapshot);
|
snapshot = gtk_snapshot_new_with_parent (parent_snapshot);
|
||||||
|
|
||||||
gtk_widget_get_allocation (widget, &allocation);
|
|
||||||
gtk_snapshot_push_debug (snapshot,
|
gtk_snapshot_push_debug (snapshot,
|
||||||
"RenderNode for %s %p @ %d x %d",
|
"RenderNode for %s %p",
|
||||||
G_OBJECT_TYPE_NAME (widget), widget,
|
G_OBJECT_TYPE_NAME (widget), widget);
|
||||||
allocation.width, allocation.height);
|
|
||||||
|
|
||||||
filter_value = _gtk_style_context_peek_property (_gtk_widget_get_style_context (widget), GTK_CSS_PROPERTY_FILTER);
|
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);
|
gtk_css_filter_value_push_snapshot (filter_value, snapshot);
|
||||||
|
|
||||||
style = gtk_css_node_get_style (priv->cssnode);
|
|
||||||
get_box_margin (style, &margin);
|
|
||||||
get_box_border (style, &border);
|
|
||||||
get_box_padding (style, &padding);
|
|
||||||
|
|
||||||
if (opacity < 1.0)
|
if (opacity < 1.0)
|
||||||
gtk_snapshot_push_opacity (snapshot, opacity);
|
gtk_snapshot_push_opacity (snapshot, opacity);
|
||||||
|
|
||||||
if (!GTK_IS_WINDOW (widget))
|
if (!GTK_IS_WINDOW (widget))
|
||||||
{
|
{
|
||||||
gtk_snapshot_offset (snapshot, - padding.left - border.left, - border.top - padding.top);
|
gtk_css_style_snapshot_background (&boxes, snapshot);
|
||||||
gtk_css_style_snapshot_background (style,
|
gtk_css_style_snapshot_border (&boxes, snapshot);
|
||||||
snapshot,
|
|
||||||
allocation.width - margin.left - margin.right,
|
|
||||||
allocation.height - margin.top - margin.bottom);
|
|
||||||
gtk_css_style_snapshot_border (style,
|
|
||||||
snapshot,
|
|
||||||
allocation.width - margin.left - margin.right,
|
|
||||||
allocation.height - margin.top - margin.bottom);
|
|
||||||
gtk_snapshot_offset (snapshot, padding.left + border.left, border.top + padding.top);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->overflow == GTK_OVERFLOW_HIDDEN)
|
if (priv->overflow == GTK_OVERFLOW_HIDDEN)
|
||||||
{
|
gtk_snapshot_push_clip (snapshot, gtk_css_boxes_get_padding_rect (&boxes));
|
||||||
gtk_snapshot_push_clip (snapshot,
|
|
||||||
&GRAPHENE_RECT_INIT (- padding.left,
|
|
||||||
- padding.top,
|
|
||||||
allocation.width - margin.left - margin.right - border.left - border.right,
|
|
||||||
allocation.height - margin.top - margin.bottom - border.top - border.bottom));
|
|
||||||
}
|
|
||||||
|
|
||||||
klass->snapshot (widget, snapshot);
|
klass->snapshot (widget, snapshot);
|
||||||
|
|
||||||
if (priv->overflow == GTK_OVERFLOW_HIDDEN)
|
if (priv->overflow == GTK_OVERFLOW_HIDDEN)
|
||||||
gtk_snapshot_pop (snapshot);
|
gtk_snapshot_pop (snapshot);
|
||||||
|
|
||||||
gtk_snapshot_offset (snapshot, - (padding.left + border.left), -(border.top + padding.top));
|
gtk_css_style_snapshot_outline (&boxes, snapshot);
|
||||||
|
|
||||||
gtk_css_style_snapshot_outline (style,
|
|
||||||
snapshot,
|
|
||||||
allocation.width - margin.left - margin.right,
|
|
||||||
allocation.height - margin.top - margin.bottom);
|
|
||||||
|
|
||||||
gtk_snapshot_offset (snapshot, padding.left + border.left, border.top + padding.top);
|
|
||||||
|
|
||||||
if (opacity < 1.0)
|
if (opacity < 1.0)
|
||||||
gtk_snapshot_pop (snapshot);
|
gtk_snapshot_pop (snapshot);
|
||||||
|
Loading…
Reference in New Issue
Block a user