Commit Graph

692 Commits

Author SHA1 Message Date
Robert Bragg
7d9b733446 cogl: cleanly separate primitives + paths code
The function prototypes for the primitives API were spread between
cogl-path.h and cogl-texture.h and should have been in a
cogl-primitives.h.

As well as shuffling the prototypes around into more sensible places
this commit splits the cogl-path API out from cogl-primitives.c into
a cogl-path.c
2010-02-12 14:05:01 +00:00
Robert Bragg
ba4b00be42 cogl: remove redundant _cogl_journal_flush prototype
There was a redundant _cogl_journal_flush function prototype in
cogl-primitives.h
2010-02-12 14:05:01 +00:00
Robert Bragg
0f5f4e8645 cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.

There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.

The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:

 return_type
 cogl_function_name (CoglType arg0,
                     CoglType arg1);

Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.

The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.

The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.

The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-12 14:05:00 +00:00
Robert Bragg
10fa7c7ce9 cogl: deprecates cogl_check_extension
OpenGL is an implementation detail for Cogl so it's not appropriate to
expose OpenGL extensions through the Cogl API.

Note: Clutter is currently still using this API, because it is still
doing raw GL calls in ClutterGLXTexturePixmap, so this introduces a
couple of (legitimate) build warnings while compiling Clutter.
2010-02-12 14:05:00 +00:00
Neil Roberts
f74f4bdc2b cogl: Add a fallback for when the signbit macro is missing
The signbit macro is defined in C99 so it should be available but some
versions of GCC don't appear to define it by default. If it's not
available we can use a hack to test the bit directly.
2010-02-11 15:59:53 +00:00
Neil Roberts
a0a40f07b3 cogl-material: Layers are not equal if the filters aren't equal
A material layer can not be considered equal if it is using different
texture filtering modes. This was causing problems where rectangles
with different filters would end up batched together and then rendered
with the wrong filter mode.
2010-02-10 12:41:09 +00:00
Emmanuele Bassi
282abe91f7 cogl: Move material_copy() out of the deprecated section
We strongly suggest people should be using cogl_material_copy(), but it
was hidden behind the deprecation guards.
2010-02-09 17:07:08 +00:00
Emmanuele Bassi
0145562cad Fix some compiler warnings
GCC complains that some variable might be used uninitialized.
2010-02-09 16:58:03 +00:00
Neil Roberts
d3948fab8c cogl-bitmap: Remove const from premult_alpha_last_four_pixels_sse2
The function modifies the pixels pointed by p in-place so the pointer
can not be constant. The compiler was accepting this because the
modification is done from inline assembler.
2010-02-09 16:30:28 +00:00
Emmanuele Bassi
62fa1f9c28 docs: Clean up the unused symbols for Cogl
Gtk-doc is reporting a lot of false positives in the unused text file,
mostly because of new private files that have been added to Cogl but not
to the gtk-doc ignore list for the Cogl API reference.

Once the false positives have been removed we have a couple of really
missing symbols that should be added to the cogl-sections.txt file.
2010-02-09 15:29:29 +00:00
Bastian Winkler
82c6be5269 cogl-buffer: Use correct argument types in cogl_buffer_set_data_EXP
offset and size arguments are gsize in cogl-buffer.h

http://bugzilla.openedhand.com/show_bug.cgi?id=1980

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-02-09 15:01:09 +00:00
Emmanuele Bassi
ea0d0f1231 docs: Move some Cogl defines in the private section
The PixelFormat bit and mask #defines should not be used and are there
mostly for convenience, so we can push them to the "private" sub-section
of the API reference.

This pushed Cogl's API reference coverage to 100%.
2010-02-09 14:48:11 +00:00
Emmanuele Bassi
2674a1ead2 docs: Fixes for Cogl API reference
98% symbol docs coverage.
  335 symbols documented.
  0 symbols incomplete.
  8 not documented.

