summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* stash: Adds outline of drm driver based on SNA codewip/drm-driverRobert Bragg2012-12-06106-4/+22849
|
* texture: Adds cogl_texture_set_data convenience apiRobert Bragg2012-12-062-0/+88
| | | | | | | This adds a cogl_texture_set_data function that is basically just a convenience wrapper around cogl_texture_set_region. In the common case where you want to upload the full contents of a mipmap level though this api takes 4 less arguments (6 in total) so it's a bit simpler.
* texture: remove unused cogl_texture_get_max_wasteRobert Bragg2012-12-0611-80/+0
| | | | | | This removes cogl_texture_get_max_waste which wasn't used internally anywhere and it doesn't really seem like a meaningful thing for applications to query.
* Allow lazy texture storage allocationRobert Bragg2012-12-0628-328/+522
| | | | | | | | | | | | | Consistent with how we lazily allocate framebuffers this patch allows us to instantiate textures but still specify constraints and requirements before allocating storage so that we can be sure to allocate the most appropriate/efficient storage. This adds a cogl_texture_allocate() function that is analogous to cogl_framebuffer_allocate() which can optionally be called to gracefully catch any errors with texture allocation but if this function isn't used explicitly then Cogl will implicitly ensure textures are allocated before the storage is needed.
* texture: add width/height members to base CoglTextureRobert Bragg2012-12-0618-228/+104
| | | | | | | There was a lot of redundancy in how we tracked the width and height of different texture types which is greatly simplified by adding width and height members to CoglTexture directly and removing the get_width and get_height vfuncs from CoglTextureVtable
* Move _cogl_texture_get_gl_format to -texture-gl.cRobert Bragg2012-12-0610-17/+17
| | | | | This moves the _cogl_texture_get_gl_format function from cogl-texture.c to cogl-texture-gl.c and renames it _cogl_texture_gl_get_format.
* framebuffer: move last use of GL into -framebuffer-gl.cRobert Bragg2012-12-069-363/+414
| | | | | | | This moves the last direct use of GL in cogl-framebuffer.c for handling cogl_framebuffer_read_pixels_into_bitmap() into driver/gl/cogl-framebuffer-gl.c and adds a ->framebuffer_read_pixels_into_bitmap vfunc to CoglDriverVtable.
* Remove cogl-internal.hRobert Bragg2012-12-0552-213/+152
| | | | | | | | 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
* remove reference to cogl 1.x api in cogl.hRobert Bragg2012-12-051-8/+1
| | | | | | There were some section headers in cogl.h referring to the 1.x api vs the 2.x api which aren't meaningful anymore since master only relates to the 2.x api.
* matrix-stack: make CoglMatrixStack publicRobert Bragg2012-12-0517-421/+964
| | | | | | | | | | We have found several times now when writing code using Cogl that it would really help if Cogl's matrix stack api was public as a utility api. In Rig for example we want to avoid redundant arithmetic when deriving the matrices of entities used to render and we aren't able to simply use the framebuffer's matrix stack to achieve this. Also when implementing cairo-cogl we found that it would be really useful if we could have a matrix stack utility api.
* matrix-stack: only maintain composite_gets in debug buildsRobert Bragg2012-12-042-1/+9
| | | | | | | | | | | | | At times there can be huge numbers of CoglMatrixEntry structures allocated if they are being used to track the transform of many drawing commands or objects in a scenegraph. Therefore the size of a CoglMatrixEntry should be kept as small as possible both to help reduce the memory usage of applications but also to improve cache usage since matrix stack manipulations are performance critical at times. This reduces the size of CoglMatrixEntry structures for non-debug builds by removing the composite_gets counter used to sanity check how often the transform for an entry is resolved.
* matrix-stack: move pointer to top of CoglMatrixEntryRobert Bragg2012-12-041-1/+1
| | | | | | This moves the parent pointer member to the top of the CoglMatrixEntry structure since it will lead to wasted padding when we build for 64bit cpus.
* matrix-stack: getting parent ptr before freeingRobert Bragg2012-12-041-1/+5
| | | | | | | | When unrefing a CoglMatrixEntry we walk up the ancestry unrefing and freeing entries until we find an entry that doesn't need to be freed. The problem fixed by this patch was that we didn't dereference the parent member of each entry until after the entry was freed and so there was the potential for reading a junk parent pointer back.
* journal: don't call cogl_attribute_buffer_new with NULLRobert Bragg2012-12-041-1/+1
| | | | | | It is considered an error to pass a NULL data pointer to cogl_attribute_buffer_new so we now call cogl_attribute_buffer_new_with_size instead.
* x11: Remove cogl_xlib_{get,set}_display()Damien Lespiau2012-12-033-52/+0
| | | | | | | | These functions have been replaced by equivalent functions on the renderer. Note that cogl_xlib_set_display() was a no-op anyway as _cogl_xlib_display was never used.
* x11: Replace all internal usage of cogl_xlib_get_display()Damien Lespiau2012-12-032-9/+19
| | | | And use the renderer replacement, cogl_xlib_renderer_get_display()
* Fix handling of binding errors when uploading a full textureNeil Roberts2012-11-284-10/+31
| | | | | | | | | Both the texture drivers weren't handling errors correctly when a CoglPixelBuffer was used to set the contents of an entire texture. This was causing it to hit an assertion failure in the pixel buffer tests. Reviewed-by: Robert Bragg <robert@linux.intel.com>
* Simplify test-pixel-bufferNeil Roberts2012-11-282-206/+207
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | test-pixel-buffer previously had two tests, one to check filling the pixel buffer by mapping it and another to fill it by just setting the data. These tests were set up in a kind of confusing way where it would try to paint both steps and then validate them together using colors looked up from a table. This patch separates out the two tests and gets rid of the tables which hopefully makes them a bit easier to follow. The contents of the bitmap are now set to an image with has a different colour for each of its four quadrants instead of just a single colour in the hope that this will be a bit more of an extensive test. The old code had a third test that was commented out. This test has been removed. The textures are now created using cogl_texture_2d_new_* which means they won't be in the atlas. This exposes a bug where setting the entire contents of the texture won't handle errors properly and it will hit an assertion. The previous code using the atlas would end up only setting a sub-region of the larger atlas texture so the bug wouldn't be hit. To make sure we still test this code path there is now a third test which explicitly sets a sub-region of the texture using the bitmap. Reviewed-by: Robert Bragg <robert@linux.intel.com>
* Adds test-texture-mipmap-get-set testRobert Bragg2012-11-273-0/+178
| | | | | This adds a conformance test to check that cogl_texture_set_region() works when uploading to mipmap levels greater than 0.
* tests: port test-texture-get-set-data to be standaloneRobert Bragg2012-11-273-49/+24
| | | | | This ports the test-texture-get-set-data clutter test to be a standalone Cogl test.
* texture: expose mipmap level in set region apisRobert Bragg2012-11-2730-259/+597
| | | | | | | | | | | | | | | cogl_texture_set_region() and cogl_texture_set_region_from_bitmap() now have a level argument so image data can be uploaded to a specific mipmap level. The prototype for cogl_texture_set_region was also updated to simplify the arguments. The arguments for cogl_texture_set_region_from_bitmap were reordered to be consistent with cogl_texture_set_region with the source related arguments listed first followed by the destination arguments. Reviewed-by: Neil Roberts <neil@linux.intel.com>
* replace public cogl_flush with _cogl_framebuffer_flushRobert Bragg2012-11-2722-106/+61
| | | | | | | | | | | | | | | | | | This removes the cogl_flush() api which depends on a global Cogl context and provides a more specific _cogl_framebuffer_flush() instead. This new function isn't public since we don't currently see a use for this api for applications. (The previously documented use for cogl_flush() to allow applications to intermix direct GL and cogl usage was missleading and wouldn't have worked for intermixing drawing commands. Intermixing GL to create objects such as textures doesn't require any flush api) Since there are a few places internally where we do actually need to flush *all* framebuffer journals we keep an equivalent to cogl_flush() renamed to _cogl_flush() which now takes a CoglContext pointer. cogl1-context.h has now been removed since there was nothing left in it. Reviewed-by: Neil Roberts <neil@linux.intel.com>
* atlas-texture: remove some use of _COGL_GET_CONTEXTRobert Bragg2012-11-275-93/+105
| | | | | | | | | This removes several uses of _COGL_GET_CONTEXT in cogl-atlas-texture.c. Notably this involved making CoglPangoGlyphCache track an associated CoglContext pointer which cogl-pango can pass to _cogl_atlas_texture_new_with_size(). Reviewed-by: Neil Roberts <neil@linux.intel.com>
* glx: avoid use of _COGL_GET_CONTEXT()Robert Bragg2012-11-271-26/+13
| | | | | | Removes some (not all) use of _COGL_GET_CONTEXT() from cogl-winsys-glx.c Reviewed-by: Neil Roberts <neil@linux.intel.com>
* onscreen: remove unused _cogl_onscreen_newRobert Bragg2012-11-272-31/+0
| | | | Reviewed-by: Neil Roberts <neil@linux.intel.com>
* framebuffer: remove use of _COGL_GET_CONTEXTRobert Bragg2012-11-271-2/+1
| | | | Reviewed-by: Neil Roberts <neil@linux.intel.com>
* journal: don't reference global contextRobert Bragg2012-11-271-28/+19
| | | | | | This removes all use of _COGL_GET_CONTEXT from cogl-journal.c Reviewed-by: Neil Roberts <neil@linux.intel.com>
* error: Don't allocate a new CoglError when propagatingNeil Roberts2012-11-272-3/+16
| | | | | | | | | | | | | | | | | | The _cogl_propagate_error() function takes ownership of the incoming error pointer so there's no need to allocate a new error when passing it on. The errors can potentially be passed up from a number of layers so it seems worthwhile to avoid the allocation. The _cogl_propagate_gerror() function was previously using _cogl_propagate_error(). Presumably this would not have worked because that function would try to free the error from glib using cogl_error_free but that would use the wrong free function and thus the wrong slice allocator. The GError propagating function is only used when gdk-pixbuf is enabled which now requires glib support anyway so we can just avoid defining the function when compiling without glib. Reviewed-by: Robert Bragg <robert@linux.intel.com>
* Fix spelling of _cogl_propagate_errorNeil Roberts2012-11-279-13/+13
| | | | | | ‘Propagate’ was misspelled as ‘propogate’. Reviewed-by: Robert Bragg <robert@linux.intel.com>
* framebuffer: remove framebuffer stackRobert Bragg2012-11-2610-422/+0
| | | | | | | The framebuffer stack is no longer used internally and all public apis that require framebuffers takes explicit framebuffer pointers. Reviewed-by: Neil Roberts <neil@linux.intel.com>
* blit: avoid referring to framebuffer stackRobert Bragg2012-11-267-94/+97
| | | | | | | | | | | This make _cogl_framebuffer_blit take explicit src and dest framebuffer pointers and updates all the texture blitting strategies in cogl-blit.c to avoid pushing/popping to/from the the framebuffer stack. The removes the last user of the framebuffer stack which we've been aiming to remove before Cogl 2.0 Reviewed-by: Neil Roberts <neil@linux.intel.com>
* moves some gl texture code too cogl-texture-gl.cRobert Bragg2012-11-2614-88/+160
| | | | | | | | This adds a driver/gl/cogl-texture-gl.c file and moves some gl specific bits from cogl-texture.c into it. The moved symbols were also given a _gl_ infix and the calling code was updated accordingly. Reviewed-by: Neil Roberts <neil@linux.intel.com>
* Make cogl_texture_draw_and_read_to_bitmap publicRobert Bragg2012-11-263-32/+51
| | | | | | | | | | | | | | | This makes the internal api _cogl_texture_draw_and_read public as cogl_texture_draw_and_read_to_bitmap() so that applications can manually use this api to handle fallbacks when it's not possible to directly read a textures contents. The intention is to no longer automatically render and read-back textures as a fallback on drivers that don't support glGetTexImage2D since this fallback depends on the idea of a current framebuffer which we'd like to get rid of and there is no feedback that the contents of the framebuffer have been destroyed if the fallback is hit. Reviewed-by: Neil Roberts <neil@linux.intel.com>
* matrix-stack: init cache->flippedRobert Bragg2012-11-261-0/+1
| | | | | | | This ensures we initialize the value of cache->flipped in _cogl_matrix_entry_cache_init() Reviewed-by: Neil Roberts <neil@linux.intel.com>
* bitmap: ret CoglError from _new_with_malloc_bufferRobert Bragg2012-11-267-14/+64
| | | | | | | | _cogl_bitmap_new_with_malloc_buffer() now takes a CoglError for throwing exceptional errors and all callers have been updated to pass through any application error pointer as appropriate. Reviewed-by: Neil Roberts <neil@linux.intel.com>
* texture: split out high-level texture constructorsRobert Bragg2012-11-2616-325/+423
| | | | | | | | | | | | This splits out the very high level texture constructors that may internally construct one of several types of lower level texture due to various constraints. This also updates the prototypes for these constructors to take an explicit context pointer and return a CoglError consistent with other texture constructors. Reviewed-by: Neil Roberts <neil@linux.intel.com>
* atlas: catch _create_texture errorsRobert Bragg2012-11-261-2/+6
| | | | | | | | | Previously we were passing NULL to cogl_texture_2d_new_{from_bitmap,with_size} so if there was an error the application would be aborted. This ensures we pass an internal CoglError so errors can be caught and suppressed instead. Reviewed-by: Neil Roberts <neil@linux.intel.com>
* Allow propogation of OOM errors to appsRobert Bragg2012-11-2660-914/+1727
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Check for out-of-memory when allocating 3d texturesRobert Bragg2012-11-261-9/+21
| | | | | | | | | | | | This makes Cogl explicitly check for out-of-memory errors reported by the opengl driver in cogl_texture_3d_new_with_size() calls. This allows us to throw a COGL_SYSTEM_ERROR_NO_MEMORY error and return NULL so applications may gracefully handle this condition. This patch only affects the cogl_texture_3d_new_with_size() api not _new_from_data() or _new_from_bitmap(). Reviewed-by: Neil Roberts <neil@linux.intel.com>
* Check for out-of-memory when allocating 2d texturesRobert Bragg2012-11-264-2/+116
| | | | | | | | | | | | This makes Cogl explicitly check for out-of-memory errors reported by the opengl driver in cogl_texture_2d_new_with_size() calls. This allows us to throw a COGL_SYSTEM_ERROR_NO_MEMORY error and return NULL so applications may gracefully handle this condition. This patch only affects the cogl_texture_2d_new_with_size() api not _new_from_data() or _new_from_bitmap(). Reviewed-by: Neil Roberts <neil@linux.intel.com>
* Fixes for --disable-glibNeil Roberts2012-11-2676-200/+173
| | | | | | | | | | | | | | | | | | | | | | This fixes some problems which were stopping --disable-glib from working properly: • A lot of the public headers were including glib.h. This shouldn't be necessary because the API doesn't expose any glib types. Otherwise any apps would require glib in order to get the header. • The public headers were using G_BEGIN_DECLS. There is now a replacement macro called COGL_BEGIN_DECLS which is defined in cogl-types.h. • A similar fix has been done for G_GNUC_NULL_TERMINATED and G_GNUC_DEPRECATED. • The CFLAGS were not including $(builddir)/deps/glib which was preventing it finding the generated glibconfig.h when building out of tree. Reviewed-by: Robert Bragg <robert@linux.intel.com>
* configure: Don't allow --enable-gdk-pixbuf with --disable-glibNeil Roberts2012-11-261-71/+70
| | | | | | | | | | | | | | | | | | | | | | The GDK pixbuf support requires being able to propagate errors from GDKPixbuf as GErrors. This won't work if we are using the builtin version of GLib because any attempt to call g_error_free from within Cogl will use the internal version which will free the error using the wrong slice allocator. It probably doesn't make much sense to build without glib but with gdk-pixbuf so there's not much point in trying to work around this situation. Previously if you specified --enable-gdk-pixbuf but gdk-pixbuf was not available it would silently disable it. This pach also fixes it so that it will report an error in that case. If --enable-gdk-pixbuf is not specified it will now default to enabling it only if both glib is enabled and gdk-pixbuf is available. This patch looks slightly longer than it ought to be because it moves the check for glib up to above the descisions about the image backend. Reviewed-by: Robert Bragg <robert@linux.intel.com>
* Add cogl_sdl_onscreen_get_window()Neil Roberts2012-11-263-0/+34
| | | | | | | This adds a function to get a pointer to the SDL_Window associated with a CoglOnscreen when using the SDL2 winsys. Reviewed-by: Robert Bragg <robert@linux.intel.com>
* cogl-gles2-context: Cast func pointers to void* when fillingChun-wei Fan2012-11-241-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | vtable (Sorry, I had to re-apply Neil's patch as the original one somehow did not apply) The function prototypes for the GL functions in CoglContext have the GLAPIENTRY attribute which on Windows makes them use the stdcall calling convention. The function pointers exposed from cogl-gles2.h don't have GLAPIENTRY so they end up having a different calling convention on Windows. When Cogl is compiled there it ends up giving a lot of warnings because it assigns a pointer to an incompatible function type. We probably don't want to make the functions exposed in cogl-gles2.h use the stdcall calling convention because we control that API so there is no need to introduce a second calling convention. The GLES2 context support currently isn't going to work on Windows anyway because there is no EGL or GLES2 implementation. Eventually if we make the Cogl GLES2 context virtualized on top of Cogl then we will provide our own implementations of all these functions so we can easily keep the C calling convention even on Windows. Until then to avoid the warnings on Windows we can just cast the function pointers temporarily to (void*) when filling in the vtable. This will also fix the build on Windows using Visual Studio, as it is more picky on calling convention mismatches. Reviewed-by: Robert Bragg <robert@linux.intel.com>
* sdl: Don't set SDL_GL_DOUBLEBUFFER when the swap chain has no prefNeil Roberts2012-11-232-4/+6
| | | | | | | | | | | | | | | | | | | | | | | The ‘length’ for the swap chain is initially -1 which is supposed to mean ‘no preference’. However, both of the SDL winsys's were explicitly setting the SDL_GL_DOUBLEBUFFER attribute to zero in that case which would try to disable double buffering. On OS X, the equivalent to eglSwapBuffers (ie, [NSOpenGLContext flushBuffer]) does nothing for a single buffer context. The cogl-sdl-hello example does not specify the swap chain length so presumably it would end up with a single buffer config. When cogl_onscreen_swap_buffers is called it therefore does nothing and nothing is painted. I guess to make single-buffered contexts actually useful we should expose some public equivalent to glFlush so that you can ensure the rendering commands will actually hit the buffer. Alternatively we could document that cogl_onscreen_swap_buffers performs this task on single-buffered configs and then we could make the SDL winsys explicitly call glFlush in that case. Reviewed-by: Robert Bragg <robert@linux.intel.com>
* Add a conformance test using alpha texturesNeil Roberts2012-11-233-0/+126
| | | | | | | | This adds a conformance test with an alpha-component texture. The texture is rendered using a pipeline with the same layer combine mode as cogl-pango. Reviewed-by: Robert Bragg <robert@linux.intel.com>
* Use GL_ARB_texture_swizzle to emulate GL_ALPHA texturesNeil Roberts2012-11-2310-71/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The core profile of GL3 has removed support for component-alpha textures. Previously the GL3 driver would just ignore this and try to create them anyway. This would generate a GL error on Mesa. To fix this the GL texture driver will now create a GL_RED texture when GL_ALPHA textures are not supported natively. It will then set a texture swizzle using the GL_ARB_texture_swizzle extension so that the alpha component will be taken from the red component of the texture. The swizzle is part of the texture object state so it only needs to be set once when the texture is created. The ‘gen’ virtual function of the texture driver has been changed to also take the internal format as a parameter. The GL driver will now set the swizzle as appropriate here. The GL3 driver now reports an error if the texture swizzle extension is not available because Cogl can't really work properly without out it. The extension is part of GL 3.3 so it is quite likely that it has wide support from drivers. Eventually we could get rid of this requirement if we have our own GLSL front-end and we could generate the swizzle ourselves. When uploading or downloading texture data to or from a component-alpha texture, we can no longer rely on GL to do the conversion. The swizzle doesn't have any effect on the texture data functions. In these cases Cogl will now force an intermediate buffer to be used and it will manually do the conversion as it does for the GLES drivers. Reviewed-by: Robert Bragg <robert@linux.intel.com>
* Remove the pipeline layer user matrixNeil Roberts2012-11-2120-520/+23
| | | | | | | | | | | | | | | | | | | | The pipeline layer user matrix is not used very often and the way it is currently implemented comes at a non-trivial cost. Any pipeline layer that requires the big state needs to have a CoglMatrix added to its state. The generated vertex shader will always multiply the coordinates by the matrix even if it is just the identity matrix. The same functionality can be achieved on programmable hardware using a shader snippet. The snippet hook for the texture coordinate transform is still available to make this convenient. If we later decide that this is a really useful feature for fixed function hardware then we can add it back in and try to make it work more efficiently. In the meantime however it seems like a good idea to get rid of the API now before Cogl 2.0 is released and the API becomes fixed. Reviewed-by: Robert Bragg <robert@linux.intel.com>
* sdl: Support setting resizable before allocate in SDL 1Neil Roberts2012-11-201-1/+9
| | | | | | | | The SDL 1 winsys now checks for the initial resizable state of the onscreen framebuffer when it is allocated and updates the video flags accordingly. Reviewed-by: Robert Bragg <robert@linux.intel.com>
* Fix flushing the stencil viewport clipping workaroundNeil Roberts2012-11-202-14/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | There were two problems with the stencil viewport clip workaround introduced in afc5daab8: • When the viewport is changed the current clip state is not marked as dirty. That means that when the framebuffer state is next flushed it would continue to use the stencil from the previous viewport. • When the viewport is automatically updated due to the window being resized the viewport age was not incremented so the clip state wouldn't be flushed. I noticed the bugs by running cogl-sdl2-hello. This patch makes it so that the clip state is dirtied in cogl_framebuffer_set_viewport if the workaround is enabled. The automatic viewport changing code now just calls cogl_framebuffer_set_viewport instead of directly prodding the viewport values. This has the side-effect that it will also cause the journal to be flushed. This seems like the right thing to do anyway and presumably there would have been a bug before where it wouldn't have flushed the journal, although presumably this is extremely unlikely because it would have to have done a resize in the middle of painting the scene. Reviewed-by: Robert Bragg <robert@linux.intel.com>