mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-14 14:20:21 +00:00
gtk: Preserve css background color spaces
When rendering css backgrounds, use the new gtk_css_color_get_color and gtk_snapshot_append_color2 apis to preserve color spaces as far as possible.
This commit is contained in:
parent
e11e5525db
commit
501356116d
@ -36,6 +36,7 @@
|
|||||||
#include "gtkcsscolorvalueprivate.h"
|
#include "gtkcsscolorvalueprivate.h"
|
||||||
#include "gtkcssstyleprivate.h"
|
#include "gtkcssstyleprivate.h"
|
||||||
#include "gtkcsstypesprivate.h"
|
#include "gtkcsstypesprivate.h"
|
||||||
|
#include "gtksnapshotprivate.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@ -46,30 +47,29 @@
|
|||||||
static void
|
static void
|
||||||
gtk_theming_background_snapshot_color (GtkCssBoxes *boxes,
|
gtk_theming_background_snapshot_color (GtkCssBoxes *boxes,
|
||||||
GtkSnapshot *snapshot,
|
GtkSnapshot *snapshot,
|
||||||
const GdkRGBA *bg_color,
|
const GtkCssColor *bg_color,
|
||||||
guint n_bg_values)
|
guint n_bg_values)
|
||||||
{
|
{
|
||||||
GtkCssStyle *style = boxes->style;
|
GtkCssStyle *style = boxes->style;
|
||||||
const GskRoundedRect *box;
|
const GskRoundedRect *box;
|
||||||
GtkCssArea clip;
|
GtkCssArea clip;
|
||||||
|
GdkColor color;
|
||||||
|
|
||||||
clip = _gtk_css_area_value_get (_gtk_css_array_value_get_nth (style->background->background_clip, n_bg_values - 1));
|
clip = _gtk_css_area_value_get (_gtk_css_array_value_get_nth (style->background->background_clip, n_bg_values - 1));
|
||||||
box = gtk_css_boxes_get_box (boxes, clip);
|
box = gtk_css_boxes_get_box (boxes, clip);
|
||||||
|
|
||||||
|
gtk_css_color_to_color (bg_color, &color);
|
||||||
if (gsk_rounded_rect_is_rectilinear (box))
|
if (gsk_rounded_rect_is_rectilinear (box))
|
||||||
{
|
{
|
||||||
gtk_snapshot_append_color (snapshot,
|
gtk_snapshot_append_color2 (snapshot, &color, &box->bounds);
|
||||||
bg_color,
|
|
||||||
&box->bounds);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gtk_snapshot_push_rounded_clip (snapshot, box);
|
gtk_snapshot_push_rounded_clip (snapshot, box);
|
||||||
gtk_snapshot_append_color (snapshot,
|
gtk_snapshot_append_color2 (snapshot, &color, &box->bounds);
|
||||||
bg_color,
|
|
||||||
&box->bounds);
|
|
||||||
gtk_snapshot_pop (snapshot);
|
gtk_snapshot_pop (snapshot);
|
||||||
}
|
}
|
||||||
|
gdk_color_finish (&color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -248,7 +248,7 @@ gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
|
|||||||
{
|
{
|
||||||
GtkCssStyle *style = boxes->style;
|
GtkCssStyle *style = boxes->style;
|
||||||
GtkCssValue *background_image;
|
GtkCssValue *background_image;
|
||||||
const GdkRGBA *bg_color;
|
const GtkCssColor *bg_color;
|
||||||
const GtkCssValue *box_shadow;
|
const GtkCssValue *box_shadow;
|
||||||
gboolean has_bg_color;
|
gboolean has_bg_color;
|
||||||
gboolean has_bg_image;
|
gboolean has_bg_image;
|
||||||
@ -260,10 +260,10 @@ gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
background_image = style->used->background_image;
|
background_image = style->used->background_image;
|
||||||
bg_color = gtk_css_color_value_get_rgba (style->used->background_color);
|
bg_color = gtk_css_color_value_get_color (style->used->background_color);
|
||||||
box_shadow = style->used->box_shadow;
|
box_shadow = style->used->box_shadow;
|
||||||
|
|
||||||
has_bg_color = !gdk_rgba_is_clear (bg_color);
|
has_bg_color = !gtk_css_color_is_clear (bg_color);
|
||||||
has_bg_image = _gtk_css_image_value_get_image (_gtk_css_array_value_get_nth (background_image, 0)) != NULL;
|
has_bg_image = _gtk_css_image_value_get_image (_gtk_css_array_value_get_nth (background_image, 0)) != NULL;
|
||||||
has_shadow = !gtk_css_shadow_value_is_none (box_shadow);
|
has_shadow = !gtk_css_shadow_value_is_none (box_shadow);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user