Commit Graph

2325 Commits

Author SHA1 Message Date
Robert Bragg
bdb645e7f5 kms: defer setting crtc modes until first swap buffers
Instead of creating a dummy framebuffer allocation just so we can setup
crtc modes during display_setup we now wait until the first swap_buffers
request before setting up the crtc modes.

This patch also adds a cogl_kms_display_queue_modes_reset() function
that allows developers to explicitly queue a reset of the crtc modes.
The idea is that applications that handle VT switching can use this for
VT enter events to explicitly ensure their mode is restored since modes
are often not automatically restored correctly.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-04-11 15:44:58 +01:00
Robert Bragg
125c31a70b kms: Add mirror support and env var configurability
This adds support for mirroring the display output on two KMS
connectors.

This patch also checks for a number of environment variables that can
influence how KMS is configured. The following variables can be set:

COGL_KMS_MIRROR: If this is set to anything then Cogl will try and setup
two connectors with the same resolution so that onscreen frame buffers
can be mirrored.

COGL_KMS_CONNECTOR0: This can be set to an integer identifier for a
specific KMS connector id to use for the first output.

COGL_KMS_CONNECTOR0_MODE: Can be set to a mode name like "1024x768"
explicitly select what mode should be used for the first output.

If COGL_KMS_MIRROR is set then COGL_KMS_CONNECTOR1 and
COGL_KMS_CONNECTOR1_MODE can optionally be set to specify a connector id
and mode name for the second output.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-04-11 15:44:58 +01:00
Neil Roberts
f9d3ea03ec kms: Implement the swap buffers notify feature
The KMS EGL platform now notifies when a swap is complete. The
notification is delayed until the application calls
cogl_context_dispatch. The GLX backend doesn't currently do this but I
think that is how it should behave to make it easier for the
application to handle locks and such.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-11 15:44:50 +01:00
Neil Roberts
cfefff1500 egl-kms: Use drmModePageFlip
The KMS platform now uses drmModePageFlip to present the buffer. The
main loop mechanism is used to poll for events on the DRM file
descriptor so that we notice when the page flip is complete. The
swap_buffers is throttled so that if there is a pending flip it will
block until it is complete before starting another flip.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-11 15:44:45 +01:00
Neil Roberts
d1d2120a91 kms: Use GBM surfaces
Instead of creating FBOs on the GL side, the KMS EGL platform uses the
latest changes to Mesa to create an EGL surface using a GBM surface as
the native surface type. This removes some of the special vtable hooks
that the KMS platform needed because it is now much more similar to
the other platforms.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-11 15:44:32 +01:00
Robert Bragg
cc4c578887 fix cogl_context_new crash if fail to connect renderer
If a NULL display is passed to cogl_context_new() then it has to
implicitly create a CoglRenderer and CoglDisplay and propagate any
resulting errors back to the user. Previously the implementation relied
on passing a NULL renderer to cogl_display_new() as the means for
implicitly connecting to a renderer. The problem with this though is
that cogl_display_new() isn't designed to ever return NULL but if it
failed to connect to a renderer automatically it would do and then
cogl_context_new would pass NULL to cogl_display_setup() leading to a
crash.

This patch changes the implementation of cogl_context_new() to now
explicitly create a CoglRenderer and connect to it if a NULL display is
given. This way we can easily propagate any errors. In addition
cogl_display_new has been changed to abort if it fails to implicitly
connect to a renderer due to a NULL renderer argument.

