Commit Graph

230 Commits

Author SHA1 Message Date
Robert Bragg
f5f066df9c Try to clean up how we handle actor transformations
When building actor relative transforms, instead of using the matrix
stack to combine transformations and making assumptions about what is
currently on the stack we now just explicitly initialize an identity
matrix and apply transforms to that.

This removes the full_vertex_t typedef for internal transformation code
and we just use ClutterVertex.

ClutterStage now implements apply_transform like any other actor now
and the code we had in _cogl_setup_viewport has been moved to the
stage's apply_transform instead.

ClutterStage now tracks an explicit projection matrix and viewport
geometry. The projection matrix is derived from the perspective whenever
that changes, and the viewport is updated when the stage gets a new
allocation. The SYNC_MATRICES mechanism has been removed in favour of
_clutter_stage_dirty_viewport/projection() APIs that get used when
switching between multiple stages to ensure cogl has the latest
information about the onscreen framebuffer.
2010-09-13 18:18:34 +01:00
Emmanuele Bassi
ba9aa3b332 texture: Move the material unref() in ::dispose 2010-09-06 18:09:19 +01:00
Emmanuele Bassi
128e981f6c texture: Do some more validation in get_cogl_texture()
Check the layer type, even though right now we only have one type
available.
2010-09-06 18:09:19 +01:00
Emmanuele Bassi
7e56a98413 texture: Use a base material for all instances
Creating new materials for every Texture instance results in a lot of
ARBfp programs being generated/compiled. Since most textures will just
be similar we should create a template material for all of them, and
then copy it in every instance. Cogl will try to optimize the generation
of the program and, hopefully, will reuse the same program most of the
time.

With this change, a simple test shows that loading 48 textures will
result in just two programs being compiled - with and without batching
enabled.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2295
2010-09-06 18:09:19 +01:00
Emmanuele Bassi
abef73bb58 Replace cogl_color_set_from_* with cogl_color_init_from_*
The former is not yet "officially" deprecated by the latter, but it's
confusing to have them both in the code base.
2010-09-03 16:58:47 +01:00
Emmanuele Bassi
3e74f42f07 introspection: Add annotations
Reduce the amount of warnings coming from g-ir-scanner.
2010-09-03 12:14:50 +01:00
Robert Bragg
f8940e3c9a clutter-texture: queue redraw when changing pick_with_alpha
The expectation is that actors should call clutter_actor_queue_redraw
when ever some private state changes that affects painting *or* picking.
ClutterTexture was not doing this for pick_with_alpha property changes.
2010-08-18 18:30:30 +01:00
Emmanuele Bassi
92b1a33eb3 texture: Default square textures to height-for-width
Square textures should have a preferred geometry request set to
height-for-width, as it is the default for Clutter itself.
2010-08-16 15:56:49 +01:00
Neil Roberts
8d51617979 Conditionally use g_object_notify_by_pspec
This adds a wrapper macro to clutter-private that will use
g_object_notify_by_pspec if it's compiled against a version of GLib
that is sufficiently new. Otherwise it will notify by the property
name as before by extracting the name from the pspec. The objects can
then store a static array of GParamSpecs and notify using those as
suggested in the documentation for g_object_notify_by_pspec.

Note that the name of the variable used for storing the array of
GParamSpecs is obj_props instead of properties as used in the
documentation because some places in Clutter uses 'properties' as the
name of a local variable.

Mose of the classes in Clutter have been converted using the script in
the bug report. Some classes have not been modified even though the
script picked them up as described here:

json-generator:

 We probably don't want to modify the internal copy of JSON

behaviour-depth:
rectangle:
score:
stage-manager:

 These aren't using the separate GParamSpec* variable style.

blur-effect:
win32/device-manager:

 Don't actually define any properties even though it has the enum.

box-layout:
flow-layout:

  Have some per-child properties that don't work automatically with
  the script.

clutter-model:

  The script gets confused with ClutterModelIter

stage:

  Script gets confused because PROP_USER_RESIZE doesn't match
  "user-resizable"

test-layout:

  Don't really want to modify the tests

http://bugzilla.clutter-project.org/show_bug.cgi?id=2150
2010-08-10 17:12:06 +01:00
Emmanuele Bassi
315965290b texture: Update the request mode depending on the size
If a Texture has been set to:

  • keep its size synchronized with the image data
  • maintain the aspect ratio of the image data

