Advertisement
Guest User

my little background effect

a guest
Aug 8th, 2012
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 19.51 KB | None | 0 0
  1. diff -ruN a/files/usr/share/cinnamon/applets/calendar@cinnamon.org/applet.js b/files/usr/share/cinnamon/applets/calendar@cinnamon.org/applet.js
  2. --- a/files/usr/share/cinnamon/applets/calendar@cinnamon.org/applet.js  2012-08-04 23:40:06.000000000 -0300
  3. +++ b/files/usr/share/cinnamon/applets/calendar@cinnamon.org/applet.js  2012-08-01 10:46:36.546118615 -0300
  4. @@ -41,6 +41,8 @@
  5.              this._orientation = orientation;
  6.              
  7.              this._initContextMenu();
  8. +            fx = new St.BackgroundEffect();
  9. +            this.menu.actor.add_effect_with_name('blur',fx);
  10.                                      
  11.              this._calendarArea = new St.BoxLayout({name: 'calendarArea' });
  12.              this.menu.addActor(this._calendarArea);
  13. diff -ruN a/files/usr/share/cinnamon/applets/menu@cinnamon.org/applet.js b/files/usr/share/cinnamon/applets/menu@cinnamon.org/applet.js
  14. --- a/files/usr/share/cinnamon/applets/menu@cinnamon.org/applet.js  2012-08-04 23:40:06.000000000 -0300
  15. +++ b/files/usr/share/cinnamon/applets/menu@cinnamon.org/applet.js  2012-08-05 06:18:51.048078727 -0300
  16. @@ -641,7 +641,8 @@
  17.              this.menuManager = new PopupMenu.PopupMenuManager(this);
  18.              this.menu = new Applet.AppletPopupMenu(this, orientation);
  19.              this.menuManager.addMenu(this.menu);  
  20. -                        
  21. +            fx = new St.BackgroundEffect();
  22. +            this.menu.actor.add_effect_with_name('blur',fx);
  23.              this.actor.connect('key-press-event', Lang.bind(this, this._onSourceKeyPress));
  24.              this.showRecent = global.settings.get_boolean("menu-show-recent");
  25.              global.settings.connect("changed::menu-show-recent", Lang.bind(this, function() {
  26. diff -ruN a/src/Makefile.in b/src/Makefile.in
  27. --- a/src/Makefile.in   2012-08-04 23:41:01.000000000 -0300
  28. +++ b/src/Makefile.in   2012-08-01 10:46:36.546118615 -0300
  29. @@ -183,6 +183,7 @@
  30.     $(libgvc_la_LDFLAGS) $(LDFLAGS) -o $@
  31.  libst_1_0_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
  32.  am__objects_7 = libst_1_0_la-st-adjustment.lo libst_1_0_la-st-bin.lo \
  33. +        libst_1_0_la-st-background-effect.lo \
  34.     libst_1_0_la-st-border-image.lo libst_1_0_la-st-box-layout.lo \
  35.     libst_1_0_la-st-box-layout-child.lo libst_1_0_la-st-button.lo \
  36.     libst_1_0_la-st-clipboard.lo libst_1_0_la-st-container.lo \
  37. @@ -574,6 +575,7 @@
  38.  # please, keep this sorted alphabetically
  39.  st_source_h = \
  40.     st/st-adjustment.h          \
  41. +        st/st-background-effect.h               \
  42.     st/st-bin.h             \
  43.     st/st-border-image.h            \
  44.     st/st-box-layout.h          \
  45. @@ -618,6 +620,7 @@
  46.  # please, keep this sorted alphabetically
  47.  st_source_c = \
  48.     st/st-adjustment.c          \
  49. +        st/st-background-effect.c               \
  50.     st/st-bin.c             \
  51.     st/st-border-image.c            \
  52.     st/st-box-layout.c          \
  53. @@ -1162,6 +1165,7 @@
  54.  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgvc_la-gvc-mixer-source.Plo@am__quote@
  55.  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgvc_la-gvc-mixer-stream.Plo@am__quote@
  56.  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libst_1_0_la-st-adjustment.Plo@am__quote@
  57. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libst_1_0_la-st-background-effect.Plo@am__quote@
  58.  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libst_1_0_la-st-bin.Plo@am__quote@
  59.  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libst_1_0_la-st-border-image.Plo@am__quote@
  60.  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libst_1_0_la-st-box-layout-child.Plo@am__quote@
  61. @@ -1492,6 +1496,13 @@
  62.  @AMDEP_TRUE@@am__fastdepCC_FALSE@  DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  63.  @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libst_1_0_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libst_1_0_la-st-adjustment.lo `test -f 'st/st-adjustment.c' || echo '$(srcdir)/'`st/st-adjustment.c
  64.  
  65. +libst_1_0_la-st-background-effect.lo: st/st-background-effect.c
  66. +@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libst_1_0_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libst_1_0_la-st-background-effect.lo -MD -MP -MF $(DEPDIR)/libst_1_0_la-st-background-effect.Tpo -c -o libst_1_0_la-st-background-effect.lo `test -f 'st/st-background-effect.c' || echo '$(srcdir)/'`st/st-background-effect.c
  67. +@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/libst_1_0_la-st-background-effect.Tpo $(DEPDIR)/libst_1_0_la-st-background-effect.Plo
  68. +@AMDEP_TRUE@@am__fastdepCC_FALSE@  $(AM_V_CC)source='st/st-background-effect.c' object='libst_1_0_la-st-background-effect.lo' libtool=yes @AMDEPBACKSLASH@
  69. +@AMDEP_TRUE@@am__fastdepCC_FALSE@  DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  70. +@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libst_1_0_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libst_1_0_la-st-background-effect.lo `test -f 'st/st-background-effect.c' || echo '$(srcdir)/'`st/st-background-effect.c
  71. +
  72.  libst_1_0_la-st-bin.lo: st/st-bin.c
  73.  @am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libst_1_0_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libst_1_0_la-st-bin.lo -MD -MP -MF $(DEPDIR)/libst_1_0_la-st-bin.Tpo -c -o libst_1_0_la-st-bin.lo `test -f 'st/st-bin.c' || echo '$(srcdir)/'`st/st-bin.c
  74.  @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/libst_1_0_la-st-bin.Tpo $(DEPDIR)/libst_1_0_la-st-bin.Plo
  75. diff -ruN a/src/Makefile-st.am b/src/Makefile-st.am
  76. --- a/src/Makefile-st.am    2012-08-04 23:40:06.000000000 -0300
  77. +++ b/src/Makefile-st.am    2012-08-01 10:46:36.550120546 -0300
  78. @@ -67,6 +67,7 @@
  79.  # please, keep this sorted alphabetically
  80.  st_source_h =                  \
  81.     st/st-adjustment.h          \
  82. +        st/st-background-effect.h               \
  83.     st/st-bin.h             \
  84.     st/st-border-image.h            \
  85.     st/st-box-layout.h          \
  86. @@ -124,6 +125,7 @@
  87.  # please, keep this sorted alphabetically
  88.  st_source_c =                  \
  89.     st/st-adjustment.c          \
  90. +        st/st-background-effect.c               \
  91.     st/st-bin.c             \
  92.     st/st-border-image.c            \
  93.     st/st-box-layout.c          \
  94. diff -ruN a/src/st/st-background-effect.c b/src/st/st-background-effect.c
  95. --- a/src/st/st-background-effect.c 1969-12-31 21:00:00.000000000 -0300
  96. +++ b/src/st/st-background-effect.c 2012-08-08 12:49:37.936803035 -0300
  97. @@ -0,0 +1,337 @@
  98. +#include "st-background-effect.h"
  99. +#define ST_BACKGROUND_EFFECT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_BACKGROUND_EFFECT, StBackgroundEffectClass))
  100. +#define ST_IS_BACKGROUND_EFFECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_BACKGROUND_EFFECT))
  101. +#define ST_BACKGROUND_EFFECT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_BACKGROUND_EFFECT, StBackgroundEffectClass))
  102. +
  103. +G_DEFINE_TYPE (StBackgroundEffect, st_background_effect, CLUTTER_TYPE_OFFSCREEN_EFFECT);
  104. +
  105. +#define CLUTTER_ENABLE_EXPERIMENTAL_API
  106. +
  107. +#include "cogl/cogl.h"
  108. +
  109. +static const gchar *box_blur_glsl_declarations =
  110. +    "uniform vec2 pixel_step;\n";
  111. +#define SAMPLE(offx, offy) \
  112. +  "cogl_texel += texture2D (cogl_sampler, cogl_tex_coord.st + pixel_step * " \
  113. +  "vec2 (" G_STRINGIFY (offx) ", " G_STRINGIFY (offy) ") * 2.0);\n"
  114. +static const gchar *box_blur_glsl_shader =
  115. +    "  cogl_texel = texture2D (cogl_sampler, cogl_tex_coord.st);\n"
  116. +    SAMPLE (-1.0, -1.0)
  117. +    SAMPLE ( 0.0, -1.0)
  118. +    SAMPLE (+1.0, -1.0)
  119. +    SAMPLE (-1.0,  0.0)
  120. +    SAMPLE ( 0.0,  0.0)
  121. +    SAMPLE (+1.0,  0.0)
  122. +    SAMPLE (-1.0, +1.0)
  123. +    SAMPLE ( 0.0, +1.0)
  124. +    SAMPLE (+1.0, +1.0)
  125. +    "  cogl_texel /= 10.0;\n";
  126. +#undef SAMPLE
  127. +
  128. +typedef enum
  129. +{
  130. +    COGL_PIPELINE_CULL_FACE_MODE_NONE,
  131. +    COGL_PIPELINE_CULL_FACE_MODE_FRONT,
  132. +    COGL_PIPELINE_CULL_FACE_MODE_BACK,
  133. +    COGL_PIPELINE_CULL_FACE_MODE_BOTH
  134. +} CoglPipelineCullFaceMode;
  135. +
  136. +typedef enum
  137. +{
  138. +    COGL_PIPELINE_FILTER_NEAREST = 0x2600,
  139. +    COGL_PIPELINE_FILTER_LINEAR = 0x2601,
  140. +    COGL_PIPELINE_FILTER_NEAREST_MIPMAP_NEAREST = 0x2700,
  141. +    COGL_PIPELINE_FILTER_LINEAR_MIPMAP_NEAREST = 0x2701,
  142. +    COGL_PIPELINE_FILTER_NEAREST_MIPMAP_LINEAR = 0x2702,
  143. +    COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR = 0x2703
  144. +} CoglPipelineFilter;
  145. +
  146. +static gboolean
  147. +st_background_effect_pre_paint (ClutterEffect *effect)
  148. +{
  149. +    StBackgroundEffect *self = ST_BACKGROUND_EFFECT (effect);
  150. +    ClutterEffectClass *parent_class;
  151. +    gfloat width;
  152. +    gfloat height;
  153. +    gfloat posx;
  154. +    gfloat posy;
  155. +    guchar *data;
  156. +    guint size;
  157. +    guint rowstride;
  158. +    gdouble new_time;
  159. +    gdouble time_used;
  160. +
  161. +    if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (effect)))
  162. +        return FALSE;
  163. +
  164. +    self->actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect));
  165. +    if (self->actor == NULL)
  166. +        return FALSE;
  167. +
  168. +    if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL))
  169. +    {
  170. +        /* if we don't have support for GLSL shaders then we
  171. +         * forcibly disable the ActorMeta
  172. +         */
  173. +        g_warning ("Unable to use the ShaderEffect: the graphics hardware "
  174. +                   "or the current GL driver does not implement support "
  175. +                   "for the GLSL shading language.");
  176. +        clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (effect), FALSE);
  177. +        return FALSE;
  178. +    }
  179. +
  180. +    new_time = clock();
  181. +    time_used = ((double) (new_time - self->old_time)*100) / CLOCKS_PER_SEC;
  182. +    self->old_time = new_time;
  183. +
  184. +    posx = 0.0f;
  185. +    posy = 0.0f;
  186. +
  187. +    width = 0.0f;
  188. +    height = 0.0f;
  189. +
  190. +    clutter_actor_get_transformed_position (self->actor, &posx, &posy);
  191. +    clutter_actor_get_transformed_size (self->actor, &width, &height);
  192. +
  193. +
  194. +    if  (( posx != self->posx_old)||( posy != self->posy_old)||( width != self->width_old)||( height != self->height_old)||(time_used > 50)) // not so fast babe!
  195. +    {
  196. +        self->posx_old = posx;
  197. +        self->posy_old = posy;
  198. +        self->width_old = width;
  199. +        self->height_old = height;
  200. +
  201. +        self->bg_posx_i = posx+2;
  202. +        self->bg_posy_i = posy+2;
  203. +        self->bg_width_i = width-4;
  204. +        self->bg_height_i = height-4;
  205. +
  206. +        size = (self->bg_width_i) * (self->bg_height_i) * 4;
  207. +
  208. +        if (size > 100)
  209. +        {
  210. +            rowstride = (self->bg_width_i) * 4;
  211. +
  212. +            data = g_malloc (size);
  213. +
  214. +            cogl_read_pixels (self->bg_posx_i,
  215. +                              self->bg_posy_i,
  216. +                              self->bg_width_i,
  217. +                              self->bg_height_i,
  218. +                              COGL_READ_PIXELS_COLOR_BUFFER,
  219. +                              COGL_PIXEL_FORMAT_RGBA_8888_PRE,
  220. +                              data);
  221. +
  222. +            if (data != NULL)
  223. +            {
  224. +
  225. +                if (self->bg_texture != NULL)
  226. +                {
  227. +                    cogl_handle_unref (self->bg_texture);
  228. +                    self->bg_texture = NULL;
  229. +                }
  230. +
  231. +                self->bg_texture = cogl_texture_new_from_data  (self->bg_width_i,
  232. +                                   self->bg_height_i,
  233. +                                   COGL_TEXTURE_NO_SLICING,
  234. +                                   COGL_PIXEL_FORMAT_RGBA_8888,
  235. +                                   COGL_PIXEL_FORMAT_ANY,
  236. +                                   rowstride,
  237. +                                   data);
  238. +
  239. +                g_free (data);
  240. +            }
  241. +        }
  242. +    }
  243. +
  244. +    parent_class = CLUTTER_EFFECT_CLASS (st_background_effect_parent_class);
  245. +
  246. +    if (parent_class->pre_paint (effect))
  247. +    {
  248. +        ClutterOffscreenEffect *offscreen_effect =  CLUTTER_OFFSCREEN_EFFECT (effect);
  249. +        CoglHandle fg_texture;
  250. +
  251. +        fg_texture = clutter_offscreen_effect_get_texture (offscreen_effect);
  252. +
  253. +        if (fg_texture != COGL_INVALID_HANDLE)
  254. +        {
  255. +            self->fg_width_i = cogl_texture_get_width (fg_texture);
  256. +            self->fg_height_i = cogl_texture_get_height (fg_texture);
  257. +
  258. +
  259. +            if (self->bg_texture != NULL)
  260. +            {
  261. +
  262. +                if (self->pixel_step_uniform > -1)
  263. +                {
  264. +                    gfloat pixel_step[2];
  265. +
  266. +                    pixel_step[0] = 1.0f / (self->bg_width_i);
  267. +                    pixel_step[1] = 1.0f / (self->bg_height_i);
  268. +
  269. +                    cogl_pipeline_set_uniform_float (self->pipeline1,
  270. +                                                     self->pixel_step_uniform,
  271. +                                                     2,
  272. +                                                     1,
  273. +                                                     pixel_step);
  274. +                }
  275. +
  276. +                cogl_pipeline_set_layer_texture (self->pipeline1, 0, self->bg_texture);
  277. +
  278. +            }
  279. +
  280. +            cogl_pipeline_set_layer_texture (self->pipeline2, 0, fg_texture);
  281. +        }
  282. +        return TRUE;
  283. +    }
  284. +    else
  285. +    {
  286. +        return FALSE;
  287. +    }
  288. +
  289. +}
  290. +
  291. +static void
  292. +st_background_effect_paint_target (ClutterOffscreenEffect *effect)
  293. +{
  294. +    StBackgroundEffect *self = ST_BACKGROUND_EFFECT (effect);
  295. +    guint8 paint_opacity;
  296. +    paint_opacity = clutter_actor_get_paint_opacity (self->actor);
  297. +
  298. +    cogl_pipeline_set_color4ub (self->pipeline1,
  299. +                                paint_opacity,
  300. +                                paint_opacity,
  301. +                                paint_opacity,
  302. +                                paint_opacity);
  303. +
  304. +    cogl_pipeline_set_color4ub (self->pipeline2,
  305. +                                paint_opacity,
  306. +                                paint_opacity,
  307. +                                paint_opacity,
  308. +                                paint_opacity);
  309. +
  310. +    cogl_push_source (self->pipeline1);
  311. +    cogl_rectangle (4.0f, 4.0f, (self->bg_width_i) + 4.0f, (self->bg_height_i) + 4.0f);
  312. +    cogl_pop_source ();
  313. +
  314. +    cogl_push_source (self->pipeline2);
  315. +    cogl_rectangle (0.0f, 0.0f, (self->fg_width_i), (self->fg_height_i));
  316. +    cogl_pop_source ();
  317. +
  318. +    ClutterActor *stage;
  319. +    stage = clutter_actor_get_stage (self->actor);
  320. +    clutter_actor_queue_redraw (stage);
  321. +
  322. +}
  323. +
  324. +static void
  325. +st_background_effect_dispose (GObject *gobject)
  326. +{
  327. +    StBackgroundEffect *self = ST_BACKGROUND_EFFECT (gobject);
  328. +
  329. +    if (self->pipeline1 != NULL)
  330. +    {
  331. +        cogl_object_unref (self->pipeline1);
  332. +        self->pipeline1 = NULL;
  333. +    }
  334. +
  335. +    if (self->pipeline2 != NULL)
  336. +    {
  337. +        cogl_object_unref (self->pipeline2);
  338. +        self->pipeline2 = NULL;
  339. +    }
  340. +
  341. +    if (self->bg_texture != NULL)
  342. +    {
  343. +        cogl_handle_unref (self->bg_texture);
  344. +        self->bg_texture = NULL;
  345. +    }
  346. +
  347. +    G_OBJECT_CLASS (st_background_effect_parent_class)->dispose (gobject);
  348. +}
  349. +
  350. +
  351. +static void
  352. +st_background_effect_class_init (StBackgroundEffectClass *klass)
  353. +{
  354. +    ClutterEffectClass *effect_class = CLUTTER_EFFECT_CLASS (klass);
  355. +    GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
  356. +    ClutterOffscreenEffectClass *offscreen_class;
  357. +
  358. +    effect_class->pre_paint = st_background_effect_pre_paint;
  359. +    gobject_class->dispose = st_background_effect_dispose;
  360. +
  361. +    offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass);
  362. +    offscreen_class->paint_target = st_background_effect_paint_target;
  363. +}
  364. +
  365. +static void
  366. +st_background_effect_init (StBackgroundEffect *self)
  367. +{
  368. +    CoglContext *ctx;
  369. +    StBackgroundEffectClass *klass = ST_BACKGROUND_EFFECT_GET_CLASS (self);
  370. +
  371. +    if (G_UNLIKELY (klass->base_pipeline == NULL))
  372. +    {
  373. +        ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
  374. +
  375. +        klass->base_pipeline = cogl_pipeline_new (ctx);
  376. +    }
  377. +
  378. +    self->pipeline1 = cogl_pipeline_copy (klass->base_pipeline);
  379. +    self->pipeline2 = cogl_pipeline_copy (klass->base_pipeline);
  380. +
  381. +    CoglSnippet *snippet;
  382. +    snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_LOOKUP,
  383. +                                box_blur_glsl_declarations,
  384. +                                NULL);
  385. +
  386. +    cogl_snippet_set_replace (snippet, box_blur_glsl_shader);
  387. +    cogl_pipeline_add_layer_snippet (self->pipeline1, 0, snippet);
  388. +    cogl_object_unref (snippet);
  389. +
  390. +    cogl_pipeline_set_layer_wrap_mode (self->pipeline1, 0,
  391. +                                       COGL_MATERIAL_WRAP_MODE_CLAMP_TO_EDGE);
  392. +
  393. +    cogl_pipeline_set_layer_wrap_mode (self->pipeline2, 0,
  394. +                                       COGL_MATERIAL_WRAP_MODE_CLAMP_TO_EDGE);
  395. +
  396. +    cogl_pipeline_set_cull_face_mode (self->pipeline1,
  397. +                                      COGL_PIPELINE_CULL_FACE_MODE_NONE);
  398. +
  399. +    cogl_pipeline_set_cull_face_mode (self->pipeline2,
  400. +                                      COGL_PIPELINE_CULL_FACE_MODE_NONE);
  401. +
  402. +    cogl_pipeline_set_layer_filters (self->pipeline1, 0,
  403. +                                     COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR,
  404. +                                     COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR);
  405. +
  406. +    cogl_pipeline_set_layer_filters (self->pipeline2, 0,
  407. +                                     COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR,
  408. +                                     COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR);
  409. +
  410. +    cogl_pipeline_set_layer_null_texture (self->pipeline1,
  411. +                                          0,
  412. +                                          COGL_TEXTURE_TYPE_2D);
  413. +
  414. +    cogl_pipeline_set_layer_null_texture (self->pipeline2,
  415. +                                          0,
  416. +                                          COGL_TEXTURE_TYPE_2D);
  417. +
  418. +    self->pixel_step_uniform =
  419. +        cogl_pipeline_get_uniform_location (self->pipeline1, "pixel_step");
  420. +
  421. +    self->bg_texture = NULL;
  422. +
  423. +    self->old_time = 0;
  424. +
  425. +}
  426. +
  427. +
  428. +ClutterEffect *
  429. +st_background_effect_new ()
  430. +{
  431. +    return g_object_new (ST_TYPE_BACKGROUND_EFFECT,
  432. +                         NULL);
  433. +}
  434. +
  435. diff -ruN a/src/st/st-background-effect.h b/src/st/st-background-effect.h
  436. --- a/src/st/st-background-effect.h 1969-12-31 21:00:00.000000000 -0300
  437. +++ b/src/st/st-background-effect.h 2012-08-08 12:15:32.000000000 -0300
  438. @@ -0,0 +1,59 @@
  439. +#ifndef __ST_BACKGROUND_EFFECT_H__
  440. +#define __ST_BACKGROUND_EFFECT_H__
  441. +
  442. +#include <clutter/clutter.h>
  443. +G_BEGIN_DECLS
  444. +#define ST_TYPE_BACKGROUND_EFFECT        (st_background_effect_get_type ())
  445. +#define ST_BACKGROUND_EFFECT(obj)        (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_BACKGROUND_EFFECT, StBackgroundEffect))
  446. +#define ST_IS_BACKGROUND_EFFECT(obj)     (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_BACKGROUND_EFFECT))
  447. +
  448. +typedef struct _StBackgroundEffect        StBackgroundEffect;
  449. +typedef struct _StBackgroundEffectClass   StBackgroundEffectClass;
  450. +
  451. +/* object */
  452. +
  453. +struct _StBackgroundEffect
  454. +{
  455. +    ClutterOffscreenEffect parent_instance;
  456. +
  457. +    ClutterActor *actor;
  458. +    CoglHandle bg_texture;
  459. +    CoglHandle bg_sub_texture;
  460. +
  461. +    gint pixel_step_uniform;
  462. +
  463. +    gint bg_posx_i;
  464. +    gint bg_posy_i;
  465. +
  466. +    gint bg_width_i;
  467. +    gint bg_height_i;
  468. +
  469. +    gint fg_width_i;
  470. +    gint fg_height_i;
  471. +
  472. +    gfloat posx_old;
  473. +    gfloat posy_old;
  474. +    gfloat width_old;
  475. +    gfloat height_old;
  476. +
  477. +    CoglPipeline *pipeline1;
  478. +    CoglPipeline *pipeline2;
  479. +
  480. +    gdouble old_time;
  481. +};
  482. +
  483. +/* class */
  484. +
  485. +struct _StBackgroundEffectClass
  486. +{
  487. +    ClutterOffscreenEffectClass parent_class;
  488. +    CoglPipeline *base_pipeline;
  489. +    gboolean changed;
  490. +};
  491. +
  492. +GType   st_background_effect_get_type (void) G_GNUC_CONST;
  493. +
  494. +ClutterEffect *st_background_effect_new ();
  495. +
  496. +G_END_DECLS
  497. +#endif /* __ST_BACKGROUND_EFFECT_H__ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement