1
0
Fork 0
Commit graph

21 commits

Author SHA1 Message Date
Jasper St. Pierre
fd375a7bc9 blur-effect: Fix the blur filter
Make sure we don't sample the center twice, and don't sample things
that aren't our immediate neighbors.

https://bugzilla.gnome.org/show_bug.cgi?id=683076
2012-09-03 21:18:43 +01:00
Robert Bragg
fbf94310fc Pass a CoglContext when calling cogl_pipeline_new
The experimental cogl_pipeline_new() api was recently changed so it
explicitly takes a CoglContext. This updates all calls to
cogl_pipeline_new() in clutter accordingly.
2012-02-21 17:46:11 +00:00
Emmanuele Bassi
b1ff53d980 effects: Delay the creation of the base pipeline
Unconditionally creating CoglPipeline and CoglSnippets inside the class
initialization functions does not seem to be enough when dealing with
headless builds.

Our last resort is to lazily create the base pipeline the first time we
try to copy it, during the instance initialization.
2012-02-15 09:34:27 +00:00
Emmanuele Bassi
c1a57e537b Do not check for features inside class initialization
The class initialization function may be called when Clutter hasn't been
fully initialized — for instance, when scanning the source with gtk-doc
or with the introspection scanner.
2012-02-14 17:14:25 +00:00
Neil Roberts
3218cd6865 Convert all of the internal shader-based effects to use snippets
This converts the blur, colorize and desaturate effects to use
snippets instead of CoglPrograms. Cogl can handle the snippets much
more efficiently than programs so this should be a performance win. It
also fixes the problem that Cogl would end up recompiling the program
for every instance of the effects because Clutter was not reusing the
same program.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2012-02-14 12:09:32 +00:00
Neil Roberts
b4887c3699 blur-effect: Use the texture size to work out the x/y step
The blur effect needs to pass a uniform to the GLSL shader so that it
can know the texture coordinate offset from one texel to another. To
calculate this the blur effect was previously using the allocation
size of the actor rounded up to the next power of two. Presumably the
assumption was that Cogl would round up the size of the texture to the
next power of two when allocating the texture. However this is not be
true if the driver supports NPOT textures. Also it doesn't take into
account the paint volume of the actor which may cause the texture to
be a completely different size. This patch just changes to directly
use the size of the texture.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2012-02-14 12:09:31 +00:00
Robert Bragg
63cc5ab698 blur: don't accumulate texture padding twice
This removes the create_texture implementation for ClutterBlurEffect
because we already account for padding in the get_paint_volume
implementation so we were creating textures larger than necessary.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-10-19 15:27:03 +01:00
Emmanuele Bassi
ca092477c2 Appease the gods in introspection
Reduce the amount of bogus warnings g-ir-scanner prints out.
2011-01-20 16:35:26 +00:00
Emmanuele Bassi
e5da5b0907 shaders: Fix the usage of the Cogl GLSL variables 2010-11-17 12:47:46 +00:00
Robert Bragg
5f30835eae cogl-shader: Prepend boilerplate for portable shaders
We now prepend a set of defines to any given GLSL shader so that we can
define builtin uniforms/attributes within the "cogl" namespace that we
can use to provide compatibility across a range of the earlier versions
of GLSL.

This updates test-cogl-shader-glsl.c and test-shader.c so they no longer
needs to special case GLES vs GL when splicing together its shaders as
well as the blur, colorize and desaturate effects.

To get a feel for the new, portable uniform/attribute names here are the
defines for OpenGL vertex shaders:

 #define cogl_position_in gl_Vertex
 #define cogl_color_in gl_Color
 #define cogl_tex_coord_in  gl_MultiTexCoord0
 #define cogl_tex_coord0_in gl_MultiTexCoord0
 #define cogl_tex_coord1_in gl_MultiTexCoord1
 #define cogl_tex_coord2_in gl_MultiTexCoord2
 #define cogl_tex_coord3_in gl_MultiTexCoord3
 #define cogl_tex_coord4_in gl_MultiTexCoord4
 #define cogl_tex_coord5_in gl_MultiTexCoord5
 #define cogl_tex_coord6_in gl_MultiTexCoord6
 #define cogl_tex_coord7_in gl_MultiTexCoord7
 #define cogl_normal_in gl_Normal

 #define cogl_position_out gl_Position
 #define cogl_point_size_out gl_PointSize
 #define cogl_color_out gl_FrontColor
 #define cogl_tex_coord_out gl_TexCoord

 #define cogl_modelview_matrix gl_ModelViewMatrix
 #define cogl_modelview_projection_matrix gl_ModelViewProjectionMatrix
 #define cogl_projection_matrix gl_ProjectionMatrix
 #define cogl_texture_matrix gl_TextureMatrix

And for fragment shaders we have:

 #define cogl_color_in gl_Color
 #define cogl_tex_coord_in gl_TexCoord

 #define cogl_color_out gl_FragColor
 #define cogl_depth_out gl_FragDepth

 #define cogl_front_facing gl_FrontFacing
