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)
Removing CoglHandle has been an on going goal for quite a long time now
and finally this patch removes the last remaining uses of the CoglHandle
type and the cogl_handle_ apis.
Since the big remaining users of CoglHandle were the cogl_program_ and
cogl_shader_ apis which have replaced with the CoglSnippets api this
patch removes both of these apis.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 6ed3aaf4be21d605a1ed3176b3ea825933f85cf0)
Since the original patch was done after removing deprecated API
this back ported patch doesn't affect deprecated API and so
actually this cherry-pick doesn't remove all remaining use of
CoglHandle as it did for the master branch of Cogl.
This adds a _COGL_STATIC_ASSERT macro that can be used for compile time
assertions in C code. If supported by the compiler this macro uses
_Static_assert so that a message can be printed out if the assertion
fails.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 465b39a764f2720e77678cafa56acb0e69007ffd)
This splits the GL header inclusion from cogl-defines.h into a
separate headear called cogl-gl-header.h which we will only include
internally. That way we don't leak GL declarations out of our public
headers. The texture functions that were using GLenum and GLuint in
the public header have now changed to just use unsigned int. Note
however that if an EGL winsys is enabled then it will still publicly
include an EGL header. This is a bit more awkward to fix because we
have public API which returns an EGLDisplay and we can't determine
what type that is.
There is also a conformance test which just verifies that no GL header
has been included while compiling. The test isn't added to
test-conform-main because it doesn't actually test anything at
runtime.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit ef5680d3fda5df929dbd0b420c8f598ded58dfee)
This adds experimental 2.0 api replacements for the cogl_rectangle[_*]
functions that don't depend on having a current pipeline set on the
context via cogl_{set,push}_source() or having a current framebuffer set
on the context via cogl_push_framebuffer(). The aim for 2.0 is to switch
away from having a statefull context that affects drawing to having
framebuffer drawing apis that are explicitly passed a framebuffer and
pipeline.
To test this change several of the conformance tests were updated to use
this api instead of cogl_rectangle and
cogl_rectangle_with_texture_coords. Since it's quite laborious going
through all of the conformance tests the opportunity was taken to make
other clean ups in the conformance tests to replace other uses of
1.x api with experimental 2.0 api so long as that didn't affect what was
being tested.
This adds a conformance test which renders a texture point using a 2x2
texture with a different color for each texel. It then verifies that
each texel is mapped to the correct position on the point. The test is
currently failing.
The test requires the point sprite feature flag so this patch also
adds a TEST_REQUIREMENT_* flag for that.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This tries rendering some points at various sizes and checks that they
are the expected size and make a rectangle shape. This is currently
failing when the GLSL vertend is used because it flushes the point
size in the wrong place.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This renames the TestRequirement enum to TestFlags and then adds a
TEST_KNOWN_FAILURE flag. The rename is because the new flag is not
really a requirement. If the flag is set then the test is assumed to
always fail.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
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>
test-cogl-sub-texture was fixed to now run on GLES2 since commit
5928cade0b so this removes the TEST_REQUIREMENT_GL flag for this test
so it doesn't get flagged as an unexpected pass.
This adds a test similar to the test-read-texture-formats test but
that updates data on a 1x1 pixel RGBA texture instead. On GLES2 this
should end up testing all of the convesion code because in that case
GL only supports reading back RGBA data.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The test-read-alpha-texture test has been replaced with a test that
tries reading an RGBA texture in all current pixel formats. On GLES2
this should end up testing all of the convesion code because in that
case GL only supports reading back RGBA data. The test now works on
GLES2 since the conversion code for all of the formats has been added
so this also removes the GL requirement.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This just creates a 1x1 RGBA texture and then reads it back in
COGL_PIXEL_FORMAT_A_8 format. Gnome Shell is doing this to create a
shadow and I accidentally broke it so this should hopefully stop that
happening again.
https://bugzilla.gnome.org/show_bug.cgi?id=671016
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This patch reworks our conformance testing framework because it seems
that glib's gtesting framework isn't really well suited to our use case.
For example we weren't able to test windows builds given the way we
were using it and also for each test we'd like to repeat the test
with several different environments so we can test important driver and
feature combinations.
This patch instead switches away to a simplified but custom approach for
running our unit tests. We hope that having a more bespoke setup will
enable us to easily extend it to focus on the details important to us.
Notable changes with this new approach are:
We can now run 'make test' for our mingw windows builds.
We've got rid of all the test-*report* make rules and we're just left
with 'make test'
'make test' now runs each test several times with different driver and
feature combinations checking the result for each run. 'make test' will
then output a concise table of all of the results.
The combinations tested are:
- OpenGL Fixed Function
- OpenGL ARBfp
- OpenGL GLSL
- OpenGL No NPOT texture support
- OpenGLES 2.0
- OpenGLES 2.0 No NPOT texture support
Reviewed-by: Neil Roberts <neil@linux.intel.com>
When requesting the texture data to test that we get back what we
uploaded, we need to ask for it in a premult format otherwise it will
get converted and the test will fail. This was working for the GL
driver because of a bug where it would fail to do the conversion.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
As we move towards Cogl 2.0 we are aiming to remove the need for a
default global CoglContext and so everything should be explicitly
related to a context somehow. CoglPipelines are top level objects and
so this patch adds a context argument to cogl_pipeline_new().
Reviewed-by: Neil Roberts <neil@linux.intel.com>
We are in the process of removing all _EXP suffix mangling for
experimental APIs (Ref: c6528c4b6c) and adding missing gtk-doc
comments so that we can instead rely on the "Stability: unstable"
markers in the gtk-doc comments. This patch tackles the cogl-texture-3d
api symbols.
This patch also replaces use of CoglHandle with a CoglTexture3D type
instead.
Finally this patch also ensures the CoglTexture3D constructors take an
explicit CoglContext pointer but not a CoglTextureFlags argument,
consistent with other CoglTexture constructors.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This adds a utility function for inferring a CoglPixelFormat from a
set of channel masks, a bits-per-pixel value, a pixel-depth value and
pixel byte order.
This plan is to use this to improve how we map X visuals to Cogl pixel
formats.
This patch was based on some ideas from Damien Leone <dleone@nvidia.com>
https://bugzilla.gnome.org/show_bug.cgi?id=660188
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This adds a test for doing custom sampling using the cogl_sampler
variable in the texture lookup hook.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
There were lots of tests bundled into a single long function which was
becoming a bit unwieldy. It was also quite difficult to match up the
test's drawing with its color test. This patch just moves each little
sub test into its own function.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
There are currently quite a few places in Cogl where we muddle the
layer index and the texture unit number. The theory is that these two
numbers shouldn't be related and it should be possible to pick large
layer numbers with gaps.
This patch adds a test case to check that we can reference a large
layer number from a texture combine string by creating a pipeline with
only three layers but that have very large layer indices. This doesn't
currently work because Cogl interprets the numbers in the combine
strings to be the unit indices and not the layer indices. The
documentation however calls these numbers layer numbers so presumably
it is not meant to work that way.
There are probably many other bugs related to this that the test case
doesn't pick up so it would be good to add some more tests here, for
example to test that you can bind an attribute to the texture
coordinates for a large layer index.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The ARBfp fragend has a bug when the texture combine string references
another texture unit where it will use the texture type of the current
layer rather than the texture type of the layer the string refers to.
This patch adds a small test which demonstrates that.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
All CoglBuffer constructors now take an explicit CoglContext
constructor. This is part of the on going effort to adapt to Cogl API so
it no longer depends on a global, default context.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This adds cogl_framebuffer_ apis for drawing attributes and primitives
that replace corresponding apis that depend on the default CoglContext.
This is part of the on going effort to adapt the Cogl api so it no
longer depends on a global context variable.
All the new drawing functions also take an explicit pipeline argument
since we are also aiming to avoid being a stateful api like Cairo and
OpenGL. Being stateless makes it easier for orthogonal components to
share access to the GPU. Being stateless should also minimize any
impedance miss-match for those wanting to build higher level stateless
apis on top of Cogl.
Note: none of the legacy, global state options such as
cogl_set_depth_test_enabled(), cogl_set_backface_culling_enabled() or
cogl_program_use() are supported by these new drawing apis and if set
will simply be silently ignored.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This adds a little test which makes a copy of a CoglPrimitive and
verifies that all of the properties on the new primitive are the same
as the old one.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This adds an extra test to test-offscreen then ensures the offscreen
framebuffer for a texture automatically flushes its journal in the
following three situations:
1. cogl_read_pixels is called immediately when the offscreen buffer is
current.
2. cogl_texture_get_data is called on the offscreen's texture
immediately after rendering to it.
3. The texture is rendered to the screen and immediately read back
with cogl_read_pixels.
Currently the 2nd situation fails.
https://bugzilla.gnome.org/show_bug.cgi?id=668913
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The compare pixel function was a static function used internally by
the test_utils_check_* functions. It takes a pointer to a pixel in a
buffer read back from Cogl and compares it with an expected value.
This function could also be useful in tests wanting to check the data
returned from a call to cogl_texture_get_data so we should share it
with the rest of the tests.
https://bugzilla.gnome.org/show_bug.cgi?id=668913
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This makes the test launcher script pass on the exit code from the
conformance test as its own exit status. This makes using a particular
test with git bisect run easier.
https://bugzilla.gnome.org/show_bug.cgi?id=665190
Reviewed-by: Robert Bragg <robert@linux.intel.com>
When comparing a pixel, the comparison routines now allow each
component to be off by +/- 1. This is to compensate for varying
rounding across drivers.
https://bugzilla.gnome.org/show_bug.cgi?id=665723
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This verifies that the post strings are executed in the order they
were added to the pipeline and the post strings are executed in the
reverse order.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The test creates some pipelines with snippets with custom attributes
and uses CoglAttribute to define values for them.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
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>
Previously the function containing the default texture lookup is
always generated regardless of whether there is a snippet with a
replace string which would cause it not be used. Now this snippets are
all scanned to check for replace strings before generating the texture
lookup.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The loop that generates code for a list of snippets now starts from
the first snippet that has a replace string. Any snippets before that
would be ignored so there's no point in generating code for them.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Instead of specifying the hook point when adding to the pipeline using
a separate function for each hook, the hook is now a property of the
snippet. The hook is set on construction and is then read-only.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
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>
If present, the 'replace' string will be used instead of whatever code
would normally be invoked for that hook point. It will also replace
any previous snippets.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Each snippet is now given its own function which contains the pre and
post strings. Between these strings the function will chain on to
another function. The generated cogl source is now stored in a
function called cogl_generated_source() which the last snippet will
chain on to. This should make it so that each snippet has its own
namespace for local variables and it can share variables declared in
the pre string in the post string. Hopefully the GLSL compiler will
just inline all of the functions so it shouldn't make much difference
to the compiled output.
Reviewed-by: Robert Bragg <robert@linux.intel.com>