Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] bumpmaps - rework and turn on #8428

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
881f0ee
background effects: rework and turn on.
brownsr Mar 25, 2018
0076013
background-effect: correct some issues codacy found
brownsr Apr 8, 2018
b338ec4
Merge branch 'master' into bge
brownsr Feb 25, 2019
87326b4
background-effect: remove a spurious bumpmap file read
brownsr Feb 25, 2019
75798b8
background-effect: only load the bumpmap file once
brownsr Feb 26, 2019
f85e86e
background-effect: remove graphics settings that make no difference
brownsr Feb 26, 2019
fb0bed8
background-effect: indentation tidy
brownsr Feb 26, 2019
3fa9018
background-effect: add masking for rounded corners
brownsr Feb 26, 2019
de4dd6f
background-effect: add corner masking to blur effect
brownsr Feb 26, 2019
3378afe
background-effects: clear down properly on style change
brownsr Feb 26, 2019
823bc82
background-effect: correction to previous commit
brownsr Feb 26, 2019
b560939
background-effects: ensure effect shows initially
brownsr Feb 26, 2019
a79ca9b
background effects: minor refactoring for legibility
brownsr Feb 26, 2019
105cac3
Revert "background effects: minor refactoring for legibility"
brownsr Feb 27, 2019
50847a9
background-effect: clear off some compile warnings
brownsr Feb 27, 2019
e1808f5
background-effect: correct a compiler warning
brownsr Feb 27, 2019
39ebd3e
background-effect: add documentation comments
brownsr Feb 27, 2019
1d70462
Merge branch 'master' into bge
brownsr Mar 24, 2019
21982d7
st-widget: indentation corrections
brownsr Mar 24, 2019
cb3584a
st-background-effect: remove unnecessary pre paint functions
brownsr Mar 24, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1,025 changes: 500 additions & 525 deletions src/st/st-background-effect.c

Large diffs are not rendered by default.

103 changes: 66 additions & 37 deletions src/st/st-background-effect.h
Expand Up @@ -2,70 +2,99 @@
#define __ST_BACKGROUND_EFFECT_H__

#include <clutter/clutter.h>

G_BEGIN_DECLS
#define ST_TYPE_BACKGROUND_EFFECT (st_background_effect_get_type ())
#define ST_BACKGROUND_EFFECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_BACKGROUND_EFFECT, StBackgroundEffect))
#define ST_IS_BACKGROUND_EFFECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_BACKGROUND_EFFECT))
#define ST_TYPE_BACKGROUND_BLUR_EFFECT (st_background_blur_effect_get_type ())
#define ST_TYPE_BACKGROUND_BUMPMAP_EFFECT (st_background_bumpmap_effect_get_type ())

#define ST_BACKGROUND_BLUR_EFFECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_BACKGROUND_BLUR_EFFECT, StBackgroundBlurEffect))
#define ST_IS_BACKGROUND_BLUR_EFFECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_BACKGROUND_EFFECT))

#define ST_BACKGROUND_BUMPMAP_EFFECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_BACKGROUND_BUMPMAP_EFFECT, StBackgroundBumpmapEffect))
#define ST_IS_BACKGROUND_BUMPMAP_EFFECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_BACKGROUND_BUMPMAP_EFFECT))

typedef struct _StBackgroundEffect StBackgroundEffect;
typedef struct _StBackgroundEffectClass StBackgroundEffectClass;
typedef struct _StBackgroundBlurEffect StBackgroundBlurEffect;
typedef struct _StBackgroundBlurEffectClass StBackgroundBlurEffectClass;

typedef struct _StBackgroundBumpmapEffect StBackgroundBumpmapEffect;
typedef struct _StBackgroundBumpmapEffectClass StBackgroundBumpmapEffectClass;
/* object */

struct _StBackgroundEffect
struct _StBackgroundBlurEffect
{
ClutterOffscreenEffect parent_instance;

ClutterActor *actor;
CoglHandle bg_texture;
CoglHandle bg_sub_texture;
CoglHandle bg_bumpmap;
gchar* bumpmap_location;
CoglTexture *bg_texture;
CoglTexture *corner_texture;

gint pixel_step_uniform0;
gint pixel_step_uniform1;
gint pixel_step_uniform2;
gint BumpTex_uniform;
gint bump_step_uniform;
gint pixel_step_uniform;
gint blur_size;
int border_radius[4];

gint bg_posx_i;
gint bg_posy_i;
gint bg_posx;
gint bg_posy;

gint bg_width_i;
gint bg_height_i;
gint bg_width;
gint bg_height;

gint fg_width_i;
gint fg_height_i;
CoglPipeline *pipeline1;
};

gint bumptex_width_i;
gint bumptex_height_i;
struct _StBackgroundBumpmapEffect
{
ClutterOffscreenEffect parent_instance;

gfloat posx_old;
gfloat posy_old;
gfloat width_old;
gfloat height_old;
ClutterActor *actor;
CoglTexture *bg_texture;
CoglTexture *corner_texture;
CoglHandle bg_bumpmap;
char *bumpmap_path;

CoglPipeline *pipeline0;
CoglPipeline *pipeline1;
CoglPipeline *pipeline2;
CoglPipeline *pipeline3;
CoglPipeline *pipeline4;
gint pixel_step_uniform0;
gint BumpTex_uniform;
gint bump_step_uniform;
int border_radius[4];

gint bg_posx;
gint bg_posy;

gint bg_width;
gint bg_height;

gint bumptex_width;
gint bumptex_height;

glong old_time;
guint8 opacity;
CoglPipeline *pipeline0;
};