Not bad, if I may say so.
2010-02-09 14:41:37 +00:00
Neil Roberts
2938ae0475 cogl-texture-2d: Use _cogl_texture_driver_gen to generate the GL tex
_cogl_texture_driver_gen is needed to set the texture minification
mode to Cogl's default of GL_LINEAR. There was also a line to set this
in _cogl_texture_2d_new_with_size but it wasn't working because it was
called *before* the texture was bound. If the texture was later
rendered with the default material it then it would end up with GL's
default mipmap filtering mode but without mipmaps so it would render
white squares instead.
2010-02-09 12:21:10 +00:00
Neil Roberts
f16fd0ddbb cogl: Use SSE2 when possible for premultiplying
This adds a fast path for premultiplying an RGBA image using SSE2
instructions. SSE registers are 128-bit and we need at least 16-bits
per component for the intermediate result of the multiplication so we
can do two pixels in parallel with one register. The function
interleaves 2 SSE registers to multiply 4 pixels in one function call
with the hope that this will pipeline better.

http://bugzilla.openedhand.com/show_bug.cgi?id=1939
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-02-09 11:03:21 +00:00
Halton Huo
2ecb6f7b20 Remove return from void functions
This patch fixes compilation on suncc.

http://bugzilla.openedhand.com/show_bug.cgi?id=1978

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-02-09 10:24:25 +00:00
Damien Lespiau
23717452bf cogl-buffer: Use TEXTURE as the only value for CoglBufferUsageHint
We should try to use more explicit defines than GL for our hints. For
now we only support using a CoglBuffer to generate textures.
2010-02-08 17:14:49 +00:00
Damien Lespiau
273fd23742 cogl-buffer: make sure the code compiles on GL ES
OpenGL ES has no PBO extension, so we fallback to using a malloc'ed
buffer. Make sure the OpenGL-only defines don't leak into the OpenGL ES
compilation.
2010-02-08 17:14:49 +00:00
Damien Lespiau
ca80e8802b cogl-pixel-buffer: Add a fallback path
First, let's add a new public feature called, surprisingly,
COGL_FEATURE_PBOS to check the availability of PBOs and provide a
fallback path when running on older GL implementations or on OpenGL ES

