1
0
Fork 0
Commit graph

572 commits

Author SHA1 Message Date
Robert Bragg
be9564b3db material: copy_differences: handle copying fog state
When the support for redirecting the legacy fog state through cogl
material was added in 9b9e764dc, the code to handle copying the fog
state in _cogl_material_copy_differences was missed.
2010-07-13 19:26:57 +01:00
Neil Roberts
ae88bff329 Add a GL_GENERATE_MIPMAP fallback to the texture 2d and 3d backends
The CoglTexture2DSliced backend has a fallback for when the
framebuffer extension is missing so it's not possible to use
glGenerateMipmap. This involves keeping a copy of the upper-left pixel
of the tex image so that we can temporarily enable GL_GENERATE_MIPMAP
on the texture object and do a sub texture update by reuploading the
contents of the first pixel. This patch copies that mechanism to the
2D and 3D backends. The CoglTexturePixel structure which was
previously internal to the sliced backend has been moved to
cogl-texture-private.h so that it can be shared.
2010-07-13 18:41:01 +01:00
Neil Roberts
671abec8b7 Make the material functions for setting the p wrap mode public
Now that we have 3D texture support it makes sense to expose the wrap
mode for the p coordinate.
2010-07-13 14:29:07 +01:00
Neil Roberts
ec718d4ca4 Rename the third texure coordinate from 'r' to 'p'
Using 'r' to name the third component is problematic because that is
commonly used to represent the red component of a vector representing
a color. Under GLSL this is awkward because the texture swizzling for
a vector uses a single letter for each component and the names for
colors, textures and positions are synonymous. GLSL works around this
by naming the components of the texture s, t, p and q. Cogl already
effectively already exposes this naming because it exposes GLSL so it
makes sense to use that naming consistently. Another alternative could
be u, v and w. This is what Blender and Direct3D use. However the w
component conflicts with the w component of a position vertex.
2010-07-13 14:29:07 +01:00
Neil Roberts
5288f6d88d Add a Cogl texture 3D backend
This adds a publicly exposed experimental API for a 3D texture
backend. There is a feature flag which can be checked for whether 3D
textures are supported. Although we require OpenGL 1.2 which has 3D
textures in core, GLES only provides them through an extension so the
feature can be used to detect that.

The textures can be created with one of two new API functions :-

cogl_texture_3d_new_with_size

 and

cogl_texture_3d_new_from_data

There is also internally a new_from_bitmap function. new_from_data is
implemented in terms of this function.

The two constructors are effectively the only way to upload data to a
3D texture. It does not work to call glTexImage2D with the
GL_TEXTURE_3D target so the virtual for cogl_texture_set_region does
nothing. It would be possible to make cogl_texture_get_data do
something sensible like returning all of the images as a single long
image but this is not currently implemented and instead the virtual
just always fails. We may want to add API specific to the 3D texture
backend to get and set a sub region of the texture.

All of those three functions can throw a GError. This will happen if
the GPU does not support 3D textures or it does not support NPOTs and
an NPOT size is requested. It will also fail if the FBO extension is
not supported and the COGL_TEXTURE_NO_AUTO_MIPMAP flag is not
given. This could be avoided by copying the code for the
GL_GENERATE_MIPMAP TexParameter fallback, but in the interests of
keeping the code simple this is not yet done.

This adds a couple of functions to cogl-texture-driver for uploading
3D data and querying the 3D proxy
texture. prep_gl_for_pixels_upload_full now also takes sets the
GL_UNPACK_IMAGE_HEIGHT parameter so that 3D textures can have padding
between the images. Whenever 3D texture is uploading, both the height
of the images and the height of all of the data is specified (either
explicitly or implicilty from the CoglBitmap) so that the image height
can be deduced by dividing by the depth.
2010-07-13 14:28:52 +01:00
Neil Roberts
159c7ed7e5 configure: Include gl2ext.h or glext.h under GLES
Under big GL, glext.h is included automatically by gl.h. However under
GLES this doesn't appear to happen so it has to be included explicitly
to get the defines for extensions. This patch changes the
clutter_gl_header to be called cogl_gl_headers and it can now take a
space seperated list of multiple headers. This is then later converted
to a list of #include lines which ends up cogl-defines.h. The gles2
and gles1 backends now add their respective ext header to this list.
2010-07-13 14:28:51 +01:00
Neil Roberts
42dcffbc3a Make a public CoglBitmapError enum
There are many places in the texture backend that need to do
conversion using the CoglBitmap code. Currently none of these
functions can throw an error but they do return a value to indicate
failure. In future it would make sense if new texture functions could
throw an error and in that case they would want to use a CoglBitmap
error if the failure was due to the conversion. This moves the
internal CoglBitmap error from the quartz backend to be public in
cogl-bitmap.h so that it can be used in this way.
2010-07-13 14:28:45 +01:00
Neil Roberts
396ef40d43 Rename COGL_ERROR_MISSING_FEATURE to COGL_ERROR_UNSUPPORTED
We can use this error in more unsupported situations than just when we
have a Cogl feature flag for the error. For example if a non-sliced
texture is created with dimensions that are too large then we could
throw this error. Therefore it seems good to rename to something more
general.
2010-07-13 14:28:36 +01:00
Neil Roberts
c3489a0a22 Move _cogl_texture_2d_is_pot to cogl-util.h
This function could be used in many places in Cogl so it makes sense
to share it in cogl-util.h as _cogl_util_is_pot().
2010-07-13 14:28:35 +01:00
Neil Roberts
ccd45fc723 cogl-gles2-wrapper: Layers aren't equal if one is enabled and one is not
Previously when comparing whether the settings for a layer are equal
it would only check if one of them was enabled. If so then it would
assume the other one was enabled and continue to compare the texture
environment. Now it also checks whether the enabledness differs.
2010-07-13 14:28:35 +01:00
Neil Roberts
044523db26 Add the deprecated ref-counting for cogl_program
cogl_program has always had cogl_program_ref and cogl_program_unref
but this was missed from 89cb325fd4 so they got removed.
2010-07-09 19:09:49 +01:00
Neil Roberts
2c8bf00995 Don't define public cogl_is_* functions for internal types
This adds a COGL_OBJECT_INTERNAL_DEFINE macro and friends that are the
same as COGL_OBJECT_DEFINE except that they prefix the cogl_is_*
function with an underscore so that it doesn't get exported in the
shared library.
2010-07-09 18:57:54 +01:00
Neil Roberts
9e3705ecb3 Add cogl_vertex_buffer_is_indices to the public headers
This function has always been defined in the shared library but it was
missed from the public headers.
2010-07-09 18:57:54 +01:00
Neil Roberts
b25035ad2d cogl: Don't define the deprecated ref/unref accessors for new types
Previously COGL_OBJECT_DEFINE would always define deprecated
cogl_$type_{ref,unref} functions even if the type is new or if the
type is entirely internal. An application would still find it
difficult to use these because they wouldn't be in the headers, but it
still looks bad that they are exported from the shared library. This
patch changes it so that the deprecated ref counting functions are
defined using a separate macro and only the types that have these
functions in the headers call this macro.
2010-07-09 18:57:54 +01:00
Robert Bragg
ea708094c5 material: use common node type for materials and layers
Since 365605cf42, materials and layers are represented in a tree
structure that allows traversing up through parents and iterating down
through children.  This re-works the related typedefs and reparenting
code so that they can be shared.
2010-07-09 18:04:27 +01:00
Damien Lespiau
2d20589d8e cogl-texture-pixmap-x11: This API is new in 1.4, not 1.2
CoglTexturePixmapX11 has been introduced in the 1.3 development cycle. A
Stability: Unstable tag was missing too, so add it.
2010-07-09 17:55:31 +01:00
Damien Lespiau
c0fb59702c cogl: Add Stability tag to new experimental API
Functions guarded with COGL_ENABLE_EXPERIMENTAL API should be also maked
as being Unstable with the Stability gtk-doc tag.

Fixes: http://bugzilla.clutter-project.org/show_bug.cgi?id=2175
2010-07-09 17:17:11 +01:00
Neil Roberts
bf8384baf1 Use GL_MAX_TEXTURE_SIZE on GLES when checking supported tex size
Under big GL, _cogl_texture_driver_size_supported uses the proxy
texture to check whether the given texture size is supported. Proxy
textures aren't available under GLES so previously this would just
return TRUE to assume all texture sizes are supported. This patch
makes it use glGetIntegerv with GL_MAX_TEXTURE_SIZE to give a second
best guess.

This fixes the sliced texture backend so that it will use slices when
the texture is too big.
2010-07-09 11:14:15 +01:00
Neil Roberts
0fbdafd318 Fix cogl_texture_get_data when an intermediate buffer is used
When an intermediate buffer is used for downloading texture data it
was using the wrong byte length for a row so the copy back to the
user's buffer would fail.
2010-07-09 11:14:15 +01:00
Neil Roberts
d3ea1ec6f8 Use GL_NEAREST filter in the draw-and-read get_data texture fallback
The fallback for when glGetTexImage is not available renders the
texture to the framebuffer to read the data using glReadPixels. This
patch just sets the COGL_MATERIAL_FILTER_NEAREST filter mode on the
material before rendering to avoid linear filtering which would alter
the texture data.
2010-07-09 11:14:15 +01:00
Neil Roberts
f8d1955ab7 Use cogl_read_pixels in the cogl texture draw-and-read fallback
The fallback for when glGetTexImage is not available draws parts of
the texture to the framebuffer and uses glReadPixels to extract the
data. However it was using cogl_rectangle to draw and then immediately
using raw glReadPixels to fetch the data. This won't cause a journal
flush so the rectangle won't necessarily have hit the framebuffer
yet. Instead it now uses cogl_read_pixels which does flush the
journal.
2010-07-09 11:14:15 +01:00
Neil Roberts
475a72fd94 cogl-material: Fix some problems with flushing texture overrides
There were a few problems flushing texture overrides so that sliced
textures would not work:

* In _cogl_material_set_layer_texture it ignored the 'overriden'
  parameter and always set texture_overridden to FALSE.

* cogl_texture_get_gl_texture wasn't being called correctly in
  override_layer_texture_cb. It returns a gboolean to indicate the
  error status but this boolean was being assigned to gl_target.

* _cogl_material_layer_texture_equal did not take into account the
  override.

* _cogl_material_layer_get_texture_info did not return the overridden
  texture so it would always use the first texture slice.
2010-07-09 11:14:15 +01:00
Neil Roberts
61cbeeacfa cogl-texture: Share the common code in the set_region virtual
There was a lot of common code that was copied to all of the backends
to convert the data to a suitable format and wrap it into a CoglBitmap
so that it can be passed to _cogl_texture_driver_upload_subregion_to_gl.
This patch moves the common code to cogl-texture.c so that the virtual
just takes a CoglBitmap that is already in the right format.
2010-07-09 11:14:14 +01:00
Neil Roberts
223317c500 cogl-texture: Share the common code in the get_data virtual
Previously cogl_texture_get_data would pretty much directly pass on to
the get_data texture virtual function. This ended up with a lot of
common code that was copied to all of the backends. For example, the
method is expected to return the required data size if the data
pointer is NULL and to calculate its own rowstride if the rowstride is
0. Also it needs to convert the downloaded data if GL can't support
that format directly.