/* class */

struct _StBackgroundEffectClass
struct _StBackgroundBlurEffectClass
{
ClutterOffscreenEffectClass parent_class;
CoglPipeline *base_pipeline;
gboolean changed;
};
struct _StBackgroundBumpmapEffectClass
{
ClutterOffscreenEffectClass parent_class;
CoglPipeline *base_pipeline;
gboolean changed;
};

GType st_background_effect_get_type (void) G_GNUC_CONST;
GType st_background_blur_effect_get_type (void) G_GNUC_CONST;
GType st_background_bumpmap_effect_get_type (void) G_GNUC_CONST;

ClutterEffect *st_background_blur_effect_new (void);
ClutterEffect *st_background_bumpmap_effect_new (void);

ClutterEffect *st_background_effect_new (void);
gboolean st_paint_background_blur_effect (StBackgroundBlurEffect *background_blur_effect,
CoglFramebuffer *fb,
const ClutterActorBox *box);
gboolean st_paint_background_bumpmap_effect (StBackgroundBumpmapEffect *background_blur_effect,
CoglFramebuffer *fb,
const ClutterActorBox *box);

G_END_DECLS
#endif /* __ST_BACKGROUND_EFFECT_H__ */
Expand Down
17 changes: 16 additions & 1 deletion src/st/st-theme-node-drawing.c
Expand Up @@ -36,6 +36,7 @@
#include "st-texture-cache.h"
#include "st-theme-node-private.h"
#include "st-cogl-wrapper.h"
#include "st-background-effect.h"

/****
* Rounded corners
Expand Down Expand Up @@ -1999,7 +2000,9 @@ void
st_theme_node_paint (StThemeNode *node,
CoglFramebuffer *fb,
const ClutterActorBox *box,
guint8 paint_opacity)
guint8 paint_opacity,
StBackgroundBlurEffect *background_blur_effect,
StBackgroundBumpmapEffect *background_bumpmap_effect)
{
float width, height;
ClutterActorBox allocation;
Expand Down Expand Up @@ -2043,6 +2046,18 @@ st_theme_node_paint (StThemeNode *node,
* such that it's aligned to the outside edges)
*/


/* if there is a background effect then paint it first as a bottom layer
i.e. the existing background under the actor will be found, an effect
generated and applied to it, and then the new background is written out
over the existing background. */

if (background_blur_effect)
st_paint_background_blur_effect (background_blur_effect, fb, box);

if (background_bumpmap_effect)
st_paint_background_bumpmap_effect (background_bumpmap_effect, fb, box);

if (node->box_shadow_material)
_st_paint_shadow_with_opacity (node->box_shadow,
node->box_shadow_material,
Expand Down
1 change: 1 addition & 0 deletions src/st/st-theme-node-private.h
Expand Up @@ -71,6 +71,7 @@ struct _StThemeNode {

char *background_image;
char *background_bumpmap;
int background_blur;
StBorderImage *border_image;
StShadow *box_shadow;
StShadow *background_image_shadow;
Expand Down
5 changes: 2 additions & 3 deletions src/st/st-theme-node-transition.c
Expand Up @@ -314,10 +314,9 @@ setup_framebuffers (StThemeNodeTransition *transition,
priv->offscreen_box.x2,
priv->offscreen_box.y2, 0.0, 1.0);

st_theme_node_paint (priv->old_theme_node, priv->old_offscreen, allocation, 255);

st_theme_node_paint (priv->new_theme_node, priv->new_offscreen, allocation, 255);
st_theme_node_paint (priv->old_theme_node, priv->old_offscreen, allocation, 255, NULL, NULL);

st_theme_node_paint (priv->new_theme_node, priv->new_offscreen, allocation, 255, NULL, NULL);
return TRUE;
}

Expand Down
5 changes: 5 additions & 0 deletions src/st/st-theme-node.c
Expand Up @@ -1810,6 +1810,7 @@ _st_theme_node_ensure_background (StThemeNode *node)
node->background_gradient_type = ST_GRADIENT_NONE;
node->background_position_set = FALSE;
node->background_size = ST_BACKGROUND_SIZE_AUTO;
node->background_blur = 0;

ensure_properties (node);

Expand Down Expand Up @@ -2070,6 +2071,10 @@ _st_theme_node_ensure_background (StThemeNode *node)
{
get_color_from_term (node, decl->value, &node->background_gradient_end);
}
else if (strcmp (property_name, "-blur") == 0)
{
get_length_from_term_int (node, decl->value, FALSE, &node->background_blur);
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/st/st-theme-node.h
Expand Up @@ -27,6 +27,7 @@
#include "st-border-image.h"
#include "st-icon-colors.h"
#include "st-shadow.h"
#include "st-background-effect.h"

G_BEGIN_DECLS

Expand Down Expand Up @@ -248,7 +249,9 @@ gboolean st_theme_node_paint_equal (StThemeNode *node,
void st_theme_node_paint (StThemeNode *node,
CoglFramebuffer *framebuffer,
const ClutterActorBox *box,
guint8 paint_opacity);
guint8 paint_opacity,
StBackgroundBlurEffect *background_blur_effect,
StBackgroundBumpmapEffect *background_bumpmap_effect);

void st_theme_node_copy_cached_paint_state (StThemeNode *node,
StThemeNode *other);
Expand Down