Commit Graph

1686 Commits

Author SHA1 Message Date
Robert Bragg
ac72d0685c profile: Print warning if "Mainloop" timer missing
As a helpful aid Cogl will now print a warning if no "Mainloop" UProf
timer was setup by the application that explains that either Clutter
should be built with --enable-profile or if Clutter isn't being used
then it shows how it can create its own Mainloop timer.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 3d052dbca86bf36f30b2d60ff59b967d14665436)
2012-09-03 15:51:45 +01:00
Robert Bragg
85efcfac2a journal: Add a uprof timer around the _flush() discard
This adds a uprof timer around the _cogl_journal_discard() at the end of
_cogl_journal_flush() since this sometimes takes a significant
proportion of the time to flush the journal.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 14ffc3a197100be814452af2d0f839970353b04d)
2012-09-03 15:51:45 +01:00
Robert Bragg
c477e9ce49 debug: define COGL_DEBUG_ macros for non-debug builds
Since we only want to disable the debug features that may impact
performance when building with --disable-debug this ensures that the
COGL_DEBUG_ macros aren't defined as NOPs for non-debug builds.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit c4b50040b5c033e370eb721d1d217eced8ebdaad)
2012-09-03 15:51:45 +01:00
Robert Bragg
fb22383993 pipeline: make _GET_LAYER_NO_CREATE enum a flag
_cogl_pipeline_get_layer_with_flags accepts a CoglPipelineGetLayerFlags
flags argument and understands one COGL_PIPELINE_GET_LAYER_NO_CREATE
flag. There was a mistake with the definition of this enum though so
COGL_PIPELINE_GET_LAYER_NO_CREATE had a value of 0 and so testing for
the flag using the bitwise & operator would never find the flag set.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 5923f92f1428b3eb4977b5f21723f1b19a9d284a)
2012-09-03 15:51:45 +01:00
Robert Bragg
71f20064ab debug: ignore wireframe debug drawing for line primitives
If a primitive is already line based then we don't need to do anything
special to draw it in wireframe mode.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit fb575a42c308739a7185311a613b1a5f49dbfb39)
2012-09-03 15:51:44 +01:00
Robert Bragg
971b5cfae1 primitive: Don't leak indices
If a CoglPrimitive is associated with a set of indices then we must
unref those indices when freeing the primitive to avoid a leak.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 45cac786b55c953e44f98b864add952b9e398b13)
2012-09-03 15:51:44 +01:00
Robert Bragg
74d749eca4 kms: Update to latest gbm api
gbm_bo_get_pitch was renamed to gbm_bo_get_stride to be consistent with
how the terms pitch and stride are used throughout mesa. This updates
the Cogl backend to use the new gbm_bo_get_stride name.

For compatibility with previous version of libgbm we now explicitly
check the version of libgbm in configure.ac and expose
COGL_GBM_{MAJOR,MINOR,MICRO} defines to the code so we can conditionally
use the older gbm_bo_get_pitch() name with older versions.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 47c6247095e2f1f8725c4eb08d38c9de15e283cd)
2012-09-03 15:51:44 +01:00
Neil Roberts
ef73e6e3b9 cogl-version: Fix the 'since' tags in the documentation
The COGL_VERSION_* macros will also be in Cogl 1.12.0.

(cherry picked from commit e9473b58b80a06d3be34a4b518aade190ed9b666)
2012-09-03 15:48:05 +01:00
Neil Roberts
f13f6b9175 cogl-version: Fix the version number
The version number macros were using the @COGL_VERSION_*@
substitutions. These are always defined to 2.0.0 in the 1.x releases
so we need to use the Cogl @COGL_1_VERSION_*@ substitutions instead to
get the real version number.
2012-09-03 15:47:56 +01:00
Neil Roberts
b3f56ccb48 tex-driver-gles: Fix subregion uploads without GL_EXT_unpack_subimage
When the GL_EXT_unpack_subimage extension is not available and a
subregion of a texture is uploaded then it should first copy the
subregion to a newly allocated bitmap. However it was then later still
trying to prepare the upload using the original src_x and src_y values
which would cause an assertion failure. This patch fixes it to just
reset those to zero if the subregion is first copied.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 6f9a62db6f846f1d76e3ca16d9d8cdadf82a7009)
2012-08-29 15:01:31 +01:00
Chun-wei Fan
55e4394780 Update/fix cogl.symbols for 1.12
Update the cogl.symbols file for the 1.12 series, where symbols
were added for the following commits:

010d16f6: Adds initial GLES2 integration support
6eb88648: Add a cogl_matrix_init_from_euler function
5e8ff248: Add functions to directly transform from a euler or a quaternion
1686e754: bitmap: Adds cogl_android_bitmap_new_from_asset()
df515741: onscreen: Adds support for resizable windows
e347135b: Move cogl_wayland_display_ proto to cogl-wayland-server.h

Plus, when we branched out for 1.12, some needed symbols were missing, so
we would need to make up for them, in particular those in cogl-shader.h
and cogl-path-functions.h.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-08-17 01:20:13 +08:00
Chun-wei Fan
8dbf7ffe05 cogl/Makefile.am: Correct the way gen-enums.bat is created
Don't use --symbol-prefix cogl_gtype as we are still using the old
namespace in cogl-1.12, so there will still be the various _get_type()'s
like before

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-08-17 01:20:02 +08:00
Tomeu Vizoso
04348bda0b cogl-gles2: Install headers in cogl/ instead of in cogl2/
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-08-16 16:36:34 +01:00
Neil Roberts
32fbd0ada6 kms: Use a dummy surface instead of the surfaceless extension
The surfaceless extension that Mesa advertises has been renamed to
EGL_KHR_surfaceless_context instead of a separate extension for the
GLES, GLES2 and GL APIs and the new extension has been ratified by
Khronos. Therefore the KMS backend no longer runs against Mesa master.
We could just rename the extension we check for, however Weston (the
sample Wayland compositor) has switched to just creating a dummy GBM
surface and not using the surfaceless extension at all. We should
probably do the same thing.

Using the surfaceless extension could be a good idea but we don't
really need to rely on it for KMS and we would want to do it for all
EGL backends, not just the KMS backend.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit d4f22f8cb013d417c99ba03924538924191c2fe6)
2012-08-15 17:29:16 +01:00
Neil Roberts
51d94769be framebuffer: Take const pointers for the matrix setters
cogl_framebuffer_set_{projection,modelview}_matrix don't need to read
from the matrix argument so they should probably take a const pointer.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 710d6af053aca97935b54f9ff68858ef51f4482b)
2012-08-15 17:29:16 +01:00
Neil Roberts
41539dd7f0 bitmap: Use the 'copy' blend mode when loading images on Quartz
When loading images on Quartz, the image is rendered into a bitmap
context using a buffer allocated with
_cogl_bitmap_new_with_malloc_buffer. However this buffer is not
initialised and by default Quartz will blend the source image with the
destination so if there are transparent parts in the source image it
will leave garbage in the destination. This patch changes the blend
mode to 'copy' so that it won't try to blend.

Before 5b785dd4 the buffer was cleared because it was allocated with
g_malloc0 so it was working in that case. Presumably it should be more
efficient to disable blending and avoid the clear though.

https://bugzilla.gnome.org/show_bug.cgi?id=680124

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 5ba7f4e6837a539d92cbe45491f79a8926fd6828)
2012-08-15 17:14:25 +01:00
Sjoerd Simons
57f420e21e Remove one final user of cogl-handle and cogl-handle.h itself
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-08-15 13:46:25 +01:00
Neil Roberts
19ccb72b80 cogl-gles2-context: Wrap glCopyTex{Sub,}Image2D to flip the result
When the CoglGLES2Context is bound to read from a CoglOffscreen then
the result will be upside down from what GL expects if
glCopyTexImage2D is used directly. To fix that, this patch now wraps
glCopyTexImage2D and glCopyTexSubImage2D so that the copy is doing by
binding an FBO to the target texture and then rendering a quad
sampling from the texture in the offscreen framebuffer.

The rendering is done using the Cogl context rather than the GLES2
context because otherwise it would have to do a fair bit of work to
try and stash the old state on the context before setting up the state
to do the blit. The down side of this is that the contexts need to be
synchronized so that the rendering will be up-to-date. As far as I
understand from the GL spec, this requires a glFinish and then the
texture needs to be rebound in the new context because updates to
shared objects are guaranteed to be reflected until the object is
rebound.

GLES2 supports using glCopyTexImage2D for cube map textures. As Cogl
doesn't currently have support for cube maps, it is quite hard to get
that to work with this patch. For now attempts to copy to a cube map
texture will just be sliently ignored.

This patch also includes a test case which renders an image to the
framebuffer and then copies it to a texture. The texture is then
rendered back to the framebuffer and the contents are checked for the
correct orientation using glReadPixels.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 30b6da8134bad95267265e26685c7475f6c351c9)
2012-08-15 13:46:20 +01:00
Neil Roberts
77edc1f204 cogl-gles2-context: Keep track of extra data per texture object
This patch adds a hash table mapping texture object IDs to a struct so
that we can keep track of some of the state for each texture object.
Currently it will just track the width and height of the texture 2D
target.

Additionally it will now try to delete any texture objects that have
data created for them by the GLES2 context so that it won't leak them.
It only tracks objects that get data set on them, not all objects that
are bound because it is possible to use the GLES2 context with foreign
textures via cogl_gles2_texture_get_handle() and we don't want to
delete those.

In order to keep track of the currently bound texture object it also
needs to track the active texture unit.

Note that this state tracking will probably go wrong if GL throws an
error for invalid state. For example if glActiveTexture is called with
an invalid texture unit then GL will ignore the binding but Cogl will
assume it is valid and the state tracking will get out of sync.
Perhaps it would be good if Cogl could detect the errors but this is
difficult to do without consuming them.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit d8c72bb56cf3598fc57d629edc618f1bfa79f125)
2012-08-15 13:44:22 +01:00
Neil Roberts
8e12e40da9 cogl-gles2-context: Flip the rendering when framebuffer is offscreen
Cogl has a different origin for texture coordinates than OpenGL so
that the results of rendering to a texture should leave the top of the
image at the texture coordinate 0,0 rather than the bottom. When a
GLES2 context is used to render to a Cogl texture via a CoglOffscreen
we don't really want the application to have to be aware of the
mismatch and flip the texture coordinates. To get that to work, this
patch now tracks all of the programs that the application generates
using the context and sneaks in an extra vertex shader with an
alternative main function. This main function multiplies the final
calculated gl_Position by a vector uniform which we can use to flip
the image. When the application uploads the source code for a vertex
shader we now replace any occurrences of the token 'main' with '_c31'
and this renamed function gets called from the replacement main
function. The token has a weird name so that it will be unlikely to
conflict with a variable name in the application's source but it also
needs to have the same number of characters as the original token so
that it won't affect column numbers in the error reporting.

We are also wrapping glGetShaderSource so that we can try to revert
the token name. The same goes for the error logs just in case the
error report mentions function names.

Both places that cause drawing to occur (glDrawElements and
glDrawArrays) are now also wrapped so that we can update the uniform
value whenever the program is used with a different type of
framebuffer from last time.

We additionally need to manually track the state for the viewport, the
stencil box and the front face because all of these will be affected
by whether we are flipping the image or not. Any attempts to change
these states will be queued and instead flushed at the last minute
before drawing.

There are still some known issues with this patch:

• glCopyTexImage2D and glCopyTexSubImage2D will do the wrong thing
  when copying data from a CoglOffscreen. This could be quite fiddly
  to solve.

• Point sprites won't flip correctly. To make this work we would need
  to flip the gl_PointSprite builtin variable somehow. This is done in
  the fragment shader not the vertex shader so flipping the calculated
  gl_Position doesn't help here.

• The patch doesn't attempt to flip rendering to framebuffers for
  textures created within the GLES2 context. This probably makes sense
  because those textures are likely to be used within the GLES2
  context in which case we want to leave the texture coordinates as
  they are. However, if the texture is shared back out to Cogl with
  cogl_gles2_texture_2d_new_from_handle then the texture will be
  upside-down.

• The application can discover our secret uniform that we added via
  glGetActiveUniform. It might be worth trying to disguise this by
  wrapping that function although that could be quite fiddly.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit d589bf19e51f22c3241b2a18db10f22131ac126a)
2012-08-14 18:55:42 +01:00
Neil Roberts
0c66431df3 Add a wrapper for 'memmem'
memmem is a GNU libc extension that works like strstr except that the
size of the needle and the haystack are passed into the function
instead of using null-terminated strings.

This patch adds a wrapper function called 'cogl_util_memmem' so that
we can use this function. There is a configure check and if the
function is not available then a fallback implementation will be used.
Otherwise cogl_util_memmem is just defined to memmem.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 1dd1b0a67f6238e13f7f9253fb03addada0541b7)
2012-08-14 18:55:42 +01:00
Neil Roberts
12a1ef72c0 cogl-gles2-context: Keep some extra data for shaders and programs
All of the functions that create and destroy shaders are now wrapped
in the CoglGLES2Context so that we can track some extra data for them.
There are hash tables mapping object IDs to the corresponding data.
The data is currently not used for anything but will be in later
patches.

The glUseProgram, glAttachShader and glDetachShader functions
additionally need to be wrapped because GL does not delete shader
objects that are in use. Therefore we need to have a reference count
on the data so we can recognise when the last use has been removed.

The IDs are assumed to be specific to an individual CoglGLES2Context.
This is technically not the case because all of the CoglGLES2Contexts
are in the same share list. However we don't really want this to be
the case so currently we will assume sharing the object IDs between
contexts is undefined behaviour. Eventually we may want to actually
enforce this.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 05dc1e34785ae5f5484cd398ecc5464bd8bd3dcd)
2012-08-14 18:55:42 +01:00
Neil Roberts
0cd88bd676 cogl-gles2-context: Fix the default viewport and scissor size
In GL, the default viewport and scissor should be set to the size of
the first surface that the context is bound to. If a CoglGLES2Context
is first used with an offscreen framebuffer then this surface will
actually be the dummy 1x1 window which will mess up the defaults. To
fix that, this patch makes it just always override the viewport and
scissor the first time the context is bound to something.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 02567b3e6b64e6849b9f7c6aa2137401be7ece8d)
2012-08-14 18:55:42 +01:00
Robert Bragg
6a024acaa9 display: inc cogl-wayland-server.h if needed
Since 0773107deb9ede the prototype for
cogl_wayland_display_set_compositor_display() has moved into
cogl-wayland-server.h but cogl-display.c wasn't updated to include this
header.

(cherry picked from commit f6ccff9992fcfb9497ce91dd299460362476ba7a)
2012-08-06 18:51:34 +01:00
Robert Bragg
e347135b6a Move cogl_wayland_display_ proto to cogl-wayland-server.h
We need to avoid including wayland-server.h or wayland-client.h
indirectly when including cogl.h because there are overlapping typedef
names between the client and server wayland headers and we can't assume
whether Cogl is being used client or server side. This moves the
prototype for cogl_wayland_display_set_compositor_display() into
cogl-wayland-server.h which Cogl apps must include explicitly if the
want access to server side Cogl Wayland symbols.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 0773107deb9eded408e2801f217462c5d551f15a)
2012-08-06 18:51:34 +01:00
Neil Roberts
0e168ed0aa Fix the header guards for cogl-texture-2d{,-private}.h
The header guard for cogl-texture-2d-private.h was
__COGL_TEXTURE_2D_H. This would conflict with the header guard for
cogl-texture-2d.h except there a small typo ('TEXURE') so that it
was subtly different. This fixes them both to make more sense.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 222ec4d009973cb62020a9da05f72dea41460b33)
2012-08-06 18:51:33 +01:00
Neil Roberts
96b726b518 cogl-winsys-sdl: Fix the signature for the get_proc_address method
This function should take an extra third paramter to specify whether
the procedure is in core or not. The parameter is not used so this
patch just fixes an annoying warning.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit eed4ac80cd8c3fa1859493c9bb00547038be6095)
2012-08-06 18:51:33 +01:00
Neil Roberts
59ff396875 cogl-winsys-egl-kms: Remove some unused variables
This just gets rid of some annoying warnings.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 3d0aea04d1f6a8094b749e20a59d8a9a95a6235e)
2012-08-06 18:51:33 +01:00
Neil Roberts
5fff83cd3c cogl-texture-2d-private: Include egl-defines.h
The cogl-texture-2d-private.h header checks for the presence of
EGL_KHR_image_base before declaring
_cogl_egl_texture_2d_new_from_image. This define will only be
available if the EGL headers are included so we should make sure that
happens. This was resulting in a warning complaining that the function
was not previously declared.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit bd4840d7858efcf30eb5cf5d6fd0d39bdd59d1c1)
2012-08-06 18:51:33 +01:00
Neil Roberts
74fd618df9 Add conf vars to trick Cogl to think extensions are disabled
This adds two new configuration environment variables:

