The DeviceManager class should be abstract in Clutter, and implemented
by each backend, as different backends will have different ways to
detect, initialize and list devices; the X11 backend alone has *two*
ways of dealing with devices.
This commit makes DeviceManager an abstract class and delegates the
device initialization and enumeration to per-backend sub-classes.
The responsible for creating the device manager is, obviously, the
backend singleton.
The X11 and Win32 backends have been updated to the new layout; the
Win32 backend has been updated blindly, so it might require additional
testing.
The Win32 backend now implements the create_context method which
creates a context and binds it to a 1x1 invisible window. That way
there will always be a context bound and the features can be retrieved
without creating the default stage. This reflects the changes in
1c6ffc8..b245d55 to the GLX backend.
Mostly lifted from the core pointer and keyboard X11 backend support.
The win32 backend registers two devices (a core pointer and a core
keyboard) and assigns them to the event structure when doing the
translation from native events to Clutter events.
Thanks to: Samuel Degrande <Samuel.Degrande@lifl.fr> for testing this
patch.
The win32 backend now handles the WM_SETCURSOR message and sets a
fully transparent cursor if the cursor-visible property has been
cleared on the stage. The icon is stored in the library via a resource
file. The instance handle for the DLL is needed to load the resource
so there is now a DllMain function to grab the handle.
This function should only need to be called in exceptional circumstances
since Cogl can normally determine internally when a flush is necessary.
As an optimization Cogl drawing functions may batch up primitives
internally, so if you are trying to use raw GL outside of Cogl you stand a
better chance of being successful if you ask Cogl to flush any batched
geometry before making your state changes.
cogl_flush() ensures that the underlying driver is issued all the commands
necessary to draw the batched primitives. It provides no guarantees about
when the driver will complete the rendering.
This provides no guarantees about the GL state upon returning and to avoid
confusing Cogl you should aim to restore any changes you make before
resuming use of Cogl.
If you are making state changes with the intention of affecting Cogl drawing
primitives you are 100% on your own since you stand a good chance of
conflicting with Cogl internals. For example clutter-gst which currently
uses direct GL calls to bind ARBfp programs will very likely break when Cogl
starts to use ARBfb programs internally for the material API, but for now it
can use cogl_flush() to at least ensure that the ARBfp program isn't applied
to additional primitives.
This does not provide a robust generalized solution supporting safe use of
raw GL, its use is very much discouraged.
Previously the journal was always flushed at the end of
_cogl_rectangles_with_multitexture_coords, (i.e. the end of any
cogl_rectangle* calls) but now we have broadened the potential for batching
geometry. In ideal circumstances we will only flush once per scene.
In summary the journal works like this:
When you use any of the cogl_rectangle* APIs then nothing is emitted to the
GPU at this point, we just log one or more quads into the journal. A
journal entry consists of the quad coordinates, an associated material
reference, and a modelview matrix. Ideally the journal only gets flushed
once at the end of a scene, but in fact there are things to consider that
may cause unwanted flushing, including:
- modifying materials mid-scene
This is because each quad in the journal has an associated material
reference (i.e. not copy), so if you try and modify a material that is
already referenced in the journal we force a flush first)
NOTE: For now this means you should avoid using cogl_set_source_color()
since that currently uses a single shared material. Later we
should change it to use a pool of materials that is recycled
when the journal is flushed.
- modifying any state that isn't currently logged, such as depth, fog and
backface culling enables.
The first thing that happens when flushing, is to upload all the vertex data
associated with the journal into a single VBO.
We then go through a process of splitting up the journal into batches that
have compatible state so they can be emitted to the GPU together. This is
currently broken up into 3 levels so we can stagger the state changes:
1) we break the journal up according to changes in the number of material layers
associated with logged quads. The number of layers in a material determines
the stride of the associated vertices, so we have to update our vertex
array offsets at this level. (i.e. calling gl{Vertex,Color},Pointer etc)
2) we further split batches up according to material compatability. (e.g.
materials with different textures) We flush material state at this level.
3) Finally we split batches up according to modelview changes. At this level
we update the modelview matrix and actually emit the actual draw command.
This commit is largely about putting the initial design in-place; this will be
followed by other changes that take advantage of the extended batching.
The clutter_context_get_default() function is private, but shared
across Clutter. For this reason, it should be prefixed by '_' so
that the symbol is hidden from the shared object.
* clutter/clutter-actor.c:
(clutter_actor_set_min_width),
(clutter_actor_set_min_height),
(clutter_actor_set_natural_width),
(clutter_actor_set_natural_height): Ignore any override of the
minimum and natural size of the stage on backends that only
support static stages.
* clutter/clutter-stage.c (clutter_stage_allocate): Use the
preferred size of the ClutterStage implementation instead of
the display size.
* clutter/clutter-backend.[ch]: Remove get_display_size() and
clutter_backend_get_display_size().
* clutter/eglnative/clutter-backend-egl.c:
* clutter/fruity/clutter-backend-fruity.c:
* clutter/osx/clutter-backend-osx.c:
* clutter/sdl/clutter-backend-sdl.c:
* clutter/win32/clutter-backend-win32.c:
* clutter/x11/clutter-backend-x11.c: Remove get_display_size()
implementations.
signedness of old_xpos and old_ypos to get rid of compiler
warnings.
* clutter/win32/clutter-backend-win32.c
(clutter_backend_win32_get_features): Cast the result of
glGetString to a signed char pointer to avoid compiler warnings.
* clutter/win32/clutter-backend-win32.c: Reflect changes to the
GLX/X11 backend in revisions 2708-2709 and 2713-2715 which
simplify the backend a little.
* clutter/win32/clutter-stage-win32.c
(clutter_stage_win32_request_coords): Don't resize foreign
windows.
(clutter_stage_win32_unrealize): Don't destroy foreign windows.
(clutter_stage_win32_init): Added initialiser for is_foreign_win.
(clutter_win32_get_stage_from_window): Resort to looking in the
stage list if the window isn't the right window class so that it
can still find stages with foreign windows.
(clutter_win32_set_stage_foreign): New public function to set a
foreign window for a stage.
* clutter/win32/clutter-event-win32.c
(clutter_win32_disable_event_retrieval): New public function to
disable event retrieval.
(message_translate): Don't handle WM_SIZE or WM_MOVE for foreign
windows.
* clutter/win32/clutter-backend-win32.h (struct
_ClutterBackendWin32): Added a flag to disable event retrieval
* clutter/win32/clutter-backend-win32.c
(clutter_backend_win32_ensure_context): Update debug note to
include whether the stage is foreign or not.
subclassing code.
* clutter/win32/clutter-stage-win32.h:
* clutter/win32/clutter-stage-win32.c: Now inherits from
ClutterGroup and implements ClutterStageWindow instead of
inheriting directly from ClutterStage.
* clutter/win32/clutter-event-win32.c (message_translate): Now
takes an extra parameter to return whether DefWindowProc should be
called. This is needed to prevent the default WM_CLOSE handler
from destroying the window.
* clutter/win32/clutter-backend-win32.c
(clutter_backend_win32_dispose): Destroy all of the stages using
g_slist_foreach as per bug #871. Now also destroys the GL context.
(clutter_backend_win32_get_features): Added assertions to ensure
there is a valid GL context.
(clutter_backend_win32_ensure_context): Accepts NULL stage. Gets
implementation pointer from the stage.
* clutter/win32/clutter-backend-win32.c
(clutter_backend_win32_init): Added a call to
timeBeginPeriod. Without this the frame rates are terrible because
the glib timeouts are not accurate enough. However this requires
Glib >= 2.16.0 to take any effect because of a change in the way
g_poll is implemented. See revision 6597 of glib.
(clutter_backend_win32_finalize): Added a call to timeEndPeriod.
* configure.ac: Added -lwinmm to the library dependencies for the
Win32 backend.
* clutter/win32/clutter-win32.h:
* clutter/win32/clutter-stage-win32.h:
* clutter/win32/clutter-stage-win32.c:
* clutter/win32/clutter-event-win32.c:
* clutter/win32/clutter-backend-win32.h:
* clutter/win32/clutter-backend-win32.c:
Upgraded for multi-stage support.
* clutter/win32/clutter-stage-win32.c
(clutter_stage_win32_request_coords): Fixed so that it doesn't set
the position or size if it hasn't changed. This was causing
problems when the window was resized using the top left corner. In
that case the window receives resize and move messages separately
which caused the window to flash at a different size or position
while one message was handled before the other.
(clutter_stage_win32_realize): Added PFD_GENERIC_ACCELERATED to
the list of pixel format flags to force it to use hardware
acceleration.
2008-03-30 Neil Roberts <neil@o-hand.com>
* clutter-sections.txt: Added clutter_win32_get_stage_from_window