Commit Graph

4209 Commits

Author SHA1 Message Date
Robert Bragg
9a663d8e41 debug: Adds a COGL_DEBUG=disable-fast-read-pixel option
COGL_DEBUG=disable-fast-read-pixel can be used to disable the
optimization for reading a single pixel colour back by looking at the
geometry in the journal and not involving the GPU. With this disabled we
will always flush the journal, rendering to the framebuffer and then use
glReadPixels to get the result.
2011-01-21 16:18:11 +00:00
Robert Bragg
1bdb0e6e98 cogl: Implements a software only read-pixel fast-path
This adds a transparent optimization to cogl_read_pixels for when a
single pixel is being read back and it happens that all the geometry of
the current frame is still available in the framebuffer's associated
journal.

The intention is to indirectly optimize Clutter's render based picking
mechanism in such a way that the 99% of cases where scenes are comprised
of trivial quad primitives that can easily be intersected we can avoid
the latency of kicking a GPU render and blocking for the result when we
know we can calculate the result manually on the CPU probably faster
than we could even kick a render.

A nice property of this solution is that it maintains all the
flexibility of the render based picking provided by Clutter and it can
gracefully fall back to GPU rendering if actors are drawn using anything
more complex than a quad for their geometry.

It seems worth noting that there is a limitation to the extensibility of
this approach in that it can only optimize picking a against geometry
that passes through Cogl's journal which isn't something Clutter
directly controls.  For now though this really doesn't matter since
basically all apps should end up hitting this fast-path. The current
idea to address this longer term would be a pick2 vfunc for ClutterActor
that can support geometry and render based input regions of actors and
move this optimization up into Clutter instead.

Note: currently we don't have a primitive count threshold to consider
that there could be scenes with enough geometry for us to compensate for
the cost of kicking a render and determine a result more efficiently by
utilizing the GPU. We don't currently expect this to be common though.

Note: in the future it could still be interesting to revive something
like the wip/async-pbo-picking branch to provide an asynchronous
read-pixels based optimization for Clutter picking in cases where more
complex input regions that necessitate rendering are in use or if we do
add a threshold for rendering as mentioned above.
2011-01-21 16:18:11 +00:00
Robert Bragg
e289e85397 matrix: fix transform/project_points() APIs
Both cogl_matrix_transform_points and _project_points take points_in and
points_out arguments and explicitly allow pointing to the same array
(i.e. to transform in-place) The implementation of the various internal
transform functions though were not handling this possability and so it
was possible the reference partially transformed vertex values as if
they were original input values leading to incorrect results. This patch
ensures we take a temporary copy of the current input point when
transforming.
2011-01-21 16:18:11 +00:00
Robert Bragg
23ed01d4e9 cogl: Adds _cogl_util_point_in_polygon API
This adds a utility function that can determine if a given point
intersects an arbitrary polygon, by counting how many edges a
"semi-infinite" horizontal ray crosses from that point. The plan is to
use this for a software based read-pixel fast path that avoids using the
GPU to rasterize journaled primitives and can instead intersect a point
being read with quads in the journal to determine the correct color.
2011-01-21 16:18:11 +00:00
Robert Bragg
142b229c5c cogl: Adds _cogl_swap_buffers_notify for clutter backends
This adds a stop-gap mechanism for Cogl to know when the window system
is requested to present the current backbuffer to the frontbuffer by
adding a _cogl_swap_buffers_notify function that backends are now
expected to call right after issuing the equivalent request to OpenGL
vie the platforms OpenGL binding layer. This (blindly) updates all the
backends to call this new function.

For now Cogl doesn't do anything with the notification but the intention
is to use it as part of a planned read-pixel optimization which will
need to reset some state at the start of each new frame.
2011-01-21 16:18:10 +00:00
Robert Bragg
e150f474b3 clip: rename get_clip_stack + add framebuffer_get_stack
Instead of having _cogl_get/set_clip stack which reference the global
CoglContext this instead makes those into CoglClipState method functions
named _cogl_clip_state_get/set_stack that take an explicit pointer to a
CoglClipState.

This also adds _cogl_framebuffer_get/set_clip_stack convenience
functions that avoid having to first get the ClipState from a
framebuffer then the stack from that - so we can maintain the
convenience of _cogl_get_clip_stack.
2011-01-21 16:18:10 +00:00
Robert Bragg
179dc9b7d1 clip-stack: Adds _cogl_clip_stack_get_bounds API
This adds an internal function to be able to query the screen space
bounding box of the current clip entries contained in a given
CoglClipStack.

This bounding box which is cheap to determine can be useful to know the
largest extents that might be updated while drawing with this clip
stack.

