1
0
Fork 0
Commit graph

380 commits

Author SHA1 Message Date
Damien Lespiau
3653a9a64d Public headers should not have #ifdefs relying on private defines
HAVE_COGL_GLES2 is defined in config.h through the configure script and
should not be used in public headers.

The patch makes configure generate the right define that can be used
later in the header.
2009-06-19 06:43:34 +01:00
Colin Walters
63c84c46f8 Plug minor memory leak in cogl_vertex_buffer_submit_real
Free a temporary list.
2009-06-16 15:46:51 +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
Robert Bragg
9d82995773 [_cogl_texture_bitmap_prepare] use bitmap format for FORMAT_ANY + no alpha
My patch to choose a premultiplied format when the user gives
COGL_PIXEL_FORMAT_ANY for the internal_format broke the case where the data
in question doesn't have and alpha channel.

This was accidentally missed when merging the premultiplication branch
since I merged a local version of the branch that missed this commit.
2009-06-11 18:49:30 +01:00
Robert Bragg
71b62e75d2 [cogl] Don't allow calling cogl_set_source_texture with an INVALID_HANDLE
Although the underlying materials should allow layers with INVALID_HANDLES
it shouldn't be necissary to expose that via cogl_set_source_texture() and
it's easier to resolve a warning/crash here than odd artefacts/crashes later
in the pipeline.
2009-06-11 16:28:01 +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
ec77b91398 [cogl-texture docs] Improves the documentation of the internal_format args
Clarifies that if you give COGL_PIXEL_FORMAT_ANY as the internal format for
cogl_texture_new_from_file or cogl_texture_new_from_data then Cogl will
choose a premultiplied internal format.
2009-06-11 14:31:01 +01:00
Robert Bragg
70636b4815 [fog] Document that fogging only works with opaque or unmultipled colors
The fixed function fogging provided by OpenGL only works with unmultiplied
colors (or if the color has an alpha of 1.0) so since we now premultiply
textures and colors by default a note to this affect has been added to
clutter_stage_set_fog and cogl_set_fog.

test-depth.c no longer uses clutter_stage_set_fog for this reason.

In the future when we can depend on fragment shaders we should also be
able to support fogging of premultiplied primitives.
2009-06-11 14:17:53 +01:00
Robert Bragg
a9b011f3ed [premultiplication] Be more conservative with what data gets premultiplied
We don't want to force texture data to be premultipled if the user
explicitly specifies a non premultiplied internal_format such as
COGL_PIXEL_FORMAT_RGBA_8888.  So now Cogl will only automatically
premultiply data when COGL_PIXEL_FORMAT_ANY is given for the
internal_format, or a premultiplied internal format such as
COGL_PIXEL_FORMAT_RGBA_8888_PRE is requested but non-premultiplied source
data is given.

This approach is consistent with OpenVG image formats which have already
influenced Cogl's pixel format semantics.
2009-06-11 14:17:53 +01:00
Robert Bragg
9d3aa57604 [bitmap] Fixes _cogl_bitmap_fallback_unpremult
The _cogl_unpremult_alpha_{first,last} functions which
_cogl_bitmap_fallback_unpremult depends on were incorrectly casting each
of the byte components of a texel to a gulong and performing shifts as
if it were dealing with the whole texel.

It now just uses array indexing to access the byte components without
needing to cast or manually shift any bits around.

Even though we used to depend on unpremult whenever we used a
ClutterCairoTexture, clutter_cairo_texture_context_destroy had it's own
unpremult code which worked which is why this bug wouldn't have been noticed
before.
2009-06-11 14:17:52 +01:00
Robert Bragg
cb959ef457 [cogl-bitmap] Fix minor copy and paste error in _cogl_bitmap_fallback_premult
The returned bitmap format should include the COGL_PREMULT_BIT flag not
have it explicitly removed as for _cogl_bitmap_fallback_unpremult.
2009-06-11 14:17:52 +01:00
Owen W. Taylor
c3448314d5 Default to a blend function that expects premultiplied colors
Many operations, like mixing two textures together or alpha-blending
onto a destination with alpha, are done most logically if texture data
is in premultiplied form. We also have many sources of premultiplied
texture data, like X pixmaps, FBOs, cairo surfaces. Rather than trying
to work with two different types of texture data, simplify things by
always premultiplying texture data before uploading to GL.

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

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

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

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

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

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

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

Signed-off-by: Robert Bragg <robert@linux.intel.com>
2009-06-11 14:17:52 +01:00
Owen W. Taylor
888a261999 Implement premultiplication for CoglBitmap
cogl-bitmap.c cogl-bitmap-pixbuf.c cogl-bitmap-fallback.c cogl-bitmap-private.h:
  Add _cogl_bitmap_can_premult(), _cogl_bitmap_premult() and implement
  a reasonably fast implementation in the "fallback" code.

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

