backend: Provide a default get_features() implementation

Continue gutting ClutterBackendCogl; get_features() is the last bit that
still does something, but now we can use the Cogl API.
This commit is contained in:
Emmanuele Bassi 2011-11-04 16:13:04 +00:00
parent b97324ee9f
commit 80fdbeb954
5 changed files with 49 additions and 77 deletions

View File

@ -356,6 +356,39 @@ clutter_backend_real_ensure_context (ClutterBackend *backend,
cogl_set_framebuffer (framebuffer);
}
static ClutterFeatureFlags
clutter_backend_real_get_features (ClutterBackend *backend)
{
ClutterFeatureFlags flags = 0;
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_MULTIPLE_ONSCREEN))
{
CLUTTER_NOTE (BACKEND, "Cogl supports multiple onscreen framebuffers");
flags |= CLUTTER_FEATURE_STAGE_MULTIPLE;
}
else
{
CLUTTER_NOTE (BACKEND, "Cogl only supports one onscreen framebuffer");
flags |= CLUTTER_FEATURE_STAGE_STATIC;
}
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_THROTTLE))
{
CLUTTER_NOTE (BACKEND, "Cogl supports swap buffers throttling");
flags |= CLUTTER_FEATURE_SYNC_TO_VBLANK;
}
else
CLUTTER_NOTE (BACKEND, "Cogl doesn't support swap buffers throttling");
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_BUFFERS_EVENT))
{
CLUTTER_NOTE (BACKEND, "Cogl supports swap buffers complete events");
flags |= CLUTTER_FEATURE_SWAP_EVENTS;
}
return flags;
}
static void
clutter_backend_real_redraw (ClutterBackend *backend,
ClutterStage *stage)
@ -540,6 +573,7 @@ clutter_backend_class_init (ClutterBackendClass *klass)
klass->translate_event = clutter_backend_real_translate_event;
klass->create_context = clutter_backend_real_create_context;
klass->ensure_context = clutter_backend_real_ensure_context;
klass->get_features = clutter_backend_real_get_features;
klass->redraw = clutter_backend_real_redraw;
}

View File

@ -129,46 +129,6 @@ clutter_backend_cogl_constructor (GType gtype,
return g_object_ref (backend_singleton);
}
static ClutterFeatureFlags
clutter_backend_cogl_get_features (ClutterBackend *backend)
{
ClutterBackendCogl *backend_cogl = CLUTTER_BACKEND_COGL (backend);
ClutterFeatureFlags flags = 0;
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_MULTIPLE_ONSCREEN))
{
CLUTTER_NOTE (BACKEND, "Cogl supports multiple onscreen framebuffers");
flags |= CLUTTER_FEATURE_STAGE_MULTIPLE;
}
else
{
CLUTTER_NOTE (BACKEND, "Cogl only supports one onscreen framebuffer");
flags |= CLUTTER_FEATURE_STAGE_STATIC;
}
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_THROTTLE))
{
CLUTTER_NOTE (BACKEND, "Cogl supports swap buffers throttling");
flags |= CLUTTER_FEATURE_SYNC_TO_VBLANK;
}
else
CLUTTER_NOTE (BACKEND, "Cogl doesn't support swap buffers throttling");
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_BUFFERS_EVENT))
{
CLUTTER_NOTE (BACKEND, "Cogl supports swap buffers complete events");
flags |= CLUTTER_FEATURE_SWAP_EVENTS;
}
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_REGION))
{
CLUTTER_NOTE (BACKEND, "Cogl supports swapping buffer regions");
backend_cogl->can_blit_sub_buffer = TRUE;
}
return flags;
}
static void
_clutter_backend_cogl_class_init (ClutterBackendCoglClass *klass)
{
@ -181,7 +141,6 @@ _clutter_backend_cogl_class_init (ClutterBackendCoglClass *klass)
backend_class->pre_parse = clutter_backend_cogl_pre_parse;
backend_class->post_parse = clutter_backend_cogl_post_parse;
backend_class->get_features = clutter_backend_cogl_get_features;
}
static void