For example the plan is to use this as part of an optimized read-pixel
path handled on the CPU which will need to track the currently valid
extents of the last call to cogl_clear()
2011-01-21 16:18:10 +00:00
Robert Bragg
f834596fd4 journal: Support per-framebuffer journals
Instead of having a single journal per context, we now have a
CoglJournal object for each CoglFramebuffer. This means we now don't
have to flush the journal when switching/pushing/popping between
different framebuffers so for example a Clutter scene that involves some
ClutterEffect actors that transiently redirect to an FBO can still be
batched.

This also allows us to track state in the journal that relates to the
current frame of its associated framebuffer which we'll need for our
optimization for using the CPU to handle reading a single pixel back
from a framebuffer when we know the whole scene is currently comprised
of simple rectangles in a journal.
2011-01-21 16:18:10 +00:00
Robert Bragg
385e0f84c6 cogl-object: Adds an internal _cogl_object_set_user_data
This adds an internal alternative to cogl_object_set_user_data that also
passes an instance pointer to destroy notify callbacks.

When setting private data on a CoglObject it's often desirable to know
the instance being destroyed when we are being notified to free the
private data due to the object being freed. The typical solution to this
is to track a pointer to the instance in the private data itself so it
can be identified but that usually requires an extra micro allocation
for the private data that could have been avoided if only the callback
were given an instance pointer.

The new internal _cogl_object_set_user_data passes the instance pointer
as a second argument which means it is ABI compatible for us to layer
the public version on top of this internal function.
2011-01-21 16:18:10 +00:00
Robert Bragg
131578c13a framebuffer: Move clear code to cogl-framebuffer.c
This moves the implementation of cogl_clear into cogl-framebuffer.c as
two new internal functions _cogl_framebuffer_clear and
_cogl_framebuffer_clear4f. It's not clear if this is what the API will
look like as we make more of the CoglFramebuffer API public due to the
limitations of using flags to identify buffers when framebuffers may
contain any number of ancillary buffers but conceptually it makes some
sense to tie the operation of clearing a color buffer to a framebuffer.