2010-11-10 14:24:52 +00:00
Robert Bragg
f3bffe5cab blur-effect: fix paint volume padding
For the blur effect we use a BLUR_PADDING constant to pad out the volume
of the source actor on the x and y axis. Previously we were offsetting
the origin negatively using BLUR_PADDING and then adding BLUR_PADDING
to the width and height, but we should have been adding 2*BLUR_PADDING
instead.
2010-09-29 15:12:57 +01:00
Robert Bragg
3540d222e1 paint volumes: another pass at the design
This is a fairly extensive second pass at exposing paint volumes for
actors.

The API has changed to allow clutter_actor_get_paint_volume to fail
since there are times - such as when an actor isn't a descendent of the
stage - when the volume can't be determined. Another example is when
something has connected to the "paint" signal of the actor and we simply
have no way of knowing what might be drawn in that handler.

The API has also be changed to return a const ClutterPaintVolume pointer
(transfer none) so we can avoid having to dynamically allocate the
volumes in the most common/performance critical code paths. Profiling was
showing the slice allocation of volumes taking about 1% of an apps time,
for some fairly basic tests. Most volumes can now simply be allocated on
the stack; for clutter_actor_get_paint_volume we return a pointer to
&priv->paint_volume and if we need a more dynamic allocation there is
now a _clutter_stage_paint_volume_stack_allocate() mechanism which lets
us allocate data which expires at the start of the next frame.

The API has been extended to make it easier to implement
get_paint_volume for containers by using
clutter_actor_get_transformed_paint_volume and
clutter_paint_volume_union. The first allows you to query the paint
volume of a child but transformed into parent actor coordinates. The
second lets you combine volumes together so you can union all the
volumes for a container's children and report that as the container's
own volume.

The representation of paint volumes has been updated to consider that
2D actors are the most common.

The effect apis, clutter-texture and clutter-group have been update
accordingly.
2010-09-29 15:12:57 +01:00
Emmanuele Bassi
a6e5ecebe3 blur-effect: Add padding to account for the blur
The blur effect will sample pixels on the edges of the offscreen buffer,
so we want to add a padding to avoid clamping the blur.

We do this by creating a larger target texture, and updating the paint
volume of the actor during paint to take that padding into account.
2010-09-29 15:12:57 +01:00
Emmanuele Bassi
ddf1e4c77b effects: Make sure we're using GLSL 1.10 2010-09-21 13:32:31 +01:00
Emmanuele Bassi
daf6e73936 Remove last uses of cogl_program_uniform*
Following the commits:

  c03544da - clutter-shader: use cogl_program_set_uniform_xyz API
  a26119b5 - tests: Remove use of cogl_program_use

Remove the users of cogl_program_uniform_* and cogl_program_use() in the
shader-based effects.
2010-08-12 17:08:26 +01:00
Emmanuele Bassi
d10ebe9fca effects: Check before using the cogl_shader_* API
Since BlurEffect and DesaturateEffect are using the shader API
implicitly and not using ClutterShaderEffect, we need to check if the
underlying GL implementation supports the GLSL shading language and warn
if not.
2010-08-11 17:25:17 +01:00
Emmanuele Bassi
7daeb217bd blur-effect: Do not inherit from ShaderEffect
We might want to switch the BlurEffect from a box-blur to a
super-sampling of the texture target, in order to make it cheap(er).
If we inherit from ShaderEffect, though, we're setting in stone the
fact that we are going to use a fragment shader for blurring.

Since there is not parametrization of the blur, the code necessary
to implement effect is pretty small, and we can use the Cogl API
directly.
2010-08-11 14:21:23 +01:00
Emmanuele Bassi
8583986e16 blur-effect: Fix loop unrolling
The box blur shader was not sampling all the points for producing the
desired effect.
2010-06-07 15:45:24 +01:00
Emmanuele Bassi
23084b9768 docs: Effects fixes for the API reference 2010-06-03 14:34:41 +01:00
Emmanuele Bassi
0e9a1dee6d shader-effect: Simplify setting the shader source
Sub-classes of ShaderEffect currently have to get the handle for the
Cogl shader and call cogl_shader_source(); this makes it awkward to
implement a ShaderEffect, and it exposes handles and Cogl API that we
might want to change in the future.

We should provide a ClutterShaderEffect method that allows to (safely)
set the shader source at the right time for sub-classes to use.
2010-06-03 14:10:55 +01:00
Emmanuele Bassi
5a5b21446c effect: Add BlurEffect
A simple, GLSL shader-based blur effect.

The blur shader is taken straight from the test-shader.c interactive
test case. It's a fairly clunky, inefficient and visually incorrect
implementation of a box blur, but it's all we have right now until I
figure out a way to do multi-pass shading with the current API.
2010-06-03 14:10:55 +01:00