Commit Graph

68 Commits

Author SHA1 Message Date
Neil Roberts
10b16b4b7e Add a test case for cogl_path
This tests various paths drawing rectangles and verifies that the
expected pixels are filled in. Some of the paths are drawn by copying
an existing path and modifying it which should test the copy-on-write
code.
2010-04-08 19:54:20 +01:00
Neil Roberts
c3a942abde Add a conformance test for rectangle textures
The test creates a GL_TEXTURE_RECTANGLE_ARB texture using
cogl_texture_new_from_foreign and confirms that rendering it works
correctly. If the rectangle texture extension isn't available then
this test always succeeds.

http://bugzilla.openedhand.com/show_bug.cgi?id=2015
2010-03-04 14:52:12 +00:00
Bastian Winkler
96c31bbf0e model: Implement ClutterScriptable interface
Allow a ClutterModel to be constructed through the ClutterScript API.
Currently this allows a model to be generated like like this:

{
  "id" : "test-model",
  "type" : "ClutterListModel",
  "columns" : [
    [ "text-column", "gchararray" ],
    [ "int-column", "gint" ],
    [ "actor-column", "ClutterRectangle" ]
  ]
}

where 'columns' is an array containing arrays of column-name,
column-type pairs.

http://bugzilla.openedhand.com/show_bug.cgi?id=2007
2010-02-25 23:09:11 +00:00
Emmanuele Bassi
bd303d6efb conform: Verify parsing of multiple properties
The ClutterAnimator support for parsing multiple properties should be
verified in the conformance test suite.

http://bugzilla.openedhand.com/show_bug.cgi?id=2003
2010-02-24 16:43:17 +00:00
Damien Lespiau
b5d5821304 tests: Add a test for CoglPixelBuffers
Exercise the whole public CoglBuffer / CoglPixelBuffer and
cogl_texture_new_from_buffer API.
2010-02-08 17:14:49 +00:00
Emmanuele Bassi
4dd11d6915 animator: Provide a ClutterScript parser
The whole point of having the Animator class is that the developer can
describe a complex animation using ClutterScript. Hence, ClutterAnimator
should hook into the Script machinery and parse a specific description
format for its keys.
2010-02-08 15:52:18 +00:00
Neil Roberts
830f2402d4 Merge branch 'more-texture-backends'
This adds three new texture backends.

- CoglTexture2D: This is a trimmed down version of CoglTexture2DSliced
  which only supports a single texture and only works with the
  GL_TEXTURE_2D target. The code is a lot simpler so it has a less
  overheads than dealing with slices. Cogl will use this wherever
  possible.

- CoglSubTexture: This is used to get a CoglHandle to represent a
  subregion of another texture. The texture can be used as if it was a
  standalone texture but it does not need to copy the resources.

- CoglAtlasTexture: This collects RGB and RGBA textures into a single
  GL texture with the aim of reducing texture state changes and
  increasing batching. The backend will try to manage the atlas and
  may move the textures around to close gaps in the texture. By
  default all textures will be placed in the atlas.
2010-02-06 00:20:32 +00:00
Emmanuele Bassi
12b004b0e7 tests: Add an initial Behaviour conformance suite
The coverage of the Behaviour sub-classes is currently abysmal. An
initial test suite for Behaviours should at least verify that the
accessors and the constructors are doing the right thing.

This initial test suite just verifies the BehaviourOpacity sub-class,
but it already bumps up the overall coverage by 2%.
2010-02-02 12:58:27 +00:00
Neil Roberts
36f18e5ac5 cogl: Make CoglSubTexture only work for quad rendering
The sub texture backend doesn't work well as a completely general
texture backend because for example when rendering with cogl_polygon
it needs to be able to tranform arbitrary texture coordinates without
reference to the other coordintes. This can't be done when the texture
coordinates are a multiple of one because sometimes the coordinate
should represent the left or top edge and sometimes it should
represent the bottom or top edge. For example if the s coordinates are
0 and 1 then 1 represents the right edge but if they are 1 and 2 then
1 represents the left edge.

Instead the sub-textures are now documented not to support coordinates
outside the range [0,1]. The coordinates for the sub-region are now
represented as integers as this helps avoid rounding issues. The
region can no longer be a super-region of the texture as this
simplifies the code quite a lot.

There are two new texture virtual functions:

transform_quad_coords_to_gl - This transforms two pairs of coordinates
     representing a quad. It will return FALSE if the coordinates can
     not be transformed. The sub texture backend uses this to detect
     coordinates that require repeating which causes cogl-primitives
     to use manual repeating.