The short term intention is to enable tracking the current clear color
as a property of the framebuffer as part of an optimization for reading
back single pixels when the geometry is simple enough that we can
compute the result quickly on the CPU. (If the point doesn't intersect
any geometry we'll need to return the last clear color.)
2011-01-21 16:18:09 +00:00
Emmanuele Bassi
e46571d639 device-manager/xi2: Sync the stage of source devices
Keep the slave devices in sync with their master, so that we don't
ignore their events because they lack the stage pointer.
2011-01-21 15:26:52 +00:00
Emmanuele Bassi
516366d769 event: Clean up clutter_event_copy()
Try to avoid duplication of variables and blocks.
2011-01-21 15:14:11 +00:00
Emmanuele Bassi
7a339d1663 device: unset the axes array pointer when resetting
Otherwise we'll get a nice realloc() error from glibc.
2011-01-21 14:12:19 +00:00
Emmanuele Bassi
4ab8a3f0c1 stage: Do not create the default stage on stage.is_default()
Use the stage manager to see if a default stage was effectively set,
otherwise we end up creating a default stage when destroying a
non-default one.
2011-01-21 11:43:00 +00:00
Emmanuele Bassi
0e99346915 device-manager/xi2: Fix device hotplugging
Hierarchy and Device changed events come through with the X window set
to be the root window, not the stage window. We need to whitelist them
so that we can actually support hotplugging and device changes.
2011-01-21 11:41:36 +00:00
Emmanuele Bassi
7514f5fe92 glx: Clean up GLX implementation
Like commit a277b4091a, but targeted at
the GLX backend.
2011-01-21 10:49:12 +00:00
Emmanuele Bassi
6da51f6ed3 device/x11: Store min/max keycode in the XI device class
The generic device class shouldn't have the minimum and maximum keycode,
since no other input backend provides those.
2011-01-21 10:25:46 +00:00
Emmanuele Bassi
a277b4091a x11: Hide all private symbols
The x11 backend exposes a lot of symbols that are meant to only be used
when implementing a subclassed backend, like the glx and eglx ones.

The uninstalled headers are also filled with cruft declarations of
functions long since removed.

Let's try to clean up this mess.
2011-01-21 10:25:46 +00:00
Emmanuele Bassi
89467abae5 docs: More documentation fixes for InputDevice 2011-01-21 10:25:46 +00:00
Emmanuele Bassi
0f56abf569 */event: Never manipulate the event queue directly
Always use _clutter_event_push() instead.
2011-01-21 10:25:45 +00:00
Emmanuele Bassi
400ecdfc81 win32: Update DeviceManager device creation 2011-01-21 10:25:45 +00:00
Emmanuele Bassi
73cf6bd52c device: Allow enabling/disabling non-master devices
Slave and floating devices should always be disabled, and not deliver
events to the scene. It is up to the user to enable non-master devices
and handle events coming from them.

ClutterInputDevice gets a new :enabled property, defaulting to FALSE;
when a device manager creates a new device it has to set it to TRUE if
the :device-mode property is set to CLUTTER_INPUT_MODE_MASTER.

The main event queue entry point, _clutter_event_push(), will
automatically discard events coming from disabled devices.
2011-01-21 10:25:45 +00:00
Emmanuele Bassi
137f7d42a8 backend/eglx: Add newly created stages to the translators
The events directed to the stage should be translated by the stage.
2011-01-21 10:25:45 +00:00
Emmanuele Bassi
d3ed3d3a7b device: Add more doc annotations
Even for internal API.
2011-01-21 10:25:45 +00:00
Emmanuele Bassi
50e52f550a device: Use a double for translate_axis() argument
While XI1 has axis data in events exposed as integers, XI2 uses double
precision floating point values.
2011-01-21 10:25:45 +00:00
Emmanuele Bassi
d078fe0930 event: Fix up clutter_event_copy()
We need to copy the scroll axis data, and we need to copy the private
Event data from the source event to the target event structure.
2011-01-21 10:25:45 +00:00
Emmanuele Bassi
405e611279 device/xi2: Translate the axis data after setting devices
We need the devices (source and virtual) to be set before translating
the axis data from XI2 to the Clutter event.
2011-01-21 10:25:45 +00:00
Emmanuele Bassi
dd5f6ca7e1 device: Add more accessors for properties
Allow using real accessor methods for getting the ClutterInputDevice
properties set on construction.
2011-01-21 10:25:45 +00:00
Emmanuele Bassi
333ca35cec device: Add get_axis_value()
We need a convenience function for extracting the value of a specific
axis type out of the array of axis values attached to events.
2011-01-21 10:25:45 +00:00
Emmanuele Bassi
d805237c31 event: Add accessor for the axes field
CLUTTER_BUTTON_* and CLUTTER_MOTION event types have axes data attached
to them, so we want to expose a common ClutterEvent method for
extracting that data.
2011-01-21 10:25:44 +00:00
Emmanuele Bassi
431200f40d device: Add keys and axes accessors
Allow retrieving the number of keys and axes, since we provide the API
to iterate over them both.
2011-01-21 10:25:44 +00:00
Emmanuele Bassi
0a869e0718 egl/x11: Defer X11-specific code to the X11 backend
The ClutterStageX11 implementation does most of the heavy lifting, so
subclasses like ClutterStageGLX and ClutterStageEGL do not need to
handle things like creating the stage Window and selecting events; just
chaining up and using the internal API will suffice.
2011-01-21 10:25:44 +00:00
Emmanuele Bassi
a3102a777e docs: Fill out documentation for new symbols 2011-01-21 10:25:44 +00:00
Emmanuele Bassi
fa3c5a28a7 backend/x11: Allow querying xinput support
Undeprecate the XInput-related X11 API: since we don't enable XI support
by default we still need to ask for it, and see if we have it after the
backend initialization sequence.
2011-01-21 10:25:44 +00:00
Emmanuele Bassi
c8cc03f8a7 event/x11: Epic clean up
Event translation is now done where it belongs: we don't need a massive
switch in a file with direct access to private structure members.

So long, event_translate(); and thanks for all the fish.
2011-01-21 10:25:44 +00:00
Emmanuele Bassi
c044e44dc7 device/x11: Use similar core for axis translation as XI2 2011-01-21 10:25:44 +00:00
Emmanuele Bassi
c9c6236d37 stage/x11: Do not check a boolean for equality
Booleans should only be used like direct conditions, never as
comparisons with TRUE or FALSE.
2011-01-21 10:25:44 +00:00
Emmanuele Bassi
ee15d0d2d0 Add copyright and licensing blurbs 2011-01-21 10:25:44 +00:00
Emmanuele Bassi
2cb0077f7d device/xi2: Implement get_core_device()
We ask XI2 to get the client pointer for CLUTTER_POINTER_DEVICE, and
we use the attached keyboard device for CLUTTER_KEYBOARD_DEVICE. For
everything else, we return NULL.
2011-01-21 10:25:44 +00:00
Emmanuele Bassi
9c48486d7a device/xi2: Remove the ::remove implementation
Removing a device is only internal API, and we already have a function
for that: we don't need to implement the DeviceManager virtual as well.
2011-01-21 10:25:44 +00:00
Emmanuele Bassi
0075c45ca4 device/xi2: Blow the cached devices list
Every time we add or remove a device we should clear the cached list
that we return in get_devices(), so that it gets repopulated.
2011-01-21 10:25:44 +00:00
Emmanuele Bassi
de93f721c1 Clean up the copyright and licensing blurbs 2011-01-21 10:25:43 +00:00
Emmanuele Bassi
7c25b063aa x11: Use XI2 API only if we support it
XIQueryVersion() is XI2 API.
2011-01-21 10:25:43 +00:00
Emmanuele Bassi
caf359d8c9 input-device: Add documentation 2011-01-21 10:25:43 +00:00
Emmanuele Bassi
342cdd2575 input-device: Move select_stage_events() to a vfunc
Don't use a signal, use a virtual function.
2011-01-21 10:25:43 +00:00
Emmanuele Bassi
2777c52f27 input-device: Make ClutterInputDeviceClass private
We keep the symbol in the public header, but the definition is now
private. You could not sub-class InputDevice anyway, without the
instance structure, and the lack of padding in the class made actually
implementing devices in backends really hard.
2011-01-21 10:25:43 +00:00
Emmanuele Bassi
1b1e77b469 event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.

The new design for handling X11 event translation works this way:

  - ClutterBackend::translate_event() has been added as the central
    point used by a ClutterBackend implementation to translate a
    native event into a ClutterEvent;

  - ClutterEventTranslator is a private interface that should be
    implemented by backend-specific objects, like stage
    implementations and ClutterDeviceManager sub-classes, and
    allows dealing with class-specific event translation;

  - ClutterStageX11 implements EventTranslator, and deals with the
    stage-relative X11 events coming from the X11 event source;

  - ClutterStageGLX overrides EventTranslator, in order to
    deal with the INTEL_GLX_swap_event extension, and it chains up
    to the X11 default implementation;

  - ClutterDeviceManagerX11 has been split into two separate classes,
    one that deals with core and (optionally) XI1 events, and the
    other that deals with XI2 events; the selection is done at run-time,
    since the core+XI1 and XI2 mechanisms are mutually exclusive.

All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-21 10:25:43 +00:00
Emmanuele Bassi
ca092477c2 Appease the gods in introspection
Reduce the amount of bogus warnings g-ir-scanner prints out.
2011-01-20 16:35:26 +00:00
Emmanuele Bassi
ef78104227 Expose deprecated symbols whilst building Clutter
Don't use ugly "#undef CLUTTER_DISABLE_DEPRECATED" inside source code
using deprecated symbols; we have the handy CLUTTER_COMPILATION define
that we can use as part of the "disable deprecated" conditional.
2011-01-20 13:29:37 +00:00
Emmanuele Bassi
cd96e631f1 glx: Deprecate ClutterGLXTexturePixmap
Since 1.4 the ClutterGLXTexturePixmap is just a wrapper around
ClutterX11TexturePixmap, so we can safely deprecate it. All the
functionality it provided is now effectively available from the
superclass or directly from Cogl.
2011-01-20 13:21:50 +00:00
Emmanuele Bassi
94b905b9e1 build: Generate an instealled config header
Clutter has some platform-specific API that is accessible only if the
right backend has been compiled in. Third party applications that wish
to be portable across backends might want to use defines and other
pre-processor tricks to determine header inclusion and API usage.

While Clutter has an internal set of symbols it can use, third party
applications don't have the luxury of being able to access the config.h
generated by Clutter's configure script.

For this reason, Clutter should install a configuration header with a
series of namespaced defines that can be picked up by applications and
other third party code.
2011-01-19 14:33:27 +00:00
Chris Lord
bb41cb54cb timeline: Check if the timeline is playing in do_tick
Check that the timeline is still playing before executing in
_clutter_timeline_do_tick. This fixes the possibility of receiving a
new-frame signal when stopping a timeline in response to a different
timeline's signal emission.
2011-01-18 16:23:50 +00:00
Lucas Rocha
c61e22d067 drag-action: fix case where motion events are indefinitely disabled
When drag threshold is not reached, emit_drag_begin() is not called
causing default value of priv->motion_events_enabled (false) to used to
restore motion events enabled state in Clutter. This causes drag action
to indefinitely disable motion events. The current value of motion
events enabled state is now queried on button press which guarantees
that the state will be restored with the correct value in
emit_drag_end()

http://bugzilla.clutter-project.org/show_bug.cgi?id=2522
2011-01-18 14:48:14 +00:00
Emmanuele Bassi
cecc7a4bfb stage: Fix gtk-doc annotation for set_accept_focus() 2011-01-18 14:46:02 +00:00
Bastian Winkler
5d8b6aa6fa introspection: Add missing (out) annotations for get_color()
Some actors are missing the (out) annotations for the get_color()
methods.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2518
2011-01-17 17:31:59 +00:00
Lucas Rocha
6af7b76cb5 click-action: add API to get modifier type
This is to allow implementing modified click such as ctrl+click,
shift+click, and so on.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2520
2011-01-17 17:31:46 +00:00
Damien Lespiau
6100aee5bd color: Mark the new static color API as being new from 1.6
The patch was written a while ago but only merged in the 1.5.x cycle.
2011-01-17 15:22:48 +00:00
Neil Roberts
ae9781e526 cogl-program: Don't use separate definitions on GLES 1.1
Previously most of the code for cogl-program and cogl-shader was
ifdef'd out for GLES 1.1 and alternate stub definitions were
defined. This patch removes those and instead puts #ifdef's directly
in the functions that need it. This should make it a little bit easier
to maintain.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2516
2011-01-17 12:56:58 +00:00
Neil Roberts
b7677d047d cogl-pipeline-opengl: #ifdef out set_glsl_program for GLES 1.1
glUseProgram is not available under GLES 1.1 so it was breaking the
build.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2516
2011-01-17 12:38:46 +00:00
Neil Roberts
568d32acf3 cogl-pipeline: Fix the enum names for the constant combine source
When determining whether to hash the combine constant Cogl checks the
arguments to the combine funcs to determine whether the combine
constant is used. However is was using the GLenums GL_CONSTANT_COLOR
and GL_CONSTANT_ALPHA but these are not valid values for the
CoglPipelineCombineSource enum so presumably the constant would never
get hashed. This patch makes it use Cogl's enum of
COGL_PIPELINE_COMBINE_SOURCE_CONSTANT instead.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2516
2011-01-17 12:38:46 +00:00
Adel Gadllah
0c070cdf91 ClutterX11TexturePixmap: Fix doc comment
The wrong signal name was used probably a copy & paste
mistake, fix that.
2011-01-17 12:21:22 +00:00
Neil Roberts
88fe56d175 cogl-buffer: Support mapping buffers for write on GLES
GLES has an extension called GL_OES_mapbuffer to support mapping
buffer objects but only for writing. Cogl now has two new feature
flags to advertise whether mapping for reading and writing is
supported. Under OpenGL, these features are always set if the VBO
extension is advertised and under GLES only the write flag is set if
the GL_OES_mapbuffer extension is advertised.
2011-01-13 16:36:45 +00:00
Neil Roberts
7e73f0d423 cogl: Enable the VBOs feature for GLES2
The GLES2 wrapper code has been removed so there are no longer any
problems with enabling VBOs.
2011-01-13 16:36:45 +00:00
Neil Roberts
9bb74988d5 cogl: Fallback to set_data when mapping a buffer to fill it
In the journal code and when generating the stroke path the vertices
are generated on the fly and stored in a CoglBuffer using
cogl_buffer_map. However cogl_buffer_map is allowed to fail but it
wasn't checking for a NULL return value. In particular on GLES it will
always fail because glMapBuffer is only provided by an extension. This
adds a new pair of internal functions called
_cogl_buffer_{un,}map_for_fill_or_fallback which wrap
cogl_buffer_map. If the map fails then it will instead return a
pointer into a GByteArray attached to the context. When the buffer is
unmapped the array is copied into the buffer using
cogl_buffer_set_data.
2011-01-13 16:36:32 +00:00
Neil Roberts
77a486caf2 cogl-context: Don't enable point sprites on GLES2
On GLES2 there's no builtin mechanism to replace texture coordinates
with point sprite coordinates so calling glEnable(GL_POINT_SPRITE)
isn't valid. Instead the point sprite coords are implemented by using
a special builtin varying variable in GLSL.
2011-01-13 14:26:03 +00:00
Robert Bragg
88a085fdd8 pipeline: differentiate texture target and data state
There are several places where we need to compare the texture state of a
pipeline and sometimes we need to take into consideration if the
underlying texture has changed but other times we may only care to know
if the texture target has changed.

For example the fragends typically generate programs that they want to
share with all pipelines with equivalent fragment processing state, and
in this case when comparing pipelines we only care about the texture
targets since changes to the underlying texture won't affect the
programs generated.

Prior to this we had tried to handle this by passing around some special
flags to various functions that evaluate pipeline state to say when we
do/don't care about the texture data, but this wasn't working in all
cases and was more awkward to manage than the new approach.

Now we simply have two state bits:
COGL_PIPELINE_LAYER_STATE_TEXTURE_TARGET and
COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA and CoglPipelineLayer has an
additional target member. Since all the appropriate code takes masks of
these state bits to determine what to evaluate we don't need any extra
magic flags.
2011-01-13 12:23:33 +00:00
Robert Bragg
8ab68d26a5 pipeline: optimize state init if changing property
When notifying that a pipeline property is going to change, then at
times a pipeline will take over being the authority of the corresponding
state group. Some state groups can contain multiple properties and so to
maintain the integrity of all of the properties we have to initialize
all the property values in the new authority. For state groups with only
one property we don't have to initialize anything during the
pre_change_notify() because we can assume the value will be initialized
as part of the change being notified.

This patch optimizes how we handle this initialization of state groups
in a couple of ways; firstly we no longer do anything to initialize
state-groups with only one property, secondly we no longer use
_cogl_pipeline_copy_differences - (we have a new
_cogl_pipeline_init_multi_property_sparse_state() func) so we can avoid
lots calls to handle_automatic_blend_enable() which is sometimes seen
high in sysprof profiles.
2011-01-13 12:23:33 +00:00
Neil Roberts
3c9f72abbf cogl-atlas-texture: Don't disable atlas if can't read texture data
Previously atlasing would be disabled if the GL driver does not
support reading back texture data. This meant that atlasing would not
happen on GLES. However we also require that the driver support FBOs
and the texture data is only read back as a fallback if the FBO
fails. Therefore the atlas should be ok on GLES 2 which has FBO
support in core.
2011-01-13 11:50:09 +00:00
Robert Bragg
676df42c6f pipeline: don't skip flush if skip_gl_color flag differs
We try and bail out of flushing pipeline state asap if we can see the
pipeline has already been flushed and hasn't changed but we weren't
checking to see if the skip_gl_color flag is the same as when it was
last flush too and so we'd sometimes bail out without updating the
glColor correctly.
2011-01-11 14:30:02 +00:00
Neil Roberts
38e527a3cf cogl-vertex-attribute: Optionally avoid applying the legacy state
When an item is added to the journal the current pipeline immediately
gets the legacy state applied to it and the modified pipeline is
logged instead of the original. However the actual drawing from the
journal is done using the vertex attribute API which was also applying
the legacy state. This meant that the legacy state used would be a
combination of the state set when the journal entry was added as well
as the state set when the journal is flushed. To fix this there is now
an extra CoglDrawFlag to avoid applying the legacy state when setting
up the GL state for the vertex attributes. The journal uses this flag
when flushing.
2011-01-11 14:06:09 +00:00
Bastian Winkler
f4fc7284eb script-parser: Also honor properties of type GType
The script parser should also handle GType properties.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2513
2011-01-11 12:37:53 +00:00
Damien Lespiau
f2080f099e shader: Don't notify properties when finalizing shaders
clutter_shader_finalize() was calling clutter_shader_release() which in
turn notifies "compiled". GObject was complaining that we were trying to
_ref() an object that was in _finalize().

 #0  g_log (log_domain=0x3e15c4 "GLib-GObject", log_level=G_LOG_LEVEL_CRITICAL,
     format=0x76c938 "%s: assertion `%s' failed") at gmessages.h:97
 #1  0x0070777d in g_return_if_fail_warning (
     log_domain=0x3e15c4 "GLib-GObject",
     pretty_function=0x3e37a4 "g_object_ref",
     expression=0x3e2a00 "object->ref_count > 0") at gmessages.c:586
 #2  0x003b862b in g_object_ref (_object=0x8567af0) at gobject.c:2615
 #3  0x003bd238 in g_object_notify_by_pspec (object=0x8567af0, pspec=0x87ea2f0)
     at gobject.c:1075
 #4  0x00b6500b in clutter_shader_release (shader=0x8567af0)
     at ./clutter-shader.c:612
 #5  0x00b659b9 in clutter_shader_finalize (object=0x8567af0)
     at ./clutter-shader.c:107

