Emmanuele Bassi [Fri, 6 Nov 2009 15:06:39 +0000 (15:06 +0000)]
Clean up cogl.h template
The inclusion order is mostly random, and it should really be
in alphabetic order, just like clutter.h.
Also, cogl-vertex-buffer.h is included twice.
Tim Horton [Fri, 6 Nov 2009 11:57:43 +0000 (11:57 +0000)]
osx: CGBitmapContextCreate can't make 24bpp, alphaless offscreen pixmaps
While loading a JPEG from disk (with clutter_texture_new_from_file),
I got the following:
<Error>: CGBitmapContextCreate: unsupported parameter combination: 8
integer bits/component; 24 bits/pixel; 3-component colorspace;
kCGImageAlphaNone; 3072 bytes/row.
<Error>: CGContextDrawImage: invalid context
Looking around, I found that CGBitmapContextCreate can't make 24bpp
offscreen pixmaps without an alpha channel...
This fixes the bug, and seems to not break other things...
http://bugzilla.openedhand.com/show_bug.cgi?id=1159
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
Emmanuele Bassi [Fri, 6 Nov 2009 14:07:46 +0000 (14:07 +0000)]
script: Coding style clean-ups
Emmanuele Bassi [Fri, 6 Nov 2009 14:07:26 +0000 (14:07 +0000)]
script: Document private functions
Emmanuele Bassi [Fri, 6 Nov 2009 14:04:36 +0000 (14:04 +0000)]
Do not pass flags to g_module_open(NULL)
The flags are ignored when opening the main module, so we
should pass 0 to avoid confusion when reading the source.
Emmanuele Bassi [Fri, 6 Nov 2009 11:50:22 +0000 (11:50 +0000)]
Merge branch 'josh-osx-fixes'
* josh-osx-fixes:
osx: Fix a warning on Snow Leopard
docs: Fix OS X docs to install Ports in correct order
osx: Implement the updated ClutterStageWindow interface
Joshua Lock [Thu, 5 Nov 2009 15:50:21 +0000 (15:50 +0000)]
tests: Remove a spurious #include
The test-backface-culling has what looks like a stray #include in which
stops the test compiling for backends without GdkPixbuf. Remove it.
http://bugzilla.openedhand.com/show_bug.cgi?id=1867
Joshua Lock [Thu, 5 Nov 2009 15:48:25 +0000 (15:48 +0000)]
osx: Fix a warning on Snow Leopard
Apple where nice and changed API between releases. This patch checks the
version of the compilation environment and tries to use the right parameter
type.
http://bugzilla.openedhand.com/show_bug.cgi?id=1866
Joshua Lock [Thu, 5 Nov 2009 15:31:56 +0000 (15:31 +0000)]
docs: Fix OS X docs to install Ports in correct order
The order in which the MacPorts are installed is important otherwise we open
the user up to a world of pain.
This patch also tweaks the OS X docs to follow the formatting of the rest of
the docs and to discuss the option of GtkDoc.
http://bugzilla.openedhand.com/show_bug.cgi?id=1865
Joshua Lock [Thu, 5 Nov 2009 15:44:32 +0000 (15:44 +0000)]
osx: Implement the updated ClutterStageWindow interface
In the new Clutter world backend stage implementations should be lightweight
objects implementing the ClutterStageWindow interface and not ClutterActor
subclasses.
This patch performs various cut-n-pastes to acheive that for the OSX backend
http://bugzilla.openedhand.com/show_bug.cgi?id=1864
Emmanuele Bassi [Fri, 6 Nov 2009 11:33:32 +0000 (11:33 +0000)]
behaviour: Implement the implicit alpha parsing
ClutterBehaviour should implement the Scriptable interface
and parse ClutterAlpha when implicitly defined, instead of
having this ad hoc code inside ClutterScriptParser itself.
After all, only ClutterBehaviour supports Alpha defined
implicitly.
Emmanuele Bassi [Fri, 6 Nov 2009 11:32:28 +0000 (11:32 +0000)]
conform: Add unit for properties holding objects
Exercise the definition of GObjects for properties defined using
GParamSpecObject.
Emmanuele Bassi [Fri, 6 Nov 2009 11:17:42 +0000 (11:17 +0000)]
script: Generic assignment of properties requiring objects
The ClutterScriptParser should do most of the heavy-lifting for
parsing a JSON object member defining another JSON object into
a GObject property defined using a GParamSpecObject.
Emmanuele Bassi [Fri, 6 Nov 2009 10:53:43 +0000 (10:53 +0000)]
conformance: Add unit on the implicit alpha definition
Exercise the implicit alpha and timeline definition to catch
regressions in the ClutterScript parser code.
Emmanuele Bassi [Fri, 6 Nov 2009 10:17:30 +0000 (10:17 +0000)]
script: Apply properties when constructing implicit timelines
The object construction is done in two passes, now, so we must do both
passes when parsing implicit timelines from a fake ObjectInfo.
Robert Bragg [Thu, 5 Nov 2009 16:50:24 +0000 (16:50 +0000)]
Remove all internal use of deprecated cogl_clip_* API
cogl_clip_push, and cogl_clip_push_window_rect which are now deprecated were
used in various places internally so this just switches to using the
replacement functions.
Robert Bragg [Thu, 5 Nov 2009 10:56:24 +0000 (10:56 +0000)]
[clip-stack] stop using deprecated cogl_clip_push_window_rect API
try_pushing_rect_as_window_rect now uses the new
cogl_clip_push_window_rectangle API.
Robert Bragg [Wed, 4 Nov 2009 19:31:43 +0000 (19:31 +0000)]
[cogl-clip] deprecate parts and cleanup the API
cogl_clip_push() which accepts a rectangle in model space shouldn't have
been defined to take x,y,width,height arguments because this isn't consistant
with other Cogl API dealing with model space rectangles. If you are using a
coordinate system with the origin at the center and the y+ extending up,
then x,y,width,height isn't as natural as (x0,y0)(x1,y1). This API has
now been replace with cogl_clip_push_rectangle()
(As a general note: the Cogl API should only use the x,y,width,height style
when the appropriate coordinate space is defined by Cogl to have a top left
origin. E.g. window coordinates, or potentially texture coordinates)
cogl_clip_push_window_rect() shouldn't have been defined to take float
arguments since we only clip with integral pixel precision. We also
shouldn't have abbreviated "rectangle". This API has been replaced with
cogl_clip_push_window_rectangle()
cogl_clip_ensure() wasn't documented at all in Clutter 1.0 and probably
no one even knew it existed. This API isn't useful, and so it's now
deprecated. If no one complains we may remove the API altogether for
Clutter 1.2.
cogl_clip_stack_save() and cogl_clip_stack_restore() were originally added
to allow us to save/restore the clip when switching to/from offscreen
rendering. Now that offscreen draw buffers are defined to own their clip
state and the state will be automatically saved and restored this API is now
redundant and so deprecated.
Robert Bragg [Wed, 4 Nov 2009 20:17:56 +0000 (20:17 +0000)]
[clip-stack] Internally track model space clip rects as (x0,y0)(x1,y1) pairs
Don't track the rectangles as x0,y0,width,height. This is in preparation
for some API tidy up.
Robert Bragg [Wed, 4 Nov 2009 19:42:17 +0000 (19:42 +0000)]
[clip-stack] move lots of supporting code from cogl.c to cogl-clip-stack.c
There was quite a bit of code in cogl.c that was only used to support
cogl-clip-stack.c, so this has now been moved to cogl-clip-stack.c
Robert Bragg [Wed, 4 Nov 2009 16:55:18 +0000 (16:55 +0000)]
[debug] Adds a COGL_DEBUG=force-scanline-paths
For a long time now the GLES driver for Cogl has supported a fallback
scanline rasterizer for filling paths when no stencil buffer is available,
but now that we build the same cogl-primitives code for GL and GLES I
thought it may sometimes be useful for debugging to force Cogl to use the
scanline rasterizer instead of the current stencil buffer approach.
Emmanuele Bassi [Thu, 5 Nov 2009 17:30:33 +0000 (17:30 +0000)]
tests: Clean up interactive test build
The build for interactive tests creates symbolic links for the data
under tests/data; it also uses symbolic links for creating "binaries"
for each interactive test. This is less than ideal, though.
Instead, the tests should build a path to the data files by using
a pre-processor define like TESTS_DATADIR; both g_build_filename() and
pre-processor string concatenation can be used to generate a valid
file name with the full path to the files.
The build system should also create wrapper scripts, just like we
do inside the conformance test suite, to be able to launch single
tests.
Emmanuele Bassi [Thu, 5 Nov 2009 12:24:37 +0000 (12:24 +0000)]
layout: Add layout properties introspection
In order to know if a layout property exists and retrieve its
description in form of a GParamSpec, we need a wrapper API inside
ClutterLayoutManager. This allows introspecting a LayoutManager
sub-class and eventually serialize and deserialize it.
Emmanuele Bassi [Thu, 5 Nov 2009 12:23:49 +0000 (12:23 +0000)]
box-layout: Add get_child_meta_type() override
Return the GType of ClutterBoxChild.
Emmanuele Bassi [Thu, 5 Nov 2009 12:23:22 +0000 (12:23 +0000)]
bin-layout: Add get_child_meta_type() override
Return the GType of ClutterBinLayer.
Emmanuele Bassi [Thu, 5 Nov 2009 11:57:06 +0000 (11:57 +0000)]
layout: Add LayoutManager::get_child_meta_type()
In order to inspect a LayoutManager using LayoutMeta we need a
virtual function that returns the GType of the LayoutMeta used.
Emmanuele Bassi [Wed, 4 Nov 2009 16:45:44 +0000 (16:45 +0000)]
script: Allow parsing child properties
The ClutterScript parser needs to be extended to parse child properties
and apply them after an actor has been added to a container. In order to
distinguish child properties from regular GObject properties we can use
the "child::" prefix, e.g.:
{
"type" : "ClutterRectangle",
"id" : "child-01",
"child::has-focus" : true,
...
}
Parsing child properties can be deferred to the ClutterScriptable
interface, just like regular properties.
Robert Bragg [Sat, 17 Oct 2009 03:06:56 +0000 (04:06 +0100)]
[cogl-primitives] Get rid of driver specific cogl-primitives code
These files were practically identical, except the gles code had additional
support for filling paths without a stencil buffer. All the driver code has
now been moved into cogl/cogl-primitives.c
Emmanuele Bassi [Wed, 4 Nov 2009 15:21:03 +0000 (15:21 +0000)]
script: Clean up Color parsing rules
All the ClutterColor parsing rules should be coalesced inside
clutter_script_parse_color(): object, array and string notations
are the canonical ways of defining a ClutterColor inside a
ClutterScript definition. Having a single function in charge of
the parsing cleans up the code.
Emmanuele Bassi [Wed, 4 Nov 2009 15:20:12 +0000 (15:20 +0000)]
script: Simplify boxed types parsing
We should use the typed accessors for complex JSON types, and
be more liberal in what we accept.
Emmanuele Bassi [Wed, 4 Nov 2009 14:05:13 +0000 (14:05 +0000)]
script: Separate construction from properties application
Currently, ClutterScriptParser will construct the object (using the
construct-only and construct parameters), apply the properties from
the ClutterScript definition, and eventuall will add children and
behaviours.
The construction phase should be more compartimentalized: the objects
should be constructed first and eventual children and behaviours
added. Then, once an object is requested or when the parsing process
has terminated, all the properties should be applied.
This change allows us to set up the actors before setting their
non-construct properties.
Emmanuele Bassi [Wed, 4 Nov 2009 13:32:26 +0000 (13:32 +0000)]
script: Move all parser code inside ClutterScriptParser
ClutterScript is currently a mix of parser-related code and
the ClutterScript object. All the parser-related code should
be moved inside a private class, ClutterScriptParser, inheriting
from JsonParser.
Emmanuele Bassi [Wed, 4 Nov 2009 11:50:45 +0000 (11:50 +0000)]
conform: Add the beginnings of a ClutterScript test suite
ClutterScript is a very complicated piece of machinery, with a
parser that has custom variations on top of the basic JSON
format; it could also be extended in the future, so if we don't
want to introduce regressions or break existing ClutterScript
definitions, we'd better have a conformance test suite.
Emmanuele Bassi [Wed, 4 Nov 2009 11:47:09 +0000 (11:47 +0000)]
tests: Allow getting data files from the tests/data directory
The units under the conformance test suite should be able to use
external files. Linking the files in tests/conform like the
interactive tests do seems like a hack piled on top of a hack, so
instead we should provide a programmatic way for a conformance
test unit to get the full path of a file, regardless of where the
tests/data directory is.
We can use a define to get the full path of tests/data and then
a function using g_build_filename() to construct the path to the
file we want.
Emmanuele Bassi [Wed, 4 Nov 2009 11:05:25 +0000 (11:05 +0000)]
Add new conformance tests to the ignore list
Emmanuele Bassi [Tue, 3 Nov 2009 18:30:28 +0000 (18:30 +0000)]
script: Take a copy of property nodes
Instead of counting on a JsonNode pointer to survive we should take
a copy. This allows keeping unresolved properties across different
ClutterScript passes.
Emmanuele Bassi [Tue, 3 Nov 2009 18:29:52 +0000 (18:29 +0000)]
script: Use JsonObject direct accessors
Instead of getting the JsonNode for a member of which we mandate
the type we can use the typed accessors of JsonObject.
Robert Bragg [Wed, 4 Nov 2009 03:46:45 +0000 (03:46 +0000)]
Merge commit 'cogl-reorg-draw-buffers'
* cogl-reorg-draw-buffers: (38 commits)
[test-fbo] greatly simplify the test
[tests] test-backface-culling: test culling with offscreen rendering
[tests] Adds test-cogl-readpixels.c for very basic cogl_read_pixels testing
[tests] Adds test-cogl-offscreen to validate offscreen draw buffer
[tests] test-cogl-viewport tests semantics of over/under size viewports
[test-texture-fbo] comment the colors defined in corner_colors
Add a conformance test for clutter_texture_new_from_actor
[cogl-texture-2d-sliced] allow COGL_FORMAT_ANY with _new_with_size()
[texture] fix rounding when calculating update_fbo viewport offset
[texture] switch to a new design for handling offscreen rendering
[texture] split out fbo update code from cluter_texture_paint
[texture] push/pop draw buffer when painting actors to a texture
[texture] Avoid redundant use of cogl_clip_stack_save when drawing offscreen
[cogl-draw-buffer] fix Cogl -> GL viewport coord conversion
[cogl_clip_push_window_rect] fix Cogl -> GL coordinate conversion
[matrix] Adds cogl_matrix_get_inverse API
[debug] Adds a COGL_DEBUG=matrices debug option
[cogl-matrix] Import Mesa's matrix manipulation code
[cogl] avoid any state changes when cogl_set_backface_culling_enable is a nop
[cogl] Use clockwise face winding for offscreen buffers with culling enabled
...
Robert Bragg [Wed, 7 Oct 2009 09:40:15 +0000 (10:40 +0100)]
[test-fbo] greatly simplify the test
This test tried to do too much, and I can't remember the last time I saw this
test work.
It no longer tries to create a texture from an offscreen actor and it no
longer tries to use shaders.
It does though show that chaining of clutter_texture_new_from_actor now
works, and that animating the source actor is reflected in textures created
from it.
When run you should see three actors:
- on the left is the pristine source actor rotating around the y-axis
- in the middle is the first texture created from the source actor
- and on the right a texture created from the middle actor
Note: the somewhat strange bobbing of the middle and right textures is
actually correct given how it was decided long ago to map the transformed
(to screen space) allocation of the source actor to the texture. When the
hand spins around the perspective projection of the top of the hand results
in the origin of the texture bobbing up to a higher stage position, but the
position of the textures is fixed. This design also means we end up
reallocating our offscreen draw buffer every frame that the actors
transformed size changes, which isn't ideal.
Robert Bragg [Thu, 22 Oct 2009 18:01:27 +0000 (19:01 +0100)]
[tests] test-backface-culling: test culling with offscreen rendering
Since offscreen rendering is internally forced to be upside down Cogl
needs to reverse the glFrontFace winding order so as not to interfere
with the use of cogl_set_backface_culling_enabled()
This ensures we test that mechanism.
Robert Bragg [Thu, 22 Oct 2009 15:56:01 +0000 (16:56 +0100)]
[tests] Adds test-cogl-readpixels.c for very basic cogl_read_pixels testing
Mostly this was written to verify that we don't flip the data read back from
an offscreen draw buffer. (since all offscreen rendering is done upside
down)
Robert Bragg [Thu, 22 Oct 2009 11:36:17 +0000 (12:36 +0100)]
[tests] Adds test-cogl-offscreen to validate offscreen draw buffer
This adds a basic test to check that rendering a few colored rectangles
offscreen works and that the modelview gets restored when switching back to
the previous buffer.
Robert Bragg [Wed, 21 Oct 2009 15:06:43 +0000 (16:06 +0100)]
[tests] test-cogl-viewport tests semantics of over/under size viewports
Unlike OpenGL Cogl puts the origin of windows/viewports at the top left
instead of bottom left. This test verifies that we correctly translate Cogl
viewports to OpenGL viewports for the awkward cases where the given viewport
has an offset and/or the viewport has a different size to the current draw
buffer.
Robert Bragg [Mon, 2 Nov 2009 01:23:25 +0000 (01:23 +0000)]
[test-texture-fbo] comment the colors defined in corner_colors
It helps to be able to quickly glance at the definition to see which
quadrant of the test actor should be which color, so when debugging a
problem and looking at the visual output you can easily verify if it's being
flipped upside down/left to right.
Neil Roberts [Thu, 17 Sep 2009 13:25:29 +0000 (14:25 +0100)]
Add a conformance test for clutter_texture_new_from_actor
This contains four tests :-
- A regular onscreen source with a clone next to it
- An offscreen source with a clone. This is currently commented out
because it no longer works.
- An onscreen source with a rectangular clip and a clone.
- An onscreen source with a clip from a path and a clone.
The sources are all a 2x2 grid of colors. Each clone is tested that it
either contains the color that should be at that grid position or that
the stage color is showing through if the source is clipped.
Robert Bragg [Sat, 31 Oct 2009 00:01:44 +0000 (00:01 +0000)]
[cogl-texture-2d-sliced] allow COGL_FORMAT_ANY with _new_with_size()
It's useful when initialzing offscreen draw buffers to be able to ask
Cogl to create a texture of a given size and with the default internal
pixel format.
Robert Bragg [Sun, 1 Nov 2009 23:56:03 +0000 (23:56 +0000)]
[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)
Robert Bragg [Mon, 2 Nov 2009 01:14:50 +0000 (01:14 +0000)]
[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.
Robert Bragg [Thu, 24 Sep 2009 13:34:09 +0000 (14:34 +0100)]
[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.
Robert Bragg [Tue, 13 Oct 2009 21:22:39 +0000 (22:22 +0100)]
[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.
Robert Bragg [Thu, 22 Oct 2009 23:16:30 +0000 (00:16 +0100)]
[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.
Robert Bragg [Sat, 31 Oct 2009 00:00:33 +0000 (00:00 +0000)]
[cogl-draw-buffer] fix Cogl -> GL viewport coord conversion
Before we call glViewport we need to convert Cogl viewport coordinates
(where the origin is defined to be top left) to OpenGL coordinates
(where the origin is defined to be bottom left)
We weren't considering that offscreen rendering is always upside down
and in this case Cogl coordinates == OpenGL coordinates.
Robert Bragg [Fri, 30 Oct 2009 23:57:56 +0000 (23:57 +0000)]
[cogl_clip_push_window_rect] fix Cogl -> GL coordinate conversion
Firstly this now uses the draw buffer height not the viewport height
when we need to perform a y = height - y conversion, since (as the
name suggests) we are dealing with window coordinates not viewport
coordinates.
Secondly this skips any conversion when the current draw buffer is an
offscreen draw buffer since offscreen rendering is always forced to be
upside down and in this case Cogl window coordinates == GL window
coordinates.
Robert Bragg [Mon, 26 Oct 2009 17:51:34 +0000 (17:51 +0000)]
[matrix] Adds cogl_matrix_get_inverse API
This new API takes advantage of the recently imported Mesa code to support
inverse matrix calculation. The matrix code keeps track (via internal
flags) of the transformations a matrix represents so that it can select an
optimized inversion function.
Note: although other aspects of the Cogl matrix API have followed a similar
style to Cairo's matrix API we haven't added a cogl_matrix_invert API
because the inverse of a CoglMatrix is actually cached as part of the
CoglMatrix structure meaning a destructive API like cogl_matrix_invert
doesn't let users take advantage of this caching design.
Robert Bragg [Mon, 26 Oct 2009 11:01:33 +0000 (11:01 +0000)]
[debug] Adds a COGL_DEBUG=matrices debug option
This adds a COGL_DEBUG=matrices debug option that can be used to trace all
matrix manipulation done using the Cogl API. This can be handy when you
break something in such a way that a trace is still comparable with a
previous working version since you can simply diff a log of the broken
version vs the working version to home in on the bug.
Robert Bragg [Mon, 26 Oct 2009 08:23:21 +0000 (08:23 +0000)]
[cogl-matrix] Import Mesa's matrix manipulation code
This pulls in code from Mesa to improve our matrix manipulation support. It
includes support for calculating the inverse of matrices based on top of a
matrix categorizing system that allows optimizing certain matrix types.
(the main thing we were after) but also adds some optimisations for
rotations.
Changes compared to the original code from Mesa:
- Coding style is consistent with the rest of Cogl
- Instead of allocating matrix->m and matrix->inv using malloc, our public
CoglMatrix typedef is large enough to directly contain the matrix, its
inverse, a type and a set of flags.
- Instead of having a _math_matrix_analyse which updates the type, flags and
inverse, we have _math_matrix_update_inverse which essentially does the
same thing (internally making use of _math_matrix_update_type_and_flags())
but with additional guards in place to bail out when the inverse matrix is
still valid.
- When initializing a matrix with the identity matrix we don't immediately
initialize the inverse matrix; rather we just set the dirty flag for the
inverse (since it's likely the user won't request the inverse of the
identity matrix)
Robert Bragg [Thu, 22 Oct 2009 18:09:20 +0000 (19:09 +0100)]
[cogl] avoid any state changes when cogl_set_backface_culling_enable is a nop
This is a simple optimization to bail out of cogl_set_backface_culling_enable
if it's not resulting in a change of state.
Robert Bragg [Thu, 22 Oct 2009 18:01:52 +0000 (19:01 +0100)]
[cogl] Use clockwise face winding for offscreen buffers with culling enabled
Because Cogl defines the origin for texture as top left and offscreen draw
buffers can be used to render to textures, we (internally) force all
offscreen rendering to be upside down. (because OpenGL defines the origin
to be bottom left)
By forcing the users scene to be rendered upside down though we also reverse
the winding order of all the drawn triangles which may interfere with the
users use of backface culling. This patch ensures that we reverse the
winding order for a front face (if culling is in use) while rendering
offscreen so we don't conflict with the users back face culling.
Robert Bragg [Fri, 30 Oct 2009 23:54:13 +0000 (23:54 +0000)]
[main] Use cogl_read_pixels not glReadPixels in clutter-main.c
The debugging function read_pixels_to_file() and _clutter_do_pick were both
directly calling glReadPixels, but we don't wan't Clutter making direct
OpenGL calls and Cogl provides a suitable alternative. It also means
read_pixels_to_file() doesn't need to manually flip the data read due to
differences in Clutter/Cogl coordinate systems.
Robert Bragg [Tue, 3 Nov 2009 12:54:45 +0000 (12:54 +0000)]
[cogl_read_pixels] don't force a 4 byte pack alignment
Technically this change shouldn't make a difference since we are
calling glReadPixels with GL_RGBA GL_UNSIGNED_BYTE which is a 4
byte format and it should always result in the same value according
to how OpenGL calculates the location of sequential rows.
i.e. k = a/s * ceil(snl/a) where:
a = alignment
s = component size (1)
n = number of components per pixel (4)
l = number of pixels in a row
gives:
k = 4/1 * ceil(4l/4) and k = 1/1 * ceil(4l/1) which are equivalent
I'm changing it because I've seen i915 driver code that bails out of
hardware accelerated paths if the alignment isn't 1, and because
conceptually we have no alignment constraints here so even if the current
value has no effect, when we start reading back other formats it may upset
things.
Robert Bragg [Mon, 2 Nov 2009 01:11:21 +0000 (01:11 +0000)]
[cogl_read_pixels] call cogl_flush() before changing glPixelStore state
We were previously calling cogl_flush() after setting up the glPixelStore
state for calling glReadPixels, but flushing the journal could itself
change the glPixelStore state.
Robert Bragg [Mon, 2 Nov 2009 01:10:02 +0000 (01:10 +0000)]
[cogl_read_pixels] ensure we flush the current draw buffer state before reading
Make sure we call _cogl_draw_buffer_flush_state() before glReadPixels() to
be sure we have bound the correct framebuffer.
Robert Bragg [Mon, 2 Nov 2009 01:12:10 +0000 (01:12 +0000)]
[cogl_read_pixels] fixes for calculating the y offset when rendering offscreen
Since offscreen rendering is forced to be upside down we don't need to do
any conversion of the users coordinates to go from Cogl window coordinates
to OpenGL window coordinates.
Robert Bragg [Thu, 22 Oct 2009 15:55:07 +0000 (16:55 +0100)]
[read-pixels] don't flip data when reading from offscreen draw buffers
Since we do all offscreen rendering upside down (so that we can have the
origin for texture coordinates be the top left of textures for the cases
where offscreen draw buffers are bound to textures) we don't need to flip
data read back from an offscreen framebuffer before we we return it to the
user.
Robert Bragg [Wed, 21 Oct 2009 22:22:45 +0000 (23:22 +0100)]
[clip-stack] tidy up transform_point() code
I was originally expecting the code not to handle offset viewports or
viewports with a different size to the framebuffer, but it turns out the
code worked fine. In the process though I think I made the code slightly
more readable.
Robert Bragg [Tue, 3 Nov 2009 13:26:58 +0000 (13:26 +0000)]
[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.
Robert Bragg [Wed, 21 Oct 2009 22:24:28 +0000 (23:24 +0100)]
[cogl_read_pixels] use buffer not viewport height to calculate y offset
glReadPixel takes window coordinates not viewport coordinates so we
shouldn't have been assuming that the viewport height == window height.
Robert Bragg [Wed, 21 Oct 2009 22:20:44 +0000 (23:20 +0100)]
[draw-buffer] Adds cogl_draw_buffer_get_{width,height} API
Simply adds missing API to query the width and height of any Cogl draw buffer.
Robert Bragg [Wed, 21 Oct 2009 22:24:49 +0000 (23:24 +0100)]
[cogl] Make sure Cogl always knows the current window geometry
Because Cogl defines the origin of viewport and window coordinates to be
top-left it always needs to know the size of the current window so that Cogl
window/viewport coordinates can be transformed into OpenGL coordinates.
This also fixes cogl_read_pixels to use the current draw buffer height
instead of the viewport height to determine the OpenGL y coordinate to use
for glReadPixels.
Robert Bragg [Thu, 22 Oct 2009 15:13:01 +0000 (16:13 +0100)]
[cogl] Make sure we draw upside down to offscreen draw buffers
First a few notes about Cogl coordinate systems:
- Cogl defines the window origin, viewport origin and texture coordinates
origin to be top left unlike OpenGL which defines them as bottom left.
- Cogl defines the modelview and projection identity matrices in exactly the
same way as OpenGL.
- I.e. we believe that for 2D centric constructs: windows/framebuffers,
viewports and textures developers are more used to dealing with a top left
origin, but when modeling objects in 3D; an origin at the center with y
going up is quite natural.
The way Cogl handles textures is by uploading data upside down in OpenGL
terms so that bottom left becomes top left. (Note: This also has the
benefit that we don't need to flip the data we get from image decoding
libraries since they typically also consider top left to be the image
origin.)
The viewport and window coords are mostly handled with various y =
height - y tweaks before we pass y coordinates to OpenGL.
Generally speaking though the handling of coordinate spaces in Cogl is a bit
fragile. I guess partly because none of it was design to be, it just
evolved from how Clutter defines its coordinates without much consideration
or testing. I hope to improve this over a number of commits; starting here.
This commit deals with the fact that offscreen draw buffers may be bound to
textures but we don't "upload" the texture data upside down, and so if you
texture from an offscreen draw buffer you need to manually flip the texture
coordinates to get it the right way around. We now force offscreen
rendering to be flipped upside down by tweaking the projection matrix right
before we submit it to OpenGL to scale y by -1. The tweak is entirely
hidden from the user such that if you call cogl_get_projection you will not
see this scale.
Robert Bragg [Thu, 22 Oct 2009 11:35:33 +0000 (12:35 +0100)]
[cogl] Ensure features are initialized first in cogl_create_context
Previously some context initializing was being done without valid feature
flags.
Robert Bragg [Fri, 16 Oct 2009 23:31:26 +0000 (00:31 +0100)]
[clip-stack] Handle flipped rectangles in try_pushing_rect_as_window_rect()
We were ignoring the possibility that the current modelview matrix may flip
the incoming rectangle in which case we didn't calculate a valid scissor
rectangle for clipping.
This fixes: http://bugzilla.o-hand.com/show_bug.cgi?id=1809
(Clipping doesn't work within an FBO)
Robert Bragg [Fri, 25 Sep 2009 13:34:34 +0000 (14:34 +0100)]
[draw-buffers] First pass at overhauling Cogl's framebuffer management
Cogl's support for offscreen rendering was originally written just to support
the clutter_texture_new_from_actor API and due to lack of documentation and
several confusing - non orthogonal - side effects of using the API it wasn't
really possible to use directly.
This commit does a number of things:
- It removes {gl,gles}/cogl-fbo.{c,h} and adds shared cogl-draw-buffer.{c,h}
files instead which should be easier to maintain.
- internally CoglFbo objects are now called CoglDrawBuffers. A
CoglDrawBuffer is an abstract base class that is inherited from to
implement CoglOnscreen and CoglOffscreen draw buffers. CoglOffscreen draw
buffers will initially be used to support the
cogl_offscreen_new_to_texture API, and CoglOnscreen draw buffers will
start to be used internally to represent windows as we aim to migrate some
of Clutter's backend code to Cogl.
- It makes draw buffer objects the owners of the following state:
- viewport
- projection matrix stack
- modelview matrix stack
- clip state
(This means when you switch between draw buffers you will automatically be
switching to their associated viewport, matrix and clip state)
Aside from hopefully making cogl_offscreen_new_to_texture be more useful
short term by having simpler and well defined semantics for
cogl_set_draw_buffer, as mentioned above this is the first step for a couple
of other things:
- Its a step toward moving ownership for windows down from Clutter backends
into Cogl, by (internally at least) introducing the CoglOnscreen draw
buffer. Note: the plan is that cogl_set_draw_buffer will accept on or
offscreen draw buffer handles, and the "target" argument will become
redundant since we will instead query the type of the given draw buffer
handle.
- Because we have a common type for on and offscreen framebuffers we can
provide a unified API for framebuffer management. Things like:
- blitting between buffers
- managing ancillary buffers (e.g. attaching depth and stencil buffers)
- size requisition
- clearing
Robert Bragg [Tue, 20 Oct 2009 15:55:10 +0000 (16:55 +0100)]
[stage-x11] Ensure viewport is initialized before first stage paint
This ensures that glViewport is called before the first stage paint.
Previously _clutter_stage_maybe_setup_viewport (which is done before we
start painting) was bailing out without calling cogl_setup_viewport because
the CLUTTER_STAGE_IN_RESIZE flag may be set if the stage was resized before
the first paint. (NB: The CLUTTER_STAGE_IN_RESIZE flag isn't removed until
we get an explicit event back from the X server since the window manager may
choose to deny/alter the resize.)
We now special case the first resize - where the viewport hasn't previously
been initialized and use the requested geometry to initialize the
glViewport without waiting for a reply from the server.
Robert Bragg [Tue, 15 Sep 2009 21:19:01 +0000 (22:19 +0100)]
[cogl-fbo] Bring the gles code more in line with gl code
Over time the two cogl-fbo.c files have needlessly diverged as bug fixes or
cleanups went into one version but not the other. This tries to bring them
back in line with each other. It should actually be simple enough to move
cogl-fbo.c to be a common file, and simply not build it for GLES 1.1, so
maybe I'll follow up with such a patch soon.
Robert Bragg [Tue, 15 Sep 2009 21:15:03 +0000 (22:15 +0100)]
[cogl-fbo] Remove poorly documented workaround for unknown driver/hardware
The comment just said: "Some implementation require a clear before drawing
to an fbo. Luckily it is affected by scissor test." and did a scissored
clear, which is clearly a driver bug workaround, but for what driver? The
fact that it was copied into the gles backend (or vica versa is also
suspicious since it seems unlikely that the workaround is necessary for both
backends.)
We can easily restore the workaround with a better comment if this problem
really still exists on current drivers, but for now I'd rather minimize
hand-wavey workaround code that can't be tested.
Damien Lespiau [Sun, 1 Nov 2009 14:36:05 +0000 (14:36 +0000)]
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.
Emmanuele Bassi [Fri, 30 Oct 2009 12:11:19 +0000 (12:11 +0000)]
build: Add missing gles/cogl-context-driver.h to dist
The gles/cogl-context-driver.h header file is missing from the
dist target, which means it's not in the tarballs.
Emmanuele Bassi [Fri, 30 Oct 2009 11:02:35 +0000 (11:02 +0000)]
Add run-time version checks
Just like CLUTTER_CHECK_VERSION does version checking at compile
time, we need a way to verify the version of the library that we
are linking against. This is mostly needed for language bindings
and for run-time loadable modules -- when we'll get those.
Neil Roberts [Tue, 27 Oct 2009 13:18:51 +0000 (13:18 +0000)]
[cogl_polygon] Enable COGL_ENABLE_BLEND when use_color is set
Otherwise you can't use the alpha channel of the vertex colors unless
the material has a texture with alpha or the material's color has
alpha less than 255.
Neil Roberts [Tue, 27 Oct 2009 12:38:10 +0000 (12:38 +0000)]
build: Add $(top_buiddir)/clutter/cogl to the include path in clutter/cogl/cogl
Some files try to include "cogl/cogl-defines-gl.h" so
$(top_builddir)/clutter/cogl needs to be in the include path for out of
tree builds to work.
Emmanuele Bassi [Mon, 26 Oct 2009 16:29:31 +0000 (16:29 +0000)]
color: Fix HLS-to-RGB conversion
Apparently, on 64bit systems the floating point noise is enough
to screw up the float-to-int truncation.
The solution is to round up by 0.5 and then use floorf(). This
gives predictable and correct results on both 32bit and 64bit
systems.
Emmanuele Bassi [Mon, 26 Oct 2009 16:02:06 +0000 (16:02 +0000)]
layout: Do not create a LayoutMeta on remove
When calling remove_child_meta() we check if there is a LayoutMeta
already attached to the Actor, and if that LayoutMeta matches the
(manager, container, actor) tuple. If the LayoutMeta does not match,
though, we create a new LayoutMeta instance -- in order to remove it
right afterwards.
Instead of doing this, we can simply check for a matching LayoutMeta
and if present, remove it.
In case of an existing, non-matching LayoutMeta, we're left with a
dangling instance, but it does not matter: the removal happens in the
unparenting phase of a ClutterContainer, so either the Actor will be
destroyed and thus the LayoutMeta will be disposed along with it; or
it will be parented to another container, and thus the LayoutMeta
will be replaced.
Emmanuele Bassi [Mon, 26 Oct 2009 15:10:20 +0000 (15:10 +0000)]
tests: Use the right key symbol for adding children
The test-box-layout should be using CLUTTER_plus instead of a
literal '+'.
Emmanuele Bassi [Mon, 26 Oct 2009 15:09:07 +0000 (15:09 +0000)]
box: Depth level changes should queue a relayout
ClutterBox is not ClutterGroup: a change in the level of an actor
through raise, lower or depth sorting must trigger a relayout.
Emmanuele Bassi [Mon, 26 Oct 2009 15:08:03 +0000 (15:08 +0000)]
box: Check before using the LayoutManager instance
A ClutterBox might not have a ClutterLayoutManager instance
associated -- for instance, during destruction. We should check
for one before calling methods on it.
Emmanuele Bassi [Mon, 26 Oct 2009 11:51:30 +0000 (11:51 +0000)]
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
Emmanuele Bassi [Mon, 26 Oct 2009 11:42:16 +0000 (11:42 +0000)]
tests: Print out the captured event type
The ::captured-event signal on the Stage is not printing out the
event type.
Emmanuele Bassi [Fri, 23 Oct 2009 16:32:18 +0000 (17:32 +0100)]
docs: Add images for layout managers
It's easier to show the layout manager policy with a simple
screen shot coming from our interactive tests.
Emmanuele Bassi [Fri, 23 Oct 2009 15:44:28 +0000 (16:44 +0100)]
cogl: Avoid C99-isms
Do not declare variables after statements.
Emmanuele Bassi [Fri, 23 Oct 2009 14:46:25 +0000 (15:46 +0100)]
cogl: Remove cogl-current-matrix.c
The cogl-current-matrix.c file is unused since commit
5e5d94dfbed18bf2b4c8c7a7ff9847952b2c4ae2 and it's not compiled
or distributed anymore.
Emmanuele Bassi [Fri, 23 Oct 2009 13:30:15 +0000 (14:30 +0100)]
Update Git ignore rules
Emmanuele Bassi [Fri, 23 Oct 2009 12:55:50 +0000 (13:55 +0100)]
Post-release bump to 1.1.3
Emmanuele Bassi [Fri, 23 Oct 2009 12:38:28 +0000 (13:38 +0100)]
Release 1.1.2 developers snapshot
Emmanuele Bassi [Fri, 23 Oct 2009 11:15:25 +0000 (12:15 +0100)]
build: Make COGL pass distcheck
Some changes to make COGL pass distcheck with Automake 1.11 and
anal-retentiveness turned up to 11.
The "major" change is the flattening of the winsys/ part of COGL,
which is built directly inside libclutter-cogl.la instead of an
intermediate libclutter-cogl-winsys.la object.
Ideally, the whole COGL should be flattened out using a
quasi-non-recursive Automake layout; unfortunately, the driver/
sub-section ships with identical targets and Automake cannot
distinguish GL and GLES objects.
Emmanuele Bassi [Fri, 23 Oct 2009 09:17:40 +0000 (10:17 +0100)]
actor: Identify allocation cycles
If an actor calls directly or indirectly clutter_actor_queue_relayout()
on itself from within the allocate() implementation it will cause a
relayout cycle. This is usually a condition that should be checked by
ClutterActor and we should emit a warning if it is verified.
Emmanuele Bassi [Fri, 23 Oct 2009 09:08:02 +0000 (10:08 +0100)]
actor: Add checks for IN_DESTRUCTION flag
ClutterActor should check whether the current instance is being
destroyed and avoid performing operations like:
• queueing redraws
• queueing relayouts
It should also warn if the actor is being parented to an actor
currently being destroyed.
Emmanuele Bassi [Fri, 23 Oct 2009 08:48:35 +0000 (09:48 +0100)]
actor: Show actor name or type in the state checks warnings
When showing a warning in the state checks we perform to verify that
the invariants are maintained when showing, mapping and realizing, we
should also print out the name of the actor failing the checks. If the
actor has no name, the GType name should be used as a fallback.
Neil Roberts [Thu, 22 Oct 2009 15:55:29 +0000 (16:55 +0100)]
Fix some compilation errors in cogl-gles2-wrapper.c
The changes in
74f2122b6 introduced some syntax errors which were
preventing the GLES2 backend from compiling.
Emmanuele Bassi [Thu, 22 Oct 2009 12:48:49 +0000 (13:48 +0100)]
clone: Set :source as CONSTRUCT
The :source property for ClutterClone is a constructor property, but
it most definitely is not a constructor-only one.