ensure_non_quad_rendering - This is used in cogl_polygon and
     cogl_vertex_buffer to inform the texture backend that
     transform_quad_to_gl is going to be used. The atlas backend
     migrates the texture out of the atlas when it hits this.
2010-01-18 09:22:04 +00:00
Neil Roberts
ead4399536 Merge branch 'master' into more-texture-backends 2010-01-15 12:15:46 +00:00
Neil Roberts
a70ebe4f52 tests: Add a simple conformance test for texture mipmaps
This adds a test which renders a texture into a 1x1 pixel quad with
and without filters that use mipmaps. The pixel without mipmaps will
be one of the colors from the texture and the one with will be the
average of all the pixels in the texture.
2010-01-15 12:05:19 +00:00
Emmanuele Bassi
c6ce9c3389 conform: Add operators tests for ClutterColor
The clutter_color_add() and clutter_color_subtract() functions are
lacking unit testing to catch eventual regressions.
2010-01-14 14:07:04 +00:00
Robert Bragg
8b950bdc87 journal: Fixes logging of multiple sets of texture coordinates
If a user supplied multiple groups of texture coordinates with
cogl_rectangle_with_multitexture_coords() then we would repeatedly log only
the first group in the journal.  This fixes that bug and adds a conformance
test to verify the fix.

Thanks to Gord Allott for reporting this bug.
2010-01-12 11:22:08 +00:00
Emmanuele Bassi
c7e8ddb7a6 conform: Add test unit for the destruction of Containers
Verify that internal children do not go through the remove()
implementation, and that non-internal children do.
2009-12-18 23:34:25 +00:00
Neil Roberts
27c4eb483d cogl: Add a conformance test for sub textures
This tests creating a sub texture from a larger texture using various
different texture coordinates. It also tries to read back the texture
data using cogl_texture_get_data.
2009-12-02 22:03:16 +00:00
Emmanuele Bassi
7d842079ca conform: Add named object property unit for ClutterScript
We should exercise the resolution of the object properties containing a
string pointing to an object previously defined using ClutterScript.
2009-11-30 19:11:00 +00:00
Robert Bragg
c12470666e tests: rename cogl conformance tests so they can be clearly identified
All Cogl conformance tests are now prefixed 'test-cogl-'
2009-11-27 00:28:39 +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
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
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
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
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
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
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
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
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
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
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
Robert Bragg
dea7f9b7d3 [test-conformance] we were calling clutter_init with un-initialized arguments
This ensure we initialize shared_state->arg{c,v}_addr before calling
clutter_init
2009-06-05 17:18:32 +01:00
Neil Roberts
3ee093e356 Merge branch 'timeline-no-fps' into 1.0-integration 2009-06-05 12:20:41 +01:00
Emmanuele Bassi
0d5e17ecd1 [units] Rework Units into logical distance value
Units as they have been implemented since Clutter 0.4 have always been
misdefined as "logical distance unit", while they were just pixels with
fractionary bits.

Units should be reworked to be opaque structures to hold a value and
its unit type, that can be then converted into pixels when Clutter needs
to paint or compute size requisitions and perform allocations.

The previous API should be completely removed to avoid collisions, and
a new type:

        ClutterUnits

should be added; the ability to install GObject properties using
ClutterUnits should be maintained.
2009-06-04 16:30:31 +01:00
Neil Roberts
9c7afe0c5b [timeline] Remove the concept of frames from timelines
Timelines no longer work in terms of a frame rate and a number of
frames but instead just have a duration in milliseconds. This better
matches the working of the master clock where if any timelines are
running it will redraw as fast as possible rather than limiting to the
lowest rated timeline.

Most applications will just create animations and expect them to
finish in a certain amount of time without caring about how many
frames are drawn. If a frame is going to be drawn it might as well
update all of the animations to some fraction of the total animation
rather than rounding to the nearest whole frame.

The 'frame_num' parameter of the new-frame signal is now 'msecs' which
is a number of milliseconds progressed along the
timeline. Applications should use clutter_timeline_get_progress
instead of the frame number.

Markers can now only be attached at a time value. The position is
stored in milliseconds rather than at a frame number.

test-timeline-smoothness and test-timeline-dup-frames have been
removed because they no longer make sense.
2009-06-04 13:21:57 +01:00
Emmanuele Bassi
b6f1322e07 [tests] Add ClutterColor conformance tests
Add a conformance test unit for the to_string() and from_string()
methods.
2009-06-01 18:43:47 +01:00
Robert Bragg
33994caa71 [cogl-material] Support string based blending and layer combine descriptions
Setting up layer combine functions and blend modes is very awkward to do
programatically.  This adds a parser for string based descriptions which are
more consise and readable.