An application needing to gracefully handle problems connecting to a
renderer at runtime should manually instantiate and connect a renderer
passing a GError argument to cogl_renderer_connect.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-04-11 12:26:52 +01:00
Robert Bragg
995f4cd019 msaa: print GError message on onscreen alloc failure
If we fail to allocate the onscreen framebuffer when first requesting 4x
msaa then we now print the GError message.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-04-11 12:26:51 +01:00
Robert Bragg
836d54445d Use cogl_framebuffer_draw_rectangle api
Instead of using cogl_rectangle() this example now uses
cogl_framebuffer_draw_rectangle(). This fixes a crash due to the example
not pushing a current framebuffer before calling cogl_rectangle().

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-04-11 12:26:48 +01:00
Robert Bragg
0205a96efb cogl-crate: remove redundant g_type_init
Cogl internally will call g_type_init if necessary so the cogl-crate
example doesn't need to do this explicitly.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-04-11 12:26:47 +01:00
Robert Bragg
b61b328f51 cogl-crate: print GError message if texture load fails
If we fail to load the crate texture then we now print error->message to
hopefully give more insight into the failure to the user.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-04-11 12:26:46 +01:00
Carles Ferrando
df237e2151 [l10n]Updated Catalan (Valencian) translation 2012-04-10 20:57:42 +02:00
Jordi Serratosa
8f08c9d9c2 [l10n] Fixes on Catalan translation 2012-04-10 20:57:40 +02:00
Neil Roberts
f676785906 Fix including a non-existent header
cogl-sampler-cache-private.h was including a header which doesn't
exist so the build was broken. The header comes from a patch which
hasn't been pushed to master yet which splits including GL/gl.h out of
cogl-defines.h into a separate header. I added the inclusion to make
it pick up the GL defines but it doesn't need to do this yet because
cogl-context.h is still including the GL header. I didn't notice the
failure because I still had a cogl-gl-header.h lying around from a
previous build with the patch.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-05 15:35:01 +01:00
Neil Roberts
cb146dc515 Add a workaround for slow read pixels on Mesa
Mesa before version 8.0.2 has a slow read pixels path that gets used
with the Intel driver where it converts all of the pixels into a
floating point representation and back even if the data is being read
into exactly the same format. There is however a faster path using the
blitter when reading into a PBO with BGRA format. It works out faster
to read into a PBO and then memcpy back out into the application's
buffer even though it adds an extra memcpy. This patch adds a
workaround in cogl_framebuffer_read_pixels_into_bitmap when it detects
this situation. In that case it will create a temporary CoglBitmap
using cogl_bitmap_new_with_size, read into it and then memcpy the data
back out.

The main impetus for this patch is that Gnome Shell has implemented
this workaround directly using GL calls but it seems like the kind of
thing that would sit better at the Cogl layer.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-05 13:52:43 +01:00
Neil Roberts
2037e0f4f1 Add a mechanism for determining GPU driver details
This adds a CoglGpuInfo struct to the CoglContext which contains some
enums describing the GL driver in use. This currently includes the
driver package (ie, is it Mesa) the version number of the package and
the vendor of the GPU (ie, is it by Intel). There is also a bitmask
which will contain the workarounds that we should do for that
particular driver configuration. The struct is initialised on context
creation by using a series of string comparisons on the strings
returned from glGetString.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-05 13:52:43 +01:00
Neil Roberts
ec5009fa23 Use GL_PACK_ALIGNMENT of 1 whenever possible
The Intel driver currently has an optimisation when calling
glReadPixels into a PBO so that it will use a blit instead of the Mesa
fallback path. However this only works if the GL_PACK_ALIGNMENT is
exactly 1, even if this would be equivalent to a higher alignment
value because the bpp*width is already aligned. To make it more likely
to hit this fast path, we now detect this situation and explicitly use
an alignment of 1. To make this work the texture driver needs to be
passed down the bpp*width as well as the rowstride when configuring
the alignment.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-05 13:51:56 +01:00
Neil Roberts
d54111795f Use ffs to calculate the GL_{UN,}PACK_ALIGNMENT
Instead of having a series of if-statements this adds an inline
function to calculate the alignment directly using ffs which is
probably slightly faster. Admittedly this is a pointless
micro-optimisation but I think it makes the code looks a bit neater
anyway.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-05 13:51:56 +01:00
Neil Roberts
c33ce5fc6b Use GL_ARB_sampler_objects
GL_ARB_sampler_objects provides a GL object which overrides the
sampler state part of a texture object with different values. The
sampler state that Cogl currently exposes is the wrap modes and
filters. Cogl exposes the state as part of the pipeline layer state
but without this extension GL only exposes it as part of the texture
object state. This means that it won't work to use a single texture
multiple times in one primitive with different sampler states. It also
makes switching between different sampler states with a single texture
not terribly efficient because it has to change the texture object
state every time.