In case the underlying OpenGL implementation does not provide PBOs, we
need a fallback path (a malloc'ed buffer). The CoglPixelBufer
constructors will instanciate a subclass of CoglBuffer that handles
map/unmap and set_data() with a malloc'ed buffer.

The public feature is useful to check before using set_data() on a
buffer as it will mean doing a memcpy() when not supporting PBOs (in
that case, it's better to create the texture directly instead of using a
CoglBuffer).
2010-02-08 17:14:49 +00:00
Damien Lespiau
cf960cfb3d cogl-texture: Add a new constructor to turn CoglBuffers into textures
The only goal of using COGL buffers is to use them to create
textures. cogl_texture_new_from_buffer() is the new symbol to create
textures out of buffers.
2010-02-08 17:14:49 +00:00
Damien Lespiau
47cc5a4e43 cogl-pixel-buffer: add a pixel buffer object class
This subclass of CoglBuffer aims at wrapping PBOs or other system
surfaces like DRM buffer objects. Two constructors are available:

cogl_pixel_buffer_new() with a size when you only care about the size of
the buffer (such a buffer can be used to store several texture data such
as the three planes of a I420 frame).

cogl_pixel_buffer_new_full() is more a 1:1 mapping between the data and
an underlying surface, with the possibility of having access to a low
level memory buffer that may have a stride.
2010-02-08 17:14:49 +00:00
Damien Lespiau
40b73a8c0c cogl-buffer: add an abstract class around openGL's buffer objects
Buffer objects are cool! This abstracts the buffer API first introduced
by GL_ARB_vertex_buffer_object and then extended to other objects.

The coglBuffer abstract class is intended to be the base class of all
the buffer objects, letting the user map() buffers. If the underlying
implementation does not support buffer objects (or only support VBO but
not FBO for instance), fallback paths should be provided.
2010-02-08 17:14:49 +00:00
Damien Lespiau
dbef77cd8b cogl: new textures sould have GL_TEXTURE_MIN_FILTER set to GL_LINEAR
The only way the user has to set the mipmap filters is through the
material/layer API. This API defaults to GL_LINEAR/GL_LINEAR for the max
and min filters. With the main use case of cogl being 2D interfaces, it
makes sense do default to GL_LINEAR for the min filter.

When creating new textures, we did not set any filter on them, using
OpenGL defaults': GL_NEAREST_MIPMAP_LINEAR for the min filter and
GL_LINEAR for the max filter. This will make the driver allocate memory
for the mipmap tree, memory that will not be used in the nominal case
(as the material API defaults to GL_LINEAR).

This patch tries to ensure that the min filter is set to GL_LINEAR
before any glTexImage*() call is done on the texture by setting the
filter when generating new OpenGL handles.
2010-02-08 17:14:49 +00:00
Damien Lespiau
0adc2c458d cogl: Introduce the GE_RET() debug macro
Some GL functions have a return value that the GE() macro is not able to
handle. Let's define a new Ge_RET() macro which will be able to handle
functions such as glMapBuffer().

While at it, removed the unused variadic dots to the GE() macro.
2010-02-08 17:14:49 +00:00
Emmanuele Bassi
5b4957a810 Merge branch 'animator-parser'
* animator-parser:
  docs: Describe the Animation definition syntax
  animator: Provide a ClutterScript parser
  animator: Allow retrieving type property type from a key
  script: Use a node when resolving an animation mode
2010-02-08 16:53:11 +00:00
Robert Bragg
b31f2dd4a2 cogl path: make sure marking the clip state dirty takes affect
When we trashed the contents of the stencil buffer during
_cogl_path_fill_nodes we marked the clip stack state as dirty and expected
the clip stack code would clean up our glStencilFunc state.

The problem is that we only try and update the clip state during
_cogl_journal_init (when we flush the framebuffer state) which is only
called when the journal first gets something logged in it.

To make sure the stencil state is cleaned up we now also flush the journal
so _cogl_journal_init will be called for the next logged rectangle.
2010-02-08 13:35:45 +00:00
Emmanuele Bassi
286ca56d4f Merge remote branch 'origin/cwiiis-stage-resize'
* origin/cwiiis-stage-resize:
  [stage-x11] Set the default size differently
  [stage] Set default size correctly
  Revert "[x11] Don't set actor size on ConfigureNotify"
  [x11] Don't set actor size on ConfigureNotify
  [stage] Now that get_geometry works, use it
  [stage-x11] make get_geometry always get geometry
  [stage] Get the current size correctly
  [stage] Set minimum width/height to 1x1
  [stage] Add set/get_minumum_size
2010-02-08 10:34:22 +00:00
Neil Roberts
b39d1b788a Merge branch 'more-texture-backends'
This adds three new texture backends.

- CoglTexture2D: This is a trimmed down version of CoglTexture2DSliced
  which only supports a single texture and only works with the
  GL_TEXTURE_2D target. The code is a lot simpler so it has a less
  overheads than dealing with slices. Cogl will use this wherever
  possible.

- CoglSubTexture: This is used to get a CoglHandle to represent a
  subregion of another texture. The texture can be used as if it was a
  standalone texture but it does not need to copy the resources.

- CoglAtlasTexture: This collects RGB and RGBA textures into a single
  GL texture with the aim of reducing texture state changes and
  increasing batching. The backend will try to manage the atlas and
  may move the textures around to close gaps in the texture. By
  default all textures will be placed in the atlas.
2010-02-06 00:20:32 +00:00
Neil Roberts
b9a9bf60b7 cogl-bitmap: Update the format after (un)premultiplying
The pixel format of the bitmap needs to have its premult flag cleared
or set after the premult conversion otherwise it may get converted
again.
2010-02-06 00:13:25 +00:00
Neil Roberts
45215cb426 cogl-atlas-texture: Fix a cut and paste error when getting the height
There was a typo in getting the height of the full texture to check
whether the sub region fits so that it was using the width
instead. This was causing crashes when debugging is enabled for some
apps.
2010-02-05 17:03:04 +00:00
Damien Lespiau
a73ac7bf57 docs: Use % for defines not #
Some links to defines in the gtk-doc annotations were using '#' instead
of '%'.
2010-02-04 21:10:02 +00:00
Damien Lespiau
8ef5e82dfa docs: fix new line in the cogl xml top level document
A comma in the FSF address is wrong. Supreme Offence.
2010-02-04 19:32:14 +00:00
Neil Roberts
264f0f0f05 cogl-texture: Avoid copying the bitmap when premultiplying from a file
In cogl_texture_new_from_file we create and own a temporary
bitmap. There's no need to copy this data if we need to do a premult
conversion so instead it just does conversion before passing it on to
cogl_texture_new_from_bitmap.
2010-02-03 23:27:45 +00:00
Neil Roberts
e83e0c3e5b cogl-texture: Split out _cogl_texture_prepare_for_upload
The Cogl atlas code was using _cogl_texture_prepare_for_upload with a
NULL pointer for the dst_bmp to determine the internal format of the
texture without converting the bitmap. It needs to do this to decide
whether the texture will go in the atlas before wasting time on the
conversion. This use of the function is a little confusing so that
part of it has been split out into a new function called
_cogl_texture_determine_internal_format. The code to decide whether a
premult conversion is needed has also been split out.
2010-02-03 23:10:52 +00:00
Neil Roberts
ef9781d7da cogl-atlas: Make the cogl_atlas_* API internal
This just adds an underscore to every entry point for the CoglAtlas
API so that it's not exported.
2010-02-03 23:09:26 +00:00
Emmanuele Bassi
76f4696e43 Delay default stage creation
The default stage creation should be delayed as much as possible,
ideally at the end of the init() process.
2010-02-03 16:34:27 +00:00
Emmanuele Bassi
e337bd2370 cogl-debug: Remove redundant newlines
The debugging notes wrapping g_debug() already have an implicit newline
at the end of the passed message.
2010-02-03 16:34:27 +00:00
Neil Roberts
44431da164 cogl-vertex-buffer: Refix disabling texture coord arrays
Commit 92a375ab4 changed the initial value of max_texcoord_attrib_unit
to -1 so that it could disable the texture coord array for the first
texture unit when there are no texture coords used in the vbo. However
max_texcoord_attrib_unit was an unsigned value so this actually became
G_MAXUINT. The disabling loop at the bottom still worked because
G_MAXUINT+1==0 but the check for whether any texture unit is greater
than max_texcoord_attrib_unit was failing so it would always end up
disabling all texture units. This is now fixed by changing
max_texcoord_attrib_unit to be signed.
2010-02-03 14:31:12 +00:00
Neil Roberts
efcbd20320 Merge remote branch 'master' into texture-debugging
Conflicts:
	clutter/cogl/cogl/cogl-context.h
2010-02-01 13:37:19 +00:00
Neil Roberts
e4455041c8 cogl-material: Compare GL texture numbers for material layer textures
When deciding if a material layer is equal it now compares the GL
target and texture number if the textures are not sliced. This is
needed to get batching across atlased textures.
2010-02-01 13:27:42 +00:00
Neil Roberts
e20c98e548 cogl: Let GL do the format conversion when uploading texture data
Cogl accepts a pixel format for both the data in memory and the
internal format to be used for the texture. If they do not match then
it would convert them using the CoglBitmap functions before uploading
the data. However, GL also lets you specify both formats so it makes
more sense to let GL do the conversion. The driver may need the
texture in a specific format so it may end up being converted anyway.

The cogl_texture_upload_data functions have been removed and replaced
with a single function to prepare the bitmap. This will only do the
premultiplication conversion because that is the only part that GL
can't do directly.
2010-02-01 13:27:34 +00:00
Neil Roberts
a6f061e41f cogl: Do the premult conversion in-place rather than copying to a new buffer
The premult part of _cogl_convert_premult has now been split out as
_cogl_convert_premult_status. _cogl_convert_premult has been renamed
to _cogl_convert_format to make it less confusing. The premult
conversion is now done in-place instead of copying the
buffer. Previously it was copying the buffer once for the format
conversion and then copying it again for the premult conversion. The
premult conversion never changes the size of the buffer so it's quite
easy to do in place. We can also use the separated out function
independently.
2010-02-01 13:27:34 +00:00
Neil Roberts
406c203b42 cogl-atlas-texture: Use a single atlas for both RGB and RGBA textures
The internal format of the atlas texture is still set to the
appropriate format so Cogl will disable blending for textures that are
intended to be RGB. This should end up ignoring the alpha channel from
the texture in the atlas. This makes the code slightly easier to
maintain and should also improve the chances of batching.
2010-02-01 13:27:29 +00:00
Emmanuele Bassi
f7bd5af4a6 Merge branch 'device-manager'
* device-manager: (37 commits)
  x11: Re-enable XI1 extension keyboards
  x11: Always handle core device events before XI events
  docs: Documentation fixes for DeviceManager
  device-manager: Fix the signals definition
  docs: Add sections for InputDevice and DeviceManager
  docs: Add clutter_input_device_get_device_name()
  tests: Print out the device details on motion
  Always register core devices
  device: Remove unused is_default member
  win32: Experimental implementation of device support
  tests: Print the device name, as well as its Id
  x11: Fill out the :name property of the InputDevices
  device: Add the :name property to InputDevice
  x11: Store core devices on the X11 Backend singleton
  device: Unset the cursor actor when leaving the stage
  device: Add pointer actor getter
  x11: Discard the LeaveNotify for off-stage ButtonRelease
  device: Do not overwrite the stage for an InputDevice
  event: Off-stage button releases have a click count of 1
  event: Scroll events do not have click count
  ...
2010-02-01 11:26:56 +00:00
Emmanuele Bassi
4fcbbfeedc Whitespace fixes in cogl-util 2010-02-01 10:40:34 +00:00
Neil Roberts
47df6724b2 cogl: Use the colours of COGL_DEBUG=rectangles to debug batching
Instead of assigning a new colour to each quad of a batch, the
rectangle debugging code now assigns a new colour to each batch so
that it can be used to visually see what is being batched. The colour
is stored in a global variable that is reset during cogl_clear. This
improves the chances that the same colour will be used for a batch in
the next frames to avoid flickering.
2010-01-28 16:52:42 +00:00
Neil Roberts
1718b1d42e cogl-vertex-buffer: Fix disabling the texture arrays from previous prim
When setting up the state for the vertex buffer,
enable_state_for_drawing_buffer tries to keep track of the highest
numbered texture unit in use. It then disables any texture arrays for
units that were previously enabled if they are greater than that
number. However if there is no texturing in the VBO then the max used
unit would be left at 0 which it would later think meant unit 0 is
still in use so it wouldn't disable it. To fix this it now initialises
the max used unit to -1 which it should interpret as ‘no units are in
use’ so it will later disable the arrays for all units.

Thanks to Jon Mayo for reporting the bug.

http://bugzilla.openedhand.com/show_bug.cgi?id=1957
2010-01-27 14:31:59 +00:00
Neil Roberts
548ed1cdf2 docs: Add some notes about the CoglPixelFormat enums
The pixel format enums didn't explain what order in memory the
components should be so it was difficult to use them.
2010-01-27 12:07:38 +00:00
Damien Lespiau
9d45e9641c cogl: Fix checks of the number of available texture units
We were checking the number of texture units against the GL enum that is
used in glGetInteger() to query that number. Let's abstract this in a
little function.

Took the opportunity to dig a bit on the usage of GL limits for the
number of texture (image) units and document our use of them. We'll need
something finer grained if we want to fully exploit texture image units
with a programmable pipeline.
2010-01-26 18:47:25 +00:00
Damien Lespiau
84a438be55 cogl: Fix gl equivalent of blend string
An example of what could be the equivalent of
    "RBG = REPLACE(TEXTURE)
     A   = MODULATE(PREVIOUS,TEXTURE)"
using the ARB_texture_env_combine extension was given, but it seems that
a few typo were left:
    * remove a spurius GL_COMBINE_ALPHA
    * use the _ALPHA variant of SRCN and OPERANDN when setting up the
      alpha combiner
2010-01-26 17:25:25 +00:00