From 80fdbeb9543e0de18ac28f8cae28c42f2e18942e Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 4 Nov 2011 16:13:04 +0000 Subject: [PATCH] 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. --- clutter/clutter-backend.c | 34 ++++++++++++++++++++++ clutter/cogl/clutter-backend-cogl.c | 41 --------------------------- clutter/cogl/clutter-stage-cogl.c | 15 +++++----- clutter/gdk/clutter-backend-gdk.c | 8 ++++-- clutter/win32/clutter-backend-win32.c | 28 ++---------------- 5 files changed, 49 insertions(+), 77 deletions(-) diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c index d97718793..de7ece385 100644 --- a/clutter/clutter-backend.c +++ b/clutter/clutter-backend.c @@ -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; } diff --git a/clutter/cogl/clutter-backend-cogl.c b/clutter/cogl/clutter-backend-cogl.c index b5b8d9e0a..1e033838b 100644 --- a/clutter/cogl/clutter-backend-cogl.c +++ b/clutter/cogl/clutter-backend-cogl.c @@ -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 diff --git a/clutter/cogl/clutter-stage-cogl.c b/clutter/cogl/clutter-stage-cogl.c index 80801443f..84b2022b5 100644 --- a/clutter/cogl/clutter-stage-cogl.c +++ b/clutter/cogl/clutter-stage-cogl.c @@ -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; } diff --git a/clutter/gdk/clutter-backend-gdk.c b/clutter/gdk/clutter-backend-gdk.c index af59c244e..dedef89f0 100644 --- a/clutter/gdk/clutter-backend-gdk.c +++ b/clutter/gdk/clutter-backend-gdk.c @@ -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 diff --git a/clutter/win32/clutter-backend-win32.c b/clutter/win32/clutter-backend-win32.c index f403a47c0..3d9a2d2db 100644 --- a/clutter/win32/clutter-backend-win32.c +++ b/clutter/win32/clutter-backend-win32.c @@ -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 *