Signed-off-by: Robert Bragg <robert@linux.intel.com>
2009-06-11 14:17:51 +01:00
Owen W. Taylor
f90017ab4e Add cogl_color_premultiply()
Add a convenience function to convert an ARGB color from
non-premultiplied to premultiplied form.

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

Signed-off-by: Robert Bragg <robert@linux.intel.com>
2009-06-11 14:17:51 +01:00
Emmanuele Bassi
bd3254c0f8 [docs] Various gtk-doc fixes for COGL
Try to keep the gtk-doc errors down to a minimum.
2009-06-10 12:57:36 +01:00
Emmanuele Bassi
91856b1bed [introspection] Add --c-include to g-ir-scanner
Since Clutter has a single-include header policy we need to put
the header to be included inside the GIR file.
2009-06-09 12:45:23 +01:00
Neil Roberts
4b125d7fde [CoglTexture] Initialise tex->first_pixels to NULL in all constructors
Otherwise if there is an error before the slices are created it will
try to free the first_pixels array and crash.

It now also checks whether first_pixels has been created before using
it to update the mipmaps. This should only happen for
cogl_texture_new_from_foreign and doesn't matter if the FBO extension
is available. It would be better in this case to fetch the first pixel
using glGetTexImage as Owen mentioned in the last commit.
2009-06-09 11:13:11 +01:00
Owen W. Taylor
1d7a7bf1e6 Fix unitialized first_pixels for foreign textures
tex->first_pixels was never set for foreign textures, leading
to a crash when the texture object is freed.

As a quick fix, simply set to NULL. A more complete fix would
require remembering if we had ever seen the first pixel uploaded,
and if not, doing a glReadPixel to get it before triggering the
mipmap update.

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

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2009-06-09 10:54:54 +01:00
Owen W. Taylor
08d580f68a On bad blend strings, print the error if not returning it
It's very common that there's no reasonable fallback to do if the
blend or combine string you set isn't supported. So, rather than
requiring everybody to pass in a GError purely to catch syntax erorrs,
automatically g_warning() if a parse error is encountered and @error
is NULL.

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

Signed-off-by: Robert Bragg <robert@linux.intel.com>
2009-06-08 23:51:08 +01:00
Johan Bilien
f87e10c024 Fix the leak of the GList of layers in CoglMaterial
http://bugzilla.openedhand.com/show_bug.cgi?id=1624

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-06-06 12:59:31 +01:00
Robert Bragg
01e1aae7dd [cogl] cogl_material_set_layer does nothing if resetting the same texture
This avoids dirtying the layer, and should avoid some uneeded state changes
2009-06-05 17:18:32 +01:00
Emmanuele Bassi
6b92296e7f [build] Fix compiler warnings
Silence GCC
2009-06-05 16:46:12 +01:00
Emmanuele Bassi
02fa34f65b Fix a compiler warning 2009-06-05 16:39:18 +01:00
Emmanuele Bassi
7e33fe3175 Merge branch '1.0-integration'
* 1.0-integration: (138 commits)
  [x11] Disable XInput by default
  [xinput] Invert the XI extension version check
  [cogl-primitives] Fix an unused variable warning when building GLES
  [clutter-stage-egl] Pass -1,-1 to clutter_stage_x11_fix_window_size
  Update the GLES backend to have the layer filters in the material
  [gles/cogl-shader] Add a missing semicolon
  [cogl] Move the texture filters to be a property of the material layer
  [text] Fix Pango unit to pixels conversion
  [actor] Force unrealization on destroy only for non-toplevels
  [x11] Rework map/unmap and resizing
  [xinput] Check for the XInput entry points
  [units] Validate units against the ParamSpec
  [actor] Add the ::allocation-changed signal
  [actor] Use flags to control allocations
  [units] Rework Units into logical distance value
  Remove a stray g_value_get_int()
  Remove usage of Units and macros
  [cogl-material] Allow setting a layer with an invalid texture handle
  [timeline] Remove the concept of frames from timelines
  [gles/cogl-shader] Fix parameter spec for cogl_shader_get_info_log
  ...

Conflicts:
	configure.ac
2009-06-05 12:41:42 +01:00
Neil Roberts
fa3ed19db5 [cogl-primitives] Fix an unused variable warning when building GLES
The 'tex' variable is only used if #ifdef'd GL code so it was throwing
an error under GLES. The variable is now moved into a block inside the
#ifdef.
2009-06-04 22:20:18 +01:00
Neil Roberts
6efbb92c58 Update the GLES backend to have the layer filters in the material
This reflects the changes made in 54d8aadf1d for the GLES backend.
2009-06-04 22:12:33 +01:00
Neil Roberts
eff82a546d [gles/cogl-shader] Add a missing semicolon
cogl_shader_get_info_log was missing a semicolon which broke the build
on GLES 2.
2009-06-04 22:10:33 +01:00
Neil Roberts
54d8aadf1d [cogl] Move the texture filters to be a property of the material layer
The texture filters are now a property of the material layer rather
than the texture object. Whenever a texture is painted with a material
it sets the filters on all of the GL textures in the Cogl texture. The
filter is cached so that it won't be changed unnecessarily.

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

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

