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>
This moves all the cogl_framebuffer_ apis relating to swap buffer
requests into the cogl_onscreen_ namespace since on CoglOnscreen
framebuffers have back buffers that can be swapped.
Reviewed-by: Neil Roberts <neil@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>
There were several members of the CoglContext struct using the
CoglHandle type for things that now have replacement typedefs which
this patch fixes.
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>
Previously for the wireframe debug mode we identified the users
"cogl_position_in" attribute, mapped that, created a replacement
attribute with a LINE_LIST topology and then drew the attribute with a
simple pipeline with a green colour. This meant we completely discarded
the users original pipeline which may have involved vertex processing
that would be useful to visualize in the wireframe.
The new approach instead keeps the users attributes and instead
generates CoglIndices that can be used to refererence the original
attributes in LINE_LIST topology and instead of scrapping the user's
pipeline we now create a weak copy of the original pipeline and just
replace the fragment processing with a snippet to force the output color
to be green.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This improves the implementation of _cogl_pipeline_equal() to ensure
that the cost of the function scales by the number of bits set in the
pipelines_difference variable set after calling
_cogl_pipeline_compare_differences() instead of scaling by the number of
state groups cogl tracks.
As Cogl tracks more and more state groups we don't want
_cogl_pipeline_equal() to get slower.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
If setting NULL user data via cogl_object_set_user_data() and we fail to
find an entry for the given key then bail out before potentially
allocating a new entry since setting NULL data is documented to
effectively delete an entry.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This exposes cogl_pipeline_get_layer_{min,max}_filter functions so that
applications can query back the filters set using
cogl_pipeline_set_layer_filters().
Reviewed-by: Neil Roberts <neil@linux.intel.com>
The cogl.h header is meant to be the public header for including the 1.x
api used by Clutter so we should stop using that as a convenient way to
include all likely prototypes and typedefs. Actually we already do a
good job of listing the specific headers we depend on in each of the .c
files we have so mostly this patch just strip out the redundant
includes for cogl.h with a few fixups where that broke the build.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
The _cogl_texture_driver_pixel_format_to_gl functions for OpenGL and
OpenGLES convert CoglPixelFormats into corresponding gl enums that can
be used to upload texture data. Previously we were only handling a few
specific formats but this patch updates the functions to handle all the
formats we know about. The functions now also switch() on the format so
that we will get build time warnings if we forget to handle new formats
in these functions.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
https://bugzilla.gnome.org/show_bug.cgi?id=660188
edit: tweaked the internal format returned by pixel_format_to_gl();
handled 1010102 formats and rebased -- Robert Bragg
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>
The previous detection was based on bits per pixel only and would
consider bpp >= 24 as X888 or 8888 24-bit color depth formats.
This commit ensures we now use the newly added
_cogl_util_pixel_format_from_masks() api that returns a CoglPixelFormat
according to channel masks and color depth. This helps to add support
for more pixel formats.
https://bugzilla.gnome.org/show_bug.cgi?id=660188
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>