test-gles2-context was giving a warning because printf was being used
without including stdio.h. This changes it to use g_print and to first
check for g_test_verbose().
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 9f4945e3daa693e1aa56fe4c1ce37fcc545f8558)
The cogl-gles2-gears example will fail to build unless
--enable-cogl-gles2 is enabled in the configure script because it
depends on libcogl-gles2. This patch makes it only conditionally build
the example depending on the BUILD_COGL_GLES2 automake conditional.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 7f57e9c444b6353ac17e920ea4fc63ebe3cc29d3)
This adds a new renderer constraint enum:
COGL_RENDERER_CONSTRAINT_SUPPORTS_GLES2_CONTEXT
that can be used by applications to ensure the renderer they connect to
has support for creating a GLES2 context via cogl_gles2_context_new().
The cogl-gles2-context and cogl-gles2-gears examples and the conformance
tests have been updated to use this constraint.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit ed61463d7194354b26624e8014859f0fbfc06a12)
This adds a conformance test that creates a GLES2 context via the cogl
api and verifies clearing an offscreen framebuffer via the gles2 api,
and switching back and forth between the Cogl and GLES2 apis.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 9369c60a596c0cbc7a8bb9a45d7b8ffb6a848311)
This adds an example of using libcogl-gles2 as a way to port existing
GLES 2.0 based code. This is a port of es2gears in the Mesa demos repo.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit fcb947178858e9d675c5f76e50510282c6b0bf8d)
This adds a library that can be used instead of libGLESv2.so to provide
symbols for the GLES 2.0 api. This can be used for convenience when
using the cogl_gles2_context_ api since you don't need to manually go
through a CoglGLES2Vtable when calling the gles2 api so it should be
easier to port existing gles2 code to integrate with Cogl.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 80d7599a2acefca7d01d8d7de9df524278ef72c5)
This makes it possible to integrate existing GLES2 code with
applications using Cogl as the rendering api.
Currently all GLES2 usage is handled with separate GLES2 contexts to
ensure that GLES2 api usage doesn't interfere with Cogl's own use of
OpenGL[ES]. The api has been designed though so we can provide tighter
integration later.
The api would allow us to support GLES2 virtualized on top of an
OpenGL/GLX driver as well as GLES2 virtualized on the core rendering api
of Cogl itself. Virtualizing the GLES2 support on Cogl will allow us to
take advantage of Cogl debugging facilities as well as let us optimize
the cost of allocating multiple GLES2 contexts and switching between
them which can both be very expensive with many drivers.
As as a side effect of this patch Cogl can also now be used as a
portable window system binding API for GLES2 as an alternative to EGL.
Parts of this patch are based on work done by Tomeu Vizoso
<tomeu.vizoso@collabora.com> who did the first iteration of adding GLES2
API support to Cogl so that WebGL support could be added to
webkit-clutter.
This patch adds a very minimal cogl-gles2-context example that shows how
to create a gles2 context, clear the screen to a random color and also
draw a triangle with the cogl api.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 4bb6eff3dbd50d8fef7d6bdbed55c5aaa70036a8)
This updates test-atlas-migration from being a Clutter-based test to a
Cogl-based test.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 32c5a3ed546effd2e2946f22f173a20cf36b2fdf)
This fixes a bug in _cogl_pipeline_flush_color_blend_alpha_depth_state
whereby we were only calling flush_depth_state if we knew that at least
depth testing was enabled. This didn't take into account that enabling
and disabling depth writing is a useful change to make even if depth
testing is disabled. It also seemed a bit messy to flush the
depth-testing enable separately from the other depth state.
_cogl_pipeline_flush_color_blend_alpha_depth_state now simply calls
flush_depth_state() if there is a _DEPTH_STATE difference and
flush_depth_state() also handles flushing the depth-testing enable
in along with all the other depth state.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 6a9dfc55b8f55d7023cb592e5bef2118d0f3d50c)
This ensures that when we initialize a CoglOnscreenTemplate that
->swap_throttled is set to TRUE so by default Cogl applications should
have their swap buffer requests throttled to the vblank frequency.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit bdac9ab56284fb84ec09af176c7e31c44dc1bfc6)
This detects when we are running on any of Mesa's software rasterizer
backends and disables use of glBlitFramebuffer and glXCopySubBuffer.
Both of these currently result in full-screen copies so there's little
point in using these to optimize how much of the screen we present.
To help ensure we re-evaluate this workaround periodically we have added
a comment marker of "ONGOING BUG" above the workaround and added a note
to our RELEASING document that says we should grep for this marker and
write a NEWS section about ongoing bug workarounds.
https://bugzilla.gnome.org/show_bug.cgi?id=674208
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 11f2f6ebb42398978ec8dd92b3c332ae8140a728)
The GPU info api previously told us a driver package name and a driver
vendor name, but now we have introduced detection for the gpu
architecture too and started to track architecture feature flags that
can tell us whether a gpu is a deferred or immediate mode renderer for
example or if a software rasterizer is being used.
This also adds support for checking more vendor names. We should now
detect the following cases:
Vendors: Intel, Imagination Technologies, ARM, Qualcomm, Nvidia, ATI
Architectures: Sandybridge, SGX, Mali
Architecture flags:
- vertex tiled
- vertex immediate mode
- vertex software
- fragment deferred
- fragment immediate mode
- fragment software
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit b3803a0a7c9e663ed219e83626841895c7d95ad7)
Tell people that they need to get a stdint.h implementation for Visual C++
2008 for use with Cogl-master/1.99.x+, and where they can obtain such an
implementation.
This is not needed for Visual C++ 2010 as it ships with stdint.h by
default.
(cherry picked from commit 938d70b78d672dd07e7124f7573d17d3e3079365)
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)
-Create a pre-defined cogl/cogl-gl-header.h(.win32) that is to be used on
any Windows builds, and adapt the MSVC build process to set up and use
that file.
-Fix up glib-mkenums code generation .bat file that is generated during
"make"/"make dist", like the autotools-based builds.
-Since cogl/cogl-defines.h now contain versionioning info, and it no longer
directly includes the GL headers, update the pre-configured
cogl-defines.h[.win32|.win32_SDL] and use autotools to fill in the
versioning info during "make"/"make dist".
-Fix up cogl/cogl-pango.rc.in so that they reflect the cogl-2.x versioning
stuff correctly and versioning info can be filled in correctly during
"make"/"make dist"
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 7ff42bb1c5280b0f53370f8d94ef5f10c9f39e2f)
Clearly from a copy and paste from init_from_y_rotation().
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 2f06f4d79e29bbf30a44edbf48e8eaa637e30930)
cogl_framebuffer_{get,set}_point_samples_per_pixel() have lost the
'point_' part.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 3c8bcf391090ad0c5f65f300458bfc901fd62800)
The API is now gone, so cogl-clipping.xml is not generated.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit ff3956c25676c898948c5c7239c85154564c0e16)
Several little changes were needed to make the CoglEuler documentation
appear:
• Fix the embeded docbook snippet in the CoglEuler section header
• Add the xinclude directive to the main document
• Add the missing <SECTION> in -sections.txt
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit c7f6e07f7b8ba0d7dc9604e888c8a46165ec3ed4)
Update SDL build configs as there are now SDL-specific public APIs and
new SDL sources.
(cherry picked from commit 006f9f7c44136fc8524649fb790da7f19cd0dc4d)
This allows people to initialize a matrix with a translation
transformation. The options to do it at the moment were:
* init_from_array() but it give cogl no information about the type of
matrix.
* init_indentity() and then translate() but it means doing a lot of
computations for no reason.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 068b3b59221e405dc288d434b0008464684a7c12)
The stock 1.2.x version of SDL only supports regular OpenGL. The
version on WebOS is specially patched to add some extra API to request
a GLES1 or GLES2 context. This patch adds a configure check to detect
when Cogl is being built with the patched version of SDL. In that case
it will additionally allow the gles1 and gles2 drivers and set the
right video mode attributes to get the corresponding context.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 3726c60deab2bd94617a562abb63f735627a25e4)
This fixes a few problems that occur when only using a GLES2 header.
• The use of GL_CLAMP_TO_BORDER and GL_MIRRORED_REPEAT were moved from
cogl-pipelinelayer-state.h to cogl-sampler-cache-private.h but the
corresponding defines were not.
• cogl-sampler-cache.c was using GL_TEXTURE_WRAP_R but this is only
defined as GL_TEXTURE_WRAP_R_OES from the GLES2 header so it needs a
#define.
• cogl-framebuffer-private.h uses GLuint but it does not include
cogl-gl-header.h. It gets away with this when GLX support is enabled
because the GL header would be included via glx.h.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 9cdb87c864fc262c4b26c13963670d60d7c18058)
The function to convert the CoglBufferUpdateHint to a GL enum was
previously ifdef'd to only use GL_STREAM_DRAW when Cogl is compiled
with big GL support. One problem with this is that it would end up
trying to use it on GLES1 if support for both is compiled. The other
problem is that GLES2 seems to actually support GL_STREAM_DRAW so we
might as well use it in that case.
This patch also changes it so that if the hint is stream with GLES1
then it will default to GL_DYNAMIC_DRAW instead of GL_STATIC_DRAW
because I think that is closer to the meaning of the stream hint.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 9e997476a7f9271bc000abdc82b1e343b92afb4c)
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)
cogl-handle.h was being listed in the sources but it has been removed
so the dist would not work.
Also the micro-perf directory under tests was not listed in
DIST_SUBDIRS so it would be skipped.
This patch was written by Rico Tzschichholz.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit fb96716aaffd72a00461ce4dd8496904de0bb1ff)
Cogl has feature flags for basic npot texture support and then separate
flags for npot + repeat and npot + mipmap. If those three features are
available then there is a feature for full-npot support too for
convenience. The cogl_texture_2d_new_ constructors were checking for
full npot support and failing if not available but since we expose the
fine grained features to the user the user should be able to check the
limitations of npot textures and still choose to allocate them.
_cogl_texture_2d_can_create() now only checks for basic npot support
when creating a npot texture. Since this change also affects the
automagic cogl_texture_ constructors they now check for basic npot +
mipmap support before considering using a Texture2D.
Notably the cogl_texture_ constructors will try constructing a Texture2D
even if we don't have npot + repeat support since the alternative is a
sliced texture which will need manual repeating anyway. Accordingly the
Texture2D::can_hardware_repeat and ::transform_quad_coords_to_gl vfuncs
have been made aware of the npot + repeat feature flag.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 6f6c5734d076372d98d0ec331b177ef7d65aa67d)
This adds a version header which contains macros to define which
version of Cogl the application is being compiled against. This helps
applications that want to support multiple incompatible versions of
Cogl at compile time.
The macros are called COGL_VERSION_{MAJOR,MINOR,MICRO}. This does not
match Clutter which names them CLUTTER_{MAJOR,MINOR,MICRO}_VERSION but
I think the former is nicer and it at least matches Cairo and Pango.
The values of the macro are defined to COGL_VERSION_*_INTERNAL which
is generated by the configure script into cogl-defines.h.
There is also a macro for the entire version as a string called
COGL_VERSION_STRING.
The internal utility macros for encoding a 3 part version number into
a single integer have been moved into the new header so they can be
used publicly as a convenient way to check if the version is within a
particular range. There is also a COGL_VERSION_CHECK macro for the
very common case that a feature will be used since a particular
version of Cogl. There is a macro called COGL_VERSION which contains
the pre-encoded version of Cogl being compiled against for
convenience.
Unlike in Clutter this patch does not add any runtime version
identification mechanism.
A test case is also added which just contains static asserts to sanity
check the macros.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 3480cf140dc355fa87ab3fbcf0aeeb0124798a8f)
When uploading the vertices the journal calls _cogl_matrix_entry_get()
to get a CoglMatrix for each journal entry so that it can so a software
transform. Since _cogl_matrix_entry_get() can be a performance hot-spot
and since it's trivial to keep track of the last CoglMatrixEntry seen we
now avoid repeatedly calling _cogl_matrix_entry_get() for sequential
entries with the same transform.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 70cad61533316e2303b8e188f2f361701dfb0c61)
This re-designs the matrix stack so we now keep track of each separate
operation such as rotating, scaling, translating and multiplying as
immutable, ref-counted nodes in a graph.
Being a "graph" here means that different transformations composed of
a sequence of linked operation nodes may share nodes.
The first node in a matrix-stack is always a LOAD_IDENTITY operation.
As an example consider if an application where to draw three rectangles
A, B and C something like this:
cogl_framebuffer_scale (fb, 2, 2, 2);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_translate (fb, 10, 0, 0);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_rotate (fb, 45, 0, 0, 1);
cogl_framebuffer_draw_rectangle (...); /* A */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_draw_rectangle (...); /* B */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_set_modelview_matrix (fb, &mv);
cogl_framebuffer_draw_rectangle (...); /* C */
cogl_framebuffer_pop_matrix(fb);
That would result in a graph of nodes like this:
LOAD_IDENTITY
|
SCALE
/ \
SAVE LOAD
| |
TRANSLATE RECTANGLE(C)
| \
SAVE RECTANGLE(B)
|
ROTATE
|
RECTANGLE(A)
Each push adds a SAVE operation which serves as a marker to rewind too
when a corresponding pop is issued and also each SAVE node may also
store a cached matrix representing the composition of all its ancestor
nodes. This means if we repeatedly need to resolve a real CoglMatrix
for a given node then we don't need to repeat the composition.
Some advantages of this design are:
- A single pointer to any node in the graph can now represent a
complete, immutable transformation that can be logged for example
into a journal. Previously we were storing a full CoglMatrix in
each journal entry which is 16 floats for the matrix itself as well
as space for flags and another 16 floats for possibly storing a
cache of the inverse. This means that we significantly reduce
the size of the journal when drawing lots of primitives and we also
avoid copying over 128 bytes per entry.
- It becomes much cheaper to check for equality. In cases where some
(unlikely) false negatives are allowed simply comparing the pointers
of two matrix stack graph entries is enough. Previously we would use
memcmp() to compare matrices.
- It becomes easier to do comparisons of transformations. By looking
for the common ancestry between nodes we can determine the operations
that differentiate the transforms and use those to gain a high level
understanding of the differences. For example we use this in the
journal to be able to efficiently determine when two rectangle
transforms only differ by some translation so that we can perform
software clipping.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit f75aee93f6b293ca7a7babbd8fcc326ee6bf7aef)
This adds a very minimal and fast allocator for chunks of memory of a
predetermined size. This has some similarities to the glib slice
allocator although notably it is not thread safe and instead of
internally tracking multiple magazines for various sized allocations the
api lets you explicitly allocate a single magazine for a single specific
size and a pointer to the magazine is passed explicitly to the allocate
and free functions.
This allocator builds on the CoglMemoryStack allocator as an underlying
heap allocator and just never rewinds the stack. This means the heap is
effectively a grow only linked list of malloc()'d blocks of memory.
A CoglMagazine tracks a singly linked list of chunks of a predetermined
size and _cogl_magazine_chunk_alloc() simply unlinks and returns the
head of the list. If the list is empty it falls back to allocating from
the underlying stack.
_cogl_magazine_chunk_free() links the chunk back into the singly linked
list for re-use.
The chunk size passed to _cogl_magazine_new() is automatically rounded
to a multiple of 8 bytes to ensure that all stack allocations end up
aligned to 8 bytes. This also ensures that when a chunk is freed then it
will be large enough to store a pointer to the next free chunk as part
of a singly linked list.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 17799c2f109a008d6cf767f501b81aa9b32bbda8)
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)
This makes the test-cogl-perf test from clutter into a standalone Cogl
benchmark.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 1684a040b238ebae140e827f4003f2d2867c04f3)
Since 5967dad2400d32c we have stopped using glib types such as guint16
and guint32 in favour of the equivalent c99 types such as uint16_t and
uint32_t. When that patch was tested we must have used a configuration
that just happened to include <stdint.h> because we have since seen that
builds can fail due to missing c99 typedefs. This patch explicitly
includes stdint.h in cogl-types.h.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit c1e2220a4314071482d2d5638688b6bcf83882a2)
The check for whether the compiler supports _Static_assert didn't work
properly because the AC_TRY_COMPILE function puts the source
definition in its own main function. The test therefore ends up
declaring a nested main function which GCC allows. If _Static_assert
isn't available then it just looks like an implicit declaration of a
function which only causes a warning in GCC so it would still compile.
This patch changes it to use AC_COMPILE_IFELSE instead. This macro
makes it possible to specify the complete source code so
_Static_assert can be called from the global scope. AC_LANG_PROGRAM is
used to generate the program. For extra aesthetics it now also
generates a 'checking for...' message while the script is running.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 9657938c3083a782234e1e9f05ab5ae88a6bc5ab)
The existing functions for stroking and filling a path depend on the
global framebuffer and source stacks. These are now replaced with
cogl_framebuffer_{stroke,fill}_path which get explicitly passed the
framebuffer and pipeline.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 713a8f8160bc5884b091c69eb7a84b069e0950e6)
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)