then it should also change its request mode depending on the orientation
of the image data, so that layout managers have a fighting chance of
sizing it correctly.
2010-08-05 16:19:51 +01:00
Emmanuele Bassi
2d4125a053 texture: Make the :filename property readable
UI builders and other tools are be interested in the file used to load
the image data.
2010-08-05 15:39:20 +01:00
Chris Kühl
24b9748f0a Fixed more set using *_get_* typos.
http://bugzilla.clutter-project.org/show_bug.cgi?id=2233
2010-07-22 11:03:04 +01:00
Neil Roberts
1dee65770a Minor fix to the documentation for clutter_texture_get_sync_size
The documentation was recursively referring to itself causing a stack
overflow in the reader's brain.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2233
2010-07-22 10:06:26 +01:00
Emmanuele Bassi
fd27ca7398 Mark property strings for translation
Both the nick and the blurb fields should be translatable, for UI
builders and other introspection-based tools.
2010-07-15 14:07:07 +01:00
Emmanuele Bassi
b2c905ff50 Hide the marshallers
The marshallers we use for the signals are declared in a private header,
and it stands to reason that they should also be hidden in the shared
object by using the common '_' prefix. We are also using some direct
g_cclosure_marshal_* symbol from GLib, instead of consistently use the
clutter_marshal_* symbol.
2010-06-11 16:09:36 +01:00
Emmanuele Bassi
91220c4b46 docs: Miscellaneous fixes to silence gtk-doc 2010-06-01 14:15:03 +01:00
Robert Bragg
d0c743787d texture: don't use a static bool to gate warning
in create_pick_material we were using a static boolean to gate when we
show a warning, but that would mean if the problem recurs between
different textures then the warning will only be shown once. We now have
a private bitfield flag instead, just so we don't spew millions of
warnings if the problem is recurring.
2010-05-28 17:24:42 +01:00
Robert Bragg
589c8d9579 [texture] Support picking textures according to their alpha channel
This adds a boolean "pick-with-alpha" property to ClutterTexture and when
true, it will use the textures alpha channel to define the actors shape when
picking.

Users should be aware that it's a bit more expensive to pick textures like
this (so probably best not to blindly enable it on *all* your textures)
since it implies rasterizing the texture during picking whereas we would
otherwise just send a solid filled quad to the GPU.  It will also interrupt
the internal batching of geometry for pick renders which can otherwise often
be done in a single draw call.
2010-05-28 16:07:17 +01:00
Robert Bragg
3f64f57830 [texture] remove redundant if (paint_opacity == 0) bailout
clutter_texture_paint shouldn't need to optimize the case where
paint_opacity == 0 and bailout, since we've been doing this optimization for
all actors in clutter_actor_paint for a while now.
2010-05-28 15:35:23 +01:00
Emmanuele Bassi
9024cd9f7c Clean up the Texture private data structure 2010-04-26 16:27:15 +01:00
Neil Roberts
a28440eafb clutter-texture: Remove confusing comments about realization
In 125bded81 some comments were introduced to ClutterTexture
complaining that it can have a Cogl texture before being
realized. Clutter always assumes that the single GL context is current
so there is no need to wait until the actor is realized before setting
a texture. This patch replaces the comments with clarification that
this should not be a problem.

The patch also changes the documentation about the realized state in
various places to clarify that it is acceptable to create any Cogl
resources before the actor is realized.

http://bugzilla.openedhand.com/show_bug.cgi?id=2075
2010-04-19 15:34:43 +01:00
Emmanuele Bassi
79acb088e7 Remove mentions of the FSF address
Since using addresses that might change is something that finally
the FSF acknowledge as a plausible scenario (after changing address
twice), the license blurb in the source files should use the URI
for getting the license in case the library did not come with it.

Not that URIs cannot possibly change, but at least it's easier to
set up a redirection at the same place.

As a side note: this commit closes the oldes bug in Clutter's bug
report tool.

http://bugzilla.openedhand.com/show_bug.cgi?id=521
2010-03-01 12:56:10 +00:00
Emmanuele Bassi
65af411cb4 analysis: ClutterTexture
Remove unused variables.
2010-02-12 14:50:11 +00:00
Robert Bragg
b898f0e227 never presume queuing redraws on invisible actors is redundant
This replaces code like this:
  if (CLUTTER_ACTOR_IS_VISIBLE (self))
    clutter_actor_queue_redraw (self);