ClutterTexture no longer has to store its own copy of the filter
mode. Instead it stores it in the material and the property is
directly set and read from that. This fixes problems with the filters
getting out of sync when a cogl handle is set on the texture
directly. It also avoids the mess of having to rerealize the texture
if the filter quality changes to HIGH because Cogl will take of
generating the mipmaps if needed.
2009-06-04 19:03:40 +01:00
Neil Roberts
26f07abc65 [cogl-material] Allow setting a layer with an invalid texture handle
It was previously possible to create a material layer with no texture
by setting some property on it such as the matrix. However it was not
possible to get back to that state without removing the layer and
recreating it. It is useful to be able to remove the texture to free
resources without forgetting the state of the layer so we can put a
different texture in later.
2009-06-04 14:04:32 +01:00
Neil Roberts
c20886c5e3 [gles/cogl-shader] Fix parameter spec for cogl_shader_get_info_log
The stub version of cogl_shader_get_info_log needed to be updated to
match the changes to the function signature in 61deeafa.
2009-06-04 12:04:47 +01:00
Neil Roberts
f89ff7f383 Load glBlendEquation and glBlendColor using cogl_get_proc_address
These are defined since OpenGL 1.2 and since Windows doesn't export
any functions defined after 1.1 we need to load them dynamically.
2009-06-04 11:50:06 +01:00
Neil Roberts
daa95b561e Rename 'near' and 'far' variables to 'z_near' and 'z_far'
The Windows headers define near and far to be empty so it breaks the
build.
2009-06-04 11:48:51 +01:00
Neil Roberts
f4a431a947 [cogl-texture] Don't take ownership of the data in cogl_texture_new_from_bitmap
When creating a Cogl texture from a Cogl bitmap it would steal the
data by setting the bitmap_owner flag and clearing the data pointer
from the bitmap. The data would be freed by the time the
new_from_bitmap is finished. There is no reason to do this because the
data will be freed when the Cogl bitmap is unref'd and it is confusing
not to be able to reuse the bitmap for creating multiple textures.
2009-06-02 18:01:41 +01:00
Emmanuele Bassi
61deeafa71 [cogl-shader] Make get_info_log() slightly nicer
The cogl_shader_get_info_log() function is very inconvenient for
language bindings and for regular use, as it requires a static
buffer to be filled -- basically just providing a wrapper around
glGetInfoLogARB().

Since COGL aims to be a more convenient API than raw GL we should
just make cogl_shader_get_info_log() return an allocated string
with the GLSL compiler log.
2009-06-01 17:40:23 +01:00
Neil Roberts
5c26cc6ba7 Use GL_QUADS for flushing a quad batch
Instead of using GL_TRIANGLES and uploading the indices every time, it
now uses GL_QUADS instead on OpenGL. Under GLES it still uses indices
but it uses the new cogl_vertex_buffer_indices_get_for_quads function
to avoid uploading the vertices every time.

This requires the _cogl_vertex_buffer_indices_pointer_from_handle
function to be exposed privately to the rest of Cogl.

The static_indices array has been removed from the Cogl context.
2009-06-01 17:29:01 +01:00
Neil Roberts
67544f38d4 [cogl-vertex-buffer] Add cogl_vertex_buffer_indices_get_for_quads
This function can be used as an efficient way of drawing groups of
quads without using GL_QUADS. It generates a VBO containing the
indices needed to render using pairs of GL_TRIANGLES. The VBO is
globally cached so that it only needs to be uploaded whenever more
indices are requested than ever before.
2009-06-01 14:50:52 +01:00
Emmanuele Bassi
293eeed507 [build] Remove cogl-enum-types.h on distclean
The cogl-enum-types.h file is created by glib-mkenums under
/clutter/cogl/common, and then copied in /clutter/cogl in order
to make the inclusion of that file work inside cogl.h.

Since we're copying it in a different location, the Makefile
for that location has to clean up the copy.
2009-05-29 17:50:58 +01:00
Emmanuele Bassi
936f638a42 [build] Fix dist issues
* cogl-deprecated.h is not being installed

