summaryrefslogtreecommitdiff
path: root/cogl/cogl-memory-stack.c
Commit message (Collapse)AuthorAgeFilesLines
* This re-licenses Cogl 1.18 under the MIT licenseRobert Bragg2014-02-221-12/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since the Cogl 1.18 branch is actively maintained in parallel with the master branch; this is a counter part to commit 1b83ef938fc16b which re-licensed the master branch to use the MIT license. This re-licensing is a follow up to the proposal that was sent to the Cogl mailing list: 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. This patch was not simply cherry-picked from master; but the same methodology was used to check the source files.
* Don't dereference an unitialised pointer in _cogl_container_ofNeil Roberts2014-02-201-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation was dereferencing the sample pointer in order to get the offset to subtract from the member pointer. The resulting value is then only used to get a pointer to the member in order to calculate the offset so it doesn't actually read from the memory location and shouldn't cause any problems. However this is probably technically invalid and could have undefined behaviour. It looks like clang takes advantage of this undefined behaviour and doesn't actually offset the pointer. It also generates a warning when it does this. This patch splits the _cogl_container_of macro into two implementations. Previously the macro was always used in the list iterator macros like this: SomeType *sample = _cogl_container_of(list_node, sample, link) Instead of doing that there is now a new macro called _cogl_list_set_iterator which explicitly assigns to the sample pointer with an initial value before assigning to it again with the real offset. This redundant initialisation gets optimised out by compiler. The second macro is still called _cogl_container_of but instead of taking a sample pointer it just directly takes the type name. That way it can use the standard offsetof macro. https://bugzilla.gnome.org/show_bug.cgi?id=723530 Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit 1efed1e0a2bce706eb4901979ed4e717bb13e4e2)
* Use the Wayland embedded linked list implementation instead of BSD'sNeil Roberts2013-06-131-20/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes cogl-queue.h and adds a copy of Wayland's embedded list implementation. The advantage of the Wayland model is that it is much simpler and so it is easier to follow. It also doesn't require defining a typedef for every list type. The downside is that there is only one list type which is a doubly-linked list where the head has a pointer to both the beginning and the end. The BSD implementation has many more combinations some of which we were taking advantage of to reduce the size of critical structs where we didn't need a pointer to the end of the list. The corresponding changes to uses of cogl-queue.h are: • COGL_STAILQ_* was used for onscreen the list of events and dirty notifications. This makes the size of the CoglContext grow by one pointer. • COGL_TAILQ_* was used for fences. • COGL_LIST_* for CoglClosures. In this case the list head now has an extra pointer which means CoglOnscreen will grow by the size of three pointers, but this doesn't seem like a particularly important struct to optimise for size anyway. • COGL_LIST_* was used for the list of foreign GLES2 offscreens. • COGL_TAILQ_* was used for the list of sub stacks in a CoglMemoryStack. • COGL_LIST_* was used to track the list of layers that haven't had code generated yet while generating a fragment shader for a pipeline. • COGL_LIST_* was used to track the pipeline hierarchy in CoglNode. The last part is a bit more controversial because it increases the size of CoglPipeline and CoglPipelineLayer by one pointer in order to have the redundant tail pointer for the list head. Normally we try to be very careful about the size of the CoglPipeline struct. Because CoglPipeline is slice-allocated, this effectively ends up adding two pointers to the size because GSlice rounds up to the size of two pointers. Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit 13abf613b15f571ba1fcf6d2eb831ffc6fa31324) Conflicts: cogl/cogl-context-private.h cogl/cogl-context.c cogl/driver/gl/cogl-pipeline-fragend-glsl.c doc/reference/cogl-2.0-experimental/Makefile.am
* stack: don't deref freed mem in _cogl_memory_stack_freeRobert Bragg2012-08-061-3/+2
| | | | | | | | | 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)
* Don't typedef CoglMemoryStack twiceNeil Roberts2012-08-061-2/+2
| | | | | | | | | | | | | | | 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)
* Adds internal CoglMemoryStack utility APIRobert Bragg2012-08-061-0/+188
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)