1
0
Fork 0
Commit graph

2552 commits

Author SHA1 Message Date
Neil Roberts
97f8eed119 cogl: Add a CoglTexture2D backend
This is an optimised version of CoglTexture2DSliced that always deals
with a single texture and always uses the GL_TEXTURE_2D
target. cogl_texture_new_from_bitmap now tries to use this backend
first. If it can't create a texture with that size then it falls back
the sliced backend.

cogl_texture_upload_data_prepare has been split into two functions
because the sliced backend needs to know the real internal format
before the conversion is performed. Otherwise the converted bitmap
will be wasted if the backend can't support the size.
2009-12-02 22:03:27 +00:00
Neil Roberts
f3df76d512 cogl: Add _cogl_texture_driver_upload_to_gl
This provides a way to upload the entire data for a texture without
having to first call glTexImage and then glTexSubImage. This should be
faster especially with indirect rendering where it would needlessy
send the data for the texture twice.
2009-12-02 22:03:26 +00:00
Neil Roberts
19a19579ba cogl: Move some of the texture_2d_sliced_new_* functions into cogl-texture
new_from_data and new_from_file can be implemented in terms of
new_from_bitmap so it makes sense to move these to cogl-texture rather
than having to implement them in every texture backend.
2009-12-02 22:03:26 +00:00
Neil Roberts
9752493272 cogl: Add a sub texture backend
This adds a new texture backend which represents a sub texture of a
larger texture. The texture is created with a reference to the full
texture and a set of coordinates describing the region. The backend
simply defers to the full texture for all operations and maps the
coordinates to the other range. You can also use coordinates outside
the range [0,1] to create a repeated version of the full texture.

A new public API function called cogl_texture_new_from_sub_texture is
available to create the sub texture.
2009-12-02 22:03:08 +00:00
Neil Roberts
070a91f311 cogl: Make the callback for foreach_sub_texture_in_region use const
The CoglTextureSliceCallback function pointer now takes const pointers
for the texture coordinates. This makes it clearer that the callback
should not modify the array and therefore the backend can use the same
array for both sets of coords.
2009-12-02 22:03:08 +00:00
Neil Roberts
1a1de0e278 cogl: Add a texture utility function for manually repeating
Given a region of texture coordinates this utility invokes a callback
enough times to cover the region with a subregion that spans the
texture at most once. Eg, if called with tx1 and tx2 as 0.5 and 3.0 it
it would invoke the callback with:

0.5,1.0  1.0,2.0  2.0,3.0

Manual repeating is needed by all texture backends regardless of
whether they can support hardware repeating because when Cogl calls
the foreach_sub_texture_in_region method then it sets the wrap mode to
GL_CLAMP_TO_EDGE and no hardware repeating is possible.
2009-12-02 22:03:08 +00:00
Neil Roberts
5fcb29c916 cogl-primitives: Check for repeating after the coordinate transform
In _cogl_multitexture_quad_single_primitive we use a wrap mode of
GL_CLAMP_TO_EDGE if the texture coordinates are all in the range [0,1]
or GL_REPEAT otherwise. This is to avoid pulling in pixels from either
side when using GL_LINEAR filter mode and rendering the entire
texture. Previously it was checking using the unconverted texture
coordinates. This is ok unless the texture backend is radically
transforming the texture coordinates, such as in the sub texture
backend where the coordinates may map to something completely
different. We now check whether the coordinates are in range after
converting them.
2009-12-02 22:03:07 +00:00
Neil Roberts
812d4d25bb cogl: Move all of the fields from CoglTexture to CoglTexture2DSliced
Most of the fields that were previously in CoglTexture are specific to
the implementation of CoglTexture2DSliced so they should be placed
there instead. For example, the 'mipmaps_dirty' flag is an
implementation detail of the ensure_mipmaps function so it doesn't
make sense to force all texture backends to have this function.

Other fields such as width, height, gl_format and format may make
sense for all textures but I've added them as virtual functions
instead. This may make more sense for a sub-texture backend for
example where it can calculate these based on the full texture.
2009-12-02 22:03:07 +00:00
Neil Roberts
071dea2fbc cogl: Move data only used for upload out of CoglTexture
The CoglTexture struct previously contained some fields which are only
used to upload data such as the CoglBitmap and the source GL
format. These are now moved to a separate CoglTextureUploadData struct
which only exists for the duration of one of the cogl_texture_*_new
functions. In cogl-texture there are utility functions which operate
on this new struct rather than on CoglTexture directly.