Then, let's split release in two, with an _internal() version that does
not notify "compiled" and use it from dispose (as the object is still
usable after a call to release_internal().

http://bugzilla.clutter-project.org/show_bug.cgi?id=2512
2011-01-11 11:20:16 +00:00
Tomeu Vizoso
3625adb9d8 ClutterListModel: Implement get_n_rows for improved performance
The default implementation in ClutterModel iterates through all
the elements.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2511
2011-01-10 21:22:22 +00:00
Adel Gadllah
850f956d4e ClutterAlignConstraint: Keep pixel aligment
We have to round the values here otherwise we might end up with
misaligned actors.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2508
2011-01-10 18:45:22 +00:00
Neil Roberts
d648de7d14 cogl-journal: Avoid enabling blending if possible
The vertex attribute API assumes that if there is a color array
enabled then we can't determine if the colors are opaque so we have to
enable blending. The journal always uses a color array to avoid
switching color state between rectangles. Since the journal switched
to using vertex attributes this means we effectively always enable
blending from the journal. To fix this there is now a new flag for
_cogl_draw_vertex_attributes to specify that the color array is known
to only contain opaque colors which causes the draw function not to
copy the pipeline. If the pipeline has blending disabled then the
journal passes this flag.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2481
2011-01-10 17:11:42 +00:00
Neil Roberts
159cd6ddc0 cogl-vertex-attribute: Add flags to _cogl_draw_vertex_attributes_array
There is an internal version of cogl_draw_vertex_attributes_array
which previously just bypassed the framebuffer flushing, journal
flushing and pipeline validation so that it could be used to draw the
journal. This patch generalises the function so that it takes a set of
flags to specify which parts to flush. The public version of the
function now just calls the internal version with the flags set to
0. The '_real' version of the function has now been merged into the
internal version of the function because it was only called in one
place. This simplifies the code somewhat. The common code which
flushed the various state has been moved to a separate function. The
indexed versions of the functions have had a similar treatment.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2481
2011-01-10 17:11:41 +00:00
Neil Roberts
0201e5fa97 cogl: Don't assume that CoglBitmaps are allocated to height*rowstride
Cogl no longer has any code that assumes the buffer in a CoglBitmap is
allocated to the full size of height*rowstride. We should comment that
this is the case so that we remember to keep it that way. This is
important for cogl_texture_new_from_data because the application may
have created the data from a sub-region of a larger image and in that
case it's not safe to read the full rowstride of the last row when the
sub region contains the last row of the larger image.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2491
2011-01-10 16:55:01 +00:00
Neil Roberts
e1cbef23f5 cogl-texture-driver-gles: Don't copy the bitmap if alignment matches
When uploading data for GLES we need to deal with cases where the
rowstride is too large to be described only by GL_UNPACK_ALIGNMENT
because there is no GL_UNPACK_ROW_LENGTH. Previously for the
sub-region uploading code it would always copy the bitmap and for the
code to upload the whole image it would copy the bitmap unless the
rowstride == bpp*width. Neither paths took into account that we don't
need to copy if the rowstride is just an alignment of bpp*width. This
moves the bitmap copying code to a separate function that is used by
both upload methods. It only copies the bitmap if the rowstride is not
just an alignment of bpp*width.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2491
2011-01-10 16:55:00 +00:00
Neil Roberts
b3058c097d cogl-util: Add an internal wrapper for the ffs function
The ffs function is defined in C99 so if we want to use it in Cogl we
need to provide a fallback for MSVC. This adds a configure check for
the function and then a fallback using a while loop if it is not
available.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2491
2011-01-10 16:55:00 +00:00
Neil Roberts
91c1602306 cogl-texture: Don't use the source rowstride if we have to copy bitmap
If we have to copy the bitmap to do the premultiplication then we were
previously using the rowstride of the source image as the rowstride
for the new image. This is wasteful if the source image is a subregion
of a larger image which would make it use a large rowstride. If we
have to copy the data anyway we might as well compact it to the
smallest rowstride. This also prevents the copy from reading past the
end of the last row of pixels.

An internal function called _cogl_bitmap_copy has been added to do the
copy. It creates a new bitmap with the smallest possible rowstride
rounded up the nearest multiple of 4 bytes. There may be other places
in Cogl that are currently assuming we can read height*rowstride of
the source buffer so they may want to take advantage of this function
too.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2491
2011-01-10 16:54:58 +00:00
Neil Roberts
c6fbc8c567 cogl-vertex-attribute: Fix the name of the cogl_normal_in attribute
The builtin vertex attribute for the normals was incorrectly checked
for as 'cogl_normal' however it is defined as cogl_normal_in in the
shader boilerplate and for the name generated by CoglVertexBuffer.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2499
2011-01-10 14:29:25 +00:00
Emmanuele Bassi
2c36b81996 container: Do not use Actor as prerequisite
The prerequisite for ClutterContainer in 1.x is GObject, and we cannot
restrict the prerequisites without an ABI break.
2011-01-10 14:03:35 +00:00
nobled
6bb81a542f egl: Fix build for --with-flavour=opengl-egl-xlib
Make sure the EGL backend doesn't forget to include desktop OpenGL headers.
2011-01-06 17:16:51 +00:00
nobled
530bc2aa70 egl: Don't use obsolete API
Fixes a GCC "implicit declaration of function" warning when compiling.
2011-01-06 16:40:58 +00:00
Kristian Høgsberg
8c23766da8 x11: Create the list of all devices correctly
Linked lists are tricky.
2011-01-06 14:28:41 +00:00
Emmanuele Bassi
2fe20ff3c5 osx: Implement the set_accept_focus() vfunc
Like the x11 and win32 backends, the quartz backend should allow setting
the key focus when showing the stage window.
2010-12-30 12:47:00 +00:00
Emmanuele Bassi
9d6a33d0c8 win32: Implement the set_accept_focus() vfunc
Implement the ClutterStageWindow::set_accept_focus() virtual function in
the win32 backend.

If accept_focus is set to be TRUE then we call SetforegroundWindow()
after calling ShowWindow(). This is similar to what GDK does when
dealing with the same situation.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2500
2010-12-30 12:47:00 +00:00
Emmanuele Bassi
497f39e2f4 x11: Implement the set_accept_focus() vfunc
Actually set the InputHint flag and set the input field of the WM_SPEC
hints depending on the value of the accept-focus bitfield.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2500
2010-12-30 12:47:00 +00:00
Emmanuele Bassi
bbede9fef5 stage: Add :accept-focus property and accessors
Allow the developer to set whether the Stage should receive key focus
when mapped. The implementation is fully backend-dependent. The default
value is TRUE because that's what we've been expecting so far.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2500
2010-12-30 12:44:13 +00:00
Emmanuele Bassi
e1cd6f49b2 stage-window: Add set_accept_focus() vfunc
Allow Stage implementations to set whether or not they want to accept
key focus when being shown.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2500
2010-12-30 12:44:13 +00:00
Johan Bilien
601b958ab1 Fixed a crash when destroying the actor of a LEAVE event
When processing a LEAVE event, one might destroy the actor, so the weak
reference device->actor would be NULL.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2502

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-12-30 12:27:26 +00:00
Johan Bilien
c95cc8d477 Only reset the relayout_pending flag when actually doing a relayout
If an actor is (unfortunately) queuing a relayout in relayout, you would
end up with (ClutterActor*)stage->needs_allocation set to TRUE and
stage->relayout_pending set to TRUE. But if then in the same cycle, an
actor calls clutter_actor_get_allocation_box, that will trigger another
(recursive) _clutter_stage_maybe_relayout, which will wrongly reset the
relayout pending to FALSE, while not actually performing a new relayout
because of the re-entrancy protection.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2503
2010-12-30 11:48:51 +00:00
Emmanuele Bassi
b6558c5a18 docs: Fixes for the Cogl API reference 2010-12-22 09:52:35 +00:00
Emmanuele Bassi
605e8d6fb5 text: Only paint cursor if we have key focus
If a Text actor does not have key focus then there's no point in showing
the cursor at all.
2010-12-21 10:50:24 +00:00
Emmanuele Bassi
491bbc226e constraints: Remove signal handlers on dispose
Same as commit 2fa8b3a3ab but done for
AlignConstraint and SnapConstraint as well.
2010-12-18 13:24:54 +00:00
Emmanuele Bassi
2fa8b3a3ab bind-constraint: Remove handlers in dispose
We should remove the signal handlers on the source actor when a
BindConstraint is disposed, to avoid dangling pointers and wrong
invocations.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2493
2010-12-18 13:16:23 +00:00
Emmanuele Bassi
6c244c0549 geometry: Avoid sign issues when interpolating
Width and height in ClutterGeometry are unsigned, and this might lead to
overflow and wrap around issues.
2010-12-17 13:53:28 +00:00
Alexandre Quessy
c3313726f0 Fixed a typo in a doc string
http://bugzilla.clutter-project.org/show_bug.cgi?id=2485
2010-12-17 13:37:05 +00:00
Emmanuele Bassi
c444447cd3 timeline: Rename the reverse property to auto-reverse
Other frameworks expose the same functionality as "auto-reverse",
probably to match the cassette tape player. It actually makes sense
for Clutter to follow suit.
2010-12-17 12:07:52 +00:00
Neil Roberts
faaff03730 clutter-stage: Don't always set the projection and viewport matrix
The stage has a dirty flag to record whenever the viewport and
projection matrices need to be flushed. However after flushing these
the flags were never cleared so it would always redundantly update the
state.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2480
2010-12-14 13:12:29 +00:00