summaryrefslogtreecommitdiff
path: root/cogl/cogl-display.c
Commit message (Collapse)AuthorAgeFilesLines
* This re-licenses Cogl under the MIT licenseRobert Bragg2014-01-141-13/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This follows up on the proposal that was sent to the Cogl mailing list to re-license from the LGPL to the MIT license: http://lists.freedesktop.org/archives/cogl/2013-December/001465.html Note: there was a copyright assignment policy in place for Clutter (and therefore Cogl which was part of Clutter at the time) until the 11th of June 2010 and so we only checked the details after that point (commit 0bbf50f905) For each file, authors were identified via this Git command: $ git blame -p -C -C -C20 -M -M10 0bbf50f905..HEAD We received blanket approvals for re-licensing all Red Hat and Collabora contributions which reduced how many people needed to be contacted individually: - http://lists.freedesktop.org/archives/cogl/2013-December/001470.html - http://lists.freedesktop.org/archives/cogl/2014-January/001536.html Individual approval requests were sent to all the other identified authors who all confirmed the re-license on the Cogl mailinglist: http://lists.freedesktop.org/archives/cogl/2014-January As well as updating the copyright header in all sources files, the COPYING file has been updated to reflect the license change and also document the other licenses used in Cogl such as the SGI Free Software License B, version 2.0 and the 3-clause BSD license.
* Removes the CoglSwapChain apiRobert Bragg2013-06-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The CoglSwapChain api made initializing a context more awkward than it ought to be in the relatively common case where you want onscreen framebuffers to have an alpha channel. The api let you specify an explicit swap-chain length and also request that the swap chain buffers should have an alpha component and then the a CoglSwapChain could be used to construct a CoglOnscreenTemplate This removes the CoglSwapChain object and apis and adds a cogl_onscreen_template_set_has_alpha() api instead. Since we can't normally control exactly how long the swap chain is even if we have api to request a length this patch doesn't replace that capability. One thing to note here is that this removes the ability to request a single buffered CoglOnscreen framebuffer but since we have never had a use case for that and have not generally considered the implications of supporting single buffered rendering in Cogl's design it is probably for the best not to imply that it's supported. Reviewed-by: Neil Roberts <neil@linux.intel.com>
* display: add _set_onscreen_template() apiRobert Bragg2013-06-141-7/+25
| | | | | | | | | | Currently it's only possible to set an onscreen template on a CoglDisplay by passing a template to cogl_display_new(). For applications that want to deal with fallbacks then they may want to replace the onscreen template so this adds a cogl_display_set_onscreen_template() function. Reviewed-by: Neil Roberts <neil@linux.intel.com>
* Remove cogl-internal.hRobert Bragg2013-01-021-1/+0
| | | | | | | | | | This remove cogl-internal.h in favour of using cogl-private.h. Some things in cogl-internal.h were moved to driver/gl/cogl-util-gl-private.h and the _cogl_gl_error_to_string function whose prototype was moved from cogl-internal.h to cogl-util-gl-private.h has had its implementation moved from cogl.c to cogl-util-gl.c Reviewed-by: Neil Roberts <neil@linux.intel.com>
* Adds CoglError apiRobert Bragg2012-09-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although we use GLib internally in Cogl we would rather not leak GLib api through Cogl's own api, except through explicitly namespaced cogl_glib_ / cogl_gtype_ feature apis. One of the benefits we see to not leaking GLib through Cogl's public API is that documentation for Cogl won't need to first introduce the Glib API to newcomers, thus hopefully lowering the barrier to learning Cogl. This patch provides a Cogl specific typedef for reporting runtime errors which by no coincidence matches the typedef for GError exactly. If Cogl is built with --enable-glib (default) then developers can even safely assume that a CoglError is a GError under the hood. This patch also enforces a consistent policy for when NULL is passed as an error argument and an error is thrown. In this case we log the error and abort the application, instead of silently ignoring it. In common cases where nothing has been implemented to handle a particular error and/or where applications are just printing the error and aborting themselves then this saves some typing. This also seems more consistent with language based exceptions which usually cause a program to abort if they are not explicitly caught (which passing a non-NULL error signifies in this case) Since this policy for NULL error pointers is stricter than the standard GError convention, there is a clear note in the documentation to warn developers that are used to using the GError api. Reviewed-by: Neil Roberts <neil@linux.intel.com>
* display: inc cogl-wayland-server.h if neededRobert Bragg2012-08-061-0/+3
| | | | | | | 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.
* Switch use of primitive glib types to c99 equivalentsRobert Bragg2012-04-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* fix cogl_context_new crash if fail to connect rendererRobert Bragg2012-04-111-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add -Wmissing-declarations to maintainer flags and fix problemsNeil Roberts2012-03-061-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Remove all internal includes of cogl.hRobert Bragg2012-02-201-1/+0
| | | | | | | | | | | 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>
* Start to reduce dependence on glibRobert Bragg2011-11-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | Since we've had several developers from admirable projects say they would like to use Cogl but would really prefer not to pull in gobject,gmodule and glib as extra dependencies we are investigating if we can get to the point where glib is only an optional dependency. Actually we feel like we only make minimal use of glib anyway, so it may well be quite straightforward to achieve this. This adds a --disable-glib configure option that can be used to disable features that depend on glib. Actually --disable-glib doesn't strictly disable glib at this point because it's more helpful if cogl continues to build as we make incremental progress towards this. The first use of glib that this patch tackles is the use of g_return_val_if_fail and g_return_if_fail which have been replaced with equivalent _COGL_RETURN_VAL_IF_FAIL and _COGL_RETURN_IF_FAIL macros. Reviewed-by: Neil Roberts <neil@linux.intel.com>
* display: always ensure we have an onscreen_templateRobert Bragg2011-09-051-0/+2
| | | | | | | | | If the user doesn't explicitly pass an onscreen template then instead of leaving display->onscreen_template as NULL we now instantiate a template ourselves. This simplifies winsys code that might want to refer to the template since it needn't first check for a NULL pointer. Reviewed-by: Neil Roberts <neil@linux.intel.com>
* display: Add an accessor to get the renderer out of a displayDamien Lespiau2011-09-051-0/+6
| | | | | | https://bugzilla.gnome.org/show_bug.cgi?id=657347 Reviewed-by: Robert Bragg <robert@linux.intel.com>
* egl: Make sure to free the underlying egl objects when the display is freedDamien Lespiau2011-07-291-6/+15
| | | | | | | | | | | | | | | | If the display has been setup up, we should destroy the underlying objects that the winsys has created. This can be done by calling the winsys->destroy_display() function in _free. Then, in that function, and for the NULL and GDL EGL platform we can destroy the surface we have created in the setup_display() function (through create_context()). This allows to have clutter create a "dummy" display in cogl_renderer_check_onscreen_template(), then free it, then recreate the context and the surface that will be the final ones. https://bugzilla.gnome.org/show_bug.cgi?id=655355
* egl-gdl: Provide defaults to be able to initialize a "dummy" contextDamien Lespiau2011-07-291-0/+4
| | | | | | | | If we are being called without any GDL specific call (either the plane we want to render to or the swap chain length) we can provide sane defaults to still be able to create a context and a surface. https://bugzilla.gnome.org/show_bug.cgi?id=655355
* egl-gdl: struct gdl_plane never was a valid typeDamien Lespiau2011-07-291-1/+1
| | | | | | The enum for the planes is called gdl_plant_id_t. https://bugzilla.gnome.org/show_bug.cgi?id=655355
* Dynamically load the GL or GLES libraryNeil Roberts2011-07-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The GL or GLES library is now dynamically loaded by the CoglRenderer so that it can choose between GL, GLES1 and GLES2 at runtime. The library is loaded by the renderer because it needs to be done before calling eglInitialize. There is a new environment variable called COGL_DRIVER to choose between gl, gles1 or gles2. The #ifdefs for HAVE_COGL_GL, HAVE_COGL_GLES and HAVE_COGL_GLES2 have been changed so that they don't assume the ifdefs are mutually exclusive. They haven't been removed entirely so that it's possible to compile the GLES backends without the the enums from the GL headers. When using GLX the winsys additionally dynamically loads libGL because that also contains the GLX API. It can't be linked in directly because that would probably conflict with the GLES API if the EGL is selected. When compiling with EGL support the library links directly to libEGL because it doesn't contain any GL API so it shouldn't have any conflicts. When building for WGL or OSX Cogl still directly links against the GL API so there is a #define in config.h so that Cogl won't try to dlopen the library. Cogl-pango previously had a #ifdef to detect when the GL backend is used so that it can sneakily pass GL_QUADS to cogl_vertex_buffer_draw. This is now changed so that it queries the CoglContext for the backend. However to get this to work Cogl now needs to export the _cogl_context_get_default symbol and cogl-pango needs some extra -I flags to so that it can include cogl-context-private.h
* Add internal _cogl_init() functionRobert Bragg2011-06-301-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a _cogl_init function for Cogl that we expect to be the first thing called before anything else is done with Cogl. It's not a public API so it's expected that all entry points for Cogl that might be the first function used should call _cogl_init(). We currently call _cogl_init() in these functions: cogl_renderer_new cogl_display_new cogl_context_new cogl_android_set_native_window _cogl_init() can be called multiple times, and only the first call has any affect. For example _cogl_init() gives us a place check and parse the COGL_DEBUG environment variable. Since we don't have any need to parse command line arguments (we can always get user configuration options from the environment) our init function doesn't require argc/argv pointers. By saying up front that we aren't interested in command line arguments that means we can avoid the mess that is GOption based library initialization which is extremely fragile due to its lack of dependency tracking between modules. Signed-off-by: Neil Roberts <neil@linux.intel.com>
* Adds _cogl_wayland_texture_2d_new_from_buffer APIRobert Bragg2011-06-011-0/+10
| | | | | | | | This adds internal API to be able to wrap a wayland buffer as a CoglTexture2D. There is a --enable-wayland-egl-server option to decide if Cogl should support this feature and potentially any EGL based winsys could support this through the EGL_KHR_image_base and EGL_WL_bind_display extensions.
* Make stub winsys into a proper winsys backendRobert Bragg2011-06-011-4/+0
| | | | | | | | | | Instead of the stub winsys being a special case set of #ifdef'd code used when COGL_HAS_FULL_WINSYS wasn't defined, the stub winsys now implements a CoglWinsysVtable like all other winsys backends (it's just that everything is a NOP). This way we can get rid of the COGL_HAS_FULL_WINSYS define and also the stub winsys can be runtime selected whereas before it was incompatible with all other winsys backends.
* EGL: Updates GDL platform supportRobert Bragg2011-05-051-0/+12
| | | | | | | The GDL API is used for example on intel ce4100 (aka Sodaville) based systems as a way to allocate memory that can be composited using the platforms overlay hardware. This updates the Cogl EGL winsys and the support in Clutter so we can continue to support these platforms.
* Add a vtable of indirection to the winsys codeRobert Bragg2011-05-051-1/+13
| | | | | | | So that we can dynamically select what winsys backend to use at runtime we need to have some indirection to how code accesses the winsys instead of simply calling _cogl_winsys* functions that would collide if we wanted to compile more than one backend into Cogl.
* Moves all GLX code down from Clutter to CoglRobert Bragg2011-04-111-0/+5
| | | | | | | | This migrates all the GLX window system code down from the Clutter backend code into a Cogl winsys. Moving OpenGL window system binding code down from Clutter into Cogl is the biggest blocker to having Cogl become a standalone 3D graphics library, so this is an important step in that direction.
* Adds renderer,display,onscreen-template and swap-chain stubsRobert Bragg2011-04-111-0/+106
As part of the process of splitting Cogl out as a standalone graphics API we need to introduce some API concepts that will allow us to initialize a new CoglContext when Clutter isn't there to handle that for us... The new objects roughly in the order that they are (optionally) involved in constructing a context are: CoglRenderer, CoglOnscreenTemplate, CoglSwapChain and CoglDisplay. Conceptually a CoglRenderer represents a means for rendering. Cogl supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are accessed through a number of different windowing APIs such as GLX, EGL, SDL or WGL and more. Potentially in the future Cogl could render using D3D or even by using libdrm and directly banging the hardware. All these choices are wrapped up in the configuration of a CoglRenderer. Conceptually a CoglDisplay represents a display pipeline for a renderer. Although Cogl doesn't aim to provide a detailed abstraction of display hardware, on some platforms we can give control over multiple display planes (On TV platforms for instance video content may be on one plane and 3D would be on another so a CoglDisplay lets you select the plane up-front.) Another aspect of CoglDisplay is that it lets us negotiate a display pipeline that best supports the type of CoglOnscreen framebuffers we are planning to create. For instance if you want transparent CoglOnscreen framebuffers then we have to be sure the display pipeline wont discard the alpha component of your framebuffers. Or if you want to use double/tripple buffering that requires support from the display pipeline. CoglOnscreenTemplate and CoglSwapChain are how we describe our default CoglOnscreen framebuffer configuration which can affect the configuration of the display pipeline. The default/simple way we expect most CoglContexts to be constructed will be via something like: if (!cogl_context_new (NULL, &error)) g_error ("Failed to construct a CoglContext: %s", error->message); Where that NULL is for an optional "display" parameter and NULL says to Cogl "please just try to do something sensible". If you want some more control though you can manually construct a CoglDisplay something like: display = cogl_display_new (NULL, NULL); cogl_gdl_display_set_plane (display, plane); if (!cogl_display_setup (display, &error)) g_error ("Failed to setup a CoglDisplay: %s", error->message); And in a similar fashion to cogl_context_new() you can optionally pass a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to just do something sensible. If you need to change the CoglOnscreen defaults you can provide a template something like: chain = cogl_swap_chain_new (); cogl_swap_chain_set_has_alpha (chain, TRUE); cogl_swap_chain_set_length (chain, 3); onscreen_template = cogl_onscreen_template_new (chain); cogl_onscreen_template_set_pixel_format (onscreen_template, COGL_PIXEL_FORMAT_RGB565); display = cogl_display_new (NULL, onscreen_template); if (!cogl_display_setup (display, &error)) g_error ("Failed to setup a CoglDisplay: %s", error->message);