with:
  clutter_actor_queue_redraw (self);

clutter_actor_queue_redraw internally knows what can be optimized when
the actor is not visible, but it also knows that the queue_redraw signal
must always be sent in case a ClutterClone is cloning a hidden actor.
2010-02-12 14:05:00 +00:00
Damien Lespiau
18d96005ec texture: Remove reading the texture data back in ::unrealize()
Reading back the texture data in unrealize does not seem like a
desirable feature any more, clutter has evolved a lot since it was
implemented.

What's wrong with it now:

  * It takes *a lot* of time to read the data back with glReadPixel(),
  * When several textures share the same CoglTexture, the same data can
    be read back multiple times,
  * If the underlying material uses multiple texture units, only the
    first one was copied back,
  * In ClutterCairoTexture, we end up having two separate copies of the
    data,
  * GL actually manages texture memory accross system/video memory
    for us!

For all the reasons above, let's get rid of the glReadPixel() in
Texture::unrealize()

Fixes: OHB#1842
2010-01-13 15:13:10 +00:00
Robert Bragg
439f8c62b0 cogl: deprecate cogl_draw_buffer API and replace with a cogl_framebuffer API
cogl_push_draw_buffer, cogl_set_draw_buffer and cogl_pop_draw_buffer are now
deprecated and new code should use the new cogl_framebuffer_* API instead.

Code that previously did:
    cogl_push_draw_buffer ();
    cogl_set_draw_buffer (COGL_OFFSCREEN_BUFFER, buffer);
    /* draw */
    cogl_pop_draw_buffer ();
should now be re-written as:
    cogl_push_framebuffer (buffer);
    /* draw */
    cogl_pop_framebuffer ();

As can be seen from the example above the rename has been used as an
opportunity to remove the redundant target argument from
cogl_set_draw_buffer; it now only takes one call to redirect to an offscreen
buffer, and finally the term framebuffer may be a bit more familiar to
anyone coming from an OpenGL background.
2009-11-26 19:33:14 +00:00
Robert Bragg
ae57c30e93 [texture] fix rounding when calculating update_fbo viewport offset
When rendering to an fbo for supporting clutter_texture_new_from_actor we
render to an fbo with the same size as the source actor, but with a viewport
the same size as the stage.  We offset the viewport so when we render the
source actor in its normal transformed stage position it lands on the fbo.
Previously we were rounding the transformed position given as a float by
truncating the fraction (just using a C cast) but that resulted in an
incorrect pixel offset when rendering offscreen depending on the source
position.

We now simply + 0.5 before casting (or -0.5 for negative numbers)
2009-11-04 03:34:07 +00:00
Robert Bragg
309f852efb [texture] switch to a new design for handling offscreen rendering
For supporting clutter_texture_new_from_actor(): when updating a
ClutterTexture's fbo we previously set up an offset frustum in the
perspective matrix before rendering source actors to an offscreen draw
buffer so as to give a perspective as if it were being drawn at its
original stage location.

Now that Cogl supports offset viewports there is a simpler way...

When we come to render the source actor to our offscreen draw buffer we
now copy the projection matrix from the stage; we create a viewport
that's also the same size as the stage (though larger than the offscreen
draw buffer) and as before we apply the modelview transformations of
the source actors ancestry before painting it.