This patch moves the common code to cogl-texture.c so the virtual is
always called with a format that can be downloaded directly by GL and
with a valid rowstride. If the download fails then the virtual can
return FALSE in which case cogl-texture will use the draw and read
fallback.
2010-07-09 11:00:48 +01:00
Neil Roberts
0e49e4f204 cogl-vertex-buffer: Default to GL_CLAMP_TO_EDGE for point sprites
For point sprites you are usually drawing the whole texture so you
most often want GL_CLAMP_TO_EDGE. This patch removes the override for
COGL_MATERIAL_WRAP_MODE_AUTOMATIC when point sprites are enabled for a
layer so that it will clamp to edge.
2010-07-08 16:34:31 +01:00
Neil Roberts
da3be3df6b cogl-material: Add support for point sprites
This adds a new API call to enable point sprite coordinate generation
for a material layer:

void
cogl_material_set_layer_point_sprite_coords_enabled (CoglHandle material,
                                                     int layer_index,
                                                     gboolean enable);

There is also a corresponding get function.

Enabling point sprite coords simply sets the GL_COORD_REPLACE of the
GL_POINT_SPRITE glTexEnv when flusing the material. There is no
separate application control for glEnable(GL_POINT_SPRITE). Instead it
is left permanently enabled under the assumption that it has no affect
unless GL_COORD_REPLACE is enabled for a texture unit.

http://bugzilla.openedhand.com/show_bug.cgi?id=2047
2010-07-08 16:34:30 +01:00
Neil Roberts
06b58baa10 cogl-material: Add a property for setting the point size
This adds cogl_material_{get,set}_point_size. If the point size is not
1.0f then glPointSize will be called when the material is flushed.

http://bugzilla.openedhand.com/show_bug.cgi?id=2047
2010-07-08 16:34:30 +01:00
Robert Bragg
dcc8c66fdd material: support dumping layer state graph to dot file
Recently I added a _cogl_debug_dump_materials_dot_file function for
debugging the sparse material state. This extends the state dumped to
include the graph of layer state also.
2010-07-07 20:46:50 +01:00
Robert Bragg
093251776f material: set ->layer_index on new layers for unit0
We were mistakenly only initializing layer->layer_index for new layers
associated with texture units > 0. This had gone unnoticed because
normally layers associated with texture unit0 have a layer index of 0
too. Mutter was hitting this issue because it was initializing layer 1
before layer 0 for one of its materials so layer 1 was temporarily
associated with texture unit 0.
2010-07-07 20:46:04 +01:00
Emmanuele Bassi
added497f4 Merge branch 'cally-merge'
* cally-merge:
  cally: Add introspection generation
  cally: Improving cally doc
  cally: Cleaning CallyText
  cally: Refactoring "window:create" and "window:destroy" emission code
  cally: Use proper backend information on CallyActor
  cally: Check HAVE_CONFIG_H on cally-util.c
  docs: Fix Cally documentation
  cally: Clean up the headers
  Add binaries of the Cally examples to the ignore file
  docs: Add Cally API reference
  Avoid to load cally module on a11y examples
  Add accessibility tests
  Initialize accessibility support on clutter_init
  Rename some methods and includes to avoid -Wshadow warnings
  Cally initialization code
  Add Cally
2010-07-07 16:06:30 +01:00
Emmanuele Bassi
0eb9fc04f5 cally: Add introspection generation
Toolkits and applications not written in C might still need access to
the Cally API to write accessibility extensions based on it for their
own native elements.
2010-07-07 15:57:43 +01:00
Robert Bragg
0c3354acba framebuffer: Replace CoglHandle with CoglFramebuffer *
One more object converted to stop using CoglHandle re:a8c8cbee513
2010-07-07 14:41:54 +01:00
Robert Bragg
8098052d56 material: route fogging state through CoglMaterial
Previously cogl_set_fog would cause a flush of the Cogl journal and
would directly bang the GL state machine to setup fogging. As part of
the ongoing effort to track most state in CoglMaterial to support
renderlists this now adds an indirection so that cogl_set_fog now just
updates ctx->legacy_fog_state. The fogging state then gets enabled as a
legacy override similar to how the old depth testing API is handled.
2010-07-07 14:12:15 +01:00
Robert Bragg
a17dfcf1c2 cogl-buffer: Move malloc fallback logic into CoglBuffer
Since we'll want to share the fallback logic with CoglVertexArray this
moves the malloc based fallback (for when OpenGL doesn't support vertex
or pixel buffer objects) into cogl-buffer.c.
2010-07-07 14:08:11 +01:00
Robert Bragg
f8d58446a8 cogl-buffer: consider it an error to free a mapped buffer
Explicitly warn if we detect that a CoglBuffer is being freed while it
is still mapped. Previously we silently unmapped the buffer, but it's
not something we want to encourage.
2010-07-07 14:08:11 +01:00
Robert Bragg
e98ee6665b cogl-buffer: Track the last used bind target in CoglBuffer
This makes CoglBuffer track the last used bind target as a private
property. This is later used when binding a buffer to map instead of
always using the PIXEL_UNPACK target.

This also adds some additional sanity checks that code doesn't try to
nest binds to the same target or bind a buffer to multiple targets at
the same time.
2010-07-07 14:08:11 +01:00
Robert Bragg
7571cc1923 cogl: expose the semantic differences of gl/gles2 npot textures
This adds three new feature flags COGL_FEATURE_TEXTURE_NPOT_BASIC,
COGL_FEATURE_TEXTURE_NPOT_MIPMAP and COGL_FEATURE_TEXTURE_NPOT_REPEAT
that can tell you if your hardware supports non power of two textures,
npot textures + mipmaps and npot textures + wrap modes other than
CLAMP_TO_EDGE.

The pre-existing COGL_FEATURE_TEXTURE_NPOT feature implies all of the
above.

By default GLES 2 core supports npot textures but mipmaps and repeat
modes can only be used with power of two textures. This patch also makes
GLES check for the GL_OES_texture_npot extension to determine if mipmaps
and repeating are supported with npot textures.
2010-07-07 13:26:41 +01:00
Neil Roberts
c243086f44 cogl-vertex-buffer: Fix the #define for glDisableVertexAttribArray
glDisableVertexAttribArray was defined to glEnableVertexAttribArray so
it would probably cause crashes if it was ever used. Presumably
nothing is using these yet because the generic attributes are not yet
tied to shader attributes in a predictable way.
2010-07-06 16:08:44 +01:00
Alexandros Frantzis
bf56e798c6 build: Exclude built sources from the dist
http://bugzilla.clutter-project.org/show_bug.cgi?id=2169

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-07-06 13:24:00 +01:00
Robert Bragg
3b4b5ba01c debug: Adds a COGL_DEBUG=disable-pbos debug option
For testing purposes, either to identify bugs in Cogl or the driver or
simulate lack of PBO support COGL_DEBUG=disable-pbos can be used to
fallback to malloc instead.
2010-07-06 12:09:01 +01:00
Robert Bragg
92d0322766 pixel-array: Allow passing of hints to cogl_buffer_map
This allows you to tell Cogl that you are planning to replace all the
buffer's data once it is mapped with cogl_buffer_map. This means if the
buffer is currently being accessed by the GPU then the driver doesn't
have to stall and wait for it to finish before it can access it from the
CPU and can instead potentially allocate a new buffer with undefined
data and map that.
2010-07-06 12:07:28 +01:00
Robert Bragg
51e4245ce1 cogl-object: cogl_is_XYZ prototype should take void *
This changes the cogl_is_XYZ function prototypes generated when using
the COGL_OBJECT_DEFINE macro to take a void * argument instead of a
CoglHandle argument.
2010-07-05 15:47:02 +01:00
Robert Bragg
9e25f8c40d pixel-array: Only allow allocation of arrays with a 2D size
This removes cogl_pixel_array_new which just took a size in bytes.

Without the image size and pixel format then the driver often doesn't
have enough information to allocate optimal GPU memory that can be
textured from directly. This is because GPUs often have ways to
spatially alter the layout of a texture to improve cache access patterns
which may require special alignment and padding dependant in the images
width, height and bpp.

Although currently we are limited by OpenGL because it doesn't let us
pass on the width and height when allocating a PBO, the hope is that we
can define a better extension at some point.
2010-07-05 15:20:04 +01:00
Robert Bragg
daa34aeb0e pixel-array: rename new_from_size to new_with_size
It is more in keeping with other coding conventions in Cogl to use new
"with" size instead of new "from" size.
2010-07-05 15:20:04 +01:00
Robert Bragg
a46cc22c1b cogl-buffer-private.h: cleanup up the coding style
This file was following the Clutter coding style of arranging prototypes
into columns which Cogl doesn't copy.
2010-07-05 15:20:04 +01:00
Robert Bragg
521d9ca203 rename CoglPixelBuffer to CoglPixelArray
This renames CoglPixelBuffer to CoglPixelArray to be consistent with the
new CoglVertexArray API.
2010-07-05 15:20:04 +01:00
Robert Bragg
cafeb02531 cogl-buffer: make the COGL_BUFFER_USAGE_HINT private
The usage hint should be implied by the CoglBuffer subclass type so the
public getter and setter APIs for manually changing the usage hint of a
CoglBuffer have now been removed.
2010-07-05 15:20:04 +01:00
Robert Bragg
9ceb0edf26 cogl-buffer: Handle subclass registration like cogl-texture
Instead of having to extend cogl_is_buffer with new buffer types
manually this now adds a new COGL_BUFFER_DEFINE macro to be used instead
of COGL_OBJECT_DEFINE for CoglBuffer subclasses. This macro will
automatically register the new type with ctx->buffer_types which will
iterated by cogl_is_buffer. This is the same coding pattern used for
CoglTexture.
2010-07-05 15:20:03 +01:00
Robert Bragg
1b7e362189 pixel-buffer: Replace CoglHandle with CoglPixelBuffer *
One more file converted to stop using CoglHandle re:a8c8cbee513
2010-07-05 15:20:03 +01:00
Robert Bragg
12a76ca4aa cogl-material: Adds debug api to dump sparse material graph
This adds a _cogl_debug_dump_materials_dot_file function that can be
used to dump all the descendants of the default material to a file using
the dot format which can then be converted to an image to visualize.
2010-07-05 15:04:46 +01:00
Robert Bragg
b5f7ab345c cogl-vertex-buffer.h: #include <cogl/cogl-defines.h>
cogl-vertex-buffer.h was assuming that the platforms GL headers had
already been included but that shouldn't have to be the case.
2010-07-05 14:54:21 +01:00
Robert Bragg
0b3c45396b cogl-object-private.h: #include glib.h and cogl-types.h
cogl-object-private.h was only working in places that had already
included glib.h and cogl-types.h
2010-07-05 14:51:28 +01:00
Robert Bragg
cc0b76b405 material: don't keep extra ref on copy-on-write materials
In _cogl_material_pre_change_notify if a material with descendants is
modified then we create a new material that is a copy of the one being
modified and reparent those descendants to the new material.

This patch ensures we drop the reference we get from cogl_material_copy
since we can rely on the descendants to keep the new material alive.
2010-07-05 14:51:05 +01:00
Robert Bragg
3428633cb3 build: Fix GLES builds since the material backend split
The commit to split the fragment processing backends out from
cogl-material.c (3e1323a636) broke the GLES 1 and 2 builds the
fix was to guard the code in each backend according to the
COGL_MATERIAL_BACKEND_XYZ defines which are setup in
cogl-material-private.h.
2010-07-05 14:50:47 +01:00
Neil Roberts
cea74d92ea Convert the ASCII art documentation in cogl-vertex-buffer to PNGs
The documentation for cogl_vertex_buffer_indices_get_for_quads was
using ugly ASCII art to draw the diagrams. These have now been
replaced with PNG figures.
2010-07-02 17:29:34 +01:00
Neil Roberts
432c37bd21 Add CoglMaterialWrapMode to the Cogl docs and fix docs for the getters
CoglMaterialWrapMode was missing from the cogl-sections.txt file so it
wasn't getting displayed. There were also no documented return values
from the getters.
2010-07-02 17:29:34 +01:00
Neil Roberts
59d06d486d Fix building the tesselator code for GLES
The tesselator code uses some defines that it expects to be in the GL
headers such as GLAPI and GLAPIENTRY. These are used to mark the entry
points as exportable on each platform. We don't really want the
tesselator code to use these but we also don't want to modify the C
files so instead they are #defined to be empty in the stub glu.h. That
header is only included internally when building the tesselator/ files
so it shouldn't affect the rest of Cogl.

GLES also doesn't have a GLdouble type so we just #define this to be a
regular double.
2010-07-01 20:39:57 +01:00
Neil Roberts
7961b1c93d cogl-material: Don't doubly ref the parent in cogl_material_copy
cogl_material_copy was taking a reference on the original texture when
making a copy. However it then calls _cogl_material_set_parent on the
material which also takes a reference on the parent. The second
reference is cleaned up whenever _cogl_material_unparent is called and
this is also called by _cogl_material_free. However, it seems that
nothing was cleaning up the first reference. I think the reference is
entirely unnecessary so this patch removes it.
2010-07-01 15:32:08 +01:00
Robert Bragg
137d38962a cogl: don't include cogl-vector.h twice in cogl.h
cogl-vector.h should only be included by cogl.h when
COGL_ENABLE_EXPERIMENTAL_API is defined. This removes the unguarded
duplicate include.
2010-07-01 12:23:10 +01:00
Robert Bragg
1000c80444 cogl: declare experimental symbols consistently
We had several different ways of exposing experimental API, in one case
the symbols had no special suffix, in two other ways the symbols were
given an _EXP suffix but in different ways.

This makes all experimental API have an _EXP suffix which is handled
using #defines in the header so the prototypes in the .c and .h files
don't have the suffix.

The documented reason for the suffix is so that anyone watching Cogl for
ABI changes who sees symbols disappear will hopefully understand what's
going on.
2010-06-30 18:51:31 +01:00
Neil Roberts
a0a06f0342 cogl/tesselator: Update to the latest code from GLU
This grabs the latest code for libtess from git Mesa. This is mostly
so that we can get the following commit which fixes a lot of compiler
warnings in Clutter:

commit 75acb896c6da758d03e86f8725d6ca0cb2c6ad82
Author: Neil Roberts <neil@linux.intel.com>
Date:   Wed Jun 30 12:41:11 2010 +0100

    glu: Fix some compiler warnings in libtess
    
    When compiled with the more aggressive compiler warnings such as
    -Wshadow and -Wempty-body the libtess code gives a lot more
    warnings. This fixes the following issues:
    
    * The 'Swap' macro tries to combine multiple statements into one and
      then consume the trailing semicolon by using if(1){/*...*/}else.
      This gives warnings because the else part ends up with an empty
      statement. It also seems a bit dangerous because if the semicolon
      were missed then it would still be valid syntax but it would just
      ignore the following statement. This patch replaces it with the more
      common idiom do { /*...*/ } while(0).
    
    * 'free' was being used as a local variable name but this shadows the
      global function. This has been renamed to 'free_handle'
    
    * TRUE and FALSE were being unconditionally defined. Although this
      isn't currently a problem it seems better to guard them with #ifndef
      because it's quite common for them to be defined in other headers.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=28845
2010-06-30 16:35:33 +01:00
Emmanuele Bassi
6fbe92193f docs: Various fixes for gtk-doc 2010-06-30 15:51:12 +01:00
Robert Bragg
be46b872e9 material: Replace CoglHandle with CoglMaterial *
As part of the ongoing effort to remove CoglHandle from the API this
switches the cogl_material API to use a strongly typed CoglMaterial
pointer instead of CoglHandle.
2010-06-30 15:04:18 +01:00
Robert Bragg
17731b3af1 material: Split the fragment processing backends out
This splits the fragment processing backends (glsl, arbfp and fixed) out
from cogl-material.c into their own cogl-material-{glsl,arbfp,fixed}.c
files in an effort to help and keep cogl-material.c maintainable.
2010-06-30 15:04:10 +01:00
Robert Bragg
e7df757739 material: remove a duplicate gtk-doc "Since: 1.4"
The cogl_material_get_depth_writing_enabled documentation had two
"Since: 1.4" annotations which was confusing the gobject introspection
scanner.
2010-06-30 14:31:46 +01:00
Neil Roberts
cdf5b222db cogl-path: Allow changing the fill rule
This adds two new API calls- cogl_path_set_fill_rule and
cogl_path_get_fill_rule. This allows modifying the fill rule of the
current path. In addition to the previous default fill rule of
'even-odd' it now supports the 'non-zero' rule. The fill rule is a
property of the path (not the Cogl context) so creating a new path or
preserving a path with cogl_path_get_handle affects the fill rule.
2010-06-29 20:37:14 +01:00
Neil Roberts
244a795f43 cogl-debug: Remove the force-scanline-paths option
The scanline path rasterizer has been removed because the paths can be
drawn with the tesselator instead. The option therefore no longer does
anything.
2010-06-29 20:37:13 +01:00
Neil Roberts
fecaaea132 cogl-path: Use the GLU tesselator to draw paths
Instead of drawing paths using the stencil buffer trick, it now
tesselates the path into triangles using the GLU tesselator and
renders them directly. A vbo is created with one vertex for each node
on the path. The tesselator is used to generate a series of indices
into the vbo as triangles. The tesselator's output of strips and fans
is converted into GL_TRIANGLES so that it can be rendered with a
single draw call (but the vertices are still shared via the
indices). The vbo is stored with the path so that if the application
uses retained paths then Cogl won't have to tessellate again.

The vertices also have texture coordinates associated with them so
that it can replicate the old behaviour of drawing a material with a
texture by fitting the texture to the bounding box of the path and
then clipping it. However if the texture contains waste or is sliced
then the vertex buffer code will refuse to draw it. In this case it
will revert back to drawing the path into the stencil buffer and then
drawing the material as a clipped quad.

The VBO is used even when setting up the stencil buffer for clipping
to a path because the tessellated geometry may cover less area.

The old scanline rasterizer has been removed because the tesselator
should work equally well on drivers with no stencil buffer.
2010-06-29 20:37:13 +01:00
Neil Roberts
b86e330957 cogl: Pull in the code for GLU tesselator from Mesa/SGI
This copies the files for the GLU tesselator from Mesa. The Mesa code
is based on the original SGI code and is released under a BSD license.

The memalloc.h header has been replaced with one that forces the code
to use g_malloc and friends. The rest of the files are not altered
from the original so it should be possible to later upgrade the files
by simply overwriting them.

There is a tesselator.h header which is expected to be included by
rest of Cogl to use the tesselator. This contains a trimmed down
version of glu.h that only includes parts that pertain to the
tesselator. There is also a stub glu.h in the GL directory which is
just provided so that the tesselator code can include <GL/gl.h>
without depending on the system header. It just redirects to
tesselator.h
2010-06-29 20:37:13 +01:00
Neil Roberts
d99a8bf694 cogl: Add const to some pointer arguments
Some of the arguments to the material and path functions were taking a
pointer to a CoglColor or an array of floats that was not intended to
be written to but were not marked with const.
2010-06-28 15:25:19 +01:00
Robert Bragg
de1f4885dd material: Avoid possibly reading invalid memory
in _cogl_material_prune_empty_layer_difference we sometimes unref the
given layer before dereferencing it to get a pointer to its parent. This
defers the unref until after we have fetched the parent pointer.
2010-06-24 17:05:26 +01:00
Neil Roberts
e33a94bff4 cogl: Remove cogl-defines.h.in from the driver make files
Commit 7fae8ac051 changed cogl-defines.h.in so there is only a
single copy in clutter/cogl/ instead of one for each driver. However
the old files were still mentioned in the EXTRA_DIST of the
Makefile.am so make distcheck was failing.
2010-06-23 17:44:09 +01:00
Chris Lord
e8e5188484 cogl-path: Disable texture coord arrays before drawing
It was possible that the texture co-ord arrays were left enabled during
stroking, which could possibly cause a crash.
2010-06-23 16:07:00 +01:00
Robert Bragg
857aee2b91 texture-pixmap-x11: don't assume anything about the GLXFBConfig type
A pedantic change to get_fbconfig_for_depth() so that we don't need to
make any assumptions about the GLXFBConfig typedef or what values
we can overload to indicate an invalid config.

get_fbconfig_for_depth() now simply returns FALSE if it fails to find a
config.
2010-06-22 16:53:59 +01:00
Emmanuele Bassi
c0d42cb021 Silence another compiler warning 2010-06-22 14:43:36 +01:00
Neil Roberts
7d206ccdbb cogl-texture-pixmap-x11: Use NULL instead of None for invalid GLXFBConfig
GLXFBConfigs are opaque pointers not XIDs so it doesn't make sense to
return None from get_fbconfig_for_depth. Instead it now returns NULL.
2010-06-22 14:19:59 +01:00
Emmanuele Bassi
0244eccfe3 Silence some compiler warnings 2010-06-22 13:48:53 +01:00
Neil Roberts
8458fb7e20 Add a CoglTexturePixmapX11 texture backend
This is a publicly exposed texture backend to create a texture which
contains the contents of an X11 pixmap. The API is currently marked as
experimental.

The backend internally holds a handle to another texture. All of the
backend virtuals simply redirect to the internal texture.

The texture can optionally be automatically updated if the
automatic_updates parameter is TRUE. If set then Cogl will listen for
damage events on the pixmap and update the texture accordingly.
Alternatively a damage object can be created externally and passed
down to Cogl.

The updates can be performed with XGetImage, XShmGetImage or the
GLX_EXT_texture_pixmap extension. If the TFP extension is used it will
optionally try to create a rectangle texture if the driver does not
support NPOTs or it is forced through the
COGL_PIXMAP_TEXTURE_RECTANGLE or CLUTTER_PIXMAP_TEXTURE_RECTANGLE
environment variables.

If the GLXFBConfig does not support mipmapping then it will fallback
to using X{Shm,}GetImage. It keeps a separate texture around for this
so that it can later start using the TFP texture again if the texture
is later drawn with mipmaps disabled.
2010-06-22 12:22:48 +01:00
Neil Roberts
9c62265939 Add -DCOGL_ENABLE_EXPERIMENTAL_API to Makefiles for Cogl and x11/glx
Cogl and Clutter should be able to use the experimental API so this
adds the required define to the CPPFLAGS in the Makefiles.
2010-06-22 12:22:47 +01:00
Neil Roberts
9d0962098f cogl-defines.h: Add a COGL_HAS_X11 define
This will be defined in cogl-defines.h whenever Cogl is built using a
winsys that supports X11. This implies CoglTexturePixmapX11 will be
available.

To make this work the two separate cogl-defines.h.in files have been
merged into one. The configure script now makes a @COGL_DEFINES@
substitution variable which contains the #define lines to put in
rather than directly having them in the seperate files.
2010-06-22 12:22:47 +01:00
Neil Roberts
16c7d12e6c cogl: Add _cogl_xlib_{,un}trap_errors
This is similar to clutter_x11_{,un}trap_errors except that it stores
the previous trap state in a caller-allocated struct so that it can be
re-entrant.

Make _cogl_xlib_trap_errors re-entrant

(this will be squashed into an earlier commit)
2010-06-22 12:22:47 +01:00
Neil Roberts
6ad668c76b cogl-texture: Avoid premult conversion if the dst format has no alpha
The _cogl_texture_needs_premult_conversion function was already
checking whether the source format had an alpha channel before
returning TRUE, but it also doesn't make sense to do the premult
conversion if the destination format has no alpha. This patch adds
that check in too.
2010-06-22 12:22:47 +01:00
Neil Roberts
31b5beb2c0 cogl: Add the infrastructure for checking for winsys extensions
This adds the framework needed to check for winsys specific extensions
(such as GLX extensions) using a similar mechanism to the
cogl-feature-functions header. There is a separate
cogl-winsys-feature-functions header which will contain macros to list
the extensions and functions. cogl_create_context_winsys now calls
_cogl_feature_check for each of these functions. _cogl_feature_check
has had to be changed to accept the driver prefix as the first
parameter so that it can prepend "GLX" rather than "GL" in this case.
2010-06-22 12:22:43 +01:00
Neil Roberts
9646e85ba7 Pass all Xlib events through Cogl
The Clutter X11 backend now passes all events through
_cogl_xlib_handle_event. This function can now internally be hooked
with _cogl_xlib_add_filter. These are added to a list of callbacks
which are all called in turn by _cogl_xlib_handle_event. This is
intended to be used internally in Cogl by any parts that need to see
Xlib events.

Cogl now also has an internally exposed function to set a pointer to
the Xlib display. This is stored in a global variable. The Clutter X11
backend sets this.

_cogl_xlib_handle_event and _cogl_xlib_set_display can be removed once
Cogl gains a proper window system abstraction.
2010-06-22 12:20:59 +01:00
Neil Roberts
2e5b4a5b81 cogl: Add a struct for winsys-specific data to CoglContext
This creates a separate struct to store the fields of the context that
are specific to the winsys. This is all stored in one file but ideally
this could work more like the CoglContextDriver struct and have a
different header for each winsys.
2010-06-22 11:47:33 +01:00
Neil Roberts
9a1aa08fda cogl: Add an internal CoglTextureRectangle backend
This adds an internal rectangle texture backend which is mostly based
on the CoglTexture2D backend. It will throw assert failures if any
operations are attempted that rectangle textures don't support, such
as mipmapping or hardware repeating.
2010-06-22 11:47:33 +01:00
Neil Roberts
82e63a4753 cogl-texture: Replace the ensure_mipmaps virtual with pre_paint
Instead of the ensure_mipmaps virtual that is only called whenever the
texture is about to be rendered with a min filter that needs the
mipmap, there is now a pre_paint virtual that is always called when
the texture is about to be painted in any way. It has a flags
parameter which is used to specify whether the mipmap will be needed.

This is useful for CoglTexturePixmapX11 because it needs to do stuff
before painting that is unrelated to mipmapping.
2010-06-22 11:47:33 +01:00
Neil Roberts
ebb05bcb64 cogl-texture: List texture subclass types rather than hardcoding them
Instead of having a hardcoded series of if-statements in
cogl_is_texture to determine which types should appear as texture
subclasses, they are now stored in a GSList attached to the Cogl
context. The list is amended to using a new cogl_texture_register_type
function. There is a convenience macro called COGL_TEXTURE_DEFINE
which uses COGL_HANDLE_DEFINE_WITH_CODE to register the texture type
when the _get_type() function is first called.
2010-06-22 11:47:33 +01:00
Neil Roberts
2f286446af Add COGL_{OBJECT,HANDLE}_DEFINE_WITH_CODE
This macro is similar to COGL_HANDLE_DEFINE_WITH_CODE except that it
allows a snippet of code to be inserted into the _get_type()
function. This is similar to how G_DEFINE_TYPE_WITH_CODE
works. COGL_HANDLE_DEFINE is now just a wrapper around
COGL_HANDLE_DEFINE_WITH_CODE.
2010-06-22 11:47:33 +01:00
Neil Roberts
f9f2f6bc6c Add _cogl_texture_2d_externally_modified
_cogl_texture_2d_externally_modified is a function specific to the
CoglTexture2D texture backend that should be called whenever the
contents of the texture are modified without the backend knowing about
it. It simply marks the mipmap tree as invalid.
2010-06-22 11:47:32 +01:00
Neil Roberts
5a5b3914ba cogl: Fix the include path in driver/*/Makefile.am
The include path for the winsys and driver folder was given relative
to $(srcdir) so it would end up relative to the driver folder which is
wrong. It is now specified as $(srcdir)/../../winsys to get the right
location. The driver folder is removed because it is actually just
$(srcdir) and that is already included.
2010-06-22 11:47:32 +01:00
Robert Bragg
0e43647fed gles2: don't disable clip planes for GLES2
GLES2 doesn't provide user clip planes (you would have to use a vertex +
fragment shader to achieve the same kind of result) so we make sure not
to call glEnable/Disable with any of the GL_CLIP_PLANE0..3 defines.

http://bugzilla.o-hand.com/show_bug.cgi?id=2177
2010-06-22 11:35:22 +01:00
Robert Bragg
9234757c35 material: fix a typo in _cogl_material_journal_unref
The function had a line like:

CoglMaterial *material =
    material = _cogl_material_pointer_from_handle (material_handle);

where the duplicate "material =" wasn't intended, so this patch removes
it.
2010-06-22 11:21:09 +01:00
Robert Bragg
c8aae9a663 egl: Consolidates eglx and eglnative into one "egl" winsys
This remove quite a lot of redundant code by consolidating the eglx and
eglnative window system backends.
2010-06-18 17:38:41 +01:00
Neil Roberts
270e1e8188 cogl-context: Use the function pointer for glActiveUnit
Under WGL, any functions that were defined after GL 1.1 are not
directly exported in the DLL so we need to reference them via the
function pointers. A new call to glActiveUnit was missed in
cogl-context.c
2010-06-18 15:34:48 +01:00
Neil Roberts
f95cdfc11e cogl-material: Don't use the symbol 'near'
The window headers contain the line

 #define near

so it's not possible to use the symbol 'near' in code that's portable
to Windows. This replaces it with 'near_val'.

I think the define is meant to improve compatibility with code written
for Windows 3.1 where near would be a keyword to make it a smaller
pointer size.
2010-06-18 15:34:48 +01:00
Richard Hughes
7cd5908ef0 build: Fix a compiler warning when using make dist
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-06-16 10:43:55 +01:00
Emmanuele Bassi
d3b26f3f4d Set the initial value of a variable
Fixes a compiler warning.
2010-06-15 16:42:30 +01:00
Robert Bragg
c506b58ecf material: Adds arbfp compile counter
This adds a uprof counter to track how many ARBfp programs get compiled
by an application.
2010-06-15 15:26:28 +01:00
Robert Bragg
ba067c3da8 material: Support sparse ARBfp program generation
We don't need to generate a new ARBfp program for every material created
if we can find an ancestor whos state will result in the same program
being generated.

The more code we can have adopt the coding pattern of deriving their
materials from other similar materials using cogl_material_copy() the
more likely this metric will be good enough on its own to minimize the
set of arbfp programs necessary to support a given application.
2010-06-15 15:26:28 +01:00
Robert Bragg
a38e597aaa material: free any layer cache in material_set_parent
Previously in _cogl_material_pre_change_notify we manually freed the
layer caches of a material if we caused a reparent, but it makes more
sense to have _cogl_material_set_parent do this directly instead.
2010-06-15 15:26:28 +01:00
Robert Bragg
92e8fbfdc6 Adds an internal weak material mechanism
This adds a _cogl_material_weak_copy() function that can be used to
create materials that don't count as strong dependants on their parents.
This means the parent can be modified without worrying about how it will
affect weak materials. The material age of the parent can potentially be
queried to determine if a weak material might need to be re-created.
2010-06-15 15:26:28 +01:00
Robert Bragg
9689ec5aad material: Adds a simple material age getter
When we add support for weak materials it's expected that Clutter will
want to attach them as private data to other materials and it needs a
mechanism to determine when a weak material should be re-created because
its parent has changed somehow.

This adds the concept of a material age (internal only currently) which
increments whenever a material is modified. Clutter can then save the
age of the material which its weak materials are derived from and later
determine when the weak material may be invalid.
2010-06-15 15:26:28 +01:00
Robert Bragg
c9702be94e primitives: we were memsetting the wrong wrap mode overrides pointer
In _cogl_texture_quad_multiple_primitives we weren't memsetting the
CoglMaterialWrapModeOverrides structure we were memsetting
&state.wrap_mode_overrides where state.wrap_mode_overrides is just a
pointer that might potentially later point to the
CoglMaterialWrapModeOverrides structure.
2010-06-15 15:26:28 +01:00
Robert Bragg
20910a1215 material: generalize how we compare simple material properties
In _cogl_material_equal we were repeating the same code pattern to
compare several of the state groups so this just adds
simple_property_equal function that's now used instead.
2010-06-15 15:26:28 +01:00
Robert Bragg
dab4ddc718 material: Make CoglMaterial responsible for depth state
This redirects the legacy depth testing APIs through CoglMaterial and
adds a new experimental cogl_material_ API for handling the depth
testing state.

This adds the following new functions:
cogl_material_set_depth_test_enabled
cogl_material_get_depth_test_enabled
cogl_material_set_depth_writing_enabled
cogl_material_get_depth_writing_enabled
cogl_material_set_depth_test_function
cogl_material_get_depth_test_function
cogl_material_set_depth_range
cogl_material_get_depth_range

As with other experimental Cogl API you need to define
COGL_ENABLE_EXPERIMENTAL_API to access them and their stability isn't
yet guaranteed.
2010-06-15 15:26:28 +01:00
Robert Bragg
fca054e949 cogl docs: Improve documentation for cogl_ortho
cogl_ortho is one of those APIs whos style was, for better or worse,
copied from OpenGL and for some inexplicable reason the near and far
arguments are inconsistent with the left, right, top, bottom arguments
because they don't take z coordinates they take a "distance" which
should be negative for a plane behind the viewer.

This updates the documentation to explain this.
2010-06-15 15:26:28 +01:00
Robert Bragg
a5d6c02f7c primitives: no longer assume _get_layers list remains valid
The internal CoglMaterialLayer pointers associated with a material may
change whenever layer properties are modified so it's no longer ok to
assume that a list of layers returned by cogl_material_get_layers
remains valid if the layers have been changed.
2010-06-15 15:26:28 +01:00
Robert Bragg
b57f68245c material: Adds simple breadcrumb debugging mechanism
Since it can sometimes be awkward to figure out where a particular
material came from when debugging, this adds a breadcrumb mechanism that
lets you associate a const string with a material that may give a clue
about its origin.
2010-06-15 15:26:27 +01:00
Robert Bragg
6b5281401c material: remove override options from _cogl_material_equal
As a follow on to using cogl_material_copy instead of flush options this
patch now removes the ability to pass flush options to
_cogl_material_equal which is the final reference to the
CoglMaterialFlushOptions mechanism.
2010-06-15 15:26:27 +01:00
Robert Bragg
3979de6982 cogl: remove _cogl_material_flush_gl_state flush options
Since cogl_material_copy should now be cheap to use we can simplify
how we handle fallbacks and wrap mode overrides etc by simply copying
the original material and making our override changes on the new
material. This avoids the need for a sideband state structure that has
been growing in size and makes flushing material state more complex.

Note the plan is to eventually use weak materials for these override
materials and attach these as private data to the original materials so
we aren't making so many one-shot materials.
2010-06-15 15:26:27 +01:00
Robert Bragg
1cc3ae6944 CoglMaterial: Implements sparse materials design
This is a complete overhaul of the data structures used to manage
CoglMaterial state.

We have these requirements that were aiming to meet:
(Note: the references to "renderlists" correspond to the effort to
support scenegraph level shuffling of Clutter actor primitives so we can
minimize GPU state changes)

Sparse State:
We wanted a design that allows sparse descriptions of state so it scales
well as we make CoglMaterial responsible for more and more state. It
needs to scale well in terms of memory usage and the cost of operations
we need to apply to materials such as comparing, copying and flushing
their state. I.e. we would rather have these things scale by the number
of real changes a material represents not by how much overall state
CoglMaterial becomes responsible for.

Cheap Copies:
As we add support for renderlists in Clutter we will need to be able to
get an immutable handle for a given material's current state so that we
can retain a record of a primitive with its associated material without
worrying that changes to the original material will invalidate that
record.

No more flush override options:
We want to get rid of the flush overrides mechanism we currently use to
deal with texture fallbacks, wrap mode changes and to handle the use of
highlevel CoglTextures that need to be resolved into lowlevel textures
before flushing the material state.

The flush options structure has been expanding in size and the structure
is logged with every journal entry so it is not an approach that scales
well at all. It also makes flushing material state that much more
complex.

Weak Materials:
Again for renderlists we need a way to create materials derived from
other materials but without the strict requirement that modifications to
the original material wont affect the derived ("weak") material. The
only requirement is that its possible to later check if the original
material has been changed.

A summary of the new design:

A CoglMaterial now basically represents a diff against its parent.
Each material has a single parent and a mask of state that it changes.

Each group of state (such as the blending state) has an "authority"
which is found by walking up from a given material through its ancestors
checking the difference mask until a match for that group is found.

There is only one root node to the graph of all materials, which is the
default material first created when Cogl is being initialized.

All the groups of state are divided into two types, such that
infrequently changed state belongs in a separate "BigState" structure
that is only allocated and attached to a material when necessary.

CoglMaterialLayers are another sparse structure. Like CoglMaterials they
represent a diff against their parent and all the layers are part of
another graph with the "default_layer_0" layer being the root node that
Cogl creates during initialization.

Copying a material is now basically just a case of slice allocating a
CoglMaterial, setting the parent to be the source being copied and
zeroing the mask of changes.

Flush overrides should now be handled by simply relying on the cheapness
of copying a material and making changes to it. (This will be done in a
follow on commit)

Weak material support will be added in a follow on commit.
2010-06-15 15:26:27 +01:00
Robert Bragg
6c8b8cef9e material: fix #ifdef guard around use of _TEXTURE_RECTANGLE
We were incorrectly guarding the use of GL_TEXTURE_RECTANGLE_ARB with
ifdef ARB_texture_rectangle instead of ifdef GL_ARB_texture_rectangle
which broke test-cogl-texture-rectangle.
2010-06-15 15:26:27 +01:00
Robert Bragg
26628553ed blend-strings: removes the AUTO_COMPOSITE function enum
This was mistakenly added some time ago because at some point when we
were discussing how to handle premultiplied alpha in Clutter/Cogl we
were considering having a magic "just do the right thing" option which
was later abandoned.
2010-06-15 15:26:27 +01:00
Robert Bragg
99bef3116d cogl-color: add cogl_color_init_from_xyz funcs
This is to try and improve API consistency. Simple cogl structures that
don't derive from CoglObject and which can be allocated on the stack,
such as CoglColor and CoglMatrix should all have  "_init" or
"_init_from" functions to initialize all the structure members. (As
opposed to a cogl_xyz_new() function for CoglObjects). CoglColor
previously used the naming scheme "_set_from" for these initializers but
"_set" is typically reserved for setting individual properties of a
structure/object.

This adds three _init functions:
cogl_color_init_from_4ub
cogl_color_init_from_4f
cogl_color_init_from_4fv

The _set_from functions are now deprecated but only with a gtk-doc
annotation for now. This is because the cogl_color_set_from API is quite
widely used already and so were giving a grace period before enabling a
GCC deprecated warning just because otherwise the MX maintainers will
complain to me that I've made their build logs look messy.
2010-06-15 15:26:27 +01:00
Robert Bragg
49907d6267 cogl-color: add private _cogl_color_get_rgba_4ubv API
The journal logs colors as 4bytes into a vertex array and since we are
planning to make CoglMaterial track its color using a CoglColor instead
of a byte array this convenience will be useful for re-implementing
_cogl_material_get_colorubv.
2010-06-15 15:26:27 +01:00
Neil Roberts
fcfff3dd04 cogl/winsys/cogl-eglx: Use the right egl header on 1.1
Commit b0cc98fdce introduced a #include for the egl header in
cogl-eglx.c The header name is different under GLES 1.1 so it broke
compilation.
2010-06-11 16:06:31 +01:00
Neil Roberts
cc7722389c cogl-program: Add cogl_program_uniform_1i to GLES
The GLES 1.1 backend was missing a stub for cogl_program_uniform_1i.
2010-06-11 16:06:31 +01:00
Neil Roberts
9343cb849a cogl-gles2: Prefix internal GLES 2 wrapper symbols with _
Some internal symbols used for the GLES 2 wrapper were accidentally
being exported. This prepends an underscore to them so they won't
appear in the shared library.
2010-06-11 16:06:31 +01:00
Neil Roberts
0bbf50f905 cogl-clip-stack: Always use the scissor when clipping
Whenever a path or a rectangle is added to the clip stack it now also
stores a screen space bounding box in the entry. Then when the clip
stack is flushed the bounding box is first used to set up the
scissor. That way when we eventually come to use the stencil buffer
the clear will be affected by the scissor so we don't have to clear
the entire buffer.
2010-06-10 21:52:55 +01:00
Neil Roberts
5a71ff4cdd cogl-path: Export _cogl_path_get_bounds
_cogl_path_get_bounds is no longer static and is exported in
cogl-path-private.h so that it can be used in the clip stack code. The
old version of the function returned x/y and width/height. However
this was mostly used to call cogl_rectangle which takes x1/y1
x2/y2. The function has been changed to just directly return the
second form because it is more useful. Anywhere that was previously
using the function now just directly looks at path->path_nodes_min and
path->path_nodes_max instead.
2010-06-10 21:52:54 +01:00
Neil Roberts
a9da7d72db cogl-clip-state: Export transform_point internally to Cogl
The transform_point function takes a modelview matrix, projection
matrix and a viewport and performs all three transformations on a
point to give a Cogl window coordinate. This is useful in a number of
places in Cogl so this patch moves it to cogl.c and adds it to
cogl-internal.h
2010-06-10 21:52:49 +01:00
Sunil Sadasivan
4abd42aced cogl_texture_get_data() copies using wrong width size.
For sliced 2D textures, _cogl_texture_2d_sliced_get_data() uses the
bitmap width, instead of the rowstride, when memcpy()ing into the
dest buffer.

Signed-off-by: Robert Bragg <robert@linux.intel.com>
2010-06-10 20:58:22 +01:00
Damien Lespiau
98f2d2516b cogl-color: Provide setters for all the channels
We only had getters for the red, green, blue and alpha channels of a
color. This meant that, if you wanted to change, say, the alpha
component of a color, one would need to query the red, green and blue
channels and use set_from_4ub() or set_from_4f().

Instead of this, just provide some setters for CoglColor, using the same
naming scheme than the existing getters.
2010-06-10 20:02:01 +01:00
Damien Lespiau
896dd975d1 cogl-color: Add cogl_color_unpremultiply()
For some operations on pre-multiplied colors (say, replace the alpha
value), you need to unpremultiply the color.

This patch provides the counterpart to cogl_color_premultiply().
2010-06-10 20:01:48 +01:00
Emmanuele Bassi
2ba6ab6dbc cogl: Initialize the framebuffer bits on state flush
The place where we actually change the framebuffer is
_cogl_framebuffer_flush_state(), so if we changed to a new frame buffer
we need to initialize the color bits there.

http://bugzilla.openedhand.com/show_bug.cgi?id=2094
2010-06-10 19:55:18 +01:00
Emmanuele Bassi
7a7dedebd5 cogl-framebuffer: Use the FBO extension for color sizes
OpenGL 3.0 deprecated querying of the GL_{RED,GREEN,BLUE}_BITS
constants, and the FBO extension provides a mechanism to query for the
color buffer sizes which *should* work even with the default
framebuffer. Unfortunately, this doesn't seem to hold for Mesa - so we
just use this for the offscreen CoglFramebuffer type, and we fall back
to glGetIntegerv() for the onscreen one.

http://bugzilla.openedhand.com/show_bug.cgi?id=2094
2010-06-10 19:53:39 +01:00
Emmanuele Bassi
3c4451cd84 cogl: Hide cogl_framebuffer_get_*_bits()
These accessors should be private, for the time being.

http://bugzilla.openedhand.com/show_bug.cgi?id=2094
2010-06-10 19:06:37 +01:00
Neil Roberts
cce5616edf cogl-material: Fix the function which sets the enable blend flag
This function had two problems. Firstly it would clear the enable
blend flag before calling pre_change_notify so that if blending was
previously enabled the journal would end up being flushed while the
flag was still cleared. Secondly it would call the pre change notify
whenever blending is needed regardless of whether it was already
needed previously.

This was causing problems in test-depth.
2010-06-09 17:26:15 +01:00
Robert Bragg
82e80e6765 material: Avoid redundant glBindTexture calls
This adds a _cogl_bind_gl_texture_transient function that should be used
instead of glBindTexture so we can have a consistent cache of the
textures bound to each texture unit so we can avoid some redundant
binding.
2010-06-09 17:26:15 +01:00
Robert Bragg
acc44161c1 material: Adds backend abstraction for fragment processing
As part of an effort to improve the architecture of CoglMaterial
internally this overhauls how we flush layer state to OpenGL by adding a
formal backend abstraction for fragment processing and further
formalizing the CoglTextureUnit abstraction.

There are three backends: "glsl", "arbfp" and "fixed". The fixed backend
uses the OpenGL fixed function APIs to setup the fragment processing,
the arbfp backend uses code generation to handle fragment processing
using an ARBfp program, and the GLSL backend is currently only there as
a formality to handle user programs associated with a material. (i.e.
the glsl backend doesn't yet support code generation)

The GLSL backend has highest precedence, then arbfp and finally the
fixed. If a backend can't support some particular CoglMaterial feature
then it will fallback to the next backend.

This adds three new COGL_DEBUG options:
* "disable-texturing" as expected should disable all texturing
* "disable-arbfp" always make the arbfp backend fallback
* "disable-glsl" always make the glsl backend fallback
* "show-source" show code generated by the arbfp/glsl backends
2010-06-09 17:15:59 +01:00
Neil Roberts
8ebf76a9a9 cogl-atlas-texture: Flush the journal before starting blit not after
_cogl_atlas_texture_blit_begin binds a texture to use as the
destination and it expects it to stay bound until
_cogl_atlas_texture_end_blit is called. However there was a call to
_cogl_journal_flush directly after setting up the blit state which
could cause the wrong texture to be bound. This just moves the flush
to before the call to _cogl_atlas_texture_blit_begin.

This was breaking test-cogl-sub-texture.
2010-06-09 15:22:05 +01:00
Robert Bragg
4ac3133208 atlas: fix some journal flushing issues
1) Always flush when migrating textures out of an atlas because although
it's true that the original texture data will remain valid in the
original texture we can't assume that journal entries have resolved the
GL texture that will be used. This is only true if a layer0_override has
been used.

2) Don't flush at the point of creating a new atlas simply flush
immediately before reorganizing an atlas. This means we are now assuming
that we will never see recursion due to atlas textures being modified
during a journal flush. This means it's the responsibility of the
primitives code to _ensure_mipmaps for example not the responsibility of
_cogl_material_flush_gl_state.
2010-06-09 15:19:31 +01:00
Robert Bragg
a21d909129 primitives: make sure to update texture storage before drawing
We want to make sure that the material state flushing code will never
result in changes to the texture storage for that material. So for
example mipmaps need to be ensured by the primitives code.

Changes to the texture storage will invalidate the texture coordinates
in the journal and we want to avoid a recursion of journal flushing.
2010-06-09 15:19:31 +01:00
Robert Bragg
1047c1c082 matrix: add cogl_matrix_equal API
This adds a way to compare two CoglMatrix structures to see if they
represent the same transformations. memcmp can't be used because a
CoglMatrix contains private flags and padding.
2010-06-09 15:19:31 +01:00
Damien Lespiau
8ee099d204 cogl-material: Use fragment programs instead of texture env combiners
THIS IS A WORK IN PROGRESS

Mesa is building a big shader when using ARB_texture_env_combine. The
idea is to bypass that computation, do it ourselves and cache the
compiled program in a CoglMaterial.

For now that feature can be enabled by setting the COGL_PIPELINE
environment variable to "arbfp". COGL_SHOW_FP_SOURCE can be set to a non
empty string to dump the fragment program source too.

TODO:
  * fog (really easy, using OPTION)
  * support tex env combiner operands, DOT3, ADD_SIGNED, INTERPOLATE
    combine modes (need refactoring the generation of temporary
    variables) (not too hard)
  * alpha testing for GLES 2.0?
2010-06-09 15:19:30 +01:00
Damien Lespiau
56dd71dba0 cogl: Introduce private feature flags and check for ARB_fp
The Cogl context has now a feature_flags_private enum that will allow us
to query and use OpenGL features without exposing them in the public
API.

The ARB_fragment_program extension is the first user of those flags.
Looking for this extension only happens in the gl driver as the gles
drivers will not expose them.

One can use _cogl_features_available_private() to check for the
availability of such private features.

While at it, reindent cogl-internal.h as described in CODING_STYLE.
2010-06-09 15:19:30 +01:00
Neil Roberts
8836c868a4 cogl-gles2-wrapper: Fix some cases using the wrong texture unit
At two places in cogl_wrap_prepare_for_draw it was trying to loop over
the texture units to flush some state. However it was retrieving the
texture unit pointer using w->active_texture_unit instead of the loop
index so it would end up with the wrong state.

Also in glEnableClientState it was using the active unit instead of
the client active unit.
2010-06-08 17:26:26 +01:00
Damien Lespiau
2e52c5f67b doc: Some fixes for the Cogl documentation
• 3 general fixes (typos, copy/paste),
 • ignore cogl-object-private.h,
 • cogl_fixed_atani() was in reality cogl_fixed_atan(), fixed in commit
   43564f05.
 • Fix the cogl-vector section: sections must have a </SECTION> tag at
   the end. Also the cogl-vector section was added in the middle of the
   cogl-buffer one. Let's shiffle it out and add that </SECTION> tag.
2010-06-07 14:32:32 +01:00
Damien Lespiau
7fa011b037 build: Don't distribute clutter-version.h and cogl-defines.h
As with a351ff2af earlier, distributing headers generated at configure
time conflicts with out of tree builds as the distributed headers will
be included first instead of including the generated ones.
2010-06-04 17:43:57 +01:00
Robert Bragg
7dbcb82622 cogl-object-private.h: white space cleanup
simply replaces tabs with spaces
2010-06-04 14:44:15 +01:00
Robert Bragg
d02d40bf61 CoglObject: Adds a COGL_OBJECT macro for casting
This adds a convenience COGL_OBJECT macro for casting CoglObject
subclasses to (CoglObject *) pointers.
2010-06-04 14:44:15 +01:00
Robert Bragg
5af3ead3a2 CoglObject: Adds cogl_object_{get,set}_user_data
This provides a mechanism for associating private data with any
CoglObject. We expect Clutter will use this to associate weak materials
with normal materials.
2010-06-04 14:44:15 +01:00
Robert Bragg
ef08c6369a cogl-path: Adds missing cogl_is_path prototype
This adds a missing cogl_is_path prototype to the public cogl-path.h
header.
2010-06-04 14:44:15 +01:00
Robert Bragg
368dc48372 cogl-path: Renames cogl_path_get/set cogl_get/set_path
These aren't path methods so aren't consistent with the
cogl_object_method naming style we are aiming for.
2010-06-04 14:44:15 +01:00
Damien Lespiau
63eeaa86ea build: Distribute cogl-object.h
cogl-object.h is a new public header. Include it in the right list of
source files to have it distributed.
2010-06-03 11:41:03 +01:00
Emmanuele Bassi
cd7c1dca76 docs: Miscellaneous fixes to silence gtk-doc 2010-06-01 14:15:03 +01:00
Robert Bragg
595271ac87 clip_stack: Remove use of CoglHandle in the CoglClipStack API
This replaces the use of CoglHandle with strongly type CoglClipStack *
pointers instead. The only function not converted for now is
cogl_is_clip_stack which will be done in a later commit.
2010-06-01 12:20:59 +01:00
Robert Bragg
653d1a3254 bitmap: Remove use of CoglHandle in the CoglBitmap API
This replaces the use of CoglHandle with strongly type CoglBitmap *
pointers instead. The only function not converted for now is
cogl_is_bitmap which will be done in a later commit.
2010-06-01 12:20:59 +01:00
Robert Bragg
817c1cddcc path: Remove use of CoglHandle in the CoglPath API
This replaces the use of CoglHandle with strongly type CoglPath *
pointers instead. The only function not converted for now is
cogl_is_path which will be done in a later commit.
2010-06-01 12:20:58 +01:00
Robert Bragg
5f8fadeb1c cogl: avoid ‘_cogl_xyz_handle_new’ defined but not used warnings
This patch makes it so that only the backwards compatibility
COGL_HANDLE_DEFINE macro defines a _cogl_xyz_handle_new function. The
new COGL_OBJECT_DEFINE macro only defines a _cogl_xyz_object_new
function.
2010-06-01 12:20:58 +01:00
Damien Lespiau
db7cc5b1b4 analysis: Fix some CoglFixed API
2 functions where not correctly defined/documented, use the actual
symbol name instead.
2010-06-01 12:08:18 +01:00
Damien Lespiau
45a947d226 analysis: Use static functions when possible
It's best to ensure the functions only used in one compilation unit are
marked as static so GCC can inline them if it feels like it.
2010-06-01 12:08:18 +01:00
Damien Lespiau
338a37d468 analysis: Make all function declarations be protoypes
It's valid C to declare a function omitting it prototype, but it seems
to be a good practise to always declare a function with its
corresponding prototype.
2010-06-01 12:08:18 +01:00
Damien Lespiau
58b0028b52 analysis: FALSE/0 used in pointer context
While this is totally fine (0 in the pointer context will be converted
in the right internal NULL representation, which could be a value with
some bits to 1), I believe it's clearer to use NULL in the pointer
context.

It seems that, in most case, it's more an overlook than a deliberate
choice to use FALSE/0 as NULL, eg. copying a _COGL_GET_CONTEXT (ctx, 0)
or a g_return_val_if_fail (cond, 0) from a function returning a
gboolean.
2010-06-01 12:08:18 +01:00
Robert Bragg
3aaef72e50 buffer: Remove use of CoglHandle in the CoglBuffer API
This replaces the use of CoglHandle with strongly type CoglBuffer *
pointers instead. The only function not converted for now is
cogl_is_buffer which will be done in a later commit.
2010-05-28 18:42:33 +01:00
Robert Bragg
7bcea1c64e Start eradicating the CoglHandle typedef
CoglHandle is a common source of complaints and confusion because people
expect a "handle" to be some form of integer type with some indirection
to lookup the corresponding objects as opposed to a direct pointer.

This patch starts by renaming CoglHandle to CoglObject * and creating
corresponding cogl_object_ APIs to replace the cogl_handle ones.

The next step though is to remove all use of CoglHandle in the Cogl APIs
and replace with strongly typed pointer types such as CoglMaterial * or
CoglTexture * etc also all occurrences of COGL_INVALID_HANDLE can just
use NULL instead.

After this we will consider switching to GTypeInstance internally so we
can have inheritance for our types and hopefully improve how we handle
bindings.

Note all these changes will be done in a way that maintains the API and
ABI.
2010-05-28 18:39:22 +01:00
Neil Roberts
0f32fb4acd cogl-texture-2d: Regenerate the mipmaps when the texture is modified
When the texture is modified by cogl_texture_set_region, it wasn't
setting mipmaps_dirty so it would never update the mipmaps.
2010-05-28 18:13:53 +01:00
Robert Bragg
4c1a12d824 [material] fix _set_alpha_test_function: missing a glEnable(GL_ALPHA_TEST)
Since the default alpha test function of GL_ALWAYS is equivalent to
GL_ALPHA_TEST being disabled we don't need to worry about Enabling/Disabling
it when flushing material state, instead it's enough to leave it always
enabled.  We will assume that any driver worth its salt wont incur any
additional cost for glEnable (GL_ALPHA_TEST) + GL_ALWAYS vs
glDisable (GL_ALPHA_TEST).

This patch simply calls glEnable (GL_ALPHA_TEST) in cogl_create_context
2010-05-28 15:35:23 +01:00
Neil Roberts
5a1cffd0bb cogl-vertex-buffer: Don't disable any texture coord arrays
The enabled state of the texture coord arrays is cached in the cogl
context so there is no need to disable them when we've finished
rendering a vbo.
2010-05-27 14:54:14 +01:00
Neil Roberts
97fd2c368e cogl: Record new enabled arrays in _cogl_disable_other_texcoord_arrays
When _cogl_disable_other_texcoord_arrays is called it disables the
neccessary texcoord arrays and then removes the bits for the disabled
arrays in ctx->texcoord_arrays_enabled. However none of the places
that call the function then set any bits in ctx->texcoord_arrays_enabled
so the arrays would never get marked and they would never get disabled
again.

This patch just changes it so that _cogl_disable_other_texcoord_arrays
also sets the corresponding bits in ctx->texcoord_arrays_enabled.
2010-05-27 14:51:44 +01:00
Neil Roberts
aaf5600b2d cogl: Use a CoglBitmask to store the list of used texcoord arrays
Instead of directly using a guint32 to store a bitmask for each used
texcoord array, it now stores them in a CoglBitmask. This removes the
limitation of 32 layers (although there are still other places in Cogl
that imply this restriction). To disable texcoord arrays code should
call _cogl_disable_other_texcoord_arrays which takes a bitmask of
texcoord arrays that should not be disabled. There are two extra
bitmasks stored in the CoglContext which are used temporarily for this
function to avoid allocating a new bitmask each time.

http://bugzilla.openedhand.com/show_bug.cgi?id=2132
2010-05-24 16:10:57 +01:00
Neil Roberts
4fb784d111 cogl: Add an internal CoglBitmask type
This implements a growable array of bits called CoglBitmask. The
CoglBitmask is intended to be cheap if less than 32 bits are used. If
more bits are required it will allocate a GArray. The type is meant to
be allocated on the stack but because it can require additional
resources it also has a destroy function.

http://bugzilla.openedhand.com/show_bug.cgi?id=2132
2010-05-24 16:10:56 +01:00
Neil Roberts
52cbc93b18 cogl-material: Fix the count of the number of layers
Previously the counter for the number of layers was only updated
whenever the texture handle for a layer changes. However there are
many other ways for a new layer to be created for example by setting a
layer combine constant. Also by default the texture on a layer is
COGL_INVALID_HANDLE so if the application tries to create an explicit
layer with no texture by calling cogl_material_set_layer with
COGL_INVALID_HANDLE then it also wouldn't update the count.

This patch fixes that by incrementing the count in
cogl_material_get_layer instead. This function is called by all
functions that may end up creating a layer so it seems like the most
appropriate place.

http://bugzilla.openedhand.com/show_bug.cgi?id=2132
2010-05-24 16:10:56 +01:00
Neil Roberts
992d5f7fb6 cogl-vertex-buffer: Don't disable layers with no texture coords
It should be quite acceptable to use a texture without defining any
texture coords. For example a shader may be in use that is doing
texture lookups without referencing the texture coordinates. Also it
should be possible to replace the vertex colors using a texture layer
without a texture but with a constant layer color.

enable_state_for_drawing_buffer no longer sets any disabled layers in
the overrides. Instead of counting the number of units with texture
coordinates it now keeps them in a mask. This means there can now be
gaps in the list of enabled texture coordinate arrays. To cope with
this, the Cogl context now also stores a mask to track the enabled
arrays. Instead of code manually iterating each enabled array to
disable them, there is now an internal function called
_cogl_disable_texcoord_arrays which disables a given mask.

I think this could also fix potential bugs when a vertex buffer has
gaps in the texture coordinate attributes that it provides. For
example if the vertex buffer only had texture coordinates for layer 2
then the disabling code would not disable the coordinates for layers 0
and 1 even though they are not used. This could cause a crash if the
previous data for those arrays is no longer valid.

http://bugzilla.openedhand.com/show_bug.cgi?id=2132
2010-05-24 16:10:56 +01:00
Emmanuele Bassi
94c1614164 Merge branch 'wip/framebuffer-bits'
* wip/framebuffer-bits:
  Implement accessors for the color bits in a framebuffer
2010-05-21 14:38:37 +01:00
Robert Bragg
fa22ee0e8d math: Adds an experimental cogl_vector3_* API
This adds a math utility API for handling 3 component, single precision
float vectors with the following; mostly self explanatory functions:

cogl_vector3_init
cogl_vector3_init_zero
cogl_vector3_equal
cogl_vector3_equal_with_epsilon
cogl_vector3_copy
cogl_vector3_free
cogl_vector3_invert
cogl_vector3_add
cogl_vector3_subtract
cogl_vector3_multiply_scalar
cogl_vector3_divide_scalar
cogl_vector3_normalize
cogl_vector3_magnitude
cogl_vector3_cross_product
cogl_vector3_dot_product
cogl_vector3_distance

Since the API is experimental you will need to define
COGL_ENABLE_EXPERIMENTAL_API before including cogl.h if you want to use
the API.
2010-05-20 17:18:24 +01:00
Neil Roberts
af591f5c09 cogl-texture-2d: Optimise _cogl_texture_2d_is_pot
This takes the simple algorithm from here:

http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2

This avoids a loop and is much faster.
2010-05-20 12:40:59 +01:00
Robert Bragg
76d5a1a858 Stubs out _cogl_xlib_handle_event
This stubs out an xlib event handling mechanism for Cogl. The intention
is for Clutter to use this to forward all x11 events to Cogl. As we move
winsys functionality down into Cogl, Cogl will become responsible for
handling a number of X events: ConfigureNotify events for onscreen
framebuffers, swap events and Damage events for cogl_x11_texture_pixmap.
2010-05-19 15:28:04 +01:00
Robert Bragg
1ed1d4fc6a build: expose automake conditionals for cogl winsys
Expose the ./configured window system/backend options to the Cogl
automake files via some new SUPPORT_XYZ conditionals.
2010-05-19 15:08:14 +01:00
Brian Tarricone
5f94a6bf6e eglx: implement cogl_get_proc_address()
http://bugzilla.openedhand.com/show_bug.cgi?id=2124
2010-05-18 17:30:31 +01:00
Neil Roberts
1eddbe8e1b cogl-material: Set the blend equation even if blend funcs are the same
Previously it would only try to set the blend equation if the RGB and
alpha blending functions were different. However it's completely valid
to use a non-standard blending function when the functions are the
same. This patch moves the blending equation to outside the if
statement.
2010-05-17 16:31:28 +01:00
Neil Roberts
9ca68bc37a cogl-material: Set blend constant even if alpha and rgb factors are the same
Previously it would only set the blend constant if glBlendFuncSeparate
was used but it is perfectly acceptable to use the blend constant when
the same factor is used for each. It now sets the blend constant
whenever one of the factors would use the constant.
2010-05-17 16:31:28 +01:00
Neil Roberts
837eb54db4 cogl-blend-string: Don't split combined blend statements into two
When a single statement is used to specify the factors for both the
RGB and alpha parts it previously split up the statement into
two. This works but it ends up unnecessarily using glBlendFuncSeparate
when glBlendFunc would suffice.

For example, the blend statement

 RGBA = ADD(SRC_COLOR*(SRC_COLOR), DST_COLOR*(1-SRC_COLOR))

would get split into the two statements

 RGBA = ADD(SRC_COLOR*(SRC_COLOR[RGB]), DST_COLOR*(1-SRC_COLOR[RGB]))
 A    = ADD(SRC_COLOR*(SRC_COLOR[A]), DST_COLOR*(1-SRC_COLOR[A]))

That translates to:

 glBlendFuncSeparate (GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR,
                      GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

This patch makes it so that arg_to_gl_blend_factor can handle the
combined RGBA mask instead. That way the single statement gets
translated to the equivalent call:

 glBlendFunc (GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
2010-05-17 16:31:28 +01:00
Neil Roberts
8193e12546 cogl-path: Use true copy-on-write semantics
Previously a path copy was implemented such that only the array of
path nodes was shared with the source and the rest of the data is
copied. This was so that the copy could avoid a deep copy if the
source path is appended to because the copy keeps track of its own
length. This optimisation is probably not worthwhile because it makes
the copies less cheap. Instead the CoglPath struct now just contains a
single pointer to a new CoglPathData struct which is separately
ref-counted. When the path is modified it will be copied if the ref
count on the data is not 1.
2010-05-11 16:10:39 +01:00
Owen W. Taylor
582bd409dd cogl-framebuffer: Flush journal when creating fbo
Since framebuffer state is not flushed prior to replaying the journal,
the trick of marking the framebuffer dirty prior to calling
glBindFramebuffer() doesn't work... the outstanding journal entries
will get replayed to the newly created framebuffer.

Fix this by flushing the journal as well.

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

Signed-off-by: Robert Bragg <robert@linux.intel.com>
2010-05-10 14:38:10 +01:00
Neil Roberts
11532f79ec cogl-clip-stack: Set *stencil_used_p when the stack is empty
If the clip stack is empty then _cogl_clip_stack_flush exits
immediately. This was missing out the assignment of *stencil_used_p at
the bottom of the function. If a path is then used after the clip is
cleared then it would think it needs to merge with the clip so the
stencil would not be cleared correctly.
2010-05-06 14:15:04 +01:00
Emmanuele Bassi
676c8a5fd4 Implement accessors for the color bits in a framebuffer
Instead of using cogl_get_bitmasks() to query the GL machinery for the
size of the color bits, we should store the values inside the
CoglFramebuffer object and query them the first time we set the framebuffer
as the current one.

Currently, cogl_get_bitmasks() is re-implemented in terms of
cogl_framebuffer_get_*_bits(). As soon as we are able to expose the
CoglOnscreen framebuffer object in the public API we'll be able to
deprecate cogl_get_bitmasks() altogether.

http://bugzilla.openedhand.com/show_bug.cgi?id=2094
2010-05-05 12:25:16 +01:00
Neil Roberts
36298bbe30 gles: Fix the functions names for the GL_OES_framebuffer_object ext
In 91cde78a7 I accidentally changed the function names that get looked
up for the framebuffer extension under GLES so that they didn't have
any suffix. The spec for extension specifies that they should have the
OES suffix.
2010-05-05 12:24:11 +01:00
Damien Lespiau
6243a5dc34 debug: Use G_UNLIKELY in the tests
Debugging code is not meant to be run in the nominal code path. Use
G_UNLIKELY to be reduce the number of bubbles in the instruction
pipeline.

Took the opportunity to re-indent the macros.
2010-05-04 17:01:14 +01:00
Robert Bragg
dc4c0e3d3e debug: wrap glClear calls with the GE macro
This adds a GE macro wrapper around our calls to glClear so we can
print a warning for any errors reported by the driver.
2010-04-30 12:10:16 +01:00
Neil Roberts
ebe86985fd cogl-texture-2d-sliced: Use the converted bitmap when uploading
When uploading texture data the cogl-texture-2d-sliced backend was
using _cogl_texture_prepare_for_upload to create a bitmap suitable for
upload but then it was using the original bitmap instead of the new
bitmap for the data. This was causing any format conversions performed
by cogl_texture_prepare_for_upload to be ignored.

http://bugzilla.openedhand.com/show_bug.cgi?id=2059
2010-04-29 13:15:36 +01:00
Neil Roberts
dae6ab7d79 cogl-texture: Don't attempt to use GL to convert formats under GLES
In commit abe91784c4 I changed cogl-texture so that it would use the
OpenGL mechanism to specify a different internal texture format from
the image format so that it can do the conversion instead of
Cogl. However under GLES the internal format and the image format must
always be the same and it only supports a limited set of formats. This
patch changes _cogl_texture_prepare_for_upload so that it does the
conversion using the cogl bitmap code when compiling for GLES.

http://bugzilla.openedhand.com/show_bug.cgi?id=2059
2010-04-29 13:15:35 +01:00
Neil Roberts
3e88dee1a3 cogl-material: Fix the check to prevent using too many layers
There was a check at the bottom of the loop which sets up the state
for each of the layers so that it would break from the loop when the
maximum number of layers is reached. However after doing this it would
not increment 'i'. 'i' is later used to disable the remaining layers
so it would end up disabling the last layer it just set up.

This patch moves the check to be part of the loop condition so that
the check is performed after incrementing 'i'.

http://bugzilla.openedhand.com/show_bug.cgi?id=2064
2010-04-29 12:15:17 +01:00
Neil Roberts
d5d98500be cogl-material: Fix the warning for when too many layers are used
The warning displayed when too many layers are used had an off-by-one
error so that it would display even if exactly the maximum number is
used. There was also a missing space at the end of the line in the
message which looked wrong when displayed on the terminal.

http://bugzilla.openedhand.com/show_bug.cgi?id=2064
2010-04-29 12:15:11 +01:00
Neil Roberts
edf2bf3d8a cogl-path: Make cogl_path_arc_rel static
cogl_path_arc_rel was never in any public headers so it isn't part of
the public API. It also has a slightly inconsistent name because the
rest of the relative path functions are called cogl_path_rel_*. This
patch makes it static for now to make it more obvious that it isn't
public. The name has changed to _cogl_path_rel_arc.
2010-04-22 18:17:59 +01:00
Neil Roberts
2b8abbdaa8 cogl-path: Add documentation for the angles of cogl_path_arc
This adds documentation for how Cogl interprets the angles given to
cogl_path_arc.
2010-04-22 18:17:59 +01:00
Neil Roberts
308ca6cb14 cogl-path: Fix the truncation when adding to a copied path
If a path is copied and then appended to, the copy needs to have the
last sub path truncated so that it fits in the total path size in case
the original path was modified. However the path size check was broken
so if the copied path had more than one sub path it would fail.
2010-04-21 22:36:43 +01:00
Neil Roberts
9d93e250d1 cogl-clip-stack: Use orientation of the polygon to set clip planes
Previously the clip stack code was trying to detect when the
orientation of the on-screen rectangle had changed by checking if the
order of the y-coordinates on the left edge was different from the
order the x-coordinates on the top edge. This doesn't work for some
rotations which was causing the clip planes to clip the wrong side of
the line. This patch makes it detect the orientation by calculating
the signed area which is a standard computer graphics algorithm.

http://bugzilla.openedhand.com/show_bug.cgi?id=2079
2010-04-21 13:24:59 +01:00
Neil Roberts
17a1595cb0 cogl-path: Document how a shape is filled
This adds some documentation to cogl_path_fill() describing the fill
rule Cogl uses.
2010-04-21 13:20:23 +01:00
Neil Roberts
8afea98437 cogl-path: Don't try to union sub paths
When drawing a path with only a single sub path, Cogl uses the
'even-odd' fill rule which means that if a part of the path intersects
with another part then the intersection would be inverted. However
when combining sub paths it treats them as separate paths and then
unions them together. This doesn't match the semantics of the even-odd
rule in SVG and Cairo. This patch makes it so that a new sub path is
just drawn as another triangle fan so that it will continue to invert
the stencil buffer. This is also much simpler and more efficient as
well as being more correct.

http://bugzilla.openedhand.com/show_bug.cgi?id=2088
2010-04-21 11:39:28 +01:00
Neil Roberts
7f629f626e cogl_read_pixels: Always use GL_RGBA/GL_UNSIGNED_BYTE under GLES
Under GLES glReadPixels is documented to only support GL_RGBA with
GL_UNSIGNED_BYTE and an implementation specfic format which can be
fetched with glGet, GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES and
GL_IMPLEMENTATION_COLOR_READ_TYPE_OES. This patch makes it always read
using GL_RGBA and GL_UNSIGNED_BYTE and then convert the results if
neccessary.

This has some room for improvement because it doesn't attempt to use
the implementation specific format. Also the conversion is somewhat
wasteful because there are currently no cogl_bitmap_* functions to
convert without allocating a new buffer so it ends up doing an
intermediate copy.

http://bugzilla.openedhand.com/show_bug.cgi?id=2057
2010-04-21 10:56:21 +01:00
Neil Roberts
f944d419a3 cogl-bitmap: Fix converting formats with and without alpha channels
_cogl_bitmap_convert_format_and_premult was failing when converting
from RGBA to RGB and vice versa. _cogl_bitmap_fallback_convert
converts without altering the premult status so when choosing a new
format it would copy over the premult bit. However, it did this
regardless of whether the new format had an alpha channel so when
converting from RGBA_8888_PRE to RGB_888 it would end up inventing a
new meaningless format which would be RGB_888_PRE. This patch makes it
avoid copying the premult flag if the destination has no alpha. It
doesn't matter if it copies when the source format has no alpha
because it will always be unset.

_cogl_bitmap_convert_format_and_premult was also breaking when
converting from RGBA_8888_PRE to RGB_888 because it would think
RGB_888 is unpremultiplied and try to convert but then
_cogl_bitmap_fallback_premult wouldn't know how to do the conversion.

http://bugzilla.openedhand.com/show_bug.cgi?id=2057
2010-04-21 10:56:21 +01:00
Neil Roberts
30c4678ff4 cogl: Implement retained clip stacks
This adds three new internal API functions which can be used to retain
the clip stack state and restore it later:

 _cogl_get_clip_stack
 _cogl_set_clip_stack
 _cogl_clip_stack_copy

The functions are currently internal and not yet used but we may want
to make them public in future to replace the cogl_clip_stack_save()
and cogl_clip_stack_restore() APIs.

The get function just returns the handle to the clip stack at the top
of the stack of stacks and the set function just replaces it.

The copy function makes a cheap copy of an existing stack by taking a
reference to the top stack entry. This ends up working like a deep
copy because there is no way to modify entries of a stack but it
doesn't actually copy the data.
2010-04-15 14:51:01 +01:00
Neil Roberts
84b87e811e cogl-clip-stack: Convert to be a CoglHandle
CoglClipStacks can now be reference counted via a CoglHandle. The
ClipClipState now stores handles in the list rather than CoglClipStack
pointers.
2010-04-15 14:51:01 +01:00
Neil Roberts
f6f375cb36 Separate out CoglClipStackState from cogl-clip-stack.c
CoglClipStackState has now been renamed to CoglClipState and is moved
to a separate file. CoglClipStack now just maintains a stack and
doesn't worry about the rest of the state. CoglClipStack sill contains
the code to flush the stack to GL.
2010-04-15 14:51:00 +01:00
Neil Roberts
07a76aacfb cogl-slip-stack: Store clip window rect entries in Cogl coordinates
When glScissor is called it needs to pass coordinates in GL's
coordinate space where the origin is the bottom left. Previously this
conversion was done before storing the window rect in the clip
stack. However this might make it more difficult if we want to be able
to grab a handle to a clip stack and use it in different circumstances
later. This patch moves the coordinate conversion to inside the clip
state flushing code.
2010-04-15 14:50:55 +01:00
Neil Roberts
2f63146474 cogl-clip-stack: Store window rect entries as ints not floats
The window rectangles are passed in as integers so there is no point
in converting them to floats when storing a stack entry for them.
2010-04-15 14:50:26 +01:00
Neil Roberts
71fdc54dde cogl-clip-stack: Use reference counted stack entries
The stack is now stored as a list of reference counted entries.
Instead of using a GList, each entry now contains a link with a
reference to its parent. The idea is that this would allow copying
stacks with a shared ancestry.

Previously the code flushed the state by finding the bottom of the
stack and then applying each entry by walking back up to the top. This
is slightly harder to do now because the list is no longer
doubly-linked. However I don't think it matters which order the
entries are applied so I've just changed it to apply them in reverse
order.

There was also a restriction that if ever the stencil buffer is used
then we could no longer use clip planes for any subsequent entries. I
don't think this makes sense because it should always work as long as
it doesn't attempt to use the clip planes more than once. I've
therefore removed the restriction.
2010-04-15 14:47:01 +01:00
Neil Roberts
ecf65cd4a5 cogl-atlas-texture: Fix a memory leak
The CoglAtlasTexture struct was not being freed in
_cogl_atlas_texture_free so there would be a small leak whenever a
texture was destroyed.

Thanks to Robert Bragg for spotting this.
2010-04-13 17:26:03 +01:00