E.g. a material layer combine function could now be given as:
  "RGBA = ADD (TEXTURE[A], PREVIOUS[RGB])"
or
  "RGB = REPLACE (PREVIOUS)"
  "A = MODULATE (PREVIOUS, TEXTURE)"

The simple syntax and grammar are only designed to expose standard fixed
function hardware, more advanced combining must be done with shaders.

This includes standalone documentation of blend strings covering the aspects
that are common to blending and texture combining, and adds documentation
with examples specific to the new cogl_material_set_blend() and
cogl_material_layer_set_combine() functions.

Note: The hope is to remove the now redundant bits of the material API
before 1.0
2009-05-28 02:43:28 +01:00
Robert Bragg
ef1a771fde [build] Fixes some compiler warnings when building for GLES 2
There were a number of variables shadowing other symbols, and an unused
display variable.
2009-05-28 01:15:41 +01:00
Emmanuele Bassi
f8f54989be Merge commit 'origin/master' into 1.0-integration
Conflicts:
	clutter/clutter-texture.c
	clutter/cogl/gl/cogl-fbo.c
2009-05-20 16:49:22 +01:00
Emmanuele Bassi
f3e33bd25a [tests] Exercise the Model filtering
Add a test unit that exercises the ClutterModel iteration API
when there is a filter in place.
2009-04-29 15:39:23 +01:00
Havoc Pennington
125bded814 Enforce invariants on mapped, realized, visibility states
Bug 1138 - No trackable "mapped" state

* Add a VISIBLE flag tracking application programmer's
  expected showing-state for the actor, allowing us to
  always ensure we keep what the app wants while tracking
  internal implementation state separately.

* Make MAPPED reflect whether the actor will be painted;
  add notification on a ClutterActor::mapped property.
  Keep MAPPED state updated as the actor is shown,
  ancestors are shown, actor is reparented, etc.

* Require a stage and realized parents to realize; this means
  at realization time the correct window system and GL resources
  are known. But unparented actors can no longer be realized.

* Allow children to be unrealized even if parent is realized.
  Otherwise in effect either all actors or no actors are realized,
  i.e. it becomes a stage-global flag.

* Allow clutter_actor_realize() to "fail" if not inside a toplevel

* Rework clutter_actor_unrealize() so internally we have
  a flavor that does not mess with visibility flag

* Add _clutter_actor_rerealize() to encapsulate a somewhat
  tricky operation we were doing in a couple of places

* Do not realize/unrealize children in ClutterGroup,
  ClutterActor already does it

* Do not realize impl by hand in clutter_stage_show(),
  since showing impl already does that

* Do not unrealize in various dispose() methods, since
  ClutterActor dispose implementation already does it
  and chaining up is mandatory

* ClutterTexture uses COGL while unrealizable (before it's
  added to a stage). Previously this breakage was affecting
  ClutterActor because we had to allow realize outside
  a stage. Move the breakage to ClutterTexture, by making
  ClutterTexture just use COGL while not realized.

* Unrealize before we set parent to NULL in clutter_actor_unparent().
  This means unrealize() implementations can get to the stage.
  Because actors need the stage in order to detach from stage.

* Update clutter-actor-invariants.txt to reflect latest changes

* Remove explicit hide/unrealize from ClutterActor::dispose since
  unparent already forces those
  Instead just assert that unparent() occurred and did the right thing.

* Check whether parent implements unrealize before chaining up
  Needed because ClutterGroup no longer has to implement unrealize.

* Perform unrealize in the default handler for the signal.
  This allows non-containers that have children to work properly,
  and allows containers to override how it's done.

* Add map/unmap virtual methods and set MAPPED flag on self and
  children in there. This allows subclasses to hook map/unmap.
  These are not signals, because notify::mapped is better for
  anything it's legitimate for a non-subclass to do.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-04-24 15:27:19 +01:00
Emmanuele Bassi
c229de8dde [tests] Add TEST_CONFORM_TODO macro
The TEST_CONFORM_TODO macro is a simple placeholder macro that
adds the test function to the "/todo" namespace and skips the
test.

It can be used for tests that are known to fail because of bugs
that haven't been fixed yet, or because of features not yet
implemented.
2009-02-19 17:21:55 +00:00
Emmanuele Bassi
e16e9b8bfc [tests] Add conformance tests for ClutterModel
ClutterModel has an interactive test but lacks a conformance
unit for automatic testing.

This is the beginning of that unit, which covers the population
and iteration over a ListModel.
2009-02-14 11:45:27 +00:00