Some of the fields that were previously stored in the CoglBitmap
struct are now copied to the CoglTexture such as the width, height,
format and internal GL format.

The rowstride was previously stored in CoglTexture and this was
publicly accessible with the cogl_texture_get_rowstride
function. However this doesn't seem to be a useful function because
there is no need to use the same rowstride again when uploading or
downloading new data. Instead cogl_texture_get_rowstride now just
calculates a suitable rowstride from the format and width of the
texture.
2009-12-02 22:03:07 +00:00
Neil Roberts
7f58c14dcd cogl: Use #ifdef GL around GL_TEXTURE_RECTANGLE_ARB
Commit 558b17ee1e added support for rectangle textures to the
framebuffer code. Under GLES there is no GL_TEXTURE_RECTANGLE_ARB
definition so this was breaking the build. The rest of Cogl uses
ifdef's around that constant so we should do the same here.
2009-12-02 21:59:58 +00:00
Emmanuele Bassi
59d84f7806 build: Fix CPP and LD flags
• The debug flags are pre-processor ones, so they should be listed
  inside AM_CPPFLAGS.

• Clutter's publicly exported symbols match the following regular
  expression:

    ^(clutter|cogl|json)_*

  The old one also listed "pango" as a possible prefix, but the
  Pango API is now under the Cogl namespace.
2009-12-02 16:03:55 +00:00
Emmanuele Bassi
17e3b526d5 docs: Document Clutter's threading model
Be explicit on how to deal with threads and Clutter.
2009-12-02 14:15:43 +00:00
Emmanuele Bassi
fc7bbf1abf docs: Fix docbook syntax
The <variablename> tag is really called <varname> in DocBook.
2009-12-02 14:15:19 +00:00
Emmanuele Bassi
3c08c411d2 docs: Annotate StageManager
The ClutterStageManager instance structure is private, so we need a
"floating" annotation.
2009-12-02 11:38:04 +00:00
Emmanuele Bassi
7a33b706a4 Remove a gtk-doc annotation
The Mesa matrix code still has a comment that looks like a gtk-doc
annotation.
2009-12-02 11:37:13 +00:00
Emmanuele Bassi
0270313121 layout: Add padding to LayoutMeta
Add some padding to the LayoutMeta and LayoutMetaClass structures.
2009-12-02 11:36:25 +00:00
Emmanuele Bassi
02398c0cf1 Remove unused variable 'lang'
Fix a compiler warning.
2009-12-01 18:16:48 +00:00
Rob Bradford
cdba8cc220 flow-layout: Include the first line when calculating number of lines
This ensures that the preferred height / width height takes into consideration
the correct amount of padding
2009-12-01 17:46:12 +00:00
Rob Bradford
c564303601 flow-layout: Respect row-spacing/col-spacine in horizontal/vertical flows
We need to add the row-spacing value when calculating the y position for lines
of actors in horizontal flowing layouts.

Similarly we need to add the col-spacing value when calculating the x posution
for actors in vertical flowing layouts.
2009-12-01 17:46:11 +00:00
Emmanuele Bassi
b43e804c07 actor: Fix a pre-condition check in set_text_direction()
The check is failing because the condition should be:

  text_dir != CLUTTER_TEXT_DIRECTION_DEFAULT
2009-12-01 16:06:57 +00:00
Emmanuele Bassi
586750751a Merge branch 'text-direction'
* text-direction:
  docs: Add text-direction accessors
  Set the default language on the Pango context
  actor: Set text direction on parenting
  tests: Display the index inside text-box-layout
  box-layout: Honour :text-direction
  text: Dirty layout cache on text direction changes
  actor: Add :text-direction property
  Use the newly added ClutterTextDirection enumeration
  Add ClutterTextDirection enumeration
2009-12-01 14:55:19 +00:00
Emmanuele Bassi
15a04a1dd3 layout-manager: Create LayoutMeta on demand
The ClutterLayoutMeta instances should be created on demand, whenever
the layout manager needs them - if the layout manager supports layout
properties.

This removes the requirement to call add_child_meta() and
remove_child_meta() on add and remove respectively; it also simplifies
the implementation of LayoutManager sub-classes since we can add
fallback code in the base abstract class.

Eventually, this will also lead to an easier to implement ClutterScript
parser for layout properties.

