This extension lets you upload texture data from a subregion of a
buffer by passing GL_UNPACK_ROW_LENGTH, GL_UNPACK_SKIP_PIXELS and
GL_UNPACK_SKIP_ROWS to glPixelStore. When this extension is available
the GLES texture driver will now avoid making a copy of the bitmap
when a subregion is used.
Note that Mesa doesn't currently advertise this extension but I've
made a patch to propose it:
http://lists.freedesktop.org/archives/mesa-dev/2012-March/020191.html
This extension allows an application to upload data in BGRA format. We
can use this to avoid a conversion in Cogl whenever it is given BGRA
data. This is quite useful when uploading data generated by Cairo
because at least on little-endian architectures that ends up as BGRA.
The patch just makes the pixel_format_to_gl implementation return
GL_BGRA_EXT for the data format and internal format whenever
COGL_PIXEL_FORMAT_BGRA_8888{,_PRE} is used.
A small caveat with this patch is that once a texture is created as
GL_BGRA, when later using glTexSubImage2D to update the texture it
must always be given data as GL_BGRA. Currently this just works out
because we store the internal format of a texture as a CoglPixelFormat
and we already swizzle the data if it does not match exactly on GLES.
However if we later switch to using a different enum for internal
formats then we might lose the ability to store the component ordering
so we'll have to think of another way to do this.
Cogl already had a vtable for the texture driver. This ended up being
used for some things that are not strictly related to texturing such
as converting between pixel formats and GL enums. Some other functions
that are driver dependent such as updating the features were not
indirected through a vtable but instead switched directly by looking
at the ctx->driver enum value. This patch normalises to the two uses
by adding a separate vtable for driver functions not related to
texturing and moves the pixel format conversion functions to it from
the texture driver vtable. It also adds a context parameter to all of
the functions in the new driver vtable so that they won't have to rely
on the global context.
It looks like the then-clause of the AS_IF macro needs to be in square
brackets otherwise the configure script gets generated wrong and you
get this output when you run it:
configure: line 17339: COGL_PANGO_DEP_CFLAGS: command not found
configure: line 17340: C: command not found
configure: line 17341: COGL_PANGO_DEP_LIBS: command not found
configure: line 17342: linker: command not found
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Because the wayland-client-protocol.h header defines symbols that
collide with the wayland-server-protocol.h header we allow applications
to explicitly ensure that they are only including one at a time by
exposing corresponding <cogl/cogl-wayland-client.h> and
<cogl/cogl-wayland-server.h> headers. This also adds a missing guard to
cogl-texture-2d.h that it isn't included directly.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
The fallback code using stb-image.c was missed out in the upgrade to
cogl_bitmap_new_for_data from commit d18b59d9e6 so it wouldn't
compile.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
• The documentation for the framebuffer and texture interfaces had a
mis-matching open and close <note> tag so DocBook got upset and the
whole documentation disappeared.
• A lot of symbols from the cogl_framebuffer_* interface were missing
from the cogl-2.0-experimental-sections.txt file.
• cogl_framebuffer_frustum had the wrong version in its Since tag:
Reviewed-by: Robert Bragg <robert@linux.intel.com>
_cogl_framebuffer_draw_multitextured_rectangles had a typo in the
function name in the declaration so it was generating a lot of
compile warnings.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
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.
Fix the situation where glib-mkenums isn't located correctly when COGL
is not built in a root folder of a drive (ex: COGL is not unpacked in
c:\ or D:\, but in c:\blah or d:\blah)
This was causing the DocBook for the documentation to be invalid so
all of the framebuffer documentation disappeared.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This adds a public convenience wrapper around
cogl_framebuffer_read_pixels_into_bitmap which allocates a temporary
CoglBitmap to read into the application's own buffer. This can only be
used for the 99% common case where the rowstride is exactly the
bpp*width and the source is the color buffer.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
In theory none of the journal flushing code should be using anything
that relies on the global framebuffer stack because it should all be
using the new 2.0-style API which explicitly mentions the target
framebuffer. Eventually we want to get rid of the framebuffer stack so
we might as well remove the push and pop now.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
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>
The KMS platform accesses all of it's GL symbols via the indirection
through the Cogl context so there is no need to link against it
directly. This helps when trying to use Cogl with GLES where pulling
in Xlib via libGL is potentially a problem.
Reviewed-by: Robert Bragg <robert@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>
We no longer have COGL_ENABLE_EXPERIMENTAL_API in cogl.symbols as those
APIs are always built into the COGL DLL, so the
-DCOGL_ENABLE_EXPERIMENTAL_API is not needed anymore in the cogl.def
generation process.
-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>
While valgrinding gnome-shell I noticed this value was being used
uninitialised as the memory is malloced.
https://bugzilla.gnome.org/show_bug.cgi?id=671984
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>