View File

@ -316,11 +316,10 @@ static void
clutter_stage_cogl_redraw (ClutterStageWindow *stage_window)
{
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
ClutterActor *wrapper;
ClutterBackend *backend;
ClutterBackendCogl *backend_cogl;
gboolean may_use_clipped_redraw;
gboolean use_clipped_redraw;
gboolean can_blit_sub_buffer;
ClutterActor *wrapper;
CLUTTER_STATIC_TIMER (painting_timer,
"Redrawing", /* parent */
@ -343,19 +342,19 @@ clutter_stage_cogl_redraw (ClutterStageWindow *stage_window)
if (!stage_cogl->onscreen)
return;
backend = clutter_get_default_backend ();
backend_cogl = CLUTTER_BACKEND_COGL (backend);
CLUTTER_TIMER_START (_clutter_uprof_context, painting_timer);
can_blit_sub_buffer =
cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_REGION);
may_use_clipped_redraw = FALSE;
if (_clutter_stage_window_can_clip_redraws (stage_window) &&
G_LIKELY (backend_cogl->can_blit_sub_buffer) &&
can_blit_sub_buffer &&
/* NB: a zero width redraw clip == full stage redraw */
stage_cogl->bounding_redraw_clip.width != 0 &&
/* some drivers struggle to get going and produce some junk
* frames when starting up... */
G_LIKELY (stage_cogl->frame_count > 3))
stage_cogl->frame_count > 3)
{
may_use_clipped_redraw = TRUE;
}

View File

@ -218,11 +218,13 @@ clutter_backend_gdk_dispose (GObject *gobject)
static ClutterFeatureFlags
clutter_backend_gdk_get_features (ClutterBackend *backend)
{
ClutterFeatureFlags flags = CLUTTER_FEATURE_STAGE_USER_RESIZE | CLUTTER_FEATURE_STAGE_CURSOR;
ClutterBackendClass *parent_class;
flags |= CLUTTER_BACKEND_CLASS (clutter_backend_gdk_parent_class)->get_features (backend);
parent_class = CLUTTER_BACKEND_CLASS (clutter_backend_gdk_parent_class);
return flags;
return parent_class->get_features (backend)
| CLUTTER_FEATURE_STAGE_USER_RESIZE
| CLUTTER_FEATURE_STAGE_CURSOR;
}
static void

View File

@ -183,34 +183,12 @@ ClutterFeatureFlags
clutter_backend_win32_get_features (ClutterBackend *backend)
{
ClutterBackendClass *parent_class;
ClutterFeatureFlags flags;
parent_class = CLUTTER_BACKEND_CLASS (clutter_backend_win32_parent_class);
flags = CLUTTER_FEATURE_STAGE_USER_RESIZE | CLUTTER_FEATURE_STAGE_CURSOR;
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_MULTIPLE_ONSCREEN))
{
CLUTTER_NOTE (BACKEND, "Cogl supports multiple onscreen framebuffers");
flags |= CLUTTER_FEATURE_STAGE_MULTIPLE;
}
else
{
CLUTTER_NOTE (BACKEND, "Cogl only supports one onscreen framebuffer");
flags |= CLUTTER_FEATURE_STAGE_STATIC;
}
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_THROTTLE))
{
CLUTTER_NOTE (BACKEND, "Cogl supports swap buffers throttling");
flags |= CLUTTER_FEATURE_SYNC_TO_VBLANK;
}
else
CLUTTER_NOTE (BACKEND, "Cogl doesn't support swap buffers throttling");
CLUTTER_NOTE (BACKEND, "backend features checked");
return flags;
return parent_class->get_features (backend)
| CLUTTER_FEATURE_STAGE_USER_RESIZE
| CLUTTER_FEATURE_STAGE_CURSOR;
}
static ClutterStageWindow *