summaryrefslogtreecommitdiff
path: root/cogl/cogl-pipeline-layer.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.
* texture: make cogl_texture_get_format api privateRobert Bragg2014-01-091-1/+1
| | | | | | | | | | | | | | | | | | | CoglPixelFormat is not a good way of describing the internal format of a texture because it's too specific given that we don't actually have exact knowledge of the internal format used by the driver. This makes cogl_texture_get_format private and in the future we'll provide a better way of querying the channels and their precision. Reviewed-by: Neil Roberts <neil@linux.intel.com> (cherry picked from commit ffde82981f22bd0185a7f33e1e6e1479f4c295b8) Note: Since we can't break API compatibility on the 1.x branch this adds a cogl/deprecated/cogl-texture-deprecated.c file with a cogl_texture_get_format() wrapper around the private api. This also moves the cogl_texture_get_rowstride() and cogl_texture_ref/unref() functions that were previously deprecated into cogl-texture-deprecated.c
* Use the Wayland embedded linked list implementation instead of BSD'sNeil Roberts2013-06-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Use a GList instead of a BSD list for CoglPipelineSnippetListNeil Roberts2013-06-131-2/+2
| | | | | | | | | | | | Previously CoglPipelineSnippetList was using the BSD embedded list type with a mini struct to combine the list node with a pointer to the snippet. This is effectively equivalent to just using a GList so we might as well do that. This will help if we eventually want to get rid of cogl-queue.h Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit 54a168f3c7829c427d54ab517533bb9f7384d022)
* pipeline-cache: Use a special trimmed down pipeline for the keyNeil Roberts2013-04-041-0/+103
| | | | | | | | | | | | | | | | | | | | | | | | When a pipeline is added to the cache, a normal copy would previously be made to use as the key in the hash table. This copy keeps a reference to the real pipeline which means all of the resources it contains are retained forever, even if they aren't necessary to generate the hash. This patch changes it to create a trimmed down copy that only has the state necessary to generate the hash. A new function called _cogl_pipeline_deep_copy is added which makes a new pipeline that is directly a child of the root pipeline. It then copies over the pertinent state from the original pipeline. The pipeline state is copied using the existing _cogl_pipeline_copy_differences function. There was no equivalent function for the layer state so I have added one. That way the pipeline key doesn't have the texture data state and it doesn't hold a reference to the original pipeline so it should be much cheaper to keep around. Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit e27e01c1215e7e7c7c0183ded11dd769bb112c5c)
* pipeline: Don't notify the undefined progend of layer changesNeil Roberts2013-01-221-3/+22
| | | | | | | | | | | | When a layer changes before the pipeline has decided which progend to use it doesn't need to notify the progend of the change. This was causing it to crash. This patch makes that change and also simplifies the notification a bit by just making the calls directly instead of having three separate functions. Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit 2006ddd68ea6a5d53b5a810d8dbf39025d9ec04c)
* Switch use of primitive glib types to c99 equivalentsRobert Bragg2012-08-061-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* Use GL_ARB_sampler_objectsNeil Roberts2012-04-051-24/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* cogl-pipeline-layer: Use CoglTextureType instead of GL target enumNeil Roberts2012-02-131-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* snippet: Add a hook for the layer texture coordinate transformationNeil Roberts2011-12-061-0/+18
| | | | | | | | | | | This adds a hook called COGL_SNIPPET_HOOK_TEXTURE_COORD_TRANSFORM. This can be used to alter the application of the layer user matrix to a texture coordinate or it can bypass it altogether. This is the first per-layer hook that affects the vertex shader state so the patch includes the boilerplate needed to get that to work. Reviewed-by: Robert Bragg <robert@linux.intel.com>
* pipeline: Assume blend enabled when there are snippetsNeil Roberts2011-12-061-0/+7
| | | | | | | | Whenever snippets are enabled we can't determine whether the final color will be fully opaque so we just have to assume blending should be enabled. Reviewed-by: Robert Bragg <robert@linux.intel.com>
* pipeline: Add a snippet hook for the texture lookupNeil Roberts2011-12-061-0/+14
| | | | | | | | | | | | | | | This adds a per-layer snippet hook for the texure lookup. Here the snippet can modify the texture coordinates used for the lookup or modify the texel resulting from the lookup. This is the first per-layer hook so this also adds the COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS state and all of the boilerplate needed to make that work. Most of the functions used by the pipeline state to manage the snippet list has been moved into cogl-pipeline-snippet.c so that it can be shared with the layer state. Reviewed-by: Robert Bragg <robert@linux.intel.com>
* Start to reduce dependence on glibRobert Bragg2011-11-011-1/+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>
* pipeline-layer: fix win32 build issueRobert Bragg2011-11-011-0/+1
| | | | | | | make sure to #include "cogl-texture-private.h" in cogl-pipeline-layer.c otherwise the build fails on win32. Reviewed-by: Neil Roberts <neil@linux.intel.com>
* cogl-pipeline/cogl-pango: Added forgotten includesChun-wei Fan2011-09-261-0/+3
| | | | | | | | | It seems that cogl-context-private.h needs to be included before including any of the pipeline-related stuff to avoid build errors on C89 compilers. This is due to the recent cogl-pipeline decoupling, seems like. Reviewed-by: Robert Bragg <robert@linux.intel.com>
* pipeline: optimize _compare_differences functionsRobert Bragg2011-09-211-54/+44
| | | | | | | | | | | | | | | | This optimizes the layer and pipeline _compare_differences functions so neither of them use the GArray api since building up the list of ancestors by appending to a shared GArray was showing quite high on profiles due to how frequently pipeline comparisons are made. Instead we now build up a transient, singly linked list by allocating GList nodes via alloca to build up the parallel lists of ancestors. This tweaked approach actually ends up being a bit more concise than before, we avoid the overhead of the GArray api and now avoid making any function calls while comparing (assuming the _get_parent() calls always inline), we avoiding needing to get the default cogl context. Reviewed-by: Neil Roberts <neil@linux.intel.com>
* pipeline: Split more code out from cogl-pipeline.cRobert Bragg2011-09-211-0/+798
This splits out the core CoglPipelineLayer support code from cogl-pipeline.c into cogl-pipeline-layer.c; it splits out the debugging code for dumping a pipeline to a .dot file into cogl-pipeline-debug.c and it splits the CoglPipelineNode support which is shared between CoglPipeline and CoglPipelineLayer into cogl-node.c. Note: cogl-pipeline-layer.c only contains the layer code directly relating to CoglPipelineLayer objects; it does not contain any _cogl_pipeline API relating to how CoglPipeline tracks and manipulates layers.