* cogl-enum-types.c.in is not part of the dist
2009-05-29 17:10:27 +01:00
Emmanuele Bassi
cbbc1a9ca3 [build] Copy cogl-enum-types.h under the guard
We avoid rebuilding cogl-enum-types.h and cogl-enum-types.c by
using a "guard" -- a stamp file that will block Makefile. Since
we need cogl-enum-types.h into /clutter/cogl as well for the
cogl.h include to work, if we copy the cogl-enum-types.h
unconditionally it will cause a rebuild of the whole COGL; which
will cause a full rebuild.

To solve this, we can copy the header file when generating it
under the stamp file.
2009-05-29 15:13:55 +01:00
Emmanuele Bassi
e565c1f1db [build] Encode the target into the backend library
The libclutter-cogl internal object should be the only dependency
for Clutter, since we are already copying it inside clutter/cogl
for the introspection scanner. For this reason, the backend-specific,
real internal object should be built with the backend encoded into
the file name, like libclutter-common. This makes the build output
a little bit more clear: instead of having two:

  LINK libclutter-cogl-common.la
  ...
  LINK libclutter-cogl.la
  LINK libclutter-cogl.la

We'll have:

  LINK libclutter-cogl-common.la
  ...
  LINK libclutter-cogl-gl.la
  LINK libclutter-cogl.la

Same applies for the GLES backend.
2009-05-29 12:50:48 +01:00
Emmanuele Bassi
b4861cbd21 Use g_once when registering enumeration types
Just like we do with GObject types and G_DEFINE_TYPE, we should
use the g_once_init_enter/g_once_init_leave mechanism to make the
GType registration of enumeration types thread safe.
2009-05-29 12:40:23 +01:00
Emmanuele Bassi
3248bb1b75 [cogl] Generate enumeration GTypes
COGL is starting to have more enumerations than I can handle
by hand. Let's use glib-mkenums and be done with it.
2009-05-29 12:31:47 +01:00
Emmanuele Bassi
7b75f93db1 [docs] Fixes for the API reference
* Add unused symbols

* Document and sync argument names with their gtk-doc counterpart

* Add missing descriptions
2009-05-28 17:18:13 +01:00
Emmanuele Bassi
7252c14197 [cogl] Make cogl_setup_viewport() a private function
The setup_viewport() function should only be used by Clutter and
not by application code.

It can be emulated by changing the Stage size and perspective and
requeueing a redraw after calling clutter_stage_ensure_viewport().
2009-05-28 14:14:50 +01:00
Emmanuele Bassi
32018584c0 [cogl deprecated] Add backface culling deprecation
The backface culling enabling function was split and renamed, just
like the depth testing one, so we need to add the macro to the
cogl-deprecated.h header.
2009-05-28 14:14:50 +01:00
Robert Bragg
be826ed4e7 [cogl vertex buffers] Give indices a CoglHandle so they are shareable
Previously indices were tightly bound to a particular Cogl vertex buffer
but we would like to be able to share indices so now we have
cogl_vertex_buffer_indices_new () which returns a CoglHandle.

In particular we could like to have a shared set of indices for drawing
lists of quads that can be shared between the pango renderer and the
Cogl journal.
2009-05-28 13:27:54 +01:00
Robert Bragg
f0849fc3e2 [cogl journal] If we are only flushing one quad use a TRIANGLE_FAN
At the moment Cogl doesn't do much batching of quads so most of the time we
are flushing a single quad at a time.  This patch simplifies how we submit
those quads to OpenGL by using glDrawArrays with GL_TRIANGLE_FAN mode
instead of sending indexed vertices using GL_TRIANGLES mode.

Note: I hope to follow up soon with changes that improve our batching and
also move the indices into a VBO so they don't need to be re-validated every
time we call glDrawElements.
2009-05-28 02:43:36 +01:00
Robert Bragg
57cb20dc06 [deprecated defines] Adds some missing cogl_texture_* deprecated defines
To assist people porting code from 0.8, the cogl_texture_* functions that
have been replaced now have defines that give some hint as to how they
should be replaced.
2009-05-28 02:43:36 +01:00
Robert Bragg
605243d952 [cogl] renamed cogl_enable_* to cogl_set_*_enabled + added getters
cogl_enable_depth_test and cogl_enable_backface_culling have been renamed
and now have corresponding getters, the new functions are:
  cogl_set_depth_test_enabled
  cogl_get_depth_test_enabled
  cogl_set_backface_culling_enabled
  cogl_get_backface_culling_enabled
2009-05-28 02:43:36 +01:00
Robert Bragg
96188bab62 [cogl matrix] Support ortho and perspective projections.
This adds cogl_matrix api for multiplying matrices either by a perspective
or ortho projective transform.  The internal matrix stack and current-matrix
APIs also have corresponding support added.

New public API:
cogl_matrix_perspective
cogl_matrix_ortho
cogl_ortho
cogl_set_modelview_matrix
cogl_set_projection_matrix
2009-05-28 02:43:35 +01:00