1
0
Fork 0
Commit graph

139 commits

Author SHA1 Message Date
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
Neil Roberts
b869e87c86 test-npot-texture: Add some verbose notes
This just adds some verbose output stating whether Cogl thinks that
NPOT textures are supported.
2009-11-18 17:28:08 +00:00
Emmanuele Bassi
c8d5703788 tests: Add unit for Animation definitions
Verify that an Animation can be defined using ClutterScript.

No initial/final state of the animation, yet.
2009-11-13 15:01:17 +00:00
Emmanuele Bassi
95b55588ad tests: Print out parser errors if present
If the conformance test for the Script parser throws an error
and we've enabled verbosity then we should print out the error
message before aborting.
2009-11-13 15:01:17 +00:00
Joshua Lock
b9e519c3b2 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
2009-11-06 11:49:21 +00:00
Emmanuele Bassi
f1ed8be066 conform: Add unit for properties holding objects
Exercise the definition of GObjects for properties defined using
GParamSpecObject.
2009-11-06 11:39:30 +00:00
Emmanuele Bassi
185107c6cf conformance: Add unit on the implicit alpha definition
Exercise the implicit alpha and timeline definition to catch
regressions in the ClutterScript parser code.
2009-11-06 11:39:30 +00:00
Robert Bragg
abae6013e1 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.
2009-11-05 21:10:18 +00:00
Emmanuele Bassi
95d78acb4c 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.
2009-11-04 16:50:35 +00:00
Emmanuele Bassi
8ba13d6495 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.
2009-11-04 15:21:03 +00:00
Emmanuele Bassi
d7cfa15851 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.
2009-11-04 11:50:45 +00:00
Emmanuele Bassi
7d891d9dd4 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.
2009-11-04 11:47:09 +00:00
Robert Bragg
ffb592de59 [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.
2009-11-04 03:34:09 +00:00
Robert Bragg
60b642f5d6 [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)
2009-11-04 03:34:09 +00:00
Robert Bragg
2ff7f2d287 [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.
2009-11-04 03:34:09 +00:00
Robert Bragg
369e68630d [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.
2009-11-04 03:34:08 +00:00
Robert Bragg
bc24190b9a [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.
2009-11-04 03:34:08 +00:00
Neil Roberts
b41a81fb08 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.
2009-11-04 03:34:08 +00:00
Robert Bragg
8790306629 [test-backface-culling] Check that inverted tex coords don't affect culling
The additional check draws another front facing rectangle but this time with
the texture coords flipped on the x axis.  The code that handles sliced
textures in cogl-primitives.c makes some suspicious changes to the geometry
when the texture coords are inverted.
2009-10-16 18:58:52 +01:00
Robert Bragg
43efab46bc Intial Re-layout of the Cogl source code and introduction of a Cogl Winsys
As part of an incremental process to have Cogl be a standalone project we
want to re-consider how we organise the Cogl source code.

Currently this is the structure I'm aiming for:
cogl/
    cogl/
	<put common source here>
	winsys/
	   cogl-glx.c
	   cogl-wgl.c
	driver/
	    gl/
	    gles/
	os/ ?
    utils/
	cogl-fixed
	cogl-matrix-stack?
        cogl-journal?
        cogl-primitives?
    pango/

The new winsys component is a starting point for migrating window system
code (i.e.  x11,glx,wgl,osx,egl etc) from Clutter to Cogl.

The utils/ and pango/ directories aren't added by this commit, but they are
noted because I plan to add them soon.

Overview of the planned structure:

* The winsys/ API is the API that binds OpenGL to a specific window system,
  be that X11 or win32 etc.  Example are glx, wgl and egl. Much of the logic
  under clutter/{glx,osx,win32 etc} should migrate here.

* Note there is also the idea of a winsys-base that may represent a window
  system for which there are multiple winsys APIs.  An example of this is
  x11, since glx and egl may both be used with x11.  (currently only Clutter
  has the idea of a winsys-base)

* The driver/ represents a specific varient of OpenGL. Currently we have "gl"
  representing OpenGL 1.4-2.1 (mostly fixed function) and "gles" representing
  GLES 1.1 (fixed funciton) and 2.0 (fully shader based)

* Everything under cogl/ should fundamentally be supporting access to the
  GPU.  Essentially Cogl's most basic requirement is to provide a nice GPU
  Graphics API and drawing a line between this and the utility functionality
  we add to support Clutter should help keep this lean and maintainable.

* Code under utils/ as suggested builds on cogl/ adding more convenient
  APIs or mechanism to optimize special cases. Broadly speaking you can
  compare cogl/ to OpenGL and utils/ to GLU.

* clutter/pango will be moved to clutter/cogl/pango

How some of the internal configure.ac/pkg-config terminology has changed:
backendextra -> CLUTTER_WINSYS_BASE # e.g. "x11"
backendextralib -> CLUTTER_WINSYS_BASE_LIB # e.g. "x11/libclutter-x11.la"
clutterbackend -> {CLUTTER,COGL}_WINSYS # e.g. "glx"
CLUTTER_FLAVOUR -> {CLUTTER,COGL}_WINSYS
clutterbackendlib -> CLUTTER_WINSYS_LIB
CLUTTER_COGL -> COGL_DRIVER # e.g. "gl"

Note: The CLUTTER_FLAVOUR and CLUTTER_COGL defines are kept for apps

As the first thing to take advantage of the new winsys component in Cogl;
cogl_get_proc_address() has been moved from cogl/{gl,gles}/cogl.c into
cogl/common/cogl.c and this common implementation first trys
_cogl_winsys_get_proc_address() but if that fails then it falls back to
gmodule.
2009-10-16 18:58:50 +01:00
Emmanuele Bassi
83b4ec7a12 units: Cache the pixels value inside Units
When computing the pixels value of a ClutterUnits value we should
be caching the value to avoid recomputing for every call of
clutter_units_to_pixels(). We already have a flag telling us to
return the cached value, but we miss the mechanism to evict the
cache whenever the Backend settings affecting the conversion, that
is default font and resolution, change.

In order to implement the eviction we can use a "serial"; the
Backend will have an internal serial field which we retrieve and
put inside the ClutterUnits structure (we split one of the two
64 bit padding fields into two 32 bit fields to maintain ABI); every
time we call clutter_units_to_pixels() we compare the units serial
with that of the Backend; if they match and pixels_set is set to
TRUE then we just return the stored pixels value. If the serials
do not match then we unset the pixels_set flag and recompute the
pixels value.

We can verify this by adding a simple test unit checking that
by changing the resolution of ClutterBackend we get different
pixel values for 1 em.

http://bugzilla.openedhand.com/show_bug.cgi?id=1843
2009-10-16 15:25:37 +01:00
Damien Lespiau
80b3a8d328 [units] Ensure we don't have ponies
The documentation states we should not parse ponies. Even with those
with exclamation marks.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-10-07 17:10:51 +01:00
Damien Lespiau
8605073edb [units] Add support for centimeters
The only tricky part of the patch is to remember that 1cm is 10mm.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-10-07 16:06:26 +01:00
Damien Lespiau
96859959bd [units] Be more strict in the grammar we are parsing
Current parsing of units has a number of shortcomings:
  * a number followed by trailing space (without any unit specified) was
    not recognized,
  * "5 emeralds" was parsed as 5em,
  * the way we parse the digits after the separator makes us lose
    precision for no good reason (5.0 is parsed as 5.00010014...f which
    makes g_assert_cmpfloat() fail)

Let's define a stricter grammar we can recognize and try to do so. The
description is in EBNF form, removing the optional <> which is a pain
when having to write DocBook, and using '' for the terminal symbols.

Last step, add more ClutterUnits unit test to get a better coverage of
the grammar we want to parse.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-10-07 16:06:26 +01:00
Thomas Wood
c7d50083ec [color] allow alpha to be omitted when converting to color from string
Parse #rgb and #rrggbb in addition to forms with the alpha channel
specified. This allows conversion of colour strings from documents such as
CSS where the alpha channel is not specified when using '#' notation.

This patch also adds the relevant conformance test.
2009-10-07 12:56:01 +01:00
Damien Lespiau
a799f6ccec Fix string parsing when no unit is given
The check should really be on the character pointed by str. Added the
corresponding test case.
2009-10-05 13:08:16 +01:00
Emmanuele Bassi
ecfa0c4f92 [build] Split out the custom silent rules
The silent rules we use for custom targets should be moved into a
separate Makefile.am that gets included from all the others.
2009-09-16 17:47:59 +01:00
Emmanuele Bassi
561f5868e8 [tests] Add preferred size conformance test unit
This unit verifies that an Actor class will invoke the get_preferred_*
virtual functions unless the caching is in effect; it also verifies
that the cached values are correctly evicted.
2009-09-15 11:27:50 +01:00
Emmanuele Bassi
092401c01b [tests] Add initial sizing conformance test suite
The size requisition and allocation mechanisms should be thoroughly
tested to avoid unwanted regressions.

For starters, we can test the explicit size setting and the side
effects of calling clutter_actor_set_size().
2009-09-15 11:27:50 +01:00
Emmanuele Bassi
87831b3427 [tests] Add a Group actor unit
We need to test that the depth sorting of ClutterGroup works correctly
in case we wish to change the data structure that stores the children,
and do so without changing the default behaviour.
2009-08-25 17:57:22 +01:00
Emmanuele Bassi
f08b583a31 [tests] Abstract GTest and Clutter initialization
The set up process of the conformance test suite is complex enough to
warrant a split up into its own function.
2009-08-14 15:58:00 +01:00
Emmanuele Bassi
a5d6b23308 [units] Add binding-friendly initializers
We should follow the convention for boxed types initializers of:

  <type_name>_from_<another_type> (boxed, value)

For ClutterUnits as well; so:

  clutter_units_pixels -> clutter_units_from_pixels
  clutter_units_em     -> clutter_units_from_em
  ...

We should still keep the short-hand version as a macro, though.
2009-07-28 13:46:11 +01:00
Haakon Sporsheim
fe416fb745 Add int dummy; to empty struct TestConformSimpleFixture definition. 2009-07-28 12:13:43 +01:00
Emmanuele Bassi
76140c5f52 [build] Use API_VERSION, not MAJORMINOR
The correct macro for Clutter's API version is CLUTTER_API_VERSION,
not CLUTTER_MAJORMINOR anymore.
2009-07-28 11:42:58 +01:00
Emmanuele Bassi
db2fda9c43 [tests] Add RGB<->HLS roundtrip test unit
The ClutterColor conformance test should have a unit for verifying
the RGB<->HLS conversion code, especially the ability to roundtrip
between the two colorspaces.
2009-07-27 12:04:24 +01:00
Robert Bragg
358d7c30dc [cogl] Ensure well defined semantics for COGL_INVALID_HANDLE material layers
Fixes and adds a unit test for creating and drawing using materials with
COGL_INVALID_HANDLE texture layers.

This may be valid if for example the user has set a texture combine string
that only references a constant color.

_cogl_material_flush_layers_gl_state will bind the fallback texture for any
COGL_INVALID_HANDLE layer, later though we could explicitly check when the
current blend mode does't actually reference a texture source in which case
binding the fallback texture is redundant.

This tests drawing using cogl_rectangle, cogl_polygon and
cogl_vertex_buffer_draw.
2009-06-30 17:35:07 +01:00
Robert Bragg
24ca92951f [cogl] Adds cogl_read_pixels to replace direct use of glReadPixels
To allow for flushing of batched geometry within Cogl we can't support users
directly calling glReadPixels.  glReadPixels is also awkward, not least
because it returns upside down image data.

All the unit tests have been swithed over and clutter_stage_read_pixels now
sits on top of this too.
2009-06-29 23:49:06 +01:00
Emmanuele Bassi
0415d62d40 Disable single header inclusion for GLib
In order to be ready for the next major version of GLib we need to
disable single header inclusion by using the G_DISABLE_SINGLE_INCLUDES
define in the build process.
2009-06-15 11:29:37 +01:00
Emmanuele Bassi
abac520f0c [tests] Add unit for Clone behaviour
A clone actor should not modify the state of its source, so we need
to check that it's not breaking any invariant.
2009-06-15 11:29:37 +01:00
Robert Bragg
96827db740 Bug 1406 - Handling of premultiplication in clutter
Merge branch 'premultiplication'

[cogl-texture docs] Improves the documentation of the internal_format args
[test-premult] Adds a unit test for texture upload premultiplication semantics
[fog] Document that fogging only works with opaque or unmultipled colors
[test-blend-strings] Explicitly request RGBA_888 tex format for test textures
[premultiplication] Be more conservative with what data gets premultiplied
[bitmap] Fixes _cogl_bitmap_fallback_unpremult
[cogl-bitmap] Fix minor copy and paste error in _cogl_bitmap_fallback_premult
Avoid unnecesary unpremultiplication when saving to local data
Don't unpremultiply Cairo data
Default to a blend function that expects premultiplied colors
Implement premultiplication for CoglBitmap
Use correct texture format for pixmap textures and FBO's
Add cogl_color_premultiply()
2009-06-11 16:00:28 +01:00
Robert Bragg
41579eb3c9 [test-premult] Adds a unit test for texture upload premultiplication semantics
cogl_texture_new_from_data lets you specify a source format for the users given
data, and an internal format which the user wants the GPU to see. This unit
test verifies that the users data is premultiplied, un-premultiplied or
left alone for a number of (source format, internal format) pairs.

cogl_texture_set_region allows specifying a source format, and the internal
format is determined from the texture being updated. As above we test
a number of format pairs and check Cogl is converting data correctly.

The test verifies that if the user allows COGL_FORMAT_ANY for the
internal_format then by default Cogl will choose a premultipled format for
RGBA textures.

Note: Currently this only tests cogl_texture_new_from_data and
cogl_texture_set_region, we should also test cogl_texture_new_from_file,
cogl_texture_new_from_bitmap and cogl_texture_new_from_foreign.
2009-06-11 14:17:53 +01:00
Robert Bragg
80aceda9bb [test-blend-strings] Explicitly request RGBA_888 tex format for test textures
This test assumes that the textures will be stored internally with exactly
the color given so that specific texture combining arithmetic can be
tested. Using COGL_PIXEL_FORMAT_ANY allows Cogl to internally premultiply
the textures, so we have to explicitly request an unmultiplied format.
2009-06-11 14:17:53 +01:00
Emmanuele Bassi
e60584ea6f Change the paint forcing on the Text cache text
The changes in the master clock and the repaint cycle have been
changed, and broke the way the test for the Text actor cache of
PangoLayouts forces a redraw.

We have to call clutter_actor_paint() on the Stage embedding the
Text actor we want to test; this is kinda fugly because if the
Layout has changed it will end up causing a reallocation cycle
in the middle of the Text actor paint. Since it's a test case,
and since forcing redraws is a bit of a hack as well, we can
close both our eyes on that.
2009-06-11 12:23:09 +01:00
Neil Roberts
9021aa2909 Revert "[timeline] Don't clamp the elapsed time when a looping tl reaches the end"
This reverts commit 9c5663d671.

The patch was causing problems for applications that expect the
elapsed_time to be at either end of the timeline when the completed
signal is fired. For example test-behave swaps the direction of the
timeline in the completed handler but if the time has overflowed the
end then the timeline would only take a short time to get back the
beginning. This caused the animation to just vibrate around the
beginning.
2009-06-11 11:46:41 +01:00
Neil Roberts
6bb5b3a13e [tests] Don't add a newline to the end of g_test_message calls
Two of the timeline tests were calling g_test_message and adding a \n
so the output looked odd.
2009-06-11 11:38:49 +01:00
Neil Roberts
19cbb30783 [test-timeline] Add a marker at the beginning of the timeline
The beginning of the timeline needs special treatment to detect a
marker so it should have one in the conformance test.
2009-06-11 11:32:41 +01:00
Neil Roberts
9c5663d671 [timeline] Don't clamp the elapsed time when a looping tl reaches the end
The new-frame signal of a timeline was previously guaranteed to be
emitted with the elapsed_time set to the end before it emits the
completed signal. This doesn't necessarily make sense for looping
timelines because it would cause the elapsed time to be clamped to a
slightly off value whenever the timeline restarts. This patch makes it
perform the wrap around before emitting the new-frame signal so that
the elapsed time always corresponds to the time elapsed since the
timeline was started.

Additionally it no longer fudges the msecs_delta property to make the
marker check work so clutter_timeline_get_delta will always return the
wall clock time since the last frame.
2009-06-10 17:47:33 +01:00
Owen W. Taylor
287d4f76ec Remove useless manual timeline ticking
The master clock now works fine whether or not there are any stages,
so in the timeline conformance tests don't need to set up their
own times.

Set CLUTTER_VBLANK=none for the conformance tests, which in addition
to removing an test-environment dependency, will result in the ticking
for timeline tests being throttled to the default frame rate.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-06-09 15:03:56 +01:00
Owen W. Taylor
6705ce6c6a Move elapsed-time calculations into ClutterTimeline
Instead of calculating a delta in the master clock, and passing that
into each timeline, make each timeline individually responsible for
remembering the last time and computing the delta.

This:

 - Fixes a problem where we could spin infinitely processing
   timeline-only frames with < 1msec differences.
 - Makes timelines consistently start timing on the first frame;
   instead of doing different things for the first started timeline
   and other timelines.
 - Improves accuracy of elapsed time computations by avoiding
   accumulating microsecond => millisecond truncation errors.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-06-09 15:03:56 +01:00
Emmanuele Bassi
d8459b0a32 [tests] Clarify the numbers 2009-06-08 10:59:22 +01:00