With the new scheme, the ClutterLayoutMeta instance is created whenever
the layout manager tries to access it; if there isn't an instance
already attached to the container's child, one is created -- assuming
that the LayoutManager sub-class has overridden the
get_child_meta_type() virtual function and it's returning a valid GType.

We can also provide a default implementation for create_child_meta(),
by getting the GType and instantiating a ClutterLayoutMeta with all the
fields already set. If the layout manager requires more work then it can
obviously override the default implementation (and even chain up to it).

The ClutterBox actor has been updated, as well as the ClutterBoxLayout
layout manager, to take advantage of the changes of LayoutManager.
2009-11-30 19:11:00 +00:00
Neil Roberts
c3e640e6e3 Use the correct colour when clearing the stage for picking
The colour test for the stage in _clutter_do_pick checks for white to
determine whether the stage was picked but since 47db7af4d we were
setting the colur to black. This usually worked because the id of the
default stage ends up being 0 which equates to black. However if a
second stage is created then it will always end up picking the first
stage.
2009-11-30 19:09:05 +00:00
Neil Roberts
1bb034fbd7 cogl: Enable blending if a lighting colour is semi-transparent
We currently enable blending if the material colour has
transparency. This patch makes it also enable blending if any of the
lighting colours have transparency. Arguably this isn't neccessary
because we don't expose any API to enable lighting so there is no
bug. However it is currently possible to enable lighting with a direct
call to glEnable and this otherwise works so it is a shame not to have
it.

