st/node-drawing: Pass CoglContext around
We already have access to it in most of places, just pass it around instead of going through globals. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3528>
This commit is contained in:
parent
084a1b3be7
commit
343761e70e
@ -293,6 +293,7 @@ typedef struct {
|
|||||||
StIconInfo *icon_info;
|
StIconInfo *icon_info;
|
||||||
StIconColors *colors;
|
StIconColors *colors;
|
||||||
GFile *file;
|
GFile *file;
|
||||||
|
CoglContext *cogl_context;
|
||||||
} AsyncTextureLoadData;
|
} AsyncTextureLoadData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -487,11 +488,12 @@ load_pixbuf_async_finish (StTextureCache *cache, GAsyncResult *result, GError **
|
|||||||
}
|
}
|
||||||
|
|
||||||
static ClutterContent *
|
static ClutterContent *
|
||||||
pixbuf_to_st_content_image (GdkPixbuf *pixbuf,
|
pixbuf_to_st_content_image (GdkPixbuf *pixbuf,
|
||||||
int width,
|
CoglContext *context,
|
||||||
int height,
|
int width,
|
||||||
int paint_scale,
|
int height,
|
||||||
float resource_scale)
|
int paint_scale,
|
||||||
|
float resource_scale)
|
||||||
{
|
{
|
||||||
ClutterContent *image;
|
ClutterContent *image;
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
@ -700,6 +702,7 @@ finish_texture_load (AsyncTextureLoadData *data,
|
|||||||
&orig_key, &value))
|
&orig_key, &value))
|
||||||
{
|
{
|
||||||
image = pixbuf_to_st_content_image (pixbuf,
|
image = pixbuf_to_st_content_image (pixbuf,
|
||||||
|
data->cogl_context,
|
||||||
data->width, data->height,
|
data->width, data->height,
|
||||||
data->paint_scale,
|
data->paint_scale,
|
||||||
data->resource_scale);
|
data->resource_scale);
|
||||||
@ -717,6 +720,7 @@ finish_texture_load (AsyncTextureLoadData *data,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
image = pixbuf_to_st_content_image (pixbuf,
|
image = pixbuf_to_st_content_image (pixbuf,
|
||||||
|
data->cogl_context,
|
||||||
data->width, data->height,
|
data->width, data->height,
|
||||||
data->paint_scale,
|
data->paint_scale,
|
||||||
data->resource_scale);
|
data->resource_scale);
|
||||||
@ -1065,6 +1069,8 @@ st_texture_cache_load_gicon (StTextureCache *cache,
|
|||||||
{
|
{
|
||||||
/* Else, make a new request */
|
/* Else, make a new request */
|
||||||
StIconInfo *info;
|
StIconInfo *info;
|
||||||
|
ClutterContext *context = clutter_actor_get_context (actor);
|
||||||
|
ClutterBackend *clutter_backend = clutter_context_get_backend (context);
|
||||||
|
|
||||||
info = st_icon_theme_lookup_by_gicon_for_scale (theme, icon,
|
info = st_icon_theme_lookup_by_gicon_for_scale (theme, icon,
|
||||||
size, scale,
|
size, scale,
|
||||||
@ -1086,6 +1092,7 @@ st_texture_cache_load_gicon (StTextureCache *cache,
|
|||||||
request->width = request->height = size;
|
request->width = request->height = size;
|
||||||
request->paint_scale = paint_scale;
|
request->paint_scale = paint_scale;
|
||||||
request->resource_scale = resource_scale;
|
request->resource_scale = resource_scale;
|
||||||
|
request->cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
||||||
|
|
||||||
load_texture_async (cache, request);
|
load_texture_async (cache, request);
|
||||||
}
|
}
|
||||||
@ -1100,12 +1107,19 @@ load_from_pixbuf (GdkPixbuf *pixbuf,
|
|||||||
{
|
{
|
||||||
g_autoptr(ClutterContent) image = NULL;
|
g_autoptr(ClutterContent) image = NULL;
|
||||||
ClutterActor *actor;
|
ClutterActor *actor;
|
||||||
|
ClutterContext *context;
|
||||||
image = pixbuf_to_st_content_image (pixbuf, -1, -1, paint_scale, resource_scale);
|
ClutterBackend *backend;
|
||||||
|
CoglContext *cogl_context;
|
||||||
|
|
||||||
actor = g_object_new (CLUTTER_TYPE_ACTOR,
|
actor = g_object_new (CLUTTER_TYPE_ACTOR,
|
||||||
"request-mode", CLUTTER_REQUEST_CONTENT_SIZE,
|
"request-mode", CLUTTER_REQUEST_CONTENT_SIZE,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
context = clutter_actor_get_context (actor);
|
||||||
|
backend = clutter_context_get_backend (context);
|
||||||
|
cogl_context = clutter_backend_get_cogl_context (backend);
|
||||||
|
image = pixbuf_to_st_content_image (pixbuf, cogl_context, -1, -1,
|
||||||
|
paint_scale, resource_scale);
|
||||||
clutter_actor_set_content (actor, image);
|
clutter_actor_set_content (actor, image);
|
||||||
|
|
||||||
return actor;
|
return actor;
|
||||||
@ -1454,6 +1468,8 @@ st_texture_cache_load_file_async (StTextureCache *cache,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
ClutterContext *context = clutter_actor_get_context (actor);
|
||||||
|
ClutterBackend *clutter_backend = clutter_context_get_backend (context);
|
||||||
/* Else, make a new request */
|
/* Else, make a new request */
|
||||||
|
|
||||||
request->cache = cache;
|
request->cache = cache;
|
||||||
@ -1465,6 +1481,7 @@ st_texture_cache_load_file_async (StTextureCache *cache,
|
|||||||
request->height = available_height;
|
request->height = available_height;
|
||||||
request->paint_scale = paint_scale;
|
request->paint_scale = paint_scale;
|
||||||
request->resource_scale = resource_scale;
|
request->resource_scale = resource_scale;
|
||||||
|
request->cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
||||||
|
|
||||||
load_texture_async (cache, request);
|
load_texture_async (cache, request);
|
||||||
}
|
}
|
||||||
@ -1477,6 +1494,7 @@ st_texture_cache_load_file_async (StTextureCache *cache,
|
|||||||
static CoglTexture *
|
static CoglTexture *
|
||||||
st_texture_cache_load_file_sync_to_cogl_texture (StTextureCache *cache,
|
st_texture_cache_load_file_sync_to_cogl_texture (StTextureCache *cache,
|
||||||
StTextureCachePolicy policy,
|
StTextureCachePolicy policy,
|
||||||
|
CoglContext *context,
|
||||||
GFile *file,
|
GFile *file,
|
||||||
int available_width,
|
int available_width,
|
||||||
int available_height,
|
int available_height,
|
||||||
@ -1501,7 +1519,7 @@ st_texture_cache_load_file_sync_to_cogl_texture (StTextureCache *cache,
|
|||||||
if (!pixbuf)
|
if (!pixbuf)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
image = pixbuf_to_st_content_image (pixbuf,
|
image = pixbuf_to_st_content_image (pixbuf, context,
|
||||||
available_height, available_width,
|
available_height, available_width,
|
||||||
paint_scale, resource_scale);
|
paint_scale, resource_scale);
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
@ -1578,6 +1596,7 @@ out:
|
|||||||
/**
|
/**
|
||||||
* st_texture_cache_load_file_to_cogl_texture: (skip)
|
* st_texture_cache_load_file_to_cogl_texture: (skip)
|
||||||
* @cache: A #StTextureCache
|
* @cache: A #StTextureCache
|
||||||
|
* @context: A #CoglContext
|
||||||
* @file: A #GFile in supported image format
|
* @file: A #GFile in supported image format
|
||||||
* @paint_scale: Scale factor of the display
|
* @paint_scale: Scale factor of the display
|
||||||
* @resource_scale: Resource scale factor
|
* @resource_scale: Resource scale factor
|
||||||
@ -1590,6 +1609,7 @@ out:
|
|||||||
*/
|
*/
|
||||||
CoglTexture *
|
CoglTexture *
|
||||||
st_texture_cache_load_file_to_cogl_texture (StTextureCache *cache,
|
st_texture_cache_load_file_to_cogl_texture (StTextureCache *cache,
|
||||||
|
CoglContext *context,
|
||||||
GFile *file,
|
GFile *file,
|
||||||
gint paint_scale,
|
gint paint_scale,
|
||||||
gfloat resource_scale)
|
gfloat resource_scale)
|
||||||
@ -1598,6 +1618,7 @@ st_texture_cache_load_file_to_cogl_texture (StTextureCache *cache,
|
|||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
texture = st_texture_cache_load_file_sync_to_cogl_texture (cache, ST_TEXTURE_CACHE_POLICY_FOREVER,
|
texture = st_texture_cache_load_file_sync_to_cogl_texture (cache, ST_TEXTURE_CACHE_POLICY_FOREVER,
|
||||||
|
context,
|
||||||
file, -1, -1, paint_scale, resource_scale,
|
file, -1, -1, paint_scale, resource_scale,
|
||||||
&error);
|
&error);
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ ClutterActor *st_texture_cache_load_file_async (StTextureCache *cache,
|
|||||||
gfloat resource_scale);
|
gfloat resource_scale);
|
||||||
|
|
||||||
CoglTexture *st_texture_cache_load_file_to_cogl_texture (StTextureCache *cache,
|
CoglTexture *st_texture_cache_load_file_to_cogl_texture (StTextureCache *cache,
|
||||||
|
CoglContext *context,
|
||||||
GFile *file,
|
GFile *file,
|
||||||
gint paint_scale,
|
gint paint_scale,
|
||||||
gfloat resource_scale);
|
gfloat resource_scale);
|
||||||
|
@ -42,6 +42,11 @@
|
|||||||
****/
|
****/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
/*
|
||||||
|
* The context here is not really part of the corner
|
||||||
|
* definition per se, but is used for the drawing part.
|
||||||
|
*/
|
||||||
|
CoglContext *cogl_context;
|
||||||
CoglColor color;
|
CoglColor color;
|
||||||
CoglColor border_color_1;
|
CoglColor border_color_1;
|
||||||
CoglColor border_color_2;
|
CoglColor border_color_2;
|
||||||
@ -75,8 +80,6 @@ elliptical_arc (cairo_t *cr,
|
|||||||
static CoglTexture *
|
static CoglTexture *
|
||||||
create_corner_pipeline (StCornerSpec *corner)
|
create_corner_pipeline (StCornerSpec *corner)
|
||||||
{
|
{
|
||||||
ClutterBackend *backend = clutter_get_default_backend ();
|
|
||||||
CoglContext *ctx = clutter_backend_get_cogl_context (backend);
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
CoglTexture *texture;
|
CoglTexture *texture;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
@ -180,7 +183,7 @@ create_corner_pipeline (StCornerSpec *corner)
|
|||||||
|
|
||||||
cairo_surface_destroy (surface);
|
cairo_surface_destroy (surface);
|
||||||
|
|
||||||
texture = cogl_texture_2d_new_from_data (ctx, size, size,
|
texture = cogl_texture_2d_new_from_data (corner->cogl_context, size, size,
|
||||||
COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT,
|
COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT,
|
||||||
rowstride,
|
rowstride,
|
||||||
data,
|
data,
|
||||||
@ -362,6 +365,7 @@ st_theme_node_get_corner_border_widths (StThemeNode *node,
|
|||||||
|
|
||||||
static CoglPipeline *
|
static CoglPipeline *
|
||||||
st_theme_node_lookup_corner (StThemeNode *node,
|
st_theme_node_lookup_corner (StThemeNode *node,
|
||||||
|
CoglContext *cogl_context,
|
||||||
float width,
|
float width,
|
||||||
float height,
|
float height,
|
||||||
float resource_scale,
|
float resource_scale,
|
||||||
@ -384,6 +388,7 @@ st_theme_node_lookup_corner (StThemeNode *node,
|
|||||||
corner.radius = radius[corner_id];
|
corner.radius = radius[corner_id];
|
||||||
corner.color = node->background_color;
|
corner.color = node->background_color;
|
||||||
corner.resource_scale = resource_scale;
|
corner.resource_scale = resource_scale;
|
||||||
|
corner.cogl_context = cogl_context;
|
||||||
st_theme_node_get_corner_border_widths (node, corner_id,
|
st_theme_node_get_corner_border_widths (node, corner_id,
|
||||||
&corner.border_width_1,
|
&corner.border_width_1,
|
||||||
&corner.border_width_2);
|
&corner.border_width_2);
|
||||||
@ -1064,12 +1069,11 @@ paint_inset_box_shadow_to_cairo_context (StThemeNode *node,
|
|||||||
*/
|
*/
|
||||||
static CoglTexture *
|
static CoglTexture *
|
||||||
st_theme_node_prerender_background (StThemeNode *node,
|
st_theme_node_prerender_background (StThemeNode *node,
|
||||||
|
CoglContext *ctx,
|
||||||
float actor_width,
|
float actor_width,
|
||||||
float actor_height,
|
float actor_height,
|
||||||
float resource_scale)
|
float resource_scale)
|
||||||
{
|
{
|
||||||
ClutterBackend *backend = clutter_get_default_backend ();
|
|
||||||
CoglContext *ctx = clutter_backend_get_cogl_context (backend);
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
StBorderImage *border_image;
|
StBorderImage *border_image;
|
||||||
CoglTexture *texture;
|
CoglTexture *texture;
|
||||||
@ -1421,6 +1425,7 @@ st_theme_node_prerender_background (StThemeNode *node,
|
|||||||
static void
|
static void
|
||||||
st_theme_node_maybe_prerender_background (StThemeNodePaintState *state,
|
st_theme_node_maybe_prerender_background (StThemeNodePaintState *state,
|
||||||
StThemeNode *node,
|
StThemeNode *node,
|
||||||
|
CoglContext *cogl_context,
|
||||||
float width,
|
float width,
|
||||||
float height,
|
float height,
|
||||||
float resource_scale)
|
float resource_scale)
|
||||||
@ -1477,13 +1482,21 @@ st_theme_node_maybe_prerender_background (StThemeNodePaintState *state,
|
|||||||
g_clear_object (&state->corner_pipeline[corner_id]);
|
g_clear_object (&state->corner_pipeline[corner_id]);
|
||||||
|
|
||||||
state->corner_pipeline[ST_CORNER_TOPLEFT] =
|
state->corner_pipeline[ST_CORNER_TOPLEFT] =
|
||||||
st_theme_node_lookup_corner (node, width, height, resource_scale, ST_CORNER_TOPLEFT);
|
st_theme_node_lookup_corner (node, cogl_context,
|
||||||
|
width, height, resource_scale,
|
||||||
|
ST_CORNER_TOPLEFT);
|
||||||
state->corner_pipeline[ST_CORNER_TOPRIGHT] =
|
state->corner_pipeline[ST_CORNER_TOPRIGHT] =
|
||||||
st_theme_node_lookup_corner (node, width, height, resource_scale, ST_CORNER_TOPRIGHT);
|
st_theme_node_lookup_corner (node, cogl_context,
|
||||||
|
width, height, resource_scale,
|
||||||
|
ST_CORNER_TOPRIGHT);
|
||||||
state->corner_pipeline[ST_CORNER_BOTTOMRIGHT] =
|
state->corner_pipeline[ST_CORNER_BOTTOMRIGHT] =
|
||||||
st_theme_node_lookup_corner (node, width, height, resource_scale, ST_CORNER_BOTTOMRIGHT);
|
st_theme_node_lookup_corner (node, cogl_context,
|
||||||
|
width, height, resource_scale,
|
||||||
|
ST_CORNER_BOTTOMRIGHT);
|
||||||
state->corner_pipeline[ST_CORNER_BOTTOMLEFT] =
|
state->corner_pipeline[ST_CORNER_BOTTOMLEFT] =
|
||||||
st_theme_node_lookup_corner (node, width, height, resource_scale, ST_CORNER_BOTTOMLEFT);
|
st_theme_node_lookup_corner (node, cogl_context,
|
||||||
|
width, height, resource_scale,
|
||||||
|
ST_CORNER_BOTTOMLEFT);
|
||||||
|
|
||||||
/* Use cairo to prerender the node if there is a gradient, or
|
/* Use cairo to prerender the node if there is a gradient, or
|
||||||
* background image with borders and/or rounded corners,
|
* background image with borders and/or rounded corners,
|
||||||
@ -1499,7 +1512,9 @@ st_theme_node_maybe_prerender_background (StThemeNodePaintState *state,
|
|||||||
|| (st_theme_node_get_background_image (node) && (has_border || has_border_radius))
|
|| (st_theme_node_get_background_image (node) && (has_border || has_border_radius))
|
||||||
|| has_large_corners)
|
|| has_large_corners)
|
||||||
{
|
{
|
||||||
state->prerendered_texture = st_theme_node_prerender_background (node, width, height, resource_scale);
|
state->prerendered_texture = st_theme_node_prerender_background (node, cogl_context,
|
||||||
|
width, height,
|
||||||
|
resource_scale);
|
||||||
|
|
||||||
if (state->prerendered_texture)
|
if (state->prerendered_texture)
|
||||||
state->prerendered_pipeline = _st_create_texture_pipeline (state->prerendered_texture);
|
state->prerendered_pipeline = _st_create_texture_pipeline (state->prerendered_texture);
|
||||||
@ -1523,6 +1538,7 @@ st_theme_node_invalidate_border_image (StThemeNode *node)
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
st_theme_node_load_border_image (StThemeNode *node,
|
st_theme_node_load_border_image (StThemeNode *node,
|
||||||
|
CoglContext *cogl_context,
|
||||||
gfloat resource_scale)
|
gfloat resource_scale)
|
||||||
{
|
{
|
||||||
if (node->border_slices_texture == NULL)
|
if (node->border_slices_texture == NULL)
|
||||||
@ -1537,6 +1553,7 @@ st_theme_node_load_border_image (StThemeNode *node,
|
|||||||
file = st_border_image_get_file (border_image);
|
file = st_border_image_get_file (border_image);
|
||||||
|
|
||||||
node->border_slices_texture = st_texture_cache_load_file_to_cogl_texture (st_texture_cache_get_default (),
|
node->border_slices_texture = st_texture_cache_load_file_to_cogl_texture (st_texture_cache_get_default (),
|
||||||
|
cogl_context,
|
||||||
file,
|
file,
|
||||||
node->cached_scale_factor,
|
node->cached_scale_factor,
|
||||||
resource_scale);
|
resource_scale);
|
||||||
@ -1560,6 +1577,7 @@ st_theme_node_invalidate_background_image (StThemeNode *node)
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
st_theme_node_load_background_image (StThemeNode *node,
|
st_theme_node_load_background_image (StThemeNode *node,
|
||||||
|
CoglContext *cogl_context,
|
||||||
ClutterPaintContext *paint_context,
|
ClutterPaintContext *paint_context,
|
||||||
float resource_scale)
|
float resource_scale)
|
||||||
{
|
{
|
||||||
@ -1574,6 +1592,7 @@ st_theme_node_load_background_image (StThemeNode *node,
|
|||||||
|
|
||||||
background_image_shadow_spec = st_theme_node_get_background_image_shadow (node);
|
background_image_shadow_spec = st_theme_node_get_background_image_shadow (node);
|
||||||
node->background_texture = st_texture_cache_load_file_to_cogl_texture (st_texture_cache_get_default (),
|
node->background_texture = st_texture_cache_load_file_to_cogl_texture (st_texture_cache_get_default (),
|
||||||
|
cogl_context,
|
||||||
background_image,
|
background_image,
|
||||||
node->cached_scale_factor,
|
node->cached_scale_factor,
|
||||||
resource_scale);
|
resource_scale);
|
||||||
@ -1627,11 +1646,13 @@ st_theme_node_invalidate_resources_for_file (StThemeNode *node,
|
|||||||
|
|
||||||
static void st_theme_node_compute_maximum_borders (StThemeNodePaintState *state);
|
static void st_theme_node_compute_maximum_borders (StThemeNodePaintState *state);
|
||||||
static void st_theme_node_prerender_shadow (StThemeNodePaintState *state,
|
static void st_theme_node_prerender_shadow (StThemeNodePaintState *state,
|
||||||
|
CoglContext *cogl_context,
|
||||||
ClutterPaintContext *paint_context);
|
ClutterPaintContext *paint_context);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
st_theme_node_render_resources (StThemeNodePaintState *state,
|
st_theme_node_render_resources (StThemeNodePaintState *state,
|
||||||
StThemeNode *node,
|
StThemeNode *node,
|
||||||
|
CoglContext *cogl_context,
|
||||||
ClutterPaintContext *paint_context,
|
ClutterPaintContext *paint_context,
|
||||||
float width,
|
float width,
|
||||||
float height,
|
float height,
|
||||||
@ -1659,13 +1680,14 @@ st_theme_node_render_resources (StThemeNodePaintState *state,
|
|||||||
box_shadow_spec = st_theme_node_get_box_shadow (node);
|
box_shadow_spec = st_theme_node_get_box_shadow (node);
|
||||||
has_inset_box_shadow = box_shadow_spec && box_shadow_spec->inset;
|
has_inset_box_shadow = box_shadow_spec && box_shadow_spec->inset;
|
||||||
|
|
||||||
st_theme_node_maybe_prerender_background (state, node, width, height, resource_scale);
|
st_theme_node_maybe_prerender_background (state, node, cogl_context,
|
||||||
|
width, height, resource_scale);
|
||||||
|
|
||||||
if (box_shadow_spec && !has_inset_box_shadow)
|
if (box_shadow_spec && !has_inset_box_shadow)
|
||||||
{
|
{
|
||||||
st_theme_node_compute_maximum_borders (state);
|
st_theme_node_compute_maximum_borders (state);
|
||||||
|
|
||||||
if (st_theme_node_load_border_image (node, resource_scale))
|
if (st_theme_node_load_border_image (node, cogl_context, resource_scale))
|
||||||
state->box_shadow_pipeline = _st_create_shadow_pipeline (box_shadow_spec,
|
state->box_shadow_pipeline = _st_create_shadow_pipeline (box_shadow_spec,
|
||||||
paint_context,
|
paint_context,
|
||||||
node->border_slices_texture,
|
node->border_slices_texture,
|
||||||
@ -1676,7 +1698,7 @@ st_theme_node_render_resources (StThemeNodePaintState *state,
|
|||||||
state->prerendered_texture,
|
state->prerendered_texture,
|
||||||
state->resource_scale);
|
state->resource_scale);
|
||||||
else
|
else
|
||||||
st_theme_node_prerender_shadow (state, paint_context);
|
st_theme_node_prerender_shadow (state, cogl_context, paint_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we don't have cached textures yet, check whether we can cache
|
/* If we don't have cached textures yet, check whether we can cache
|
||||||
@ -1696,6 +1718,7 @@ st_theme_node_render_resources (StThemeNodePaintState *state,
|
|||||||
static void
|
static void
|
||||||
st_theme_node_update_resources (StThemeNodePaintState *state,
|
st_theme_node_update_resources (StThemeNodePaintState *state,
|
||||||
StThemeNode *node,
|
StThemeNode *node,
|
||||||
|
CoglContext *cogl_context,
|
||||||
ClutterPaintContext *paint_context,
|
ClutterPaintContext *paint_context,
|
||||||
float width,
|
float width,
|
||||||
float height,
|
float height,
|
||||||
@ -1728,7 +1751,8 @@ st_theme_node_update_resources (StThemeNodePaintState *state,
|
|||||||
|
|
||||||
box_shadow_spec = st_theme_node_get_box_shadow (node);
|
box_shadow_spec = st_theme_node_get_box_shadow (node);
|
||||||
|
|
||||||
st_theme_node_maybe_prerender_background (state, node, width, height, resource_scale);
|
st_theme_node_maybe_prerender_background (state, node, cogl_context,
|
||||||
|
width, height, resource_scale);
|
||||||
|
|
||||||
if (had_box_shadow)
|
if (had_box_shadow)
|
||||||
state->box_shadow_pipeline = _st_create_shadow_pipeline (box_shadow_spec,
|
state->box_shadow_pipeline = _st_create_shadow_pipeline (box_shadow_spec,
|
||||||
@ -2480,18 +2504,16 @@ st_theme_node_paint_sliced_shadow (StThemeNodePaintState *state,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
st_theme_node_prerender_shadow (StThemeNodePaintState *state,
|
st_theme_node_prerender_shadow (StThemeNodePaintState *state,
|
||||||
|
CoglContext *ctx,
|
||||||
ClutterPaintContext *paint_context)
|
ClutterPaintContext *paint_context)
|
||||||
{
|
{
|
||||||
StThemeNode *node = state->node;
|
StThemeNode *node = state->node;
|
||||||
CoglContext *ctx;
|
|
||||||
int fb_width, fb_height;
|
int fb_width, fb_height;
|
||||||
CoglTexture *buffer;
|
CoglTexture *buffer;
|
||||||
CoglOffscreen *offscreen = NULL;
|
CoglOffscreen *offscreen = NULL;
|
||||||
CoglFramebuffer *framebuffer;
|
CoglFramebuffer *framebuffer;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
|
||||||
|
|
||||||
/* Render offscreen */
|
/* Render offscreen */
|
||||||
fb_width = ceilf (state->box_shadow_width * state->resource_scale);
|
fb_width = ceilf (state->box_shadow_width * state->resource_scale);
|
||||||
fb_height = ceilf (state->box_shadow_height * state->resource_scale);
|
fb_height = ceilf (state->box_shadow_height * state->resource_scale);
|
||||||
@ -2794,6 +2816,7 @@ st_theme_node_needs_new_box_shadow_for_size (StThemeNodePaintState *state,
|
|||||||
void
|
void
|
||||||
st_theme_node_paint (StThemeNode *node,
|
st_theme_node_paint (StThemeNode *node,
|
||||||
StThemeNodePaintState *state,
|
StThemeNodePaintState *state,
|
||||||
|
CoglContext *cogl_context,
|
||||||
ClutterPaintContext *paint_context,
|
ClutterPaintContext *paint_context,
|
||||||
ClutterPaintNode *root,
|
ClutterPaintNode *root,
|
||||||
const ClutterActorBox *box,
|
const ClutterActorBox *box,
|
||||||
@ -2831,7 +2854,7 @@ st_theme_node_paint (StThemeNode *node,
|
|||||||
fabsf (resource_scale - state->resource_scale) < FLT_EPSILON)
|
fabsf (resource_scale - state->resource_scale) < FLT_EPSILON)
|
||||||
st_theme_node_paint_state_copy (state, &node->cached_state);
|
st_theme_node_paint_state_copy (state, &node->cached_state);
|
||||||
else
|
else
|
||||||
st_theme_node_render_resources (state, node, paint_context,
|
st_theme_node_render_resources (state, node, cogl_context, paint_context,
|
||||||
width, height, resource_scale);
|
width, height, resource_scale);
|
||||||
|
|
||||||
node->rendered_once = TRUE;
|
node->rendered_once = TRUE;
|
||||||
@ -2839,7 +2862,7 @@ st_theme_node_paint (StThemeNode *node,
|
|||||||
else if (state->alloc_width != width || state->alloc_height != height ||
|
else if (state->alloc_width != width || state->alloc_height != height ||
|
||||||
fabsf (state->resource_scale - resource_scale) > FLT_EPSILON)
|
fabsf (state->resource_scale - resource_scale) > FLT_EPSILON)
|
||||||
{
|
{
|
||||||
st_theme_node_update_resources (state, node, paint_context,
|
st_theme_node_update_resources (state, node, cogl_context, paint_context,
|
||||||
width, height, resource_scale);
|
width, height, resource_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2886,7 +2909,7 @@ st_theme_node_paint (StThemeNode *node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state->prerendered_pipeline != NULL ||
|
if (state->prerendered_pipeline != NULL ||
|
||||||
st_theme_node_load_border_image (node, resource_scale))
|
st_theme_node_load_border_image (node, cogl_context, resource_scale))
|
||||||
{
|
{
|
||||||
if (state->prerendered_pipeline != NULL)
|
if (state->prerendered_pipeline != NULL)
|
||||||
{
|
{
|
||||||
@ -2914,7 +2937,7 @@ st_theme_node_paint (StThemeNode *node,
|
|||||||
st_theme_node_paint_outline (node, root, box, paint_opacity);
|
st_theme_node_paint_outline (node, root, box, paint_opacity);
|
||||||
|
|
||||||
if (state->prerendered_pipeline == NULL &&
|
if (state->prerendered_pipeline == NULL &&
|
||||||
st_theme_node_load_background_image (node, paint_context, resource_scale))
|
st_theme_node_load_background_image (node, cogl_context, paint_context, resource_scale))
|
||||||
{
|
{
|
||||||
ClutterActorBox background_box;
|
ClutterActorBox background_box;
|
||||||
ClutterActorBox texture_coords;
|
ClutterActorBox texture_coords;
|
||||||
|
@ -235,6 +235,7 @@ st_theme_node_transition_get_paint_box (StThemeNodeTransition *transition,
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
setup_framebuffers (StThemeNodeTransition *transition,
|
setup_framebuffers (StThemeNodeTransition *transition,
|
||||||
|
CoglContext *ctx,
|
||||||
ClutterPaintContext *paint_context,
|
ClutterPaintContext *paint_context,
|
||||||
ClutterPaintNode *node,
|
ClutterPaintNode *node,
|
||||||
const ClutterActorBox *allocation,
|
const ClutterActorBox *allocation,
|
||||||
@ -243,14 +244,12 @@ setup_framebuffers (StThemeNodeTransition *transition,
|
|||||||
g_autoptr (ClutterPaintNode) old_layer_node = NULL;
|
g_autoptr (ClutterPaintNode) old_layer_node = NULL;
|
||||||
g_autoptr (ClutterPaintNode) new_layer_node = NULL;
|
g_autoptr (ClutterPaintNode) new_layer_node = NULL;
|
||||||
CoglPipeline *noop_pipeline;
|
CoglPipeline *noop_pipeline;
|
||||||
CoglContext *ctx;
|
|
||||||
guint width, height;
|
guint width, height;
|
||||||
GError *catch_error = NULL;
|
GError *catch_error = NULL;
|
||||||
|
|
||||||
/* template pipeline to avoid unnecessary shader compilation */
|
/* template pipeline to avoid unnecessary shader compilation */
|
||||||
static CoglPipeline *pipeline_template = NULL;
|
static CoglPipeline *pipeline_template = NULL;
|
||||||
|
|
||||||
ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
|
||||||
width = ceilf ((transition->offscreen_box.x2 - transition->offscreen_box.x1) * resource_scale);
|
width = ceilf ((transition->offscreen_box.x2 - transition->offscreen_box.x1) * resource_scale);
|
||||||
height = ceilf ((transition->offscreen_box.y2 - transition->offscreen_box.y1) * resource_scale);
|
height = ceilf ((transition->offscreen_box.y2 - transition->offscreen_box.y1) * resource_scale);
|
||||||
|
|
||||||
@ -324,7 +323,7 @@ setup_framebuffers (StThemeNodeTransition *transition,
|
|||||||
clutter_paint_node_add_child (node, old_layer_node);
|
clutter_paint_node_add_child (node, old_layer_node);
|
||||||
|
|
||||||
st_theme_node_paint (transition->old_theme_node, &transition->old_paint_state,
|
st_theme_node_paint (transition->old_theme_node, &transition->old_paint_state,
|
||||||
paint_context,
|
ctx, paint_context,
|
||||||
old_layer_node, allocation, 255, resource_scale);
|
old_layer_node, allocation, 255, resource_scale);
|
||||||
|
|
||||||
new_layer_node = clutter_layer_node_new_to_framebuffer (transition->new_offscreen,
|
new_layer_node = clutter_layer_node_new_to_framebuffer (transition->new_offscreen,
|
||||||
@ -336,7 +335,7 @@ setup_framebuffers (StThemeNodeTransition *transition,
|
|||||||
transition->offscreen_box.x2,
|
transition->offscreen_box.x2,
|
||||||
transition->offscreen_box.y2, 0.0, 1.0);
|
transition->offscreen_box.y2, 0.0, 1.0);
|
||||||
st_theme_node_paint (transition->new_theme_node, &transition->new_paint_state,
|
st_theme_node_paint (transition->new_theme_node, &transition->new_paint_state,
|
||||||
paint_context,
|
ctx, paint_context,
|
||||||
new_layer_node, allocation, 255, resource_scale);
|
new_layer_node, allocation, 255, resource_scale);
|
||||||
|
|
||||||
g_clear_object (&noop_pipeline);
|
g_clear_object (&noop_pipeline);
|
||||||
@ -346,6 +345,7 @@ setup_framebuffers (StThemeNodeTransition *transition,
|
|||||||
|
|
||||||
void
|
void
|
||||||
st_theme_node_transition_paint (StThemeNodeTransition *transition,
|
st_theme_node_transition_paint (StThemeNodeTransition *transition,
|
||||||
|
CoglContext *cogl_context,
|
||||||
ClutterPaintContext *paint_context,
|
ClutterPaintContext *paint_context,
|
||||||
ClutterPaintNode *node,
|
ClutterPaintNode *node,
|
||||||
ClutterActorBox *allocation,
|
ClutterActorBox *allocation,
|
||||||
@ -373,6 +373,7 @@ st_theme_node_transition_paint (StThemeNodeTransition *transition,
|
|||||||
calculate_offscreen_box (transition, allocation);
|
calculate_offscreen_box (transition, allocation);
|
||||||
transition->needs_setup = clutter_actor_box_get_area (&transition->offscreen_box) == 0 ||
|
transition->needs_setup = clutter_actor_box_get_area (&transition->offscreen_box) == 0 ||
|
||||||
!setup_framebuffers (transition,
|
!setup_framebuffers (transition,
|
||||||
|
cogl_context,
|
||||||
paint_context,
|
paint_context,
|
||||||
node,
|
node,
|
||||||
allocation,
|
allocation,
|
||||||
|
@ -41,6 +41,7 @@ void st_theme_node_transition_update (StThemeNodeTransition *transition,
|
|||||||
StThemeNode *new_node);
|
StThemeNode *new_node);
|
||||||
|
|
||||||
void st_theme_node_transition_paint (StThemeNodeTransition *transition,
|
void st_theme_node_transition_paint (StThemeNodeTransition *transition,
|
||||||
|
CoglContext *cogl_context,
|
||||||
ClutterPaintContext *paint_context,
|
ClutterPaintContext *paint_context,
|
||||||
ClutterPaintNode *node,
|
ClutterPaintNode *node,
|
||||||
ClutterActorBox *allocation,
|
ClutterActorBox *allocation,
|
||||||
|
@ -344,6 +344,7 @@ gboolean st_theme_node_paint_equal (StThemeNode *node,
|
|||||||
*/
|
*/
|
||||||
void st_theme_node_paint (StThemeNode *node,
|
void st_theme_node_paint (StThemeNode *node,
|
||||||
StThemeNodePaintState *state,
|
StThemeNodePaintState *state,
|
||||||
|
CoglContext *cogl_context,
|
||||||
ClutterPaintContext *paint_context,
|
ClutterPaintContext *paint_context,
|
||||||
ClutterPaintNode *root,
|
ClutterPaintNode *root,
|
||||||
const ClutterActorBox *box,
|
const ClutterActorBox *box,
|
||||||
|
@ -404,7 +404,13 @@ st_widget_paint_background (StWidget *widget,
|
|||||||
ClutterActorBox allocation;
|
ClutterActorBox allocation;
|
||||||
float resource_scale;
|
float resource_scale;
|
||||||
guint8 opacity;
|
guint8 opacity;
|
||||||
|
ClutterContext *clutter_context;
|
||||||
|
ClutterBackend *clutter_backend;
|
||||||
|
CoglContext *cogl_context;
|
||||||
|
|
||||||
|
clutter_context = clutter_actor_get_context (CLUTTER_ACTOR (widget));
|
||||||
|
clutter_backend = clutter_context_get_backend (clutter_context);
|
||||||
|
cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
||||||
resource_scale = clutter_actor_get_resource_scale (CLUTTER_ACTOR (widget));
|
resource_scale = clutter_actor_get_resource_scale (CLUTTER_ACTOR (widget));
|
||||||
|
|
||||||
theme_node = st_widget_get_theme_node (widget);
|
theme_node = st_widget_get_theme_node (widget);
|
||||||
@ -415,6 +421,7 @@ st_widget_paint_background (StWidget *widget,
|
|||||||
|
|
||||||
if (priv->transition_animation)
|
if (priv->transition_animation)
|
||||||
st_theme_node_transition_paint (priv->transition_animation,
|
st_theme_node_transition_paint (priv->transition_animation,
|
||||||
|
cogl_context,
|
||||||
paint_context,
|
paint_context,
|
||||||
node,
|
node,
|
||||||
&allocation,
|
&allocation,
|
||||||
@ -423,6 +430,7 @@ st_widget_paint_background (StWidget *widget,
|
|||||||
else
|
else
|
||||||
st_theme_node_paint (theme_node,
|
st_theme_node_paint (theme_node,
|
||||||
current_paint_state (widget),
|
current_paint_state (widget),
|
||||||
|
cogl_context,
|
||||||
paint_context,
|
paint_context,
|
||||||
node,
|
node,
|
||||||
&allocation,
|
&allocation,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user