The only trick we need now is to offset the viewport according to the
transformed (to screen space) allocation of the source actor (something we
required previously too).  We negatively offset the stage sized viewport
such that the smaller offscreen draw buffer is positioned to sit underneath
the source actor in stage coordinates.
2009-11-04 03:34:07 +00:00
Robert Bragg
94a6028358 [texture] split out fbo update code from cluter_texture_paint
To help keep clutter_texture_paint maintainable this splits out a big
chunk of standalone code that's responsible for updating the fbo when
clutter_texture_new_from_actor has been used.
2009-11-04 03:34:06 +00:00
Robert Bragg
2762e6d9b9 [texture] push/pop draw buffer when painting actors to a texture
When updating the FBO for a source actor (to support
clutter_texture_new_from_actor()) we used to simply set an offscreen draw
buffer to be current, paint the source actor and then explicitly set the
window to be current again.  This precluded chaining texture_new_from_actor
though because updating another FBO associated with a source actor would end
up restoring the window as the current buffer instead of the previous
offscreen buffer.  Now that we use Cogl's draw buffer stack; chaining
clutter_texture_new_from_actor() should be possible.
2009-11-04 03:34:06 +00:00
Robert Bragg
c7d229585f [texture] Avoid redundant use of cogl_clip_stack_save when drawing offscreen
Since cogl draw buffers now own their clip state the stage's clip state will
automatically be saved and restored via the cogl_set_draw_buffer API.
2009-11-04 03:34:06 +00:00
Robert Bragg
8c3a132ecb [cogl] deprecate cogl_viewport() in favour of cogl_set_viewport()
cogl_viewport only accepted a viewport width and height, but there are times
when it's also desireable to have a viewport offset so that a scene can be
translated after projection but before hitting the framebuffer.
2009-11-04 03:23:21 +00:00
Damien Lespiau
0599d12ec9 texture: Don't compare fbo_source with COGL_INVALID_HANDLE
fbo_source is a ClutterActor, it should be compared to NULL instead of
COGL_INVALID_HANDLE.
2009-11-02 14:40:43 +00:00
Emmanuele Bassi
81c8cf3e6d texture: Error handling fix
When cogl_texture_new_from_data() fails in clutter_texture_set_from_data()
and no GError is provided, the clutter app will segfault when dereferencing
the GError ** and emitting LOAD_FINISHED signal.

Based on a patch by: Haakon Sporsheim <haakon.sporsheim@gmail.com>

http://bugzilla.openedhand.com/show_bug.cgi?id=1806
2009-10-26 11:51:30 +00:00
Neil Roberts
db6b0a91e0 Take a reference to the material in clutter_texture_set_cogl_material
The material is unref'd in clutter_texture_finalize and the
documentation explicitly states that the function will take a ref so
it really should.
2009-08-26 18:28:35 +01:00
Neil Roberts
bad7782ab4 Fix the documentation for clutter_texture_set_cogl_material
The documentation was a copy of the docs for set_cogl_texture so it
was somewhat broken.
2009-08-26 18:25:10 +01:00
Emmanuele Bassi
43d394ebae Remove unused TEXTURE_IN_CLONE_PAINT private flag
The CLUTTER_TEXTURE_IN_CLONE_PAINT was used with the old CloneTexture
actor; now that we have ClutterClone nothing sets the private flag
anymore, and the flag itself is not needed.
2009-07-13 16:16:38 +01:00
Emmanuele Bassi
5a554bf063 Small code clean up
Make ClutterTexture slightly more similar to the rest of the code base.
2009-07-12 01:27:31 +01:00
pippin
8fb3a48ae2 serialize upload of asyncronously loaded textures
Rate limit the uploading of textures to stop if it uses more than 5ms
during one master clock iteration.
2009-07-10 11:38:59 +01:00
Øyvind Kolås
04bb789941 [texture] fix load-async and load-data-async properties.
Removed the G_PARAM_CONSTRUCT from the property registration of
"load-async" and "load-data-async". It made it impossible to use only
load-data-async, as the async loading state would be unset when
load-async got set it's default FALSE value.
2009-06-30 16:48:53 +01:00
Emmanuele Bassi
ba6c0c27f9 [texture] Revert to integer parameters in ::size-change
In the int-to-float switch for actor properties, the ::size-change signal
was moved to use floats instead of integers. Sub-pixel precision for image
size is meaningless, though, so we should revert it back to ints.

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1659
2009-06-22 12:15:17 +01:00
Emmanuele Bassi
c6fba47a52 Hide clutter_context_get_default()
The clutter_context_get_default() function is private, but shared
across Clutter. For this reason, it should be prefixed by '_' so
that the symbol is hidden from the shared object.
2009-06-18 14:20:28 +01:00
Owen W. Taylor
5e18cee77a Avoid unnecesary unpremultiplication when saving to local data
Now that we typically have premultiplied data stored in Cogl
textures, when fetching a texture into local data for temporary
storage, use a premultiplied format to avoid an unpremultiply/
premultiply roundtrip.

http://bugzilla.openedhand.com/show_bug.cgi?id=1406