http://bugzilla.openedhand.com/show_bug.cgi?id=1907
2009-11-30 19:08:38 +00:00
Emmanuele Bassi
3cb974ee8b Set the default language on the Pango context
When creating the Pango context we should also set the language
to be the default Pango language.
2009-11-30 16:15:19 +00:00
Emmanuele Bassi
daeb3b2fec actor: Set text direction on parenting
When setting the parent on an actor we should set the text direction to
be the same as the parent's.
2009-11-30 16:14:09 +00:00
Robert Bragg
934eb5d251 primitives: Don't use dynamic arrays since VS2008 can't cope with them :-(
This changes _cogl_path_fill_nodes_scanlines to use g_alloca instead of
using a variable to declare an array length.
2009-11-27 15:24:09 +00:00
Robert Bragg
47db7af4d3 picking: avoid redundant picking geometry for the stage.
The stage's pick id can be written to the framebuffer when we call
cogl_clear so there's no need for the stage to also chain up in it's pick
function resulting in clutter-actor.c also emitting a rectangle for the
stage.
2009-11-27 00:43:57 +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
b598210e01 cogl_offscreen: deprecate cogl_offscreen_ref/unref.
New code should use cogl_handle_ref/unref
2009-11-26 19:33:13 +00:00
Neil Roberts
e12a691187 cogl: Use a vtable for the texture backends instead of a type and switch
Instead of storing an enum with the backend type for each texture and
then using a switch statement to decide which function to call, we
should store pointers to all of the functions in a struct and have
each texture point to that struct. This is potentially slightly faster
when there are more backends and it makes implementing new backends
easier because it's more obvious which functions have to be
implemented.
2009-11-25 13:47:28 +00:00
Robert Bragg
558b17ee1e offscreen: cogl_offscreen_new_to_texture now supports GL_TEXTURE_RECTANGLE_ARB
cogl_offscreen_new_to_texture previously bailed out if the given texture's
GL target was anything but GL_TEXTURE_2D, but it now also allows
foreign GL_TEXTURE_RECTANGLE_ARB textures.

Thanks to Owen for reporting this issue, ref:
https://bugzilla.gnome.org/show_bug.cgi?id=601032
2009-11-25 02:56:25 +00:00
Robert Bragg
d3a01e0c96 debug: remove the COGL_DEBUG=client-side-matrices option
Cogl only supports client side matrices so this debug option is no longer
useful.
2009-11-25 02:55:56 +00:00
Robert Bragg
b38c6b420f [cogl-material] Adds cogl_material_copy() API
cogl_material_copy can be used to create a new CoglHandle referencing a copy
of some given material.

From now on we will advise that developers always aim to use this function
instead of cogl_material_new() when creating a material that is in any way
derived from another.

By using cogl_material_copy, Cogl can maintain an ancestry for each material
and keep track of "similar" materials.  The plan is that Cogl will use this
information to minimize the cost of GPU state transitions.
2009-11-24 17:58:22 +00:00
Robert Bragg
70ca3bfe41 [cogl] remove unused gles/cogl-utils.[c,h]
The only function in gles/cogl-utils.c was cogl_util_next_p2() and it's
redundant since we also have a cogl/cogl-utils.[c,h]
2009-11-24 17:58:22 +00:00
Robert Bragg
4a63af0c63 docs: Don't document cogl_flush_gl_state as public API
This function was #if 0'd before we released Clutter 1.0 so there's no
implementation of it.  At some point we thought it might assist with
developers breaking out into raw OpenGL.  Breaking out to raw GL is a
difficult problem though so we decided instead we will wait for a specific
use case to arrise before trying to support it.
2009-11-24 17:58:22 +00:00
Emmanuele Bassi
328ce370e7 animation: Keep a weak reference on actors
Actors, unlike objects, can effectively go away whilst being
animated - usually because of an explicit destoy().

The Animation created by clutter_actor_animate() and friends
should keep a weak reference on the actor and eventually
get rid of the animation itself in case the actor goes away
whilst being animated.
2009-11-24 16:59:24 +00:00
Neil Roberts
1107fa8797 Minor fix to cogl material
_cogl_material_get_layer expects a CoglMaterial* pointer but it was
being called with a CoglHandle. This doesn't matter because the
CoglHandle is actually just the CoglMaterial* pointer anyway but it
breaks the ability to change the _cogl_material_pointer_from_handle
macro.
2009-11-23 18:36:59 +00:00
Emmanuele Bassi
8d64c4641d docs: Increase consistency in Cogl documentation 2009-11-19 14:19:59 +00:00
Emmanuele Bassi
550c14449e docs: Documentation fixes for CoglMatrix
Clean up the references, the docbook tags, and the style to fit in
with the rest of the API references for Cogl and Clutter.
2009-11-19 13:56:47 +00:00
Emmanuele Bassi
056cfcffc3 Whitespace fix for cogl-color.h 2009-11-19 13:56:47 +00:00
Emmanuele Bassi
851d628cf8 docs: Documentation fixes for CoglMaterial
Clean up the references, the docbook tags, and the style to fit in
with the rest of the API references for Cogl and Clutter.
2009-11-19 13:56:47 +00:00
Emmanuele Bassi
fe804f1d02 docs: Documentation fixes for CoglBitmap
• Use the same style for the Cogl API reference as the one used for
  the Clutter API reference.

• Fix the introspection annotations for cogl_bitmap_get_size_from_file()
2009-11-19 13:56:47 +00:00
Emmanuele Bassi
05a5a7e759 docs: Remove non-gtk-doc annotations
The imported Mesa matrix code has some documentation annotations
that make gtk-doc very angry. Since it's all private anyway we
can safely make gtk-doc ignore the offending stuff.
2009-11-19 13:55:46 +00:00
Neil Roberts
7a011af974 docs: Fix the 'Since' annotation for some functions
The 'Since' annotation needs to have a colon after it or gtk-doc won't
pick it up.
2009-11-19 11:51:21 +00:00
Neil Roberts
8ef57898ad cogl: Use APIENTRY for GL function pointer declarations
This matters for platforms such as Windows that use a different
calling covention from the default for GL functions.
2009-11-18 19:24:09 +00:00
Neil Roberts
be58e5261f build: Fix out-of-tree builds for cogl-defines.h
$(COGL_DRIVER)/cogl-defines.h is generated in the configure script so
it ends up in the build directory. Therefore the build rule for
cogl/cogl-defines.h should depend on the file in $(builddir) not
$(srcdir).
2009-11-18 19:24:09 +00:00
Emmanuele Bassi
19e485325f docs: Clean up deprecation notices
The deprecation notices in gtk-doc should also refer to the
release that added the deprecation, and if the deprecated
symbol has been replaced by something else then the new symbol
should be correctly referenced.
2009-11-18 18:04:13 +00:00
Emmanuele Bassi
5f28c8b654 build: Make cogl.h not conditional on driver defines
The main COGL header cogl.h is currently created at configure time
because it conditionally includes the driver-dependent defines. This
sometimes leads to a stale cogl.h with old definitions which can
break the build until you clean out the whole tree and start from
scratch.

We can generate a stable cogl-defines.h at build time from the
equivalent driver-dependent header and let cogl.h include that
file instead.
2009-11-18 17:49:21 +00:00
Emmanuele Bassi
60fae6a92e build: Add cogl-matrix-private.h to the dist 2009-11-18 14:43:46 +00:00