Commit Graph

22 Commits

Author SHA1 Message Date
Robert Bragg
f53fb5e2e0 Allow propogation of OOM errors to apps
This allows apps to catch out-of-memory errors when allocating textures.

Textures can be pretty huge at times and so it's quite possible for an
application to try and allocate more memory than is available. It's also
very possible that the application can take some action in response to
reduce memory pressure (such as freeing up texture caches perhaps) so
we shouldn't just automatically abort like we do for trivial heap
allocations.

These public functions now take a CoglError argument so applications can
catch out of memory errors:

cogl_buffer_map
cogl_buffer_map_range
cogl_buffer_set_data
cogl_framebuffer_read_pixels_into_bitmap
cogl_pixel_buffer_new
cogl_texture_new_from_data
cogl_texture_new_from_bitmap

Note: we've been quite conservative with how many apis we let throw OOM
CoglErrors since we don't really want to put a burdon on developers to
be checking for errors with every cogl api call. So long as there is
some lower level api for apps to use that let them catch OOM errors
for everything necessary that's enough and we don't have to make more
convenient apis more awkward to use.

The main focus is on bitmaps and texture allocations since they
can be particularly large and prone to failing.

A new cogl_attribute_buffer_new_with_size() function has been added in
case developers need to catch OOM errors when allocating attribute buffers
whereby they can first use _buffer_new_with_size() (which doesn't take a
CoglError) followed by cogl_buffer_set_data() which will lazily allocate
the buffer storage and report OOM errors.

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

(cherry picked from commit f7735e141ad537a253b02afa2a8238f96340b978)

Note: since we can't break the API for Cogl 1.x then actually the main
purpose of cherry picking this patch is to keep in-line with changes
on the master branch so that we can easily cherry-pick patches.

All the api changes relating stable apis released on the 1.12 branch
have been reverted as part of cherry-picking this patch so this most
just applies all the internal plumbing changes that enable us to
correctly propagate OOM errors.
2013-01-22 17:48:07 +00:00
Robert Bragg
8326c71b6b texture: rename texobj flush code as gl specific
This renames the set_filters and set_wrap_mode_parameters texture
virtual functions to gl_flush_legacy_texobj_filters and
gl_flush_legacy_texobj_wrap_modes respectively to clarify that they are
opengl driver specific and that they are only used to support the legacy
opengl apis for setting filters and wrap modes where the state is
associated with texture objects instead of being associated with sampler
objects.

This part of an effort to clearly delimit our abstraction over opengl so
that we can start to consider non-opengl backends for Cogl.

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

(cherry picked from commit 6f78b8a613340d7c6b736e51a16c625f52154430)
2013-01-22 17:47:58 +00:00
Robert Bragg
df21e20f65 Adds CoglError api
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>

(cherry picked from commit b068d5ea09ab32c37e8c965fc8582c85d1b2db46)

Note: Since we can't change the Cogl 1.x api the patch was changed to
not rename _error_quark() functions to be _error_domain() functions and
although it's a bit ugly, instead of providing our own CoglError type
that's compatible with GError we simply #define CoglError to GError
unless Cogl is built with glib disabled.

Note: this patch does technically introduce an API break since it drops
the cogl_error_get_type() symbol generated by glib-mkenum (Since the
CoglError enum was replaced by a CoglSystemError enum) but for now we
are assuming that this will not affect anyone currently using the Cogl
API. If this does turn out to be a problem in practice then we would be
able to fix this my manually copying an implementation of
cogl_error_get_type() generated by glib-mkenum into a compatibility
source file and we could also define the original COGL_ERROR_ enums for
compatibility too.

Note: another minor concern with cherry-picking this patch to the 1.14
branch is that an api scanner would be lead to believe that some APIs
have changed, and for example the gobject-introspection parser which
understands the semantics of GError will not understand the semantics of
CoglError. We expect most people that have tried to use
gobject-introspection with Cogl already understand though that it is not
well suited to generating bindings of the Cogl api anyway and we aren't
aware or anyone depending on such bindings for apis involving GErrors.
(GnomeShell only makes very-very minimal use of Cogl via the gjs
bindings for the cogl_rectangle and cogl_color apis.)

The main reason we have cherry-picked this patch to the 1.14 branch
even given the above concerns is that without it it would become very
awkward for us to cherry-pick other beneficial patches from master.
2013-01-22 17:47:39 +00:00
Robert Bragg
13f228fe69 Remove all remaining _EXP suffix defines
To delimit which symbols were considered experimental we used to use
some preprocessor defines to gives experimental symbols an _EXP suffix
so that anyone monitoring the ABI for changes would easily be able to
discount changes made to clearly experimental functions.

These days we simply rely on the gtk-doc "Stability: unstable"
annotation to serve this purpose because changing the actual symbol name
made it slightly more awkward to debug Cogl using GDB and was an extra
mechanical step we decided we could do without.

This patch removes the last remaining _EXP suffix defines in Cogl

(cherry picked from commit 5a1c4a979e00accd492097cfb8f6a8d0fd8331bc)
2013-01-18 10:53:29 +00:00
Chun-wei Fan
fefa6bc929 cogl.symbols: Add symbols required for Clutter 1.12
Those symbols were missed and are needed for Clutter-1.12.x to build.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-11-24 00:01:40 +08: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
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
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
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
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
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
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
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
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
364dae7e1f Update cogl.symbols
-For the snippets APIs.
-For the introduction of the cogl_matrix_orthographic(_EXP) API.
-Also for the new attribute and framebuffer APIs
2011-12-07 16:54:04 +08:00
Chun-wei Fan
2055f6ba91 VS 2008/2010 project files to build Cogl
These are the VS 2008/2010 project files to build Cogl, with a README.txt
to explain the process involved.

Note that the Cogl and Cogl-Pango projects (and filters for VS2010) are
expanded with the correct source file listings during "make dist", which
is done to simplify maintenance of these project files.

-added preconfigured config.h(.win32.in), which is expanded with the
 correct versioining info during autogen
-added preconfigued cogl/cogl-defines.h.win32
-added symbols files for cogl and cogl-pango
-Have configure.ac expand the config.h.win32.in into config.h.win32
 with the correct versioning info, etc, and to include the Visual C++
 project files for distribution
-Added rules in cogl/Makefile.am to expand the cogl VS 2008/2010 projects
 and filters from the templates with up-to-date source file listings, to
 distribute cogl-enum-types.c, cogl-enum-types.h to ease compilation and
 to avoid depending on PERL on Windows installations.
-Added rules in cogl-pango/Makefile.am to expand the cogl-pango VS2008/
 2010 projects and filters from the templates with up-to-date source file
 listings.
-Added/edited various Makefile.am's in build to distribute the VS2008/2010
 project files and associated items required for the build.
-Update .gitignore. There needs to be a pre-configured
 config.h(.win32) and its template, config.h.win32.in for Visual C++
 builds

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

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-11-25 13:12:45 +00:00