This patch adds a cache for sampler states in a shared hash table
attached to the CoglContext. The entire set of parameters for the
sampler state is used as the key for the hash table. When a unique
state is encountered the sampler cache will create a new entry,
otherwise it will return a const pointer to an existing entry. That
means we can have a single pointer to represent any combination of
sampler state.

Pipeline layers now just store this single pointer rather than storing
all of the sampler state. The two separate state flags for wrap modes
and filters have now been combined into one. It should be faster to
compare the sampler state now because instead of comparing each value
it can just compare the pointers to the cached sampler entries. The
hash table of cached sampler states should only need to perform its
more expensive hash on the state when a property is changed on a
pipeline, not every time it is flushed.

When the sampler objects extension is available each cached sampler
state will also get a sampler object to represent it. The common code
to flush the GL state will now simply bind this object to a unit
instead of flushing the state though the CoglTexture when possible.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-05 13:47:36 +01:00
Neil Roberts
4229d61d3b Fix places that ignore the COGL_TEXTURE_NO_AUTO_MIPMAP flag
Two of the meta texture constructors which take a flags parameter were
ignoring the COGL_TEXTURE_NO_AUTO_MIPMAP flag when creating an
underlying CoglTexture2D. These have now been fixed to call
cogl_primitive_texture_set_auto_mipmap after constructing the texture.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-05 13:47:36 +01:00
Neil Roberts
6197e3abf3 Add constructors which take a CoglBitmap to all primitive textures
This adds public constructors which take a CoglBitmap to all primitive
texture types. This constructor should be considered the canonical
constructor for initializing the texture with data because it should
be possible to wrap any type of data in a CoglBitmap. Having at least
this single constructor avoids the need to have an explosion of
constructors such as new_from_data, new_from_pixel_buffer and
new_from_file etc.

The already available internal bitmap constructor for CoglTexture2D
has had its flags parameter removed under the assumption that flags do
not make sense for primitive textures. The meta constructor
cogl_texture_new_from_bitmap now just explicitly calls set_auto_mipmap
after constructing the texture depending on the value of the
COGL_TEXTURE_NO_AUTO_MIPMAP flag.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-05 13:47:32 +01:00
Neil Roberts
e7f1582630 Add a CoglPrimitiveTexture interface
This interface represents any textures that are backed by a single
texture in GL and that can be used directly with the
cogl_framebuffer_draw_attributes family of functions. This currently
equates to CoglTexture2D, CoglTexture3D and CoglTextureRectangle.

The interface currently has only one method called
cogl_primitive_set_auto_mipmap. This replaces the
COGL_TEXTURE_NO_AUTO_MIPMAP flag from the CoglTextureFlags parameter
in the constructors. None of the other flags in CoglTextureFlags make
sense for primitive textures so it doesn't seem like a good idea to
need them for primitive constructors.

There is a boolean in the vtable to mark whether a texture type is
primitive which the new cogl_is_primitive function uses. There is also
a new texture virtual called set_auto_mipmap which is only required to
be implemented for primitive textures.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-04 17:02:23 +01:00
Neil Roberts
e7df2dbf79 bitmap: Store a pointer to the context
This adds a context member to CoglBitmap which stores the context it
was created with. That way it can be used in texture constructors
which use a bitmap. There is also an internal private function to get
the context out of the bitmap which all of the texture constructors
now use. _cogl_texture_3d_new_from_bitmap has had its context
parameter removed so that it more closely matches the other bitmap
constructors.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-04 14:24:01 +01:00
Neil Roberts
be9d5b34c6 pipeline: Use cogl_depth_state_init to init default depth state
The previous code to initialise the depth state on the default
pipeline wasn't initialising the magic number. If you later tried to
retrieve the depth state using cogl_pipeline_get_depth_state you would
end up with an invalid depth state struct and you would just get
warnings if you tried to use it for anything. This patch just replaces
the initialisation with a call to cogl_depth_state_init because it
uses the same values anyway.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-04-03 16:36:54 +01:00
Adel Gadllah
a000189c68 texture: Fix error handling in get_texture_bits_via_offscreen
get_texture_bits_via_offscreen does not check the return value of
cogl_framebuffer_read_pixels_into_bitmap which results into never
using the fallback path texture_get_cb.