Signed-off-by: Robert Bragg <robert@linux.intel.com>
2009-06-11 14:17:52 +01:00
Owen W. Taylor
c3448314d5 Default to a blend function that expects premultiplied colors
Many operations, like mixing two textures together or alpha-blending
onto a destination with alpha, are done most logically if texture data
is in premultiplied form. We also have many sources of premultiplied
texture data, like X pixmaps, FBOs, cairo surfaces. Rather than trying
to work with two different types of texture data, simplify things by
always premultiplying texture data before uploading to GL.

Because the default blend function is changed to accommodate this,
uses of pure-color CoglMaterial need to be adapted to add
premultiplication.

gl/cogl-texture.c gles/cogl-texture.c: Always premultiply
  non-premultiplied texture data before uploading to GL.

cogl-material.c cogl-material.h: Switch the default blend functions
  to ONE, ONE_MINUS_SRC_ALPHA so they work correctly with premultiplied
  data.

cogl.c: Make cogl_set_source_color() premultiply the color.

cogl.h.in color-material.h: Add some documentation about
  premultiplication and its interaction with color values.

cogl-pango-render.c clutter-texture.c tests/interactive/test-cogl-offscreen.c:
  Use premultiplied colors.

http://bugzilla.openedhand.com/show_bug.cgi?id=1406

Signed-off-by: Robert Bragg <robert@linux.intel.com>
2009-06-11 14:17:52 +01:00
Owen W. Taylor
4dcd5f6134 Use correct texture format for pixmap textures and FBO's
RGBA data in X pixmaps and in FBOs is already premultiplied; use
the right format when creating cogl textures.

http://bugzilla.openedhand.com/show_bug.cgi?id=1406

Signed-off-by: Robert Bragg <robert@linux.intel.com>
2009-06-11 14:17:51 +01:00
Emmanuele Bassi
9691827b5b [texture] Fix error reporting on ::load-finished
The load-finished signal has a GError* argument which is meant to
signify whether the loading was successful. However many of the
places in ClutterTexture that emit this signal directly pass their
'error' variable which is a GError** and will be NULL or not
completely independently of whether there was an error. If the
argument was dereferenced it would probably crash.

The test-texture-async interactive test case should also verify
that the ::load-finished signal is correctly emitted.

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1622
2009-06-06 16:13:41 +01:00
Emmanuele Bassi
c3dc03997c Fixes for some compiler warnings 2009-06-06 14:37:41 +01:00
Neil Roberts
54d8aadf1d [cogl] Move the texture filters to be a property of the material layer
The texture filters are now a property of the material layer rather
than the texture object. Whenever a texture is painted with a material
it sets the filters on all of the GL textures in the Cogl texture. The
filter is cached so that it won't be changed unnecessarily.

The automatic mipmap generation has changed so that the mipmaps are
only generated when the texture is painted instead of every time the
data changes. Changing the texture sets a flag to mark that the
mipmaps are dirty. This works better if the FBO extension is available
because we can use glGenerateMipmap. If the extension is not available
it will temporarily enable automatic mipmap generation and reupload
the first pixel of each slice. This requires tracking the data for the
first pixel.

The COGL_TEXTURE_AUTO_MIPMAP flag has been replaced with
COGL_TEXTURE_NO_AUTO_MIPMAP so that it will default to
auto-mipmapping. The mipmap generation is now effectively free if you
are not using a mipmap filter mode so you would only want to disable
it if you had some special reason to generate your own mipmaps.

ClutterTexture no longer has to store its own copy of the filter
mode. Instead it stores it in the material and the property is
directly set and read from that. This fixes problems with the filters
getting out of sync when a cogl handle is set on the texture
directly. It also avoids the mess of having to rerealize the texture
if the filter quality changes to HIGH because Cogl will take of
generating the mipmaps if needed.
2009-06-04 19:03:40 +01:00
Emmanuele Bassi
0187bb3965 [actor] Use flags to control allocations
Instead of passing a boolean value, the ::allocate virtual function
should use a bitmask and flags. This gives us room for expansion
without breaking API/ABI, and allows to encode more information to
the allocation process instead of just changes of absolute origin.
2009-06-04 16:30:31 +01:00
Emmanuele Bassi
bafa448666 [texture] Increase verbosity of error messages
The GError messages in set_from_rgb_data() and set_from_yuv_data()
are a little bit too thin on details.
2009-06-01 14:57:18 +01:00