Previously when adding a quad to the journal it would assume the
journal belongs to the framebuffer at the top of the framebuffer stack
and store a reference to that. We eventually want to get rid of the
framebuffer stack so we should avoid using it here. The journal now
takes a pointer back to the framebuffer in its constructor and it
always retains the pointer. As was done previously, the journal still
does not take a reference on the framebuffer unless it is non-empty so
it does not create a permanent circular reference.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
_cogl_shader_compile_real spews a warning when
shader compilation fails if COGL_GL_DEBUG is
defined. This warning is never freed.
https://bugzilla.gnome.org/show_bug.cgi?id=672243
Reviewed-by: Neil Roberts <neil@linux.intel.com>
The 1.0 wrapper for cogl_path_curve_to was using the wrong value for
y_1 so it wouldn't work.
The patch was written by Dénes Almási.
https://bugzilla.gnome.org/show_bug.cgi?id=672174
Reviewed-by: Neil Roberts <neil@linux.intel.com>
We initially assumed that copy_sub_buffer is synchronized on
which is only the case for a subset of GPUs for example it is not
synchronized on INTEL gen6 and gen7, so we remove this assumption
for now.
We should have a specific driver / GPU whitelist if we want to enable
this.
https://bugzilla.gnome.org/show_bug.cgi?id=669122
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>
None of the other cogl_is_blah functions have a const pointer so this
is just for consistency. It helps if someone is trying to have an
array of type-check function pointers to determine the Cogl object
type because in that case all of the functions would have to have the
same prototype.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This creates a CoglBitmap which points into an existing buffer in
system memory. That way it can be used to create a texture or to read
pixel data into. The function replaces the existing internal function
_cogl_bitmap_new_from_data but removes the destroy notify call back.
If the application wants notification of destruction it can just use
the cogl_object_set_user_data function as normal. Internally there is
now a convenience function to create a bitmap for system memory and
automatically free the buffer using that mechanism.
The name of the function is inspired by
cairo_image_surface_create_for_data which has similar semantics.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
On GLES, when reading texture data back it may need to allocate a
temporary CoglBitmap if the requested format is not supported by the
driver. Previously it would then copy this temporary buffer back into
the user's buffer by calling _cogl_bitmap_convert which would allocate
a second temporary buffer. It would then copy that data into the
user's buffer. This patch changes it to create a CoglBitmap which
points to the user's data and then convert directly into that buffer
using the new _cogl_bitmap_convert_into_bitmap.
This also fixes a small leak where target_bmp would not get freed if
the target format and the closest supported format do match.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The 2.0 API for querying features (cogl_has_feature etc) does not
conflict with the old 1.0 API (cogl_features_available) so we might as
well enable it when the experimental API is requested without
requesting the 2.0-only API.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The if-undefined fallback declaration for GL_PACK_INVERT_MESA was
originally added in cogl.c along with code to use it (as part of commit
6f79eb8a5a). Later on, commit
10a38bb14f moved the code that used it to
cogl-framebuffer.c but didn't move the define along with it. Do that
now.
https://bugzilla.gnome.org/show_bug.cgi?id=672038
Reviewed-by: Neil Roberts <neil@linux.intel.com>
-Removed checks for COGL_ENABLE_EXPERIMENTAL_API since these APIs are
always built into the shared library
-Re-organised the API listing a bit so that they are in alphabetical order
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This API was re-added into COGL for the 1.10.x release as of commit
361bd516f. This will be removed once we branch into the 1.11.x development
cycle.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
If the matrix was reallocated we would use values from the stack
for the matrix parameters. This fixes that and also uses the
function instead of out of lining the same code.
https://bugzilla.gnome.org/show_bug.cgi?id=671985
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This is only used internally when debugging is enabled to give a
human-readable name to a GL error so we shouldn't be exporting it
outside of the library. This just adds an underscore to the symbol
name. This shouldn't end up removing any public symbols from the 1.9.8
release because by default a non-git build disables debug so it wasn't
exported anyway.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The cleanup in 185630085 removed some symbols that were previously
exported as public experimental API in Cogl 1.9.8. That release is
already well after the point where we were meant to freeze the ABI so
we probably shouldn't be breaking it again. This patch adds the
removed functions back in so that for 1.9.10 we won't have to bump the
soname. The symbols are bundled together in a new file called
cogl2-compatibility.c so that they will be easy to remove again after
we can break ABI. It is expected that we will revert this patch
immediately after branching for Cogl 1.10.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
I don't think there's really any point in this cache because the
pipeline code completely owns the point size state. Pipelines are
already compared for whether their point size state is different
before setting it so it shouldn't result in any extra calls to
glPointSize apart from maybe when the first pipeline is initially
flushed.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
When using the GLSL vertend on GL, the point size was being flushed in
_cogl_pipeline_vertend_glsl_start. However, this function bails out
early if the pipeline already has a usable program so it would not hit
the code to flush the point size in that case. This patch moves the
code to _cogl_pipeline_vertend_glsl_end so that it will always be
flushed if it is different. That is the same place that is flushed for
the fixed vertend.
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>
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-wayland-renderer api symbols.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
Some of the state when flushing a pipeline depends on the current
framebuffer being used. These are:
• The matrix stack, so that it can flip vertically or not depending on
whether the framebuffer is offscreen.
• The colormask. This is combined with the framebuffer's color mask.
• The cull face mode. If the framebuffer is offscreen then backface
culling is translated to frontface culling and vice-versa.
These states were not working if the new framebuffer draw_primitive
API was used because in that case the framebuffer is not pushed to the
framebuffer stack so it would use the wrong one. This patch changes it
to use ctx->current_draw_buffer which is a pointer to the framebuffer
whose state was last flushed.
https://bugzilla.gnome.org/show_bug.cgi?id=670793
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This adds a small cogl_bitmap_get_buffer public function. Note that
this can return NULL if the bitmap was not created with a pixel
buffer. It might be nice to change this eventually so that all bitmaps
have a pixel buffer.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The idea is that CoglPixelBuffer should just be a buffer that can be
used for pixel data and it has no idea about the details of any images
that are stored in it. This is analogous to CoglAttributeBuffer which
itself does not have any information about the attributes. When you
want to use a pixel buffer you should create a CoglBitmap which points
to a region of the attribute buffer and provides the extra needed
information such as the width, height and format. That way it is also
possible to use a single CoglPixelBuffer with multiple bitmaps.
The changes that are made are:
• cogl_pixel_buffer_new_with_size has been removed and in its place is
cogl_bitmap_new_with_size. This will create a pixel buffer at the
right size and rowstride for the given width/height/format and
immediately create a single CoglBitmap to point into it. The old
function had an out-parameter for the stride of the image but with
the new API this should be queriable from the bitmap (although there
is no function for this yet).
• There is now a public cogl_pixel_buffer_new constructor. This takes
a size in bytes and data pointer similarly to
cogl_attribute_buffer_new.
• cogl_texture_new_from_buffer has been removed. If you want to create
a texture from a pixel buffer you should wrap it up in a bitmap
first. There is already API to create a texture from a bitmap.
This patch also does a bit of header juggling because cogl-context.h
was including cogl-texture.h and cogl-framebuffer.h which were causing
some circular dependencies when cogl-bitmap.h includes cogl-context.h.
These weren't actually needed in cogl-context.h itself but a few other
headers were relying on them being included so this adds the #includes
where necessary.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This adds a public function to read pixels from a framebuffer into a
CoglBitmap. This replaces the internal function
_cogl_read_pixels_with_rowstride because a CoglBitmap contains a
rowstride so it can be used for the same purpose. A CoglBitmap already
has public API to make one that points to a CoglPixelBuffer so this
function can be used to read pixels into a PBO. It also avoids the
need to push the framebuffer on to the context's stack so it provides
a function which can be used in the 2.0 API after the stack is
removed.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Whenever the buffer is bound with _cogl_buffer_bind Cogl now ensures
the buffer's data store has been created. Previously it would only
ensure it was created when it was first mapped or when the first data
was set on it. This is necessary if we are going to use CoglBuffers
for retrieving data from GL. In that case the buffer won't be mapped
or have data set on it before it is used.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
If the fast-path inplace premult conversion can't be used then it will
now fallback to unpacking the buffer into a row of guint16s and use
the generic conversion.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This adds _cogl_bitmap_convert_into_bitmap which is the same as
_cogl_bitmap_convert except that it writes into an existing bitmap
instead of allocating a new one. _cogl_bitmap_convert now just
allocates a buffer and calls the new function. This is used in
_cogl_read_pixels to avoid allocating a second intermediate buffer
when the pixel format to store in is not GL_RGBA.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
If we are going to unpack the data into a known format anyway we might
as well do the premult conversion instead of delaying it to do
in-place. This helps because not all formats with alpha channels are
handled by the in-place premult conversion code. This removes the
_cogl_bitmap_convert_format_and_premult function so that now
_cogl_bitmap_convert is a completely general purpose function that can
convert from anything to anything. _cogl_bitmap_convert now includes a
fast path for when the base formats are the same and the premult
conversion can be handled with the in-place code so that we don't need
to unpack and can just copy the bitmap instead.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Previously the bitmap code was setup so that there could be an image
library used to convert between formats and then some 'fallback' code
when the image library can't handle the conversion. However there was
never any implementation of the conversion in the image library so the
fallback was always used. I don't think this split really makes sense
so this patch renames cogl-bitmap-fallback to cogl-bitmap-conversion
and removes the stub conversion functions in the image library.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
_cogl_bitmap_fallback_convert now supports converting to and from all
of the pixel formats, except it continues to preserve the premult
status of the original bitmap. The pixels are unpacked into a
temporary buffer that is either 8-bits per component or 16-bits per
component RGBA depending on whether the destination format is going to
use more than 8 bits per component (eg RGBA_1010102). The packing and
unpacking code is stored in a separate header which is included twice
to generate the functions needed for both sizes of unpacked data. The
hope is that when converting between two formats that are both 8-bit
sized, such as swizzling between BGRA and RGBA, then the
multiplications and divisions in the code will be optimized out and it
shouldn't be too inefficient. Previously the inner switch statement to
decide which conversion to use only operated on one pixel at a time so
it was probably relatively slow.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
There are a few places in Cogl that try to set the premult bit on a
pixel format depending on whether it has an alpha channel. However
this breaks if the pixel format is alpha-only because premultiplying
data without any RGB components doesn't make any sense. This adds an
internal macro to check for cases where we should add the premult bit
called COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT. This now gets used in all
places that previously just checking for COGL_A_BIT.
https://bugzilla.gnome.org/show_bug.cgi?id=671016
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The assert could use a 'default:' label but that would stop GCC from
giving a warning when a new enum value is added.
https://bugzilla.gnome.org/show_bug.cgi?id=671016
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The Wayland winsys defines functions declared in
cogl-wayland-renderer.h so it should include the header to make sure
the declarations are right. This was breaking because currently the
header #defines the _EXP suffixes on to the function names so it would
end up exporting the wrong symbol names.
This adds api for explicitly choosing what underlying driver cogl should
use internally for rendering as well as api for querying back what
driver is actually in use.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
cogl_texture_get_data uses find_best_gl_get_data_format from the
texture driver which returns the closest format to use for retrieving
pixel data given an intended format. However this function doesn't
know about the texture we are reading data from so it doesn't know
that the data we will actually receive will have the same premult
status as the texture's format. With the GL driver, this function ends
up returning exactly the same format as passed in which means it will
never do a premult conversion. Under GLES it always returns
COGL_PIXEL_FORMAT_RGBA_8888 so it will always make the data unpremult
even if the final requested format is premultiplied.
This patch fixes it so that it copies the premult status of the
closest_format from the format of the underlying texture. That way it
will later convert or not depending on the requested target format.
Note this patch breaks test-sub-texture with the GL driver because
that is incorrectly trying to read the texture data back as RGBA_8888
even though it depends on it not doing a premult conversion. The test
was already broken with GLES2 and remains broken.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
If the GL_OES_packed_depth_stencil extension is available then we can
try creating a combined depth-stencil buffer with the
GL_DEPTH24_STENCIL8 format. This adds a private flag for the feature.
https://bugzilla.gnome.org/show_bug.cgi?id=666184
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The GL_DEPTH_STENCIL format for renderbuffers is defined in a separate
extension from GL_EXT_framebuffer_object so we probably shouldn't
being trying to use it unless that extension is advertised. This just
replaces the check for whether the driver is GL for a check for a
private feature flag before trying GL_DEPTH_STENCIL. The private
feature flag is set if the extension is available on GL.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
If an application tries to bind an attribute to cogl_tex_coord_in then
on GLES2 it would try to directly use that as the name of the GL
attribute. However in the generated shader that is actually #defined
to cogl_tex_coord0_in so we need to remap the name. This adds a
parameter to validate_cogl_attribute_name so that it can optionally
return a real_attribute_name. If it doesn't set this then the calling
function will default to the Cogl attribute name.
This fixes test-texture-3d with the GLES2 driver.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Needed for _cogl_texture_get_type so that C4013 warnings/implicit
declaration of ... warnings can be avoided.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
The previous update missed renames of certain cogl_framebuffer_* functions
to cogl_onscreen_*, and were not updated as the glib-mkenums-generated
header no longer included experimental headers
Also, all comments in cogl.symbols are now done in C-style so that the
preprocessor will filter them out when processing cogl.symbols instead of
using ';' for commments, which could be MSVC-only
Reviewed-by: Neil Roberts <neil@linux.intel.com>
The previous update missed renames of certain cogl_framebuffer_* functions
to cogl_onscreen_*, and were not updated as the glib-mkenums-generated
header no longer included experimental headers
Also, all comments in cogl.symbols are now done in C-style so that the
preprocessor will filter them out when processing cogl.symbols instead of
using ';' for commments, which could be MSVC-only
-Make up for the missed cogl_texture_pixmap_x11_* symbols
-Removed texture_3d _EXP suffixes
-For newly-exposed public cogl_pipeline_get_layer_*_filter APIs
Reviewed-by: Neil Roberts <neil@linux.intel.com>
Now if COGL_ENABLE_EXPERIMENTAL_2_0_API has been defined when including
cogl.h then headers that correspond to 1.x only apis that we plan to
drop won't be included any more.
If COGL_ENABLE_EXPERIMENTAL_API is defined then you can still mix and
match 2.0 api with 1.x api in a single compilation unit.
Note: it's still possible that some 1.x symbols will still be available
when COGL_ENABLE_EXPERIMENTAL_2_0_API is defined since this patch
doesn't go through the shared headers adding guards around deprecated
functions.
This only affects people playing with the experimental api.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This also replaces use of CoglHandle with a CoglTexturePixmapX11 type
instead.
This patch also ensures the CoglTexturePixmapX11 constructor take an
explicit CoglContext pointer and can return a GError consistent with
other CoglTexture constructors.
Reviewed-by: Neil Roberts <neil@linux.intel.com>