cogl_framebuffer_read_pixels_into_bitmap does not check whether the framebuffer
is properly allocated though; so fix that as well.

https://bugzilla.gnome.org/show_bug.cgi?id=673137

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-04-02 23:32:53 +01:00
Christian Kirbach
8af076ced1 Updated German translation 2012-04-02 20:00:03 +02:00
Daniel Nylander
c24618055c Updated Swedish translation 2012-04-01 20:24:08 +02:00
Mario Blättermann
b264d80689 Updated German translation 2012-03-27 23:13:16 +02:00
Carles Ferrando
99b53e2d8b [l10n]Updated Catalan (Valencian) translation 2012-03-27 22:14:43 +02:00
Gil Forcada
34f2223f34 [l10n] Updated Catalan translation 2012-03-27 22:14:41 +02:00
Carles Ferrando
437e1e1ee1 [l10n]Updated Catalan (Valencian) translation 2012-03-27 22:13:57 +02:00
Gil Forcada
ace43bb238 [l10n] Updated Catalan translation 2012-03-27 22:13:53 +02:00
Chao-Hsiung Liao
3035886edc Updated Traditional Chinese translation(Hong Kong and Taiwan) 2012-03-27 11:51:57 +08:00
Rudolfs Mazurs
f78aed0f57 Updated Latvian translation. 2012-03-25 13:59:52 +03:00
Marek Černocký
364a495a49 Updated Czech translation 2012-03-25 12:35:05 +02:00
Neil Roberts
ae5f8323c1 gles2: Support the GL_EXT_unpack_subimage extension
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
2012-03-23 13:51:08 +00:00
Neil Roberts
21e304b339 gles: Support the GL_EXT_texture_format_BGRA8888 extension
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.
2012-03-23 13:51:08 +00:00
Neil Roberts
d6ca75fbec Add a context parameter to all of the texture driver virtuals
All of the texture driver virtual functions now take an explicit
CoglContext parameter as a step towards removing the global context.
2012-03-23 13:51:08 +00:00
Neil Roberts
60812e6a0e Add a vtable for the driver
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.
2012-03-23 13:51:08 +00:00
Gabor Kelemen
ccb6792781 Updated Hungarian translation 2012-03-23 11:56:49 +01:00
Rajesh Ranjan
6a732e89b9 hindi translation by Chandan Kumar 2012-03-23 14:51:16 +05:30
Krishnababu Krothapalli
e0a45eb104 Updated Telugu Translations 2012-03-21 22:03:53 +05:30
Chun-wei Fan
699a0bd74a Update cogl.symbols
...for the following added APIs:

cogl_bitmap_new_for_data
cogl_framebuffer_read_pixels
cogl_framebuffer_draw_multitextured_rectangles
cogl_framebuffer_draw_rectangle
cogl_framebuffer_draw_rectangles
cogl_framebuffer_draw_textured_rectangle
cogl_framebuffer_draw_textured_rectangles

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-21 22:15:34 +08:00
Bruno Brouard
14edc7ad50 Updated French translation 2012-03-20 20:57:46 +01:00
Neil Roberts
c2e8cc699f Post-release version bump to 1.10.1 2012-03-20 17:19:27 +00:00
Neil Roberts
724609f945 Release 1.10.0 (release) 2012-03-20 17:13:16 +00:00
Neil Roberts
6b90c24baa Updates NEWS for the 1.10.0 release 2012-03-20 17:13:16 +00:00
Neil Roberts
a8cc560a42 configure: Fix the pkg-config check for pango
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>
2012-03-20 17:13:09 +00:00
甘霖
96044c7d6b Update Simplified Chinese translation. 2012-03-20 15:17:53 +00:00
Robert Bragg
890a75ab06 Create standalone public wayland client/server headers
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>
2012-03-20 14:26:44 +00:00
Neil Roberts
2d1623313c bitmap-pixbuf: Fix the CoglBitmap wrapper for the STB fallback
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>
2012-03-20 13:53:50 +00:00