COGL_DISABLE_GL_EXTENSIONS and
COGL_OVERRIDE_GL_VERSION

The variables can also be set in the cogl.conf file using the same
names.

The first one is a list of GL extension names separated by commas.
When set Cogl will assume any extension listed here is not available
by removing it from the string returned from
glGetString(GL_EXTENSIONS). If the string is set in both the config
file and the environment variable then the union of the two lists will
be used.

The second overrides the value returned from glGetString(GL_VERSION).
If the string is set in both places the version from the environment
variable will take priority.

These are sometimes useful for debugging Cogl to test the various
combinations of extensions. It could also be useful to work around
driver bugs where an extension is badly supported and it would be
better not to use it.

The variables in cogl-config that just set a global char * variable
have been put together in an array instead of having a separate blob
of code for each one in order to make it simpler to add new variables.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit ec69c2dc576c78664e0b73879365cb7414ecf441)
2012-08-06 18:51:33 +01:00
Damien Lespiau
e5fea8b734 egl-x11: Don't use GLXDrawable on EGL
Someone trying to compile cogl (ThijsNL on irc0 for the Rasberry Pi
stumbled into that one. GLXDrawable may not be defined in a pure EGL/X
environment.

Change it to Window, the type used for XConfigureEvent.window.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit f05d6923fff28b1d167a391d486e319743c49215)
2012-08-06 18:51:33 +01:00
Neil Roberts
cbad21f0f4 pipeline: Remove the CoglPipelineFlag enum
This doesn't appear to be used anywhere in the code since it was added
in 1cc3ae69. Dead code is confusing so let's remove it.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 41928d0ac528acf4ba89b5b27d7ca7ac5501b194)
2012-08-06 18:51:33 +01:00
Tomeu Vizoso
bb258c1d42 Avoid including the EGL headers from the public Cogl headers
Otherwise, X11 identifiers may leak and cause havoc in big applications

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit ed0cdca0eca815543619fe72fbd42d662d53f92d)
2012-08-06 18:51:32 +01:00
Robert Bragg
961832164b quaternions: Allow multiplication into 'a' arg
When multiplying two quaternions, we now implicitly copy the components
of the 'a' argument so that the result can be reliably written back to
the 'a' argument quaternion without conflicting with the multiplication
itself. This is consistent with the cogl_matrix_multiply() api which
allows the 'result' and 'a' arguments to point to the same matrix. In
debug builds Cogl will assert that the 'b' and 'result' arguments don't
point to the same quaternion.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 207527313a8957789390069e84189254cf41e88f)
2012-08-06 18:51:32 +01:00
Robert Bragg
8f4dd4587e onscreen: Free swap notify callback state
When freeing a CoglOnscreen we weren't freeing the state associated with
swap notification callbacks.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 70bc12fe20fa1be4eac58356861a730f18d6b59e)
2012-08-06 18:51:32 +01:00
Robert Bragg
56382435fa stack: don't deref freed mem in _cogl_memory_stack_free
This fixes _cogl_memory_stack_free to ensure we don't dereference freed
memory as we iterate the sub-stacks to free them.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 1d27fedef9c599aa9976b809f18e0da1913cec26)
2012-08-06 18:51:32 +01:00
Robert Bragg
df51574116 onscreen: Adds support for resizable windows
This adds api to be able to request that the window system allows a
given onscreen framebuffer to be resizable, and api to add and remove
resize handlers to be called whenever the framebuffer does actually
change size.

The new functions are:
  cogl_onscreen_{get,set}_resizable()
  cogl_onscreen_{add,remove}_resize_handler()

The examples cogl-hello and cogl-x11-foreign have been updated to use
the new api. To smoke test how Cogl updates the viewport automatically
in response to window resizes the cogl-hello test doesn't explicitly
respond to resize events by setting the viewport and cogl-x11-foreign
responds by setting a viewport that is offset by a quarter of the
window's width/height and half the width and height of the window.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit a1a8cc00bfa2cecaf1007aec5f3dd95dc07b1786)
2012-08-06 18:51:32 +01:00
Neil Roberts
2ae352b0a6 Fix point sprite coordinates in shaders on GLES2
When using the GLES2 driver with a pipeline layer that has point
sprite coordinates enabled it extracts the texture coordinates from
the gl_PointCoord builtin instead of cogl_tex_coord_in[*].
gl_PointCoord is not quite the same as the regular texture coordinates
because it is only a vec2 instead of a vec4. This used to work ok
because either set of texture coordinates would always immediately be
accessed using a swizzle of '.st' so it would effectively be converted
to a vec2 anyway. However since the snippet hook for texture lookups
was added the texture coordinates are now passed to a function to
perform the actual lookup instead. This function always takes a vec4
so the shader would not compile. This patch fixes it to construct a
vec4 from gl_PointCoord by setting the third and fourth components to
0.0 and 1.0.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit cb3409b23caf324a548f82cfb88acc684cc71930)
2012-08-06 18:51:31 +01:00
Tomeu Vizoso
053845f796 framebuffer: Only remember offscreen allocate flags when !COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL
Otherwise, if a texture is created before all the other FBOs, a new
atlas will be created, with a FBO with COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL
causing last_offscreen_allocate_flags to be 0.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 7d2156785da8196e129eb393efb0d09093c4783e)
2012-08-06 18:51:31 +01:00
Robert Bragg
1686e754a7 bitmap: Adds cogl_android_bitmap_new_from_asset()
This adds some android specific api for creating a CoglBitmap from an
Android asset.

As part of the work it also seemed like a good time to change the
internal bitmap constructors to take an explicit CoglContext argument
and so the public cogl_bitmap_new_from_file() api was also changed
accordingly to take a CoglContext pointer as the first argument.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 099d6d1b505b55bbd09c50d081deb41ab5764e19)

  Since we aren't able to break APIs on the 1.12 branch this cherry-pick
  skips the change to cogl_bitmap_new_from_file()
2012-08-06 18:50:22 +01:00
Neil Roberts
d1dc4e1e0b Don't use the label 'ERROR' because it conflicts with windows.h
wingdi.h which gets included from windows.h #defines ERROR to 0 so we
can't use it as a label in Cogl. This patch changes it to be error in
lower case instead.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit e9bac2755c2cba84c82a856d369a30560d19a32e)
2012-08-06 14:27:45 +01:00
Neil Roberts
df77e8565e Don't use eglGetProcAddress to retrieve core functions
According to the EGL spec, eglGetProcAddress should only be used to
retrieve extension functions. It also says that returning non-NULL
does not mean the extension is available so you could interpret this
as saying that the function is allowed to return garbage for core
functions. This seems to happen at least for the Android
implementation of EGL.

To workaround this the winsys's are now passed down a flag to say
whether the function is from the core API. This information is already
in the gl-prototypes headers as the minimum core GL version and as a
pair of flags to specify whether it is available in core GLES1 and
GLES2. If the function is in core the EGL winsys will now avoid using
eglGetProcAddress and always fallback to querying the library directly
with the GModule API.

The GLX winsys is left alone because glXGetProcAddress apparently
supports querying core API and extension functions.

The WGL winsys could ideally be changed because wglGetProcAddress
should also only be used for extension functions but the situation is
slightly different because WGL considers anything from GL > 1.1 to be
an extension so it would need a bit more information to determine
whether to query the function directly from the library.

The SDL winsys is also left alone because it's not as easy to portably
determine which GL library SDL has chosen to load in order to resolve
the symbols directly.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 72089730ad06ccdd38a344279a893965ae68cec1)

  Since we aren't able to break API on the 1.12 branch
  cogl_get_proc_address is still supported but isn't easily able to
  determine whether the given name corresponds to a core symbol or
  not.  For now we just assume the symbol being queried isn't part
  of the core GL api and update the documentation accordingly.
2012-08-06 14:27:45 +01:00
Neil Roberts
7cdaaf2bd5 Don't use the transpose argument of glUniformMatrix*
According to the GLES1/2 spec, the transpose argument of
glUniformMatrix* should always be FALSE. Cogl directly exposes the
transposedness of the uniform value in
cogl_pipeline_set_uniform_matrix and we were previously passing this
value on to GL. This patch makes it instead just always transpose the
matrix in Cogl itself when copying the value to the CoglBoxedValue. It
doesn't seem like there could be much advantage to letting GL
transpose the uniform value and at least Mesa just does a very similar
loop to handle the transpose.

Mesa has started being more pedantic about this which was making
test_pipeline_uniforms fail.

http://cgit.freedesktop.org/mesa/mesa/commit/?id=60e8a4944081b42127b3

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit f42ee670ff663d03073d6b1038b21a0aa1b3ec2b)
2012-08-06 14:27:45 +01:00
Tomeu Vizoso
93d0de1d9a Mass rename CLUTTER_COMPILATION to COGL_COMPILATION
Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit a99512e5798e48ffa3a9a1a7eb98bc55647ee1b6)
2012-08-06 14:27:45 +01:00
Damien Lespiau
4ad1e9b83a Use <literal> not <pre> in the comments
Comments are interpreted as docbook snippets and <pre> is from html. The
closest maching tag for inline content seems to be <literal>.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 66c9f26dfb3133f43d319128d6636f793a1ceb4a)
2012-08-06 14:27:45 +01:00
Damien Lespiau
829aafce98 Update the cogl_sdl_context_new() code snippet
The first argument has been removed from the function. Update the
example accordingly.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 06e47af3144565bdf85abf8ae561c7ceeafa2cbc)
2012-08-06 14:27:45 +01:00
Damien Lespiau
ecc5c96aeb Initialize the inverse matrix in invert_matrix_3d()
Contrary to the other inversion functions, invert_matrix_3d() does not
initialize the inverse to the identity and then only touches the
elements it cares about. Problem is the ww component is left alone,
which makes everything go to a black hole when using an inverse matrix
as the transform matrix of a framebuffer.

This is how cameras are typically implemented, they have a transform
and the framebuffer matrix stack is initialized with the inverse
of that transform. A gdb session gives away what happens:

The camera model view matrix, slightly rotation around the X axis:
camera mv       1.000000 0.000000 0.000000 0.000000
camera mv       0.000000 0.984808 -0.173648 0.000000
camera mv       0.000000 0.173648 0.984808 10.000000
camera mv       0.000000 0.000000 0.000000 1.000000

Breakpoint 5, invert_matrix_3d (matrix=0x8056b58) at ./cogl-matrix.c:671
671       const float *in = (float *)matrix;
(gdb) p *matrix
$1 = {xx = 1, yx = 0, zx = 0, wx = 0, xy = 0, yy = 0.98480773,
  zy = 0.173648164, wy = 0, xz = 0, yz = -0.173648164, zz = 0.98480773,
  wz = 0, xw = 0, yw = 0, zw = 10, ww = 1, inv = {0 <repeats 16 times>},
  type = 6, flags = 1030, _padding3 = 0}
(gdb) finish
Run till exit from #0  invert_matrix_3d (matrix=0x8056b58)
    at ./cogl-matrix.c:671
0x00141ced in _cogl_matrix_update_inverse (matrix=0x8056b58)
    at ./cogl-matrix.c:1123
1123          if (inv_mat_tab[matrix->type](matrix))
Value returned is $2 = 1
(gdb) p *matrix
$3 = {xx = 1, yx = 0, zx = 0, wx = 0, xy = 0, yy = 0.98480773,
  zy = 0.173648164, wy = 0, xz = 0, yz = -0.173648164, zz = 0.98480773,
  wz = 0, xw = 0, yw = 0, zw = 10, ww = 1, inv = {1, 0, 0, 0, 0, 0.98480773,
    -0.173648164, 0, 0, 0.173648164, 0.98480773, 0, -0, -1.73648167,
    -9.84807777, 0}, type = 6, flags = 1030, _padding3 = 0}

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 9a19ea0147eb316247c45cbba6bb70dec5b9be4c)
2012-08-06 14:27:45 +01:00
Neil Roberts
763c1de2ab Use the old GLSL extensions if GL 2.0 is not available
Some drivers have good support for GLSL but don't have the complete
set of features needed to advertise GL 2.0 support. We should accept
the three old GLSL extensions (GL_ARB_shader_objects,
GL_ARB_vertex_shader and GL_ARB_fragment_shader) to support shaders on
these drivers.

This patch splits the shader functions into four sections :- those
that are provided only in GL 2.0, those that have the same name in the
shader objects extension, those that are provided by the vertex
shader extension (they all share the same name) and those that have a
different name in the shader objects extension.

If GL 2.0 is not supported but all three of the extensions are then
the pointers to the GL2-only functions will be replaced to point to
the equivalent functions from the extensions. That way the rest of the
Cogl source doesn't have to worry about the name differences.

https://bugzilla.gnome.org/show_bug.cgi?id=677078

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 71ecb51bd20dc3053b4221961b57e5a2b1029bdf)
2012-08-06 14:27:45 +01:00
Neil Roberts
a3989d035e Fix removing layers when the pipeline is not the owner
If cogl_pipeline_remove_layer is called on a copied pipeline to remove
a parent layer then it will still end up calling
_cogl_pipeline_remove_layer_difference on the layer. This function
was directly trying to remove the layer from the pipeline's list of
layer differences. However in the child pipeline the layer isn't in
the list because it is unchanged from its parent. The function had an
assertion to verify that this situation wasn't hit so in a debug build
it would just bail out.

This patch removes the assertion and changes it to only remove the
layer if it is owned by the pipeline. Otherwise it just sets the
COGL_PIPELINE_STATE_LAYERS difference as normal and decrements the
number of layers. This will cause it to successfully remove the layer
because either it is the last layer in which case it will be ignored
after n_layers is decreased or if it is in the middle of the list then
the subsequent layers will all be shifted down so there will be a
replacement layer difference.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 88e73dd93fa09a158064a946ab229591a5888b97)
2012-08-06 14:27:45 +01:00
Neil Roberts
17c818a9a7 Add an SDL2 winsys
This adds an alternate version of the SDL winsys using the SDL 2 API.
The two versions are mutually exclusive and share the same
CoglWinsysID. Version 2 of SDL fits a little bit better with Cogl
because it supports multiple windows and the video subsystem can be
initialised entirely independently of the rest of the subsystems.

The SDL2 winsys creates an invisible dummy window in order to bind the
GL context after creating the Cogl display. This is similar to how the
X11 winsys's work.

SDL2 seems to support compiling with support for both GL and GLES.
However there doesn't seem to be a way to select between the two
backends outside of SDL. In fact if you do compile them both in it
seems to break down because it will always try to use the window
system functions from the GLES backend because those are filled in
second in the vtable. However when creating the window it will always
prefer to use the GL function to choose a visual. This function gets
confused because the GL backend has not been initialised at that
point. The Cogl backend therefore just leaves it up to SDL to pick a
sensible backend. It will then verify that it picked a GL library
which matches the Cogl driver by checking the string from
glGetString(GL_VERSION).

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 6cb5ab41355e7bfe28f367cf4afa39a7afcfeec2)
2012-08-06 14:27:44 +01:00
Tomeu Vizoso
9a1f0c4098 cogl-gles2: Add glTexParameterf to wrapper library
Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 06d6bdb73e3d2468cf3a8c355152cbdeb1b36d94)
2012-08-06 14:27:44 +01:00
Damien Lespiau
a87b657d73 Add a note about [0, 0, 0] and cogl_vector3_normalize()
When having the [0, 0, 0] vector, normalize() won't try to divide by 0
and thus it's always safe to use that funtion.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 64370e7ddd32f25556a1792c00d14adc48a81d45)
2012-08-06 14:27:44 +01:00
Damien Lespiau
81bb87e037 Use the internal format to check if the texture size is supported
Until now, we hardcoded the internal format to GL_RGBA and used the
internal format returned by pixel_format_to_gl() as the format for
checking the texture size and format we're asked to create.

Let's use the proper internal format/format from now on.

This is needed as a later patch introduces DEPTH and DEPTH_STENCIL
textures.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit ec45f60ee2545f88302da314bcdbe1439c4ba9c9)
2012-08-06 14:27:44 +01:00
Rico Tzschichholz
5c16ad65c5 build: add newly introduced header to fix make dist
Missing bit of 4bb6eff3dbd50d8fef7d6bdbed55c5aaa70036a8

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 1674cf28f1f5b71bd25a1f253c99825d427dd243)
2012-08-06 14:27:44 +01:00
Neil Roberts
9a654d173e Fix a typo in _cogl_matrix_init_translation
The y translation was being initialised with the z value and the z
translation was being left as 0.0.

(cherry picked from commit b44feb617ecb9cbf7d53f0d745f686c17ef3246d)
2012-08-06 14:27:43 +01:00
Neil Roberts
67a095b9dd Cache the debug wireframe snippet
When rendering the debug wireframe Cogl generates a child pipeline of
the application's pipeline to replace the fragment processing.
Previously it was creating a new snippet every time something was
drawn. Cogl doesn't attempt to compare the contents of snippets when
looking in the program cache for a matching pipeline so this would
cause it to generate a new program for every primitive. It then quite
quickly ends printing the warning about there being more than 50
programs in the cache. To fix that this patch makes it cache the
snippet so that Cogl can successfully recognise that it already has a
program generated for the new pipeline.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit c4bb08ee8767b5320980dba10b20921393cb5613)
2012-08-06 14:27:43 +01:00
Neil Roberts
1357c4c6a6 Preserve the CoglDrawFlags when drawing a wireframe
Previously the CoglDrawFlags passed to
_cogl_framebuffer_draw_indexed_attributes when drawing is redirected
to draw a wireframe are overriden to avoid validating the pipeline,
flushing the framebuffer state and flushing the journal. This ends up
breaking scenes that only contain models drawn from attributes in the
application because nothing will flush the matrices. It seems to make
more sense to just use whatever draw flags were passed from the
original draw command so that it will flush the matrices if the caller
was expecting it.

One problem with this is that if the wireframe causes the journal to
be flushed then it will already have temporarily disabled the
wireframe debug flag so the journal will not be drawn with wireframes.
To fix this the patch adds a CoglDrawFlag to disable the wireframe and
uses that instead of disabling the debug flag.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 283f6733e63ba65d9921f45868edaabbd9420a61)
2012-08-06 14:27:43 +01:00
Neil Roberts
702873c199 matrix-stack: Prune stack entries when loading a replacement matrix
Previously if an application does not use the matrix stack as a stack
but instead just loads its own matrices for each frame using
cogl_framebuffer_set_modelview_matrix then it will continously push
OP_LOAD entries on the stack and the stack will grow forever. This
patch fixes that use case by resetting the top of the stack to the
last save entry whenever something is pushed that replaces the
previous matrix on the stack.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit d31ed33241a9e9e3bc25f01b2614678827a7a9aa)
2012-08-06 14:27:43 +01:00
Neil Roberts
5e8ff248d2 Add functions to directly transform from a euler or a quaternion
This adds the following new functions to apply a rotation described by
a euler or a quaternion to either a CoglMatrix or directly to the
modelview stack of a framebuffer:

cogl_matrix_rotate_quaternion
cogl_matrix_rotate_euler
cogl_framebuffer_rotate_quaternion
cogl_framebuffer_rotate_euler

The direct framebuffer functions have corresponding functions in the
CoglMatrixStack to store an entry describing the rotation.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 5064315678b496395e1d01f266f322d73e55e324)
2012-08-06 14:27:43 +01:00
Neil Roberts
aa749bb177 matrix-stack: Fix the _cogl_matrix_entry_equal function
The _cogl_matrix_entry_equal function has a large switch statement to
do the right kind of comparison for the entry. However most of the
entries have a return statement that is only conditionally reached.
There were no corresponding break statements to the case labels so
presumably if the comparison succeeded for the correct entry type it
would also flow through and try the comparison for the next type which
would be extremely unlikely to pass.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 339db0f9cc3ee2bee4c56f9cb05dcb4ddd6815ed)
2012-08-06 14:27:43 +01:00
Neil Roberts
6eb8864866 Add a cogl_matrix_init_from_euler function
This creates a matrix to represent the given euler rotation. This
should be more efficient than creating the matrix by doing three
separate rotations because no separate intermediate matrices are
created and no matrix multiplication is needed.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit e66d9965897999a4889063f6df9a20ea6abf97fe)
2012-08-06 14:27:43 +01:00
Neil Roberts
0210cc40f9 Make cogl_matrix_init_from_quaternion take a const quaternion
The quaternion is not modified so for consistency with the rest of the
API it should probably be const.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 7fa8c05c2ffb90cba03289a04e37866efc0890a5)
2012-08-06 14:27:43 +01:00
Neil Roberts
bdc8a12ea1 Fix the documentation for cogl_quaterinon_init_from_array
The documentation for cogl_quaternion_init_from_array contradicts
itself and says that the array is w,x,y,z in one part but x,y,z,w in
another. This fixes it to say w,x,y,z in both parts.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit b08a81e5dfb05fec867c08c689237fae937341ad)
2012-08-06 14:27:43 +01:00
Neil Roberts
b977d75059 Fix disabling debugging
When --disable-debug is passed to the configure script it was actually
still defining COGL_ENABLE_DEBUG so very little would end up being
disabled. If COGL_ENABLE_DEBUG actually got defined it would also fail
to compile because _cogl_debug_instances and COGL_DEBUG_N_LONGS from
cogl-debug.h were only defined if debugging is enabled but they are
used regardless.

This patch also makes it so that the _COGL_RETURN_IF_FAIL family of
macros that are used when glib support is disabled are now disabled if
debugging is disabled. When the glib macros are used they are already
disabled because we additionally define G_DISABLE_CHECKS.

'COGL_HANDLE_DEBUG' has been removed from the list of defines passed
when debugging is enabled because CoglHandle has already been removed
and it is not used anywhere in the code.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 9811a0101c9cbb4ab95c55a2b41fd10ff4c77d9f)
2012-08-06 14:27:43 +01:00
Robert Bragg
498937083e Adds gles2-context renderer constraint
This adds a new renderer constraint enum:
  COGL_RENDERER_CONSTRAINT_SUPPORTS_GLES2_CONTEXT
that can be used by applications to ensure the renderer they connect to
has support for creating a GLES2 context via cogl_gles2_context_new().

The cogl-gles2-context and cogl-gles2-gears examples and the conformance
tests have been updated to use this constraint.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit ed61463d7194354b26624e8014859f0fbfc06a12)
2012-08-06 14:27:43 +01:00
Robert Bragg
10340a5495 Adds libcogl-gles2 frontend GLES2 api
This adds a library that can be used instead of libGLESv2.so to provide
symbols for the GLES 2.0 api. This can be used for convenience when
using the cogl_gles2_context_ api since you don't need to manually go
through a CoglGLES2Vtable when calling the gles2 api so it should be
easier to port existing gles2 code to integrate with Cogl.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 80d7599a2acefca7d01d8d7de9df524278ef72c5)
2012-08-06 14:27:42 +01:00
Robert Bragg
010d16f647 Adds initial GLES2 integration support
This makes it possible to integrate existing GLES2 code with
applications using Cogl as the rendering api.

Currently all GLES2 usage is handled with separate GLES2 contexts to
ensure that GLES2 api usage doesn't interfere with Cogl's own use of
OpenGL[ES]. The api has been designed though so we can provide tighter
integration later.

The api would allow us to support GLES2 virtualized on top of an
OpenGL/GLX driver as well as GLES2 virtualized on the core rendering api
of Cogl itself. Virtualizing the GLES2 support on Cogl will allow us to
take advantage of Cogl debugging facilities as well as let us optimize
the cost of allocating multiple GLES2 contexts and switching between
them which can both be very expensive with many drivers.

As as a side effect of this patch Cogl can also now be used as a
portable window system binding API for GLES2 as an alternative to EGL.

Parts of this patch are based on work done by Tomeu Vizoso
<tomeu.vizoso@collabora.com> who did the first iteration of adding GLES2
API support to Cogl so that WebGL support could be added to
webkit-clutter.

This patch adds a very minimal cogl-gles2-context example that shows how
to create a gles2 context, clear the screen to a random color and also
draw a triangle with the cogl api.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 4bb6eff3dbd50d8fef7d6bdbed55c5aaa70036a8)
2012-08-06 14:27:42 +01:00
Robert Bragg
3f2cb89a76 Fix depth testing, write enable bug
This fixes a bug in _cogl_pipeline_flush_color_blend_alpha_depth_state
whereby we were only calling flush_depth_state if we knew that at least
depth testing was enabled. This didn't take into account that enabling
and disabling depth writing is a useful change to make even if depth
testing is disabled. It also seemed a bit messy to flush the
depth-testing enable separately from the other depth state.

_cogl_pipeline_flush_color_blend_alpha_depth_state now simply calls
flush_depth_state() if there is a _DEPTH_STATE difference and
flush_depth_state() also handles flushing the depth-testing enable
in along with all the other depth state.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 6a9dfc55b8f55d7023cb592e5bef2118d0f3d50c)
2012-08-06 14:27:42 +01:00
Robert Bragg
fb636008ad By default enable swap throttling
This ensures that when we initialize a CoglOnscreenTemplate that
->swap_throttled is set to TRUE so by default Cogl applications should
have their swap buffer requests throttled to the vblank frequency.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit bdac9ab56284fb84ec09af176c7e31c44dc1bfc6)
2012-08-06 14:27:42 +01:00
Robert Bragg
a945890de6 Workaround drisw bug where clipped redraws don't work
This detects when we are running on any of Mesa's software rasterizer
backends and disables use of glBlitFramebuffer and glXCopySubBuffer.
Both of these currently result in full-screen copies so there's little
point in using these to optimize how much of the screen we present.

To help ensure we re-evaluate this workaround periodically we have added
a comment marker of "ONGOING BUG" above the workaround and added a note
to our RELEASING document that says we should grep for this marker and
write a NEWS section about ongoing bug workarounds.

https://bugzilla.gnome.org/show_bug.cgi?id=674208

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 11f2f6ebb42398978ec8dd92b3c332ae8140a728)
2012-08-06 14:27:42 +01:00
Robert Bragg
b8e380edc3 gpu-info: Detect more info including architecture
The GPU info api previously told us a driver package name and a driver
vendor name, but now we have introduced detection for the gpu
architecture too and started to track architecture feature flags that
can tell us whether a gpu is a deferred or immediate mode renderer for
example or if a software rasterizer is being used.

This also adds support for checking more vendor names. We should now
detect the following cases:

Vendors: Intel, Imagination Technologies, ARM, Qualcomm, Nvidia, ATI
Architectures: Sandybridge, SGX, Mali
Architecture flags:
  - vertex tiled
  - vertex immediate mode
  - vertex software
  - fragment deferred
  - fragment immediate mode
  - fragment software

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit b3803a0a7c9e663ed219e83626841895c7d95ad7)
2012-08-06 14:27:42 +01:00
Chun-wei Fan
feaaaad6a0 Update cogl.symbols
There are numerous APIs added/removed in the following commits:
e7f15826 Add a CoglPrimitiveTexture interface
6197e3ab Add constructors which take a CoglBitmap to all primitive textures
bdb645e7 kms: defer setting crtc modes until first swap buffers
9a1f1df8 Rework sdl integration api
ac0c72ab Removed legacy cogl-fixed 1.x api
e8c4c80c Remove deprecated cogl_vertex_buffer api
06d522cb Remove the legacy CoglPath API
713a8f81 Replace cogl_path_{stroke,fill} with framebuffer API
6ed3aaf4 Removes all remaining use of CoglHandle
068b3b59 matrix: Add a init_translation() constructor

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 2625354b8accaebe33ee2747ff03f665aea07e4f)
2012-08-06 14:27:42 +01:00
Chun-wei Fan
23becf67a7 Fix Visual C++ build
-Create a pre-defined cogl/cogl-gl-header.h(.win32) that is to be used on
 any Windows builds, and adapt the MSVC build process to set up and use
 that file.
-Fix up glib-mkenums code generation .bat file that is generated during
 "make"/"make dist", like the autotools-based builds.
-Since cogl/cogl-defines.h now contain versionioning info, and it no longer
 directly includes the GL headers, update the pre-configured
 cogl-defines.h[.win32|.win32_SDL] and use autotools to fill in the
 versioning info during "make"/"make dist".
-Fix up cogl/cogl-pango.rc.in so that they reflect the cogl-2.x versioning
 stuff correctly and versioning info can be filled in correctly during
 "make"/"make dist"

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 7ff42bb1c5280b0f53370f8d94ef5f10c9f39e2f)
2012-08-06 14:27:42 +01:00
Damien Lespiau
e6b75b6cfc quaternion: Fix typo in the init_from_z_rotation documentation
Clearly from a copy and paste from init_from_y_rotation().

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 2f06f4d79e29bbf30a44edbf48e8eaa637e30930)
2012-08-06 14:27:42 +01:00
Damien Lespiau
542fdcd2b0 doc: Hide the private fields of CoglQuaternion
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit a98a69017cdf8879816c1a341e4982b57ef1bc32)
2012-08-06 14:27:41 +01:00
Damien Lespiau
86a5259578 doc: Include the documentation for CoglEuler
Several little changes were needed to make the CoglEuler documentation
appear:

  • Fix the embeded docbook snippet in the CoglEuler section header
  • Add the xinclude directive to the main document
  • Add the missing <SECTION> in -sections.txt

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit c7f6e07f7b8ba0d7dc9604e888c8a46165ec3ed4)
2012-08-06 14:27:41 +01:00
Damien Lespiau
e172cac480 quaternion: Document init_from_quaternion()
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 91c2a3580a6055fcb6902524d3e8354f27932e89)
2012-08-06 14:27:41 +01:00
Damien Lespiau
28655fd608 quaternion: Document init_from_euler()
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 018703a8e83835e7ab522f5e011fdd4a039523a2)
2012-08-06 14:27:41 +01:00
Damien Lespiau
7ff0b52d78 matrix: Add a init_translation() constructor
This allows people to initialize a matrix with a translation
transformation. The options to do it at the moment were:

* init_from_array() but it give cogl no information about the type of
  matrix.
* init_indentity() and then translate() but it means doing a lot of
  computations for no reason.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 068b3b59221e405dc288d434b0008464684a7c12)
2012-08-06 14:27:41 +01:00
Neil Roberts
68a6e82828 Add support for the WebOS version of SDL
The stock 1.2.x version of SDL only supports regular OpenGL. The
version on WebOS is specially patched to add some extra API to request
a GLES1 or GLES2 context. This patch adds a configure check to detect
when Cogl is being built with the patched version of SDL. In that case
it will additionally allow the gles1 and gles2 drivers and set the
right video mode attributes to get the corresponding context.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 3726c60deab2bd94617a562abb63f735627a25e4)
2012-08-06 14:27:41 +01:00
Neil Roberts
1d3d1732bd Fixes for building with --disable-gl
This fixes a few problems that occur when only using a GLES2 header.

• The use of GL_CLAMP_TO_BORDER and GL_MIRRORED_REPEAT were moved from
  cogl-pipelinelayer-state.h to cogl-sampler-cache-private.h but the
  corresponding defines were not.

• cogl-sampler-cache.c was using GL_TEXTURE_WRAP_R but this is only
  defined as GL_TEXTURE_WRAP_R_OES from the GLES2 header so it needs a
  #define.

• cogl-framebuffer-private.h uses GLuint but it does not include
  cogl-gl-header.h. It gets away with this when GLX support is enabled
  because the GL header would be included via glx.h.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 9cdb87c864fc262c4b26c13963670d60d7c18058)
2012-08-06 14:27:41 +01:00
Neil Roberts
d57fcd952e buffer: Use GL_STREAM_DRAW on GLES2
The function to convert the CoglBufferUpdateHint to a GL enum was
previously ifdef'd to only use GL_STREAM_DRAW when Cogl is compiled
with big GL support. One problem with this is that it would end up
trying to use it on GLES1 if support for both is compiled. The other
problem is that GLES2 seems to actually support GL_STREAM_DRAW so we
might as well use it in that case.

This patch also changes it so that if the hint is stream with GLES1
then it will default to GL_DYNAMIC_DRAW instead of GL_STATIC_DRAW
because I think that is closer to the meaning of the stream hint.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 9e997476a7f9271bc000abdc82b1e343b92afb4c)
2012-08-06 14:27:41 +01:00
Neil Roberts
85efb7daba Don't typedef CoglMemoryStack twice
CoglMemoryStack was being typedef'd twice, once in the private header
as an incomplete struct and once in the C source with the actual
struct definition. This removes the second typedef so that it just
defines the struct.

This patch was written by Jack River.

https://bugzilla.gnome.org/show_bug.cgi?id=675119

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 75cd425a48e0fc403bf88eace212a6d37b65df11)
2012-08-06 14:27:41 +01:00
Robert Bragg
9cf7aac80f Allow npot Texture2D creation with only basic npot support
Cogl has feature flags for basic npot texture support and then separate
flags for npot + repeat and npot + mipmap. If those three features are
available then there is a feature for full-npot support too for
convenience. The cogl_texture_2d_new_ constructors were checking for
full npot support and failing if not available but since we expose the
fine grained features to the user the user should be able to check the
limitations of npot textures and still choose to allocate them.

_cogl_texture_2d_can_create() now only checks for basic npot support
when creating a npot texture.  Since this change also affects the
automagic cogl_texture_ constructors they now check for basic npot +
mipmap support before considering using a Texture2D.

Notably the cogl_texture_ constructors will try constructing a Texture2D
even if we don't have npot + repeat support since the alternative is a
sliced texture which will need manual repeating anyway. Accordingly the
Texture2D::can_hardware_repeat and ::transform_quad_coords_to_gl vfuncs
have been made aware of the npot + repeat feature flag.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 6f6c5734d076372d98d0ec331b177ef7d65aa67d)
2012-08-06 14:27:40 +01:00
Neil Roberts
b6b9ac0b85 Add a cogl-version header
This adds a version header which contains macros to define which
version of Cogl the application is being compiled against. This helps
applications that want to support multiple incompatible versions of
Cogl at compile time.

The macros are called COGL_VERSION_{MAJOR,MINOR,MICRO}. This does not
match Clutter which names them CLUTTER_{MAJOR,MINOR,MICRO}_VERSION but
I think the former is nicer and it at least matches Cairo and Pango.

The values of the macro are defined to COGL_VERSION_*_INTERNAL which
is generated by the configure script into cogl-defines.h.

There is also a macro for the entire version as a string called
COGL_VERSION_STRING.

The internal utility macros for encoding a 3 part version number into
a single integer have been moved into the new header so they can be
used publicly as a convenient way to check if the version is within a
particular range. There is also a COGL_VERSION_CHECK macro for the
very common case that a feature will be used since a particular
version of Cogl. There is a macro called COGL_VERSION which contains
the pre-encoded version of Cogl being compiled against for
convenience.

Unlike in Clutter this patch does not add any runtime version
identification mechanism.

A test case is also added which just contains static asserts to sanity
check the macros.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 3480cf140dc355fa87ab3fbcf0aeeb0124798a8f)
2012-08-06 14:27:40 +01:00
Robert Bragg
8b22b0da65 journal: avoiding some _cogl_matrix_entry_get()'s
When uploading the vertices the journal calls _cogl_matrix_entry_get()
to get a CoglMatrix for each journal entry so that it can so a software
transform. Since _cogl_matrix_entry_get() can be a performance hot-spot
and since it's trivial to keep track of the last CoglMatrixEntry seen we
now avoid repeatedly calling _cogl_matrix_entry_get() for sequential
entries with the same transform.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 70cad61533316e2303b8e188f2f361701dfb0c61)
2012-08-06 14:27:40 +01:00
Robert Bragg
e3d6bc36d3 Re-design the matrix stack using a graph of ops
This re-designs the matrix stack so we now keep track of each separate
operation such as rotating, scaling, translating and multiplying as
immutable, ref-counted nodes in a graph.

Being a "graph" here means that different transformations composed of
a sequence of linked operation nodes may share nodes.

The first node in a matrix-stack is always a LOAD_IDENTITY operation.

As an example consider if an application where to draw three rectangles
A, B and C something like this:

cogl_framebuffer_scale (fb, 2, 2, 2);
cogl_framebuffer_push_matrix(fb);

  cogl_framebuffer_translate (fb, 10, 0, 0);

  cogl_framebuffer_push_matrix(fb);

    cogl_framebuffer_rotate (fb, 45, 0, 0, 1);
    cogl_framebuffer_draw_rectangle (...); /* A */

  cogl_framebuffer_pop_matrix(fb);

  cogl_framebuffer_draw_rectangle (...); /* B */

cogl_framebuffer_pop_matrix(fb);

cogl_framebuffer_push_matrix(fb);
  cogl_framebuffer_set_modelview_matrix (fb, &mv);
  cogl_framebuffer_draw_rectangle (...); /* C */
cogl_framebuffer_pop_matrix(fb);

That would result in a graph of nodes like this:

LOAD_IDENTITY
      |
    SCALE
    /     \
SAVE       LOAD
  |           |
TRANSLATE    RECTANGLE(C)
  |     \
SAVE    RECTANGLE(B)
  |
ROTATE
  |
RECTANGLE(A)

Each push adds a SAVE operation which serves as a marker to rewind too
when a corresponding pop is issued and also each SAVE node may also
store a cached matrix representing the composition of all its ancestor
nodes. This means if we repeatedly need to resolve a real CoglMatrix
for a given node then we don't need to repeat the composition.

Some advantages of this design are:
- A single pointer to any node in the graph can now represent a
  complete, immutable transformation that can be logged for example
  into a journal. Previously we were storing a full CoglMatrix in
  each journal entry which is 16 floats for the matrix itself as well
  as space for flags and another 16 floats for possibly storing a
  cache of the inverse. This means that we significantly reduce
  the size of the journal when drawing lots of primitives and we also
  avoid copying over 128 bytes per entry.
- It becomes much cheaper to check for equality. In cases where some
  (unlikely) false negatives are allowed simply comparing the pointers
  of two matrix stack graph entries is enough. Previously we would use
  memcmp() to compare matrices.
- It becomes easier to do comparisons of transformations. By looking
  for the common ancestry between nodes we can determine the operations
  that differentiate the transforms and use those to gain a high level
  understanding of the differences. For example we use this in the
  journal to be able to efficiently determine when two rectangle
  transforms only differ by some translation so that we can perform
  software clipping.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit f75aee93f6b293ca7a7babbd8fcc326ee6bf7aef)
2012-08-06 14:27:40 +01:00
Robert Bragg
882ff5612b Adds a "magazine" allocator for chunks of fixed size
This adds a very minimal and fast allocator for chunks of memory of a
predetermined size. This has some similarities to the glib slice
allocator although notably it is not thread safe and instead of
internally tracking multiple magazines for various sized allocations the
api lets you explicitly allocate a single magazine for a single specific
size and a pointer to the magazine is passed explicitly to the allocate
and free functions.

This allocator builds on the CoglMemoryStack allocator as an underlying
heap allocator and just never rewinds the stack. This means the heap is
effectively a grow only linked list of malloc()'d blocks of memory.

A CoglMagazine tracks a singly linked list of chunks of a predetermined
size and _cogl_magazine_chunk_alloc() simply unlinks and returns the
head of the list. If the list is empty it falls back to allocating from
the underlying stack.

_cogl_magazine_chunk_free() links the chunk back into the singly linked
list for re-use.

The chunk size passed to _cogl_magazine_new() is automatically rounded
to a multiple of 8 bytes to ensure that all stack allocations end up
aligned to 8 bytes. This also ensures that when a chunk is freed then it
will be large enough to store a pointer to the next free chunk as part
of a singly linked list.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 17799c2f109a008d6cf767f501b81aa9b32bbda8)
2012-08-06 14:27:40 +01:00
Robert Bragg
97d5406aef Adds internal CoglMemoryStack utility API
This adds a very minimal internal allocator api that lets us create a
dynamically growable (grow only) stack.

Underlying the allocator is the idea of "sub stacks" which are simply
malloc()'d chunks of memory kept in a linked list. The stack itself
maintains a pointer to the current sub-stack and a current
sub-stack-offset. 99% of the time allocating from the stack is just a
case of returning a pointer to the current sub-stack + sub-stack-offset
and bumping the offset by the allocation size. If there isn't room in
the current sub-stack then we walk through the list of free sub-stacks
looking for one that's big enough for the allocation and if we reach the
end of the list then we allocate a new sub-stack twice as big as the
last (or twice as big as the requested allocation if that's bigger).

Since it's a stack model there is no api to free allocations, just a
function to rewind the stack to the beginning.

We expect this to be useful in multiple places in Cogl as an extremely
fast allocator in cases when we know we can scrap all the allocations
after we're done figuring something out or as a building block for
other allocators.

For example the tessellator used for CoglPath allocates lots of tiny
structures that can all be freed after tessellation.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 6ee4a7a1b7f695bdfeb10ffa4112e776beea0a9d)
2012-08-06 14:27:40 +01:00
Robert Bragg
e58c7da9a8 build: Include stdint.h
Since 5967dad2400d32c we have stopped using glib types such as guint16
and guint32 in favour of the equivalent c99 types such as uint16_t and
uint32_t. When that patch was tested we must have used a configuration
that just happened to include <stdint.h> because we have since seen that
builds can fail due to missing c99 typedefs. This patch explicitly
includes stdint.h in cogl-types.h.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit c1e2220a4314071482d2d5638688b6bcf83882a2)
2012-08-06 14:27:39 +01:00
Neil Roberts
8dd77de009 Replace cogl_path_{stroke,fill} with framebuffer API
The existing functions for stroking and filling a path depend on the
global framebuffer and source stacks. These are now replaced with
cogl_framebuffer_{stroke,fill}_path which get explicitly passed the
framebuffer and pipeline.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 713a8f8160bc5884b091c69eb7a84b069e0950e6)
2012-08-06 14:27:39 +01:00
Robert Bragg
54735dec84 Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.

Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.

Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.

So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.

Instead of gsize we now use size_t

For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-08-06 14:27:39 +01:00
Robert Bragg
09642a83b5 Removes all remaining use of CoglHandle
Removing CoglHandle has been an on going goal for quite a long time now
and finally this patch removes the last remaining uses of the CoglHandle
type and the cogl_handle_ apis.

Since the big remaining users of CoglHandle were the cogl_program_ and
cogl_shader_ apis which have replaced with the CoglSnippets api this
patch removes both of these apis.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 6ed3aaf4be21d605a1ed3176b3ea825933f85cf0)

  Since the original patch was done after removing deprecated API
  this back ported patch doesn't affect deprecated API and so
  actually this cherry-pick doesn't remove all remaining use of
  CoglHandle as it did for the master branch of Cogl.
2012-08-06 14:27:39 +01:00
Robert Bragg
097d282b32 Add _COGL_STATIC_ASSERT macro
This adds a _COGL_STATIC_ASSERT macro that can be used for compile time
assertions in C code. If supported by the compiler this macro uses
_Static_assert so that a message can be printed out if the assertion
fails.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 465b39a764f2720e77678cafa56acb0e69007ffd)
2012-08-06 14:27:39 +01:00
Neil Roberts
eaf29af7ee bitmap-pixbuf: Fix the bitmap loader on Quartz
The code for loading a CoglBitmap from a file was missed when
upgrading to the new cogl_bitmap_new_for_data function in commit
d18b59d9e6 so it wouldn't compile. This changes it to use
_cogl_bitmap_new_with_malloc_buffer to allocate the buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=672533

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 5b785dd441a83024333e0a2f2b83d067f891194f)
2012-08-06 14:27:39 +01:00
Neil Roberts
d2a5d6f361 Add a context member to CoglPath
cogl_path_new now takes a CoglContext pointer which it keeps a pointer
to instead of relying on the global context.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit afc63f8211c230f8fd1f7801f9085627c46a8661)

  Since we can't change the api on this branch this just applies
  the internal cleanups so we depend less on _COGL_GET_CONTEXT
2012-08-06 14:27:38 +01:00
Neil Roberts
6400b455b8 Don't include any GL header from the public GL headers
This splits the GL header inclusion from cogl-defines.h into a
separate headear called cogl-gl-header.h which we will only include
internally. That way we don't leak GL declarations out of our public
headers. The texture functions that were using GLenum and GLuint in
the public header have now changed to just use unsigned int. Note
however that if an EGL winsys is enabled then it will still publicly
include an EGL header. This is a bit more awkward to fix because we
have public API which returns an EGLDisplay and we can't determine
what type that is.

There is also a conformance test which just verifies that no GL header
has been included while compiling. The test isn't added to
test-conform-main because it doesn't actually test anything at
runtime.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit ef5680d3fda5df929dbd0b420c8f598ded58dfee)
2012-08-06 14:27:38 +01:00
Chun-wei Fan
e85a04f0ce Fix cogl.symbols
cogl_framebuffer_draw_multitextured_rectangles is not in the public
API list, it is instead _cogl_framebuffer_draw_multitextured_rectangles,
which is private.

(Sorry, I forgot to add the reviewed by line for the same patch in the
cogl-1.10 branch :P)

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 4fc6cf5e3c1478bc0a29dfaf2f6d9e84b9d29ccd)
2012-08-06 14:27:38 +01:00
Chun-wei Fan
fa88ed8d74 cogl/Makefile.am: Fix filters for MSVC projects
We need to filter out all the *-egl-* sources as well, as the original
filter did not filter out the Wayland EGL sources

(Sorry, I forgot to add the reviewed by line for the same patch in the
cogl-1.10 branch :P)

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 3d4cb887a28d3bc2cde9e4e7cdd20a71c34a2eaa)
2012-08-06 14:27:38 +01:00
Damien Lespiau
943afe5711 winsys-glx: Remove unused variable
Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 2cffcae81fd91d97bfa239e8c7c6a5b2cefb2653)
2012-08-06 14:27:38 +01:00
Robert Bragg
9a1f1df83f Rework sdl integration api
This re-works the SDL integration api to simplify the integration for
application developers and also allow Cogl to know when the application
is about to go idle waiting for events so it can perform idle
book-keeping work.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-04-12 12:31:46 +01:00
Robert Bragg
bdb645e7f5 kms: defer setting crtc modes until first swap buffers
Instead of creating a dummy framebuffer allocation just so we can setup
crtc modes during display_setup we now wait until the first swap_buffers
request before setting up the crtc modes.

This patch also adds a cogl_kms_display_queue_modes_reset() function
that allows developers to explicitly queue a reset of the crtc modes.
The idea is that applications that handle VT switching can use this for
VT enter events to explicitly ensure their mode is restored since modes
are often not automatically restored correctly.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-04-11 15:44:58 +01:00
Robert Bragg
125c31a70b kms: Add mirror support and env var configurability
This adds support for mirroring the display output on two KMS
connectors.

This patch also checks for a number of environment variables that can
influence how KMS is configured. The following variables can be set:

COGL_KMS_MIRROR: If this is set to anything then Cogl will try and setup
two connectors with the same resolution so that onscreen frame buffers
can be mirrored.

COGL_KMS_CONNECTOR0: This can be set to an integer identifier for a
specific KMS connector id to use for the first output.

COGL_KMS_CONNECTOR0_MODE: Can be set to a mode name like "1024x768"
explicitly select what mode should be used for the first output.

If COGL_KMS_MIRROR is set then COGL_KMS_CONNECTOR1 and
COGL_KMS_CONNECTOR1_MODE can optionally be set to specify a connector id
and mode name for the second output.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-04-11 15:44:58 +01:00
Neil Roberts
f9d3ea03ec kms: Implement the swap buffers notify feature
The KMS EGL platform now notifies when a swap is complete. The
notification is delayed until the application calls
cogl_context_dispatch. The GLX backend doesn't currently do this but I
think that is how it should behave to make it easier for the
application to handle locks and such.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-11 15:44:50 +01:00
Neil Roberts
cfefff1500 egl-kms: Use drmModePageFlip
The KMS platform now uses drmModePageFlip to present the buffer. The
main loop mechanism is used to poll for events on the DRM file
descriptor so that we notice when the page flip is complete. The
swap_buffers is throttled so that if there is a pending flip it will
block until it is complete before starting another flip.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-11 15:44:45 +01:00
Neil Roberts
d1d2120a91 kms: Use GBM surfaces
Instead of creating FBOs on the GL side, the KMS EGL platform uses the
latest changes to Mesa to create an EGL surface using a GBM surface as
the native surface type. This removes some of the special vtable hooks
that the KMS platform needed because it is now much more similar to
the other platforms.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-11 15:44:32 +01:00
Robert Bragg
cc4c578887 fix cogl_context_new crash if fail to connect renderer
If a NULL display is passed to cogl_context_new() then it has to
implicitly create a CoglRenderer and CoglDisplay and propagate any
resulting errors back to the user. Previously the implementation relied
on passing a NULL renderer to cogl_display_new() as the means for
implicitly connecting to a renderer. The problem with this though is
that cogl_display_new() isn't designed to ever return NULL but if it
failed to connect to a renderer automatically it would do and then
cogl_context_new would pass NULL to cogl_display_setup() leading to a
crash.

This patch changes the implementation of cogl_context_new() to now
explicitly create a CoglRenderer and connect to it if a NULL display is
given. This way we can easily propagate any errors. In addition
cogl_display_new has been changed to abort if it fails to implicitly
connect to a renderer due to a NULL renderer argument.

An application needing to gracefully handle problems connecting to a
renderer at runtime should manually instantiate and connect a renderer
passing a GError argument to cogl_renderer_connect.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-04-11 12:26:52 +01:00
Neil Roberts
f676785906 Fix including a non-existent header
cogl-sampler-cache-private.h was including a header which doesn't
exist so the build was broken. The header comes from a patch which
hasn't been pushed to master yet which splits including GL/gl.h out of
cogl-defines.h into a separate header. I added the inclusion to make
it pick up the GL defines but it doesn't need to do this yet because
cogl-context.h is still including the GL header. I didn't notice the
failure because I still had a cogl-gl-header.h lying around from a
previous build with the patch.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-05 15:35:01 +01:00
Neil Roberts
cb146dc515 Add a workaround for slow read pixels on Mesa
Mesa before version 8.0.2 has a slow read pixels path that gets used
with the Intel driver where it converts all of the pixels into a
floating point representation and back even if the data is being read
into exactly the same format. There is however a faster path using the
blitter when reading into a PBO with BGRA format. It works out faster
to read into a PBO and then memcpy back out into the application's
buffer even though it adds an extra memcpy. This patch adds a
workaround in cogl_framebuffer_read_pixels_into_bitmap when it detects
this situation. In that case it will create a temporary CoglBitmap
using cogl_bitmap_new_with_size, read into it and then memcpy the data
back out.

The main impetus for this patch is that Gnome Shell has implemented
this workaround directly using GL calls but it seems like the kind of
thing that would sit better at the Cogl layer.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-05 13:52:43 +01:00
Neil Roberts
2037e0f4f1 Add a mechanism for determining GPU driver details
This adds a CoglGpuInfo struct to the CoglContext which contains some
enums describing the GL driver in use. This currently includes the
driver package (ie, is it Mesa) the version number of the package and
the vendor of the GPU (ie, is it by Intel). There is also a bitmask
which will contain the workarounds that we should do for that
particular driver configuration. The struct is initialised on context
creation by using a series of string comparisons on the strings
returned from glGetString.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-05 13:52:43 +01:00
Neil Roberts
ec5009fa23 Use GL_PACK_ALIGNMENT of 1 whenever possible
The Intel driver currently has an optimisation when calling
glReadPixels into a PBO so that it will use a blit instead of the Mesa
fallback path. However this only works if the GL_PACK_ALIGNMENT is
exactly 1, even if this would be equivalent to a higher alignment
value because the bpp*width is already aligned. To make it more likely
to hit this fast path, we now detect this situation and explicitly use
an alignment of 1. To make this work the texture driver needs to be
passed down the bpp*width as well as the rowstride when configuring
the alignment.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-05 13:51:56 +01:00
Neil Roberts
d54111795f Use ffs to calculate the GL_{UN,}PACK_ALIGNMENT
Instead of having a series of if-statements this adds an inline
function to calculate the alignment directly using ffs which is
probably slightly faster. Admittedly this is a pointless
micro-optimisation but I think it makes the code looks a bit neater
anyway.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-05 13:51:56 +01:00
Neil Roberts
c33ce5fc6b Use GL_ARB_sampler_objects
GL_ARB_sampler_objects provides a GL object which overrides the
sampler state part of a texture object with different values. The
sampler state that Cogl currently exposes is the wrap modes and
filters. Cogl exposes the state as part of the pipeline layer state
but without this extension GL only exposes it as part of the texture
object state. This means that it won't work to use a single texture
multiple times in one primitive with different sampler states. It also
makes switching between different sampler states with a single texture
not terribly efficient because it has to change the texture object
state every time.

This patch adds a cache for sampler states in a shared hash table
attached to the CoglContext. The entire set of parameters for the
sampler state is used as the key for the hash table. When a unique
state is encountered the sampler cache will create a new entry,
otherwise it will return a const pointer to an existing entry. That
means we can have a single pointer to represent any combination of
sampler state.

Pipeline layers now just store this single pointer rather than storing
all of the sampler state. The two separate state flags for wrap modes
and filters have now been combined into one. It should be faster to
compare the sampler state now because instead of comparing each value
it can just compare the pointers to the cached sampler entries. The
hash table of cached sampler states should only need to perform its
more expensive hash on the state when a property is changed on a
pipeline, not every time it is flushed.

When the sampler objects extension is available each cached sampler
state will also get a sampler object to represent it. The common code
to flush the GL state will now simply bind this object to a unit
instead of flushing the state though the CoglTexture when possible.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-05 13:47:36 +01:00
Neil Roberts
4229d61d3b Fix places that ignore the COGL_TEXTURE_NO_AUTO_MIPMAP flag
Two of the meta texture constructors which take a flags parameter were
ignoring the COGL_TEXTURE_NO_AUTO_MIPMAP flag when creating an
underlying CoglTexture2D. These have now been fixed to call
cogl_primitive_texture_set_auto_mipmap after constructing the texture.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-05 13:47:36 +01:00
Neil Roberts
6197e3abf3 Add constructors which take a CoglBitmap to all primitive textures
This adds public constructors which take a CoglBitmap to all primitive
texture types. This constructor should be considered the canonical
constructor for initializing the texture with data because it should
be possible to wrap any type of data in a CoglBitmap. Having at least
this single constructor avoids the need to have an explosion of
constructors such as new_from_data, new_from_pixel_buffer and
new_from_file etc.

The already available internal bitmap constructor for CoglTexture2D
has had its flags parameter removed under the assumption that flags do
not make sense for primitive textures. The meta constructor
cogl_texture_new_from_bitmap now just explicitly calls set_auto_mipmap
after constructing the texture depending on the value of the
COGL_TEXTURE_NO_AUTO_MIPMAP flag.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-05 13:47:32 +01:00
Neil Roberts
e7f1582630 Add a CoglPrimitiveTexture interface
This interface represents any textures that are backed by a single
texture in GL and that can be used directly with the
cogl_framebuffer_draw_attributes family of functions. This currently
equates to CoglTexture2D, CoglTexture3D and CoglTextureRectangle.

The interface currently has only one method called
cogl_primitive_set_auto_mipmap. This replaces the
COGL_TEXTURE_NO_AUTO_MIPMAP flag from the CoglTextureFlags parameter
in the constructors. None of the other flags in CoglTextureFlags make
sense for primitive textures so it doesn't seem like a good idea to
need them for primitive constructors.

There is a boolean in the vtable to mark whether a texture type is
primitive which the new cogl_is_primitive function uses. There is also
a new texture virtual called set_auto_mipmap which is only required to
be implemented for primitive textures.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-04 17:02:23 +01:00
Neil Roberts
e7df2dbf79 bitmap: Store a pointer to the context
This adds a context member to CoglBitmap which stores the context it
was created with. That way it can be used in texture constructors
which use a bitmap. There is also an internal private function to get
the context out of the bitmap which all of the texture constructors
now use. _cogl_texture_3d_new_from_bitmap has had its context
parameter removed so that it more closely matches the other bitmap
constructors.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-04 14:24:01 +01:00
Neil Roberts
be9d5b34c6 pipeline: Use cogl_depth_state_init to init default depth state
The previous code to initialise the depth state on the default
pipeline wasn't initialising the magic number. If you later tried to
retrieve the depth state using cogl_pipeline_get_depth_state you would
end up with an invalid depth state struct and you would just get
warnings if you tried to use it for anything. This patch just replaces
the initialisation with a call to cogl_depth_state_init because it
uses the same values anyway.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-03 16:36:54 +01:00
Adel Gadllah
a000189c68 texture: Fix error handling in get_texture_bits_via_offscreen
get_texture_bits_via_offscreen does not check the return value of
cogl_framebuffer_read_pixels_into_bitmap which results into never
using the fallback path texture_get_cb.

cogl_framebuffer_read_pixels_into_bitmap does not check whether the framebuffer
is properly allocated though; so fix that as well.

https://bugzilla.gnome.org/show_bug.cgi?id=673137

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-04-02 23:32:53 +01:00
Neil Roberts
ae5f8323c1 gles2: Support the GL_EXT_unpack_subimage extension
This extension lets you upload texture data from a subregion of a
buffer by passing GL_UNPACK_ROW_LENGTH, GL_UNPACK_SKIP_PIXELS and
GL_UNPACK_SKIP_ROWS to glPixelStore. When this extension is available
the GLES texture driver will now avoid making a copy of the bitmap
when a subregion is used.

Note that Mesa doesn't currently advertise this extension but I've
made a patch to propose it:

http://lists.freedesktop.org/archives/mesa-dev/2012-March/020191.html
2012-03-23 13:51:08 +00:00
Neil Roberts
21e304b339 gles: Support the GL_EXT_texture_format_BGRA8888 extension
This extension allows an application to upload data in BGRA format. We
can use this to avoid a conversion in Cogl whenever it is given BGRA
data. This is quite useful when uploading data generated by Cairo
because at least on little-endian architectures that ends up as BGRA.

The patch just makes the pixel_format_to_gl implementation return
GL_BGRA_EXT for the data format and internal format whenever
COGL_PIXEL_FORMAT_BGRA_8888{,_PRE} is used.

A small caveat with this patch is that once a texture is created as
GL_BGRA, when later using glTexSubImage2D to update the texture it
must always be given data as GL_BGRA. Currently this just works out
because we store the internal format of a texture as a CoglPixelFormat
and we already swizzle the data if it does not match exactly on GLES.
However if we later switch to using a different enum for internal
formats then we might lose the ability to store the component ordering
so we'll have to think of another way to do this.
2012-03-23 13:51:08 +00:00
Neil Roberts
d6ca75fbec Add a context parameter to all of the texture driver virtuals
All of the texture driver virtual functions now take an explicit
CoglContext parameter as a step towards removing the global context.
2012-03-23 13:51:08 +00:00
Neil Roberts
60812e6a0e Add a vtable for the driver
Cogl already had a vtable for the texture driver. This ended up being
used for some things that are not strictly related to texturing such
as converting between pixel formats and GL enums. Some other functions
that are driver dependent such as updating the features were not
indirected through a vtable but instead switched directly by looking
at the ctx->driver enum value. This patch normalises to the two uses
by adding a separate vtable for driver functions not related to
texturing and moves the pixel format conversion functions to it from
the texture driver vtable. It also adds a context parameter to all of
the functions in the new driver vtable so that they won't have to rely
on the global context.
2012-03-23 13:51:08 +00:00
Chun-wei Fan
699a0bd74a Update cogl.symbols
...for the following added APIs:

cogl_bitmap_new_for_data
cogl_framebuffer_read_pixels
cogl_framebuffer_draw_multitextured_rectangles
cogl_framebuffer_draw_rectangle
cogl_framebuffer_draw_rectangles
cogl_framebuffer_draw_textured_rectangle
cogl_framebuffer_draw_textured_rectangles

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-21 22:15:34 +08:00
Robert Bragg
890a75ab06 Create standalone public wayland client/server headers
Because the wayland-client-protocol.h header defines symbols that
collide with the wayland-server-protocol.h header we allow applications
to explicitly ensure that they are only including one at a time by
exposing corresponding <cogl/cogl-wayland-client.h> and
<cogl/cogl-wayland-server.h> headers. This also adds a missing guard to
cogl-texture-2d.h that it isn't included directly.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-03-20 14:26:44 +00:00
Neil Roberts
2d1623313c bitmap-pixbuf: Fix the CoglBitmap wrapper for the STB fallback
The fallback code using stb-image.c was missed out in the upgrade to
cogl_bitmap_new_for_data from commit d18b59d9e6 so it wouldn't
compile.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-20 13:53:50 +00:00
Neil Roberts
59cc2b7071 Fix some documentation problems
• The documentation for the framebuffer and texture interfaces had a
  mis-matching open and close <note> tag so DocBook got upset and the
  whole documentation disappeared.

• A lot of symbols from the cogl_framebuffer_* interface were missing
  from the cogl-2.0-experimental-sections.txt file.

• cogl_framebuffer_frustum had the wrong version in its Since tag:

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-20 13:17:07 +00:00
Neil Roberts
f485fa6b21 cogl-primitives: Fix a typo in a function declaration
_cogl_framebuffer_draw_multitextured_rectangles had a typo in the
function name in the declaration so it was generating a lot of
compile warnings.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-20 12:41:58 +00:00
Robert Bragg
3881fd3259 Adds cogl_framebuffer_draw_[*_]rectangle functions
This adds experimental 2.0 api replacements for the cogl_rectangle[_*]
functions that don't depend on having a current pipeline set on the
context via cogl_{set,push}_source() or having a current framebuffer set
on the context via cogl_push_framebuffer(). The aim for 2.0 is to switch
away from having a statefull context that affects drawing to having
framebuffer drawing apis that are explicitly passed a framebuffer and
pipeline.

To test this change several of the conformance tests were updated to use
this api instead of cogl_rectangle and
cogl_rectangle_with_texture_coords. Since it's quite laborious going
through all of the conformance tests the opportunity was taken to make
other clean ups in the conformance tests to replace other uses of
1.x api with experimental 2.0 api so long as that didn't affect what was
being tested.
2012-03-20 12:33:40 +00:00
Neil Roberts
ef9aa07d2e framebuffer: Fix a closing tag in the documentation
This was causing the DocBook for the documentation to be invalid so
all of the framebuffer documentation disappeared.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-19 14:47:50 +00:00
Neil Roberts
5cf2c5762f Add cogl_framebuffer_read_pixels()
This adds a public convenience wrapper around
cogl_framebuffer_read_pixels_into_bitmap which allocates a temporary
CoglBitmap to read into the application's own buffer. This can only be
used for the 99% common case where the rowstride is exactly the
bpp*width and the source is the color buffer.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-19 14:47:49 +00:00
Neil Roberts
a5f2f0fe2d journal: Don't push and pop the framebuffer when flushing
In theory none of the journal flushing code should be using anything
that relies on the global framebuffer stack because it should all be
using the new 2.0-style API which explicitly mentions the target
framebuffer. Eventually we want to get rid of the framebuffer stack so
we might as well remove the push and pop now.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-16 17:31:03 +00:00
Neil Roberts
ff48f3b174 journal: Always keep a pointer back to the framebuffer
Previously when adding a quad to the journal it would assume the
journal belongs to the framebuffer at the top of the framebuffer stack
and store a reference to that. We eventually want to get rid of the
framebuffer stack so we should avoid using it here. The journal now
takes a pointer back to the framebuffer in its constructor and it
always retains the pointer. As was done previously, the journal still
does not take a reference on the framebuffer unless it is non-empty so
it does not create a permanent circular reference.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-16 17:26:30 +00:00
Ray Strode
dc00c27249 Drive by leak fix when code spelunking
_cogl_shader_compile_real spews a warning when
shader compilation fails if COGL_GL_DEBUG is
defined.  This warning is never freed.

https://bugzilla.gnome.org/show_bug.cgi?id=672243

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-03-16 16:41:57 +00:00
Neil Roberts
c8f8dbec7e Fix the 1.0 wrapper for cogl_path_curve_to
The 1.0 wrapper for cogl_path_curve_to was using the wrong value for
y_1 so it wouldn't work.

The patch was written by Dénes Almási.

https://bugzilla.gnome.org/show_bug.cgi?id=672174

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-03-15 18:57:52 +00:00
Adel Gadllah
fd31da45e2 winsys-glx: Don't assume that copy_sub_buffer is synchronized
We initially assumed that copy_sub_buffer is synchronized on
which is only the case for a subset of GPUs for example it is not
synchronized on INTEL gen6 and gen7, so we remove this assumption
for now.

We should have a specific driver / GPU whitelist if we want to enable
this.

https://bugzilla.gnome.org/show_bug.cgi?id=669122

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-03-15 15:48:13 +00:00
Neil Roberts
f1d65e58b3 buffer: Remove const from cogl_is_buffer (const void *)
None of the other cogl_is_blah functions have a const pointer so this
is just for consistency. It helps if someone is trying to have an
array of type-check function pointers to determine the Cogl object
type because in that case all of the functions would have to have the
same prototype.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-14 13:48:11 +00:00
Neil Roberts
d18b59d9e6 Add a public cogl_bitmap_new_for_data
This creates a CoglBitmap which points into an existing buffer in
system memory. That way it can be used to create a texture or to read
pixel data into. The function replaces the existing internal function
_cogl_bitmap_new_from_data but removes the destroy notify call back.
If the application wants notification of destruction it can just use
the cogl_object_set_user_data function as normal. Internally there is
now a convenience function to create a bitmap for system memory and
automatically free the buffer using that mechanism.

The name of the function is inspired by
cairo_image_surface_create_for_data which has similar semantics.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-14 12:19:56 +00:00
Neil Roberts
f65a895b4f texture: When reading, convert data directly into user's buffer
On GLES, when reading texture data back it may need to allocate a
temporary CoglBitmap if the requested format is not supported by the
driver. Previously it would then copy this temporary buffer back into
the user's buffer by calling _cogl_bitmap_convert which would allocate
a second temporary buffer. It would then copy that data into the
user's buffer. This patch changes it to create a CoglBitmap which
points to the user's data and then convert directly into that buffer
using the new _cogl_bitmap_convert_into_bitmap.

This also fixes a small leak where target_bmp would not get freed if
the target format and the closest supported format do match.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-14 12:19:53 +00:00
Neil Roberts
de5d55ae93 context: Enable new feature testing on COGL_ENABLE_EXPERIMENTAL_API
The 2.0 API for querying features (cogl_has_feature etc) does not
conflict with the old 1.0 API (cogl_features_available) so we might as
well enable it when the experimental API is requested without
requesting the 2.0-only API.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-14 12:19:48 +00:00
Ryan Lortie
6f59993e1b Move the fallback define for GL_PACK_INVERT_MESA
The if-undefined fallback declaration for GL_PACK_INVERT_MESA was
originally added in cogl.c along with code to use it (as part of commit
6f79eb8a5a).  Later on, commit
10a38bb14f moved the code that used it to
cogl-framebuffer.c but didn't move the define along with it.  Do that
now.

https://bugzilla.gnome.org/show_bug.cgi?id=672038

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-03-14 12:14:24 +00:00
Chun-wei Fan
0d3acfb3ed cogl.symbols: Cleanup
-Removed checks for COGL_ENABLE_EXPERIMENTAL_API since these APIs are
 always built into the shared library
-Re-organised the API listing a bit so that they are in alphabetical order

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-03-13 23:17:21 +08:00
Chun-wei Fan
f608ef5f5c cogl.symbols: Reinstate cogl2_clip_push_from_path
This API was re-added into COGL for the 1.10.x release as of commit
361bd516f.  This will be removed once we branch into the 1.11.x development
cycle.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-03-13 23:17:13 +08:00
Chun-wei Fan
caaef35450 Revert "cogl.symbols: Reinstate cogl2_clip_push_from_path"
This reverts commit 199821d8c3.

I forgot something in the comments.  Sorry.
2012-03-13 23:00:35 +08:00
Chun-wei Fan
199821d8c3 cogl.symbols: Reinstate cogl2_clip_push_from_path
This API was re-added into COGL for the 1.10.x release as of commit
361bd516f.  This will be removed once we branch into the 1.11.x development
cycle.
2012-03-13 22:31:30 +08:00
Dave Airlie
d42efa3741 cogl-matrix-stack: fix use after free in matrix stack.
If the matrix was reallocated we would use values from the stack
for the matrix parameters. This fixes that and also uses the
function instead of out of lining the same code.

https://bugzilla.gnome.org/show_bug.cgi?id=671985

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-03-13 13:40:45 +00:00
Neil Roberts
2196518b00 Don't export cogl_gl_error_to_string
This is only used internally when debugging is enabled to give a
human-readable name to a GL error so we shouldn't be exporting it
outside of the library. This just adds an underscore to the symbol
name. This shouldn't end up removing any public symbols from the 1.9.8
release because by default a non-git build disables debug so it wasn't
exported anyway.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-09 16:40:42 +00:00
Neil Roberts
361bd516f3 Add compatibility API for functions removed after 1.9.8
The cleanup in 185630085 removed some symbols that were previously
exported as public experimental API in Cogl 1.9.8. That release is
already well after the point where we were meant to freeze the ABI so
we probably shouldn't be breaking it again. This patch adds the
removed functions back in so that for 1.9.10 we won't have to bump the
soname. The symbols are bundled together in a new file called
cogl2-compatibility.c so that they will be easy to remove again after
we can break ABI. It is expected that we will revert this patch
immediately after branching for Cogl 1.10.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-09 16:09:13 +00:00
Chun-wei Fan
36761f8989 Update cogl.symbols
This is to adjust to the added and removed functions...

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-03-08 22:04:40 +08:00
Neil Roberts
2c596f5e2e pipeline: Point sprite state shouldn't affect codegen on GL
I think this slipped in as a cut-and-paste error in b2e735ff.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-07 15:13:30 +00:00
Neil Roberts
b8df3561f4 Remove the point size cache on the context
I don't think there's really any point in this cache because the
pipeline code completely owns the point size state. Pipelines are
already compared for whether their point size state is different
before setting it so it shouldn't result in any extra calls to
glPointSize apart from maybe when the first pipeline is initially
flushed.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-07 15:13:29 +00:00
Neil Roberts
c0d7839c55 vertend-glsl: Fix flushing the point size with the GL driver
When using the GLSL vertend on GL, the point size was being flushed in
_cogl_pipeline_vertend_glsl_start. However, this function bails out
early if the pipeline already has a usable program so it would not hit
the code to flush the point size in that case. This patch moves the
code to _cogl_pipeline_vertend_glsl_end so that it will always be
flushed if it is different. That is the same place that is flushed for
the fixed vertend.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-07 15:13:29 +00:00
Neil Roberts
185630085c Add -Wmissing-declarations to maintainer flags and fix problems
This option to GCC makes it give a warning whenever a global function
is defined without a declaration. This should catch cases were we've
defined a function but forgot to put it in a header. In that case it
is either only used within one file so we should make it static or we
should declare it in a header.

The following changes where made to fix problems:

• Some functions were made static

• cogl-path.h (the one containing the 1.0 API) was split into two
  files, one defining the functions and one defining the enums so that
  cogl-path.c can include the enum and function declarations from the
  2.0 API as well as the function declarations from the 1.0 API.

• cogl2-clip-state has been removed. This only had one experimental
  function called cogl_clip_push_from_path but as this is unstable we
  might as well remove it favour of the equivalent cogl_framebuffer_*
  API.

• The GLX, SDL and WGL winsys's now have a private header to define
  their get_vtable function instead of directly declaring in the C
  file where it is called.

• All places that were calling COGL_OBJECT_DEFINE need to have the
  cogl_is_whatever function declared so these have been added either
  as a public function or in a private header.

• Some files that were not including the header containing their
  function declarations have been fixed to do so.

• Any unused error quark functions have been removed. If we later want
  them we should add them back one by one and add a declaration for
  them in a header.

• _cogl_is_framebuffer has been renamed to cogl_is_framebuffer and
  made a public function with a declaration in cogl-framebuffer.h

• Similarly for CoglOnscreen.

• cogl_vdraw_indexed_attributes is called
  cogl_framebuffer_vdraw_indexed_attributes in the header. The
  definition has been changed to match the header.

• cogl_index_buffer_allocate has been removed. This had no declaration
  and I'm not sure what it's supposed to do.

• CoglJournal has been changed to use the internal CoglObject macro so
  that it won't define an exported cogl_is_journal symbol.

• The _cogl_blah_pointer_from_handle functions have been removed.
  CoglHandle isn't used much anymore anyway and in the few places
  where it is used I think it's safe to just use the implicit cast
  from void* to the right type.

• The test-utils.h header for the conformance tests explicitly
  disables the -Wmissing-declaration option using a pragma because all
  of the tests declare their main function without a header. Any
  mistakes relating to missing declarations aren't really important
  for the tests.

• cogl_quaternion_init_from_quaternion and init_from_matrix have been
  given declarations in cogl-quaternion.h

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-06 18:45:44 +00:00
Robert Bragg
85dddf9932 build: list cogl-bitmap-packing.h as source file
This fixes make release-check because cogl-bitmap-packing.h wasn't being
packaged.
2012-03-05 23:25:30 +00:00
Robert Bragg
5eb62ad1d9 wayland-renderer: remove the _EXP suffix from symbols
We are in the process of removing all _EXP suffix mangling for
experimental APIs (Ref: c6528c4b6c) and adding missing gtk-doc
comments so that we can instead rely on the "Stability: unstable"
markers in the gtk-doc comments. This patch tackles the
cogl-wayland-renderer api symbols.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-03-05 20:23:54 +00:00
Neil Roberts
75226501cf Don't use cogl_get_draw_framebuffer when flushing pipeline state
Some of the state when flushing a pipeline depends on the current
framebuffer being used. These are:

• The matrix stack, so that it can flip vertically or not depending on
  whether the framebuffer is offscreen.
• The colormask. This is combined with the framebuffer's color mask.
• The cull face mode. If the framebuffer is offscreen then backface
  culling is translated to frontface culling and vice-versa.

These states were not working if the new framebuffer draw_primitive
API was used because in that case the framebuffer is not pushed to the
framebuffer stack so it would use the wrong one. This patch changes it
to use ctx->current_draw_buffer which is a pointer to the framebuffer
whose state was last flushed.

https://bugzilla.gnome.org/show_bug.cgi?id=670793

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 19:50:20 +00:00
Neil Roberts
76c2bd8420 cogl-bitmap: Add a public accessor for the underlying pixel buffer
This adds a small cogl_bitmap_get_buffer public function. Note that
this can return NULL if the bitmap was not created with a pixel
buffer. It might be nice to change this eventually so that all bitmaps
have a pixel buffer.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 19:02:29 +00:00
Neil Roberts
7114588884 Add the missing cast macros for some buffer objects
CoglPixelBuffer, CoglAttributeBuffer and CoglIndexBuffer were missing
public cast macros.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 18:47:52 +00:00
Neil Roberts
1397a2da19 Make _cogl_bitmap_get_{width,height,format,rowstride} public
This are now marked as public experimental

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 18:47:52 +00:00
Neil Roberts
3700cc26a5 Change API so that CoglPixelBuffer no longer knows its w/h/format
The idea is that CoglPixelBuffer should just be a buffer that can be
used for pixel data and it has no idea about the details of any images
that are stored in it. This is analogous to CoglAttributeBuffer which
itself does not have any information about the attributes. When you
want to use a pixel buffer you should create a CoglBitmap which points
to a region of the attribute buffer and provides the extra needed
information such as the width, height and format. That way it is also
possible to use a single CoglPixelBuffer with multiple bitmaps.

The changes that are made are:

• cogl_pixel_buffer_new_with_size has been removed and in its place is
  cogl_bitmap_new_with_size. This will create a pixel buffer at the
  right size and rowstride for the given width/height/format and
  immediately create a single CoglBitmap to point into it. The old
  function had an out-parameter for the stride of the image but with
  the new API this should be queriable from the bitmap (although there
  is no function for this yet).

• There is now a public cogl_pixel_buffer_new constructor. This takes
  a size in bytes and data pointer similarly to
  cogl_attribute_buffer_new.

• cogl_texture_new_from_buffer has been removed. If you want to create
  a texture from a pixel buffer you should wrap it up in a bitmap
  first. There is already API to create a texture from a bitmap.

This patch also does a bit of header juggling because cogl-context.h
was including cogl-texture.h and cogl-framebuffer.h which were causing
some circular dependencies when cogl-bitmap.h includes cogl-context.h.
These weren't actually needed in cogl-context.h itself but a few other
headers were relying on them being included so this adds the #includes
where necessary.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 18:47:45 +00:00
Neil Roberts
10a38bb14f Add a public cogl_framebuffer_read_pixels_into_bitmap
This adds a public function to read pixels from a framebuffer into a
CoglBitmap. This replaces the internal function
_cogl_read_pixels_with_rowstride because a CoglBitmap contains a
rowstride so it can be used for the same purpose. A CoglBitmap already
has public API to make one that points to a CoglPixelBuffer so this
function can be used to read pixels into a PBO. It also avoids the
need to push the framebuffer on to the context's stack so it provides
a function which can be used in the 2.0 API after the stack is
removed.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 18:16:10 +00:00
Neil Roberts
2501899044 cogl-buffer: Create the buffer store when bound
Whenever the buffer is bound with _cogl_buffer_bind Cogl now ensures
the buffer's data store has been created. Previously it would only
ensure it was created when it was first mapped or when the first data
was set on it. This is necessary if we are going to use CoglBuffers
for retrieving data from GL. In that case the buffer won't be mapped
or have data set on it before it is used.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 17:46:59 +00:00
Neil Roberts
1b47ff0dfe bitmap: Support pre/unpre-multiplying any format
If the fast-path inplace premult conversion can't be used then it will
now fallback to unpacking the buffer into a row of guint16s and use
the generic conversion.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 17:46:59 +00:00
Neil Roberts
031dd661c0 bitmap: Add a function to convert into an existing buffer
This adds _cogl_bitmap_convert_into_bitmap which is the same as
_cogl_bitmap_convert except that it writes into an existing bitmap
instead of allocating a new one. _cogl_bitmap_convert now just
allocates a buffer and calls the new function. This is used in
_cogl_read_pixels to avoid allocating a second intermediate buffer
when the pixel format to store in is not GL_RGBA.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 17:46:57 +00:00
Neil Roberts
f4cd5aceb9 _cogl_bitmap_convert: Also handle premult conversions
If we are going to unpack the data into a known format anyway we might
as well do the premult conversion instead of delaying it to do
in-place. This helps because not all formats with alpha channels are
handled by the in-place premult conversion code. This removes the
_cogl_bitmap_convert_format_and_premult function so that now
_cogl_bitmap_convert is a completely general purpose function that can
convert from anything to anything. _cogl_bitmap_convert now includes a
fast path for when the base formats are the same and the premult
conversion can be handled with the in-place code so that we don't need
to unpack and can just copy the bitmap instead.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 17:44:52 +00:00
Neil Roberts
8ce5f5ade8 bitmap: Remove the split between 'image library' and 'fallback'
Previously the bitmap code was setup so that there could be an image
library used to convert between formats and then some 'fallback' code
when the image library can't handle the conversion. However there was
never any implementation of the conversion in the image library so the
fallback was always used. I don't think this split really makes sense
so this patch renames cogl-bitmap-fallback to cogl-bitmap-conversion
and removes the stub conversion functions in the image library.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 17:44:52 +00:00
Neil Roberts
908ba29be5 bitmap-fallback: Support converting all pixel format types
_cogl_bitmap_fallback_convert now supports converting to and from all
of the pixel formats, except it continues to preserve the premult
status of the original bitmap. The pixels are unpacked into a
temporary buffer that is either 8-bits per component or 16-bits per
component RGBA depending on whether the destination format is going to
use more than 8 bits per component (eg RGBA_1010102). The packing and
unpacking code is stored in a separate header which is included twice
to generate the functions needed for both sizes of unpacked data. The
hope is that when converting between two formats that are both 8-bit
sized, such as swizzling between BGRA and RGBA, then the
multiplications and divisions in the code will be optimized out and it
shouldn't be too inefficient. Previously the inner switch statement to
decide which conversion to use only operated on one pixel at a time so
it was probably relatively slow.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 17:44:12 +00:00
Neil Roberts
323adc0c14 Avoid making up the format COGL_PIXEL_FORMAT_A_8_PRE
There are a few places in Cogl that try to set the premult bit on a
pixel format depending on whether it has an alpha channel. However
this breaks if the pixel format is alpha-only because premultiplying
data without any RGB components doesn't make any sense. This adds an
internal macro to check for cases where we should add the premult bit
called COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT. This now gets used in all
places that previously just checking for COGL_A_BIT.

https://bugzilla.gnome.org/show_bug.cgi?id=671016

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 17:43:46 +00:00
Neil Roberts
2b9aca20a8 Assert that we get a valid format in pixel_format_to_gl{,es}
The assert could use a 'default:' label but that would stop GCC from
giving a warning when a new enum value is added.

https://bugzilla.gnome.org/show_bug.cgi?id=671016

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 17:43:46 +00:00
Neil Roberts
933db01833 cogl-winsys-egl-wayland: Include cogl-wayland-renderer.h
The Wayland winsys defines functions declared in
cogl-wayland-renderer.h so it should include the header to make sure
the declarations are right. This was breaking because currently the
header #defines the _EXP suffixes on to the function names so it would
end up exporting the wrong symbol names.
2012-02-29 17:45:43 +00:00
Robert Bragg
be237cc2b7 renderer: Adds getters/setters for driver preference
This adds api for explicitly choosing what underlying driver cogl should
use internally for rendering as well as api for querying back what
driver is actually in use.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-24 14:42:31 +00:00
Neil Roberts
39c6bf59cb texture: Handle premult conversions when getting texture data
cogl_texture_get_data uses find_best_gl_get_data_format from the
texture driver which returns the closest format to use for retrieving
pixel data given an intended format. However this function doesn't
know about the texture we are reading data from so it doesn't know
that the data we will actually receive will have the same premult
status as the texture's format. With the GL driver, this function ends
up returning exactly the same format as passed in which means it will
never do a premult conversion. Under GLES it always returns
COGL_PIXEL_FORMAT_RGBA_8888 so it will always make the data unpremult
even if the final requested format is premultiplied.

This patch fixes it so that it copies the premult status of the
closest_format from the format of the underlying texture. That way it
will later convert or not depending on the requested target format.

Note this patch breaks test-sub-texture with the GL driver because
that is incorrectly trying to read the texture data back as RGBA_8888
even though it depends on it not doing a premult conversion. The test
was already broken with GLES2 and remains broken.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-23 18:08:45 +00:00
Neil Roberts
31bd4cb22c Use GL_OES_packed_depth_stencil on GLES2
If the GL_OES_packed_depth_stencil extension is available then we can
try creating a combined depth-stencil buffer with the
GL_DEPTH24_STENCIL8 format. This adds a private flag for the feature.

https://bugzilla.gnome.org/show_bug.cgi?id=666184

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-22 17:17:50 +00:00
Neil Roberts
b52d24c933 Check for GL_EXT_packed_depth_stencil
The GL_DEPTH_STENCIL format for renderbuffers is defined in a separate
extension from GL_EXT_framebuffer_object so we probably shouldn't
being trying to use it unless that extension is advertised. This just
replaces the check for whether the driver is GL for a check for a
private feature flag before trying GL_DEPTH_STENCIL. The private
feature flag is set if the extension is available on GL.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-22 17:17:50 +00:00
Neil Roberts
d3e6f2bc83 cogl-attribute: Fix binding an attribute to cogl_tex_coord_in
If an application tries to bind an attribute to cogl_tex_coord_in then
on GLES2 it would try to directly use that as the name of the GL
attribute. However in the generated shader that is actually #defined
to cogl_tex_coord0_in so we need to remap the name. This adds a
parameter to validate_cogl_attribute_name so that it can optionally
return a real_attribute_name. If it doesn't set this then the calling
function will default to the Cogl attribute name.

This fixes test-texture-3d with the GLES2 driver.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-22 17:17:50 +00:00
Chun-wei Fan
2fdb7fc743 cogl-pipeline-payer-state.c: Include cogl-texture-private.h
Needed for _cogl_texture_get_type so that C4013 warnings/implicit
declaration of ... warnings can be avoided.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-22 21:32:52 +08:00
Chun-wei Fan
4eb923a68b Another update to cogl.symbols
The previous update missed renames of certain cogl_framebuffer_* functions
to cogl_onscreen_*, and were not updated as the glib-mkenums-generated
header no longer included experimental headers

Also, all comments in cogl.symbols are now done in C-style so that the
preprocessor will filter them out when processing cogl.symbols instead of
using ';' for commments, which could be MSVC-only

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-22 21:32:42 +08:00
Chun-wei Fan
3d8972342d Revert "Another update to cogl.symbols"
This reverts commit b70af4a104.

Sorry, I missed a comment line in this part :|
2012-02-22 21:31:42 +08:00
Chun-wei Fan
b70af4a104 Another update to cogl.symbols
The previous update missed renames of certain cogl_framebuffer_* functions
to cogl_onscreen_*, and were not updated as the glib-mkenums-generated
header no longer included experimental headers

Also, all comments in cogl.symbols are now done in C-style so that the
preprocessor will filter them out when processing cogl.symbols instead of
using ';' for commments, which could be MSVC-only
2012-02-22 21:30:48 +08:00
Chun-wei Fan
021f4f2624 Update cogl/cogl.symbols
-Make up for the missed cogl_texture_pixmap_x11_* symbols
-Removed texture_3d _EXP suffixes
-For newly-exposed public cogl_pipeline_get_layer_*_filter APIs

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-22 20:30:16 +08:00
Robert Bragg
336c330d11 cogl.h: Exclude 1.x headers if 2.0 api requested
Now if COGL_ENABLE_EXPERIMENTAL_2_0_API has been defined when including
cogl.h then headers that correspond to 1.x only apis that we plan to
drop won't be included any more.

If COGL_ENABLE_EXPERIMENTAL_API is defined then you can still mix and
match 2.0 api with 1.x api in a single compilation unit.

Note: it's still possible that some 1.x symbols will still be available
when COGL_ENABLE_EXPERIMENTAL_2_0_API is defined since this patch
doesn't go through the shared headers adding guards around deprecated
functions.

This only affects people playing with the experimental api.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-21 13:26:14 +00:00
Robert Bragg
4e3f9d0fc2 tex-pixmap-x11: remove CoglHandle use + pass context
This also replaces use of CoglHandle with a CoglTexturePixmapX11 type
instead.

This patch also ensures the CoglTexturePixmapX11 constructor take an
explicit CoglContext pointer and can return a GError consistent with
other CoglTexture constructors.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-21 13:26:14 +00:00
Robert Bragg
479c5fd2c9 onscreen: move swap_buffer apis to onscreen namespace
This moves all the cogl_framebuffer_ apis relating to swap buffer
requests into the cogl_onscreen_ namespace since on CoglOnscreen
framebuffers have back buffers that can be swapped.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-21 13:26:14 +00:00
Robert Bragg
785e6375eb Adds a context arg to cogl_pipeline_new()
As we move towards Cogl 2.0 we are aiming to remove the need for a
default global CoglContext and so everything should be explicitly
related to a context somehow. CoglPipelines are top level objects and
so this patch adds a context argument to cogl_pipeline_new().

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-21 12:38:24 +00:00
Robert Bragg
13c36fff0d offscreen: Replace use of CoglHandle with CoglOffscreen
This updates cogl_offscreen_new_to_texture to return a CoglOffscreen
pointer instead of a CoglHandle.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-21 12:38:10 +00:00
Robert Bragg
0a2a3d7c80 context: removes some uses of CoglHandle
There were several members of the CoglContext struct using the
CoglHandle type for things that now have replacement typedefs which
this patch fixes.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-21 12:37:55 +00:00
Robert Bragg
47868e1f3e texture-3d: remove _EXP defines + CoglHandle and pass context
We are in the process of removing all _EXP suffix mangling for
experimental APIs (Ref: c6528c4b6c) and adding missing gtk-doc
comments so that we can instead rely on the "Stability: unstable"
markers in the gtk-doc comments. This patch tackles the cogl-texture-3d
api symbols.

This patch also replaces use of CoglHandle with a CoglTexture3D type
instead.

Finally this patch also ensures the CoglTexture3D constructors take an
explicit CoglContext pointer but not a CoglTextureFlags argument,
consistent with other CoglTexture constructors.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-21 12:37:44 +00:00
Robert Bragg
80ccf06b84 debug: support wireframe mode with vertex shaders
Previously for the wireframe debug mode we identified the users
"cogl_position_in" attribute, mapped that, created a replacement
attribute with a LINE_LIST topology and then drew the attribute with a
simple pipeline with a green colour. This meant we completely discarded
the users original pipeline which may have involved vertex processing
that would be useful to visualize in the wireframe.

The new approach instead keeps the users attributes and instead
generates CoglIndices that can be used to refererence the original
attributes in LINE_LIST topology and instead of scrapping the user's
pipeline we now create a weak copy of the original pipeline and just
replace the fragment processing with a snippet to force the output color
to be green.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:32:25 +00:00
Robert Bragg
1bba0f5d99 pipeline: make _equal() cost scale by n bits in differences
This improves the implementation of _cogl_pipeline_equal() to ensure
that the cost of the function scales by the number of bits set in the
pipelines_difference variable set after calling
_cogl_pipeline_compare_differences() instead of scaling by the number of
state groups cogl tracks.

As Cogl tracks more and more state groups we don't want
_cogl_pipeline_equal() to get slower.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:16:37 +00:00
Robert Bragg
ed06d0ca01 object: avoid creating a new entry for NULL data
If setting NULL user data via cogl_object_set_user_data() and we fail to
find an entry for the given key then bail out before potentially
allocating a new entry since setting NULL data is documented to
effectively delete an entry.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:16:37 +00:00
Robert Bragg
31097c0488 pipeline: Expose min/mag filter getters
This exposes cogl_pipeline_get_layer_{min,max}_filter functions so that
applications can query back the filters set using
cogl_pipeline_set_layer_filters().

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:16:37 +00:00
Robert Bragg
680f63a48c Remove all internal includes of cogl.h
The cogl.h header is meant to be the public header for including the 1.x
api used by Clutter so we should stop using that as a convenient way to
include all likely prototypes and typedefs. Actually we already do a
good job of listing the specific headers we depend on in each of the .c
files we have so mostly this patch just strip out the redundant
includes for cogl.h with a few fixups where that broke the build.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:45 +00:00
Robert Bragg
cc4aa97579 Handle all formats in _cogl_texture_driver_pixel_format_to_gl
The _cogl_texture_driver_pixel_format_to_gl functions for OpenGL and
OpenGLES convert CoglPixelFormats into corresponding gl enums that can
be used to upload texture data. Previously we were only handling a few
specific formats but this patch updates the functions to handle all the
formats we know about. The functions now also switch() on the format so
that we will get build time warnings if we forget to handle new formats
in these functions.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:45 +00:00
Damien Leone
c8674ef2bc Add support for X101010 and 2101010 pixel formats to fallback OpenGL rendering
https://bugzilla.gnome.org/show_bug.cgi?id=660188

edit: tweaked the internal format returned by pixel_format_to_gl();
handled 1010102 formats and rebased -- Robert Bragg

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:45 +00:00
Damien Leone
8b70468598 Improve pixel format detection for fallback OpenGL rendering
The previous detection was based on bits per pixel only and would
consider bpp >= 24 as X888 or 8888 24-bit color depth formats.

This commit ensures we now use the newly added
_cogl_util_pixel_format_from_masks() api that returns a CoglPixelFormat
according to channel masks and color depth. This helps to add support
for more pixel formats.

https://bugzilla.gnome.org/show_bug.cgi?id=660188

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:45 +00:00
Robert Bragg
e3c4522a86 Adds a _cogl_util_pixel_format_from_masks API
This adds a utility function for inferring a CoglPixelFormat from a
set of channel masks, a bits-per-pixel value, a pixel-depth value and
pixel byte order.

This plan is to use this to improve how we map X visuals to Cogl pixel
formats.

This patch was based on some ideas from Damien Leone <dleone@nvidia.com>

https://bugzilla.gnome.org/show_bug.cgi?id=660188

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:45 +00:00
Robert Bragg
fcb8b18d39 pixel formats: Documents the internal representation
This adds a comment to cogl-types.h where we define all the
CoglPixelFormat enums to give lots of information about the internal
representation of the format and to explain how new formats should be
allocated.

This information came from the discussion in bug #660188

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:45 +00:00
Damien Leone
f3fa86b482 Add 30-bit color depth pixel formats X101010 and 2101010
30-bit color depth formats are defined by using value 13 in the least
significant nibble of the pixel format enumeration. This nibble
encodes bytes-per-pixel and byte alignment.

The _cogl_pixel_format_get_bytes_per_pixl() function is updated
accordingly to support these new formats.

https://bugzilla.gnome.org/show_bug.cgi?id=660188

edit: dropped the X101010 formats but also added 1010102 formats since
Cogl avoids exposing any padded formats and leaves it to applications to
consider the A component to be padding as needed. -- Robert Bragg

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:45 +00:00
Robert Bragg
5cdc9af18a Removes the COGL_PIXEL_FORMAT_{24,32} defines
Although these are in the public headers we should assume that no one is
using them since they were never documented so no could know what they
are useful for.

If you were to guess you'd be forgiven for thinking they were bitmasks
for checking some flags to see if a format is 24 or 32 bits. If you
looked further you might instead be forgiven for thinking that if you
masked of the least significant nibble of a pixel-format then you could
check the value against these defines. Neither of the previous
operations are reliable ways to check if a format is 24 or 32bit and
instead code must use then internal
_cogl_pixel_format_get_bytes_per_pixel() api if they want to know the
pixel size for a given format which relies on a 16 entry lookup table
using the least significant nibble of a pixel-format.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:45 +00:00
Robert Bragg
e43246fe1c Remove COGL_UNORDERED_MASK define
Although it's in a public header nothing should be using this define
since it's not documented what it could be used for. The cases where we
were using it internally were quite fragile because they were trying to
mask information from the least significant nibble of CoglPixelFormat
but really that nibble just has to be dealt with using lookup tables.
The least significant nibble of a pixel format gives information about
the bytes per pixel and whether the components are byte aligned but the
information needs to be accessed using
_cogl_pixel_format_get_byes_per_pixel() and
_cogl_pixel_format_is_endian_dependant().

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:44 +00:00
Robert Bragg
a203a5e396 Remove COGL_UNPREMULT_MASK define
Since (A & ~COGL_PREMULT_BIT) is basically as readable as (A &
COGL_UNPREMULT_MASK) this patch removes the mask define. Without the
mask the code is slightly more explicit and there's less risk in error
caused by us forgetting to update the COGL_UNPREMULT_MASK if the way
CoglPixelFormat is defined evolves.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:44 +00:00
Robert Bragg
07e972505c Adds _cogl_pixel_format_is_endian_dependant api
This adds an internal utility function
_cogl_pixel_format_is_endian_dependant() that can query whether
accessing the components of a given format depends on the endianness of
the current host CPU or whether a pixel can be loaded as a word and
channels accessed using bit masking and shifting.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:44 +00:00
Robert Bragg
fbec2a5ad7 moves and renames _cogl_get_format_bpp
This moves _cogl_get_format_bpp from cogl-bitmap.c to cogl.c and renames
it to _cogl_pixel_format_get_bytes_per_pixel. This makes it clearer that
it doesn't return bits per pixel and makes the naming consistent with
other cogl api. The prototype has been moved to cogl-private.h since it
seems we should be aiming to get rid of cogl-internal.h at some point.

The patch also adds a simple gtk-doc comment since we might want to make
this api public.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:44 +00:00
Robert Bragg
e376058533 cogl-private.h: include cogl-context.h
cogl-private.h contains prototypes depending on CoglContext so
explicitly include cogl-context.h

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:44 +00:00
Robert Bragg
ee940a3d0d Move all types/prototypes from cogl.h -> cogl[1]-context.h
So we can get to the point where cogl.h is merely an aggregation of
header includes for the 1.x api this moves all the function prototypes
and type definitions into a cogl-context.h and a new cogl1-context.h.

Ideally no code internally should ever need to include cogl.h as it just
represents the public facing header for accessing the 1.x api which
should only be used by Clutter.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:44 +00:00
Robert Bragg
1022c285c6 texture-pixmap-x11.h: define __COGL_H_INSIDE__
Ideally we wouldn't have exposed cogl-texture-pixmap-x11.h as a
top level header and would have just automatically included it in cogl.h
but we already have code that assumes it can be directly included.

This ensures we define __COGL_H_INSIDE__ as a reminder that it is a top
level header in case we later need to include other cogl internal cogl
headers which would cause a build time error without this defined.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:44 +00:00
Robert Bragg
9c58d6c4e7 Clean up cogl 1.x/2.0 header separation
The cogl_public_h variable in cogl/Makefile.am was a mixture of 1.x
headers and experimental headers which meant that glib-mkenums was
processing lots of experimental api headers. This patch lists
experimental api headers under the cogl_experimental_h variable instead.
This patch also ensures we undef the COGL_ENABLE_EXPERIMENTAL_* defines
when running the gobject introspection scanner for Cogl-1.0.gir

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:44 +00:00
Emmanuele Bassi
3f561b1fbe Fix build on OSX
A missing include prevents Cogl from building on OSX.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-15 14:57:59 +00:00
Chun-wei Fan
2059d2dee0 Update cogl.symbols
Add cogl_pipline_set_layer_null_texture... which was just added to the COGL
API

Checked with Neil Roberts <neil@linux.intel.com> on IRC.
2012-02-15 22:50:09 +08:00
Jasper St. Pierre
e98f279712 Fix some doc issues
Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-14 20:42:10 +00:00
Neil Roberts
f84839e87c pipeline-state: Fix crash in the get_all_uniform_values function
The get_all_uniform_values function tries to walk the parent hierarchy
of pipelines to find pipelines overriding the uniforms state and then
grabs the values from the override. However it was accessing data
inside the ‘big state’ even if the pipeline didn't override the
uniforms state so it would crash if it encountered a parent pipeline
with no big state.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-13 18:48:17 +00:00
Neil Roberts
6ddf81c8dc Pass the sampler object to snippet hooks on the texture_hookup
The snippet hook COGL_SNIPPET_HOOK_TEXTURE_LOOKUP now gets passed an
extra variable called cogl_sampler which is the sampler attached to
this layer. For example this will be useful when implementing the blur
effect in Clutter so that it can make the texture hook for that layer
sample the texture multiple times.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-13 17:29:28 +00:00
Robert Bragg
2caf9e0f59 glsl: always emit sampler uniforms for non NULL layers
There might be custom hooks that want to sample arbitrary layers
even though they aren't referenced as part of the auto generated layer
combine code. This ensures the sampler uniforms are always output for
non-null layers so at least these can be used.

We may consider changing this later to always emit a wrapper
cogl_sampleX() function for each layer so all samples of a layer can
consistently be modified by a COGL_SNIPPET_HOOK_TEXTURE_LOOKUP hook.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-13 17:29:20 +00:00
Neil Roberts
aa9c293502 glsl: Use layer numbers not unit numbers for builtin uniforms
When generating GLSL code, the names of the builtin uniforms for the
sampler and the layer constant have been renamed to use the layer
number not the unit number. This will make it easier if we ever want
to make them public.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-13 17:15:35 +00:00
Neil Roberts
e6b3bfa41a pipeline: Use layer numbers not unit numbers in the combine strings
In a combine string the application can specify TEXTURE_? as a source
to sample from the texture attached to a particular unit. The number
specified here was being interpreted as a unit index. This is not
helpful to applications because theoretically the unit index is an
internal implementation detail so they can't reliably determine what
it is. This patch changes them to be interpreted as layer indices
instead.

To make this work the enums in CoglPipelineCombineSource are no longer
directly mapped to GLenums. Otherwise it implies a low limit on the
number of layer indices because there are only 32 reserved numbers
between GL_TEXTURE0 and GL_ACTIVE_TEXTURE.

This also fixes a bug in the ARBfp fragend where it was generating
code using the texture type of the layer doing the referencing rather
than the layer that was being referenced.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-13 17:15:35 +00:00
Neil Roberts
740bd12f2d Add a version of _cogl_pipeline_get_layer which does not create it
This adds _cogl_pipeline_get_layer_with_flags which takes a set of
flags to modify the behaviour. The only flag currently available is
one to disable creating the layer if the layer index does not already
exist.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-13 17:15:35 +00:00
Neil Roberts
fdc07c865f Add cogl_pipeline_set_layer_null_texture()
This adds a public function to replace the texture for a layer with
the default white texture. It is equivalent to calling
cogl_pipeline_set_layer_texture with NULL for the texture object
except that it also lets you choose a type for the texture. The idea
is that applications using a base pipeline to make multiple copies
that can share the generated shaders can use this function to make the
layer come into existence with the right texture type. Previously the
idiom would be to create a 1x1 dummy texture of the right type but
this ends up creating lots of redundant little textures.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-13 17:15:08 +00:00
Neil Roberts
d2a35a1e22 cogl-pipeline: Fix comparing the texture data state for NULL textures
When comparing the texture data for a pipeline layer it tries to get
the GL texture handle out of the texture object. However it's valid
for a layer to have a NULL texture object but in that case the code
would just crash. This patch fixes it to compare the texture types
when the texture object is NULL.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-13 17:10:18 +00:00
Neil Roberts
b96e6900f5 cogl-pipeline-layer: Use CoglTextureType instead of GL target enum
Instead of storing the GLenum for the target of the last used texture
for a layer it now stores the CoglTextureType instead. The state name
has been renamed to 'texture type' instead of 'texture target'.
Previously the default pipeline layer would store 0 here to represent
that there is no texture. This has been changed to store
COGL_TEXTURE_TYPE_2D instead which means that all pipeline layers
always have a valid value for the texture type. Any places that were
previously fetching the texture from a layer to determine the target
(for example when generating shaders or when enabling a particular
texture target) now use the texture type instead. This means they will
work even for layers that don't have a texture.

This also changes it so that when binding a fallback texture instead
of always using a 2D texture it will now use the default texture
corresponding to the texture type of the layer. That way when the
generated shader tries to do a texture lookup for that type of texture
it will get a valid texture object. To make this work the patch adds a
default texture for 3D textures to the context and also makes the
default rectangle texture actually be a rectangle texture instead of
using a 2D texture.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-13 17:09:34 +00:00
Neil Roberts
8012eee31f Add _cogl_texture_get_type()
This adds an internal function to get the type of the underlying
hardware texture for any CoglTexture. It can return one of three
values to represent 2D textures, 3D textures or rectangle textures.
The idea is that this can be used as a replacement for
cogl_texture_get_gl_texture when only the target is required to make
it a bit less GL-centric. The implementation adds a new virtual
function which all of the texture backends now implement.

The enum is in a public header because a later patch will want to use
it from the CoglPipeline API. We may want to consider making the
function public too later.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-13 17:02:46 +00:00
Chun-wei Fan
9b87e8602c cogl/Makefile.am: Filter out SDL winsys for Visual C++ builds
Just being a bit paranoid here, as the SDL winsys sources are dealt in the
projects as they are not built for all configurations to avoid them
included more than once in the projects, which can cause trouble.

https://bugzilla.gnome.org/show_bug.cgi?id=669785

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-13 12:22:19 +00:00
Chun-wei Fan
596ff72dc9 Update cogl.symbols
-Adapt to the removal of _EXP mangling from many of the experimental
 functions
-Adapt to newly added/replaced APIs
-_cogl_handle_atlas_texture_get_type is gone

https://bugzilla.gnome.org/show_bug.cgi?id=669785

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-13 12:22:18 +00:00
Chun-wei Fan
2c463c56b1 cogl-in-gles-core-functions.h: Remove stray ';'
There is a stray ';' which some compilers are not fond of.

https://bugzilla.gnome.org/show_bug.cgi?id=669785

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-13 12:22:18 +00:00
Chun-wei Fan
356e134ffb Win32: Update predefined cogl-defines.h's
-Add a define for COGL_HAS_GLIB_SUPPORT, the Visual C++ projects will build
 GLib support for COGL for all builds at this time, unless there is a
 significant call for the need of a COGL Visual C++ build with no
 dependency on GLib
-Pre-define COGL_SYSDEF_POLL* as listed in the default values in commit
 74974752 since Windows does not have poll.h and thus does not have special
 values for these.

https://bugzilla.gnome.org/show_bug.cgi?id=669785

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-13 12:22:17 +00:00
Robert Bragg
3ea6acc072 buffer: explicitly relate buffers to a context
All CoglBuffer constructors now take an explicit CoglContext
constructor. This is part of the on going effort to adapt to Cogl API so
it no longer depends on a global, default context.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-09 14:28:02 +00:00
Robert Bragg
269878217f debug: don't overlay wireframe
When using COGL_DEBUG=wireframe we were overlaying a wireframe of the
users geometry over the top of what was drawn for each primitive. It
seems to be more useful though that if the wireframe debug option has
been enabled then we should draw only the wireframes instead of
overlaying them.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-09 13:22:33 +00:00
Robert Bragg
b168ff8ef6 journal: use pipeline term instead of source
Since we are adapting the Cogl api to be less stateful one of the things
we no longer require is the cogl_set_source() api since a pipeline can
be explicitly passed as an argument when drawing. This means the term
"source" has been deprecated and internally we should aim to
consistently use the term "pipeline" instead. This patch updates the
journal code to use the term pipeline instead of source.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-09 13:13:07 +00:00
Robert Bragg
9a254d8292 debug: Adds COGL_DEBUG=winsys option
Although we internally had a COGL_DEBUG_WINSYS enum we weren't providing
a way to enable that via the COGL_DEBUG environment variable. This adds
a "winsys" option that can be used to enable printing of winsys debug
notes.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-09 13:10:14 +00:00
Robert Bragg
379fa8b435 display: Remove _EXP symbol mangling and add gtk-doc
We are in the process of removing all _EXP suffix mangling for
experimental APIs (Ref: c6528c4b6c) and adding missing gtk-doc
comments so that we can instead rely on the "Stability: unstable"
markers in the gtk-doc comments. This patch tackles the display api
symbols.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-09 13:09:15 +00:00
Robert Bragg
92c3063014 framebuffer: Add cogl_framebuffer draw methods
This adds cogl_framebuffer_ apis for drawing attributes and primitives
that replace corresponding apis that depend on the default CoglContext.
This is part of the on going effort to adapt the Cogl api so it no
longer depends on a global context variable.

All the new drawing functions also take an explicit pipeline argument
since we are also aiming to avoid being a stateful api like Cairo and
OpenGL. Being stateless makes it easier for orthogonal components to
share access to the GPU. Being stateless should also minimize any
impedance miss-match for those wanting to build higher level stateless
apis on top of Cogl.

Note: none of the legacy, global state options such as
cogl_set_depth_test_enabled(), cogl_set_backface_culling_enabled() or
cogl_program_use() are supported by these new drawing apis and if set
will simply be silently ignored.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-09 13:09:15 +00:00
Neil Roberts
88f8780367 cogl-primitives: Copy across the texture coordinates if no texture
Previously when using the cogl_rectangle_* family of functions with a
pipeline that doesn't have a texture for a particular layer then
validate_tex_coords_cb would bail out immediately leaving the texture
coords for that layer uninitialised. This patch changes it so that it
bails out after copying in the texture coordinates instead. This was
causing problems for pipelines that were trying to completely generate
the texture values in a CoglSnippet because they wouldn't get any
texture coordinates.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-08 19:25:19 +00:00
Robert Bragg
15d43bb697 glx: Only call swap_buffer callbacks @ dispatch time
This ensures we don't call swap buffer notify callback functions
immediately when they are received since it could be awkward for
applications to ensure they have dropped all necessary locks if they
don't know when callbacks might be invoked.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-08 18:58:06 +00:00
Robert Bragg
0f33c942f2 kms: gracefully handle NULL save_state at cleanup
If we failed to save any crtc state then we skip trying to restore the
old state at cleanup.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-08 17:00:25 +00:00
Robert Bragg
1a638b6fd6 kms: Adds api to get at the kms file descriptor
This adds a cogl_kms_renderer_get_kms_fd() function that lets developers
access the kms file descriptor being used for controlling the kernel
mode setting.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-08 17:00:25 +00:00
Robert Bragg
6b7af18313 renderer: fix s/contraint/constraint/ typo
The recent patch to add an api for explicitly constraining how a
renderer backend is chosen had a typo which this patch fixes.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-08 17:00:25 +00:00
Robert Bragg
161fad2860 texture-2d/wayland: destroy transient EGLImages
When creating a texture from a wayland buffer we create an intermediate
EGLImage that we then create a GL texture from, but we were never
destroying that EGLImage. This patch ensures we destroy the image right
after we've created the texture so we don't leak a reference to the
underlying buffer.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-08 17:00:25 +00:00
Neil Roberts
99c651d2b4 Move the add_swap_buffers_callback functions out of the winsys
Instead of having each winsys implement its own list of callbacks the
list is now just attached directly to the CoglOnscreen using code in
cogl-onscreen.c. The winsys's can invoke this list of callbacks by
calling _cogl_onscreen_notify_swap_buffers(). All of the winsys's
would probably have a very similar implementation for this anyway and
I don't think it makes much sense to try and save the cost of a list
pointer in the CoglOnscreen struct.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-08 17:00:25 +00:00
Neil Roberts
77c3b1b905 Add cogl_primitive_get_indices()
This adds a public getter for the indices property of CoglPrimitive.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-07 15:25:36 +00:00
Neil Roberts
354e923cbf Add cogl_primitive_foreach_attribute()
This adds a public function to iterate the attributes of a
CoglPrimitive. Previously there was no way to query back the
attributes but there was methods to query back all of the other
properties.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-07 15:25:36 +00:00
Neil Roberts
146803c191 Add cogl_primitive_copy()
This adds a public function to make a copy of a primitive. The copy is
shallow which means it will share the same attributes and attribute
buffers. This could be useful for code that wants to have multiple
similar primitives with slightly modified properties.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-07 15:25:35 +00:00
Neil Roberts
55427a18a6 Make _cogl_pipeline_get_layer_texture public
There was no other way to get a pointer to the texture attached to a
pipeline layer apart from the using the CoglMaterial API but I think
this was just an oversight so we should add this in. It is already
maked in the sections file for the gtk-doc.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-07 15:25:35 +00:00
Neil Roberts
ec1bb4ce39 When internally using an FBO, check for allocation errors
Both the cogl_texture_get_data and _cogl_blit_begin implementations
will internally try to create an FBO for a texture and have fallbacks
if the FBO fails. However neither of them were catching errors when
allocating the framebuffer so the fallback wouldn't work properly.
This patch just adds an explicit call to cogl_framebuffer_allocate for
these uses and causes it to use the next fallback if it fails.

Based on a patch by Adel Gadllah.

https://bugzilla.gnome.org/show_bug.cgi?id=669368

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-07 15:13:11 +00:00
Neil Roberts
43bc0a4b0d texture: Flush the dependent journals on get_data
When calling cogl_texture_get_data we need to ensure that any
framebuffers rendering to the texture have flushed their journals.

https://bugzilla.gnome.org/show_bug.cgi?id=668913

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-01-31 12:01:20 +00:00
Neil Roberts
d42f1873fc framebuffer: Flush the journal on destruction
Instead of flushing the journal whenever the current framebuffer on a
context is changed it is now flushed whenever the framebuffer is about
to be destroyed instead. To do this it implements a custom unref
function which detects when there is going to be exactly one reference
on the framebuffer and then flushes its journal. The journal now
always has a reference on the framebuffer whenever it is non-empty.
That means the unref will only cause a flush if the only thing keeping
the framebuffer alive is the entries in the journal.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-01-27 17:23:03 +00:00
Neil Roberts
688a3e196b object: Add a virtual pointer for the unref function
The virtual function gets called in cogl_object_unref. Any definition
of a CoglObject type can replace the default unref function by using
COGL_OBJECT_DEFINE_WITH_CODE to directly manipulate the
CoglObjectClass struct. The generated object constructors set the
pointer to the default implementation. The default implementation is
exported in the private header so that any overriding implementations
can chain up to it.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-01-27 17:22:57 +00:00
Neil Roberts
139421de19 object: Remove the type member of CoglObjectClass
Unlike in GObject the type number for a CoglObject is entirely an
internal implementation detail so there is no need to make a GQuark to
make it safe to export out of the library. Instead we can just
directly use a fixed pointer address as the identifier for the type.
This patch makes it use the address of the class struct of the
identifier. This should make it faster to do type checks because it
does not need to call a function every time it wants to get the type
number.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-01-27 17:18:32 +00:00
Neil Roberts
c39333a2c6 object: Reorder the CoglObject members by size
This moves the pointer members of CoglObject to the top and the int
members to the bottom so that there won't be any padding inserted on
64-bit machines. This reduces the size of the struct from 80 bytes to
72.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-01-27 17:18:32 +00:00
Emmanuele Bassi
417878538b Move GLES2 prototypes to their header
Some GLSL-related function prototypes are GLES2-only: GL implementations
are not required to provide them.

While Mesa is perfectly happy to return a dummy function pointer for
functions it doesn't support, other platforms are more picky, and will
return NULL.

In this particular case, this commit fixes GLSL support on OSX.

https://bugzilla.gnome.org/show_bug.cgi?id=668856

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-01-27 16:37:55 +00:00
Neil Roberts
5936bfb395 cogl-poll: Add a missing G_END_DECLS to the header
I accidentally left this out so I guess that would break apps using
C++.

https://bugzilla.gnome.org/show_bug.cgi?id=668385
2012-01-24 14:04:26 +00:00
Robert Bragg
b2d05f32c2 profile: use atexit not g_atexit
g_atexit has been deprecated so we simply use atexit instead now.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-01-16 23:27:36 +00:00