static void clutter_stage_egl_hide (ClutterActor *actor) { CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_MAPPED); CLUTTER_ACTOR_UNSET_FLAGS (CLUTTER_STAGE_EGL (actor)->wrapper, CLUTTER_ACTOR_MAPPED); }
static void clutter_glx_texture_pixmap_unrealize (ClutterActor *actor) { ClutterGLXTexturePixmapPrivate *priv; Display *dpy; priv = CLUTTER_GLX_TEXTURE_PIXMAP (actor)->priv; dpy = clutter_x11_get_default_display(); if (!_have_tex_from_pixmap_ext) { CLUTTER_ACTOR_CLASS (clutter_glx_texture_pixmap_parent_class)-> unrealize (actor); return; } if (!CLUTTER_ACTOR_IS_REALIZED (actor)) return; if (priv->glx_pixmap && priv->bound) { clutter_x11_trap_x_errors (); (_gl_release_tex_image) (dpy, priv->glx_pixmap, GLX_FRONT_LEFT_EXT); XSync (clutter_x11_get_default_display(), FALSE); clutter_x11_untrap_x_errors (); priv->bound = FALSE; } CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED); }
static void clutter_stage_egl_realize (ClutterActor *actor) { ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (actor); ClutterBackendEGL *backend_egl; EGLConfig configs[2]; EGLint config_count; EGLBoolean status; gboolean is_offscreen; CLUTTER_NOTE (BACKEND, "Realizing main stage"); g_object_get (stage_egl->wrapper, "offscreen", &is_offscreen, NULL); backend_egl = CLUTTER_BACKEND_EGL (clutter_get_default_backend ()); if (G_LIKELY (!is_offscreen)) { EGLint cfg_attribs[] = { EGL_BUFFER_SIZE, EGL_DONT_CARE, EGL_RED_SIZE, 5, EGL_GREEN_SIZE, 6, EGL_BLUE_SIZE, 5, EGL_DEPTH_SIZE, 16, EGL_ALPHA_SIZE, EGL_DONT_CARE, EGL_STENCIL_SIZE, 2, EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_NONE }; status = eglGetConfigs (backend_egl->edpy, configs, 2, &config_count); if (status != EGL_TRUE) g_warning ("eglGetConfigs failed"); status = eglChooseConfig (backend_egl->edpy, cfg_attribs, configs, G_N_ELEMENTS (configs), &config_count); if (status != EGL_TRUE) { g_critical ("eglChooseConfig failed"); CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED); return; } if (stage_egl->egl_surface != EGL_NO_SURFACE) { eglDestroySurface (backend_egl->edpy, stage_egl->egl_surface); stage_egl->egl_surface = EGL_NO_SURFACE; } if (backend_egl->egl_context) { eglDestroyContext (backend_egl->edpy, backend_egl->egl_context); backend_egl->egl_context = NULL; } stage_egl->egl_surface = eglCreateWindowSurface (backend_egl->edpy, configs[0], NULL, NULL); if (stage_egl->egl_surface == EGL_NO_SURFACE) { g_critical ("Unable to create an EGL surface"); CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED); return; } eglQuerySurface (backend_egl->edpy, stage_egl->egl_surface, EGL_WIDTH, &stage_egl->surface_width); eglQuerySurface (backend_egl->edpy, stage_egl->egl_surface, EGL_HEIGHT, &stage_egl->surface_height); CLUTTER_NOTE (BACKEND, "EGL surface is %ix%i", stage_egl->surface_width, stage_egl->surface_height); if (G_UNLIKELY (backend_egl->egl_context == NULL)) { CLUTTER_NOTE (GL, "Creating EGL Context"); backend_egl->egl_context = eglCreateContext (backend_egl->edpy, configs[0], EGL_NO_CONTEXT, NULL); if (backend_egl->egl_context == EGL_NO_CONTEXT) { g_critical ("Unable to create a suitable EGL context"); CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED); return; } } /* this will make sure to set the current context */ CLUTTER_NOTE (BACKEND, "Setting context"); /* this should be done in ClutterBackend::ensure_context */ status = eglMakeCurrent (backend_egl->edpy, stage_egl->egl_surface, stage_egl->egl_surface, backend_egl->egl_context); if (status != EGL_TRUE) { g_critical ("eglMakeCurrent failed"); CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED); return; } } else { g_warning("EGL Backend does not yet support offscreen rendering\n"); CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED); } }
static void clutter_stage_egl_hide (ClutterActor *actor) { CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_MAPPED); }
static void clutter_stage_win32_realize (ClutterActor *actor) { ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (actor); ClutterBackendWin32 *backend_win32; PIXELFORMATDESCRIPTOR pfd; int pf; CLUTTER_NOTE (MISC, "Realizing main stage"); backend_win32 = CLUTTER_BACKEND_WIN32 (clutter_get_default_backend ()); if (stage_win32->hwnd == NULL) { ATOM window_class = clutter_stage_win32_get_window_class (); int win_xpos, win_ypos, win_width, win_height; if (window_class == 0) { g_critical ("Unable to register window class"); goto fail; } /* If we're in fullscreen mode then use the fullscreen rect instead */ if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN)) { get_fullscreen_rect (stage_win32); win_xpos = stage_win32->fullscreen_rect.left; win_ypos = stage_win32->fullscreen_rect.top; win_width = stage_win32->fullscreen_rect.right - win_xpos; win_height = stage_win32->fullscreen_rect.left - win_ypos; } else { win_xpos = win_ypos = CW_USEDEFAULT; get_full_window_size (stage_win32, stage_win32->win_width, stage_win32->win_height, &win_width, &win_height); } stage_win32->hwnd = CreateWindowW ((LPWSTR) MAKEINTATOM (window_class), L".", get_window_style (stage_win32), win_xpos, win_ypos, win_width, win_height, NULL, NULL, GetModuleHandle (NULL), NULL); if (stage_win32->hwnd == NULL) { g_critical ("Unable to create stage window"); goto fail; } /* Store a pointer to the actor in the extra bytes of the window so we can quickly access it in the window procedure */ SetWindowLongPtrW (stage_win32->hwnd, 0, (LONG_PTR) stage_win32); } if (stage_win32->client_dc) ReleaseDC (stage_win32->hwnd, stage_win32->client_dc); stage_win32->client_dc = GetDC (stage_win32->hwnd); pf = clutter_stage_win32_choose_pixel_format (stage_win32->client_dc, &pfd); if (pf == 0 || !SetPixelFormat (stage_win32->client_dc, pf, &pfd)) { g_critical ("Unable to find suitable GL pixel format"); goto fail; } if (backend_win32->gl_context == NULL) { backend_win32->gl_context = wglCreateContext (stage_win32->client_dc); if (backend_win32->gl_context == NULL) { g_critical ("Unable to create suitable GL context"); goto fail; } /* Make the context current so we can check the GL version */ wglMakeCurrent (stage_win32->client_dc, backend_win32->gl_context); if (!clutter_stage_win32_check_gl_version ()) { g_critical ("OpenGL version number is too low"); goto fail; } } CLUTTER_NOTE (BACKEND, "Successfully realized stage"); return; fail: CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED); }
static void clutter_stage_egl_realize (ClutterActor *actor) { ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (actor); ClutterBackendEGL *backend_egl; EGLConfig configs[2]; EGLint config_count; EGLBoolean status; gboolean is_offscreen; CLUTTER_NOTE (BACKEND, "Realizing main stage"); g_object_get (stage_egl->wrapper, "offscreen", &is_offscreen, NULL); backend_egl = CLUTTER_BACKEND_EGL (clutter_get_default_backend ()); if (G_LIKELY (!is_offscreen)) { EGLint cfg_attribs[] = { EGL_BUFFER_SIZE, EGL_DONT_CARE, EGL_RED_SIZE, 5, EGL_GREEN_SIZE, 6, EGL_BLUE_SIZE, 5, EGL_DEPTH_SIZE, 16, EGL_ALPHA_SIZE, EGL_DONT_CARE, EGL_STENCIL_SIZE, 2, #ifdef HAVE_COGL_GLES2 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, #else /* HAVE_COGL_GLES2 */ EGL_SURFACE_TYPE, EGL_WINDOW_BIT, #endif /* HAVE_COGL_GLES2 */ EGL_NONE }; status = eglGetConfigs (backend_egl->edpy, configs, 2, &config_count); if (status != EGL_TRUE) { g_critical ("eglGetConfigs failed"); CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED); return; } status = eglChooseConfig (backend_egl->edpy, cfg_attribs, configs, G_N_ELEMENTS (configs), &config_count); if (status != EGL_TRUE) { g_critical ("eglChooseConfig failed"); CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED); return; } CLUTTER_NOTE (BACKEND, "Got %i configs", config_count); if (stage_egl->egl_surface != EGL_NO_SURFACE) { eglDestroySurface (backend_egl->edpy, stage_egl->egl_surface); stage_egl->egl_surface = EGL_NO_SURFACE; } if (backend_egl->egl_context) { eglDestroyContext (backend_egl->edpy, backend_egl->egl_context); backend_egl->egl_context = NULL; } stage_egl->egl_surface = eglCreateWindowSurface (backend_egl->edpy, configs[0], NULL, NULL); if (stage_egl->egl_surface == EGL_NO_SURFACE) { g_critical ("Unable to create an EGL surface"); CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED); return; } eglQuerySurface (backend_egl->edpy, stage_egl->egl_surface, EGL_WIDTH, &stage_egl->surface_width); eglQuerySurface (backend_egl->edpy, stage_egl->egl_surface, EGL_HEIGHT, &stage_egl->surface_height); CLUTTER_NOTE (BACKEND, "EGL surface is %ix%i", stage_egl->surface_width, stage_egl->surface_height); if (G_UNLIKELY (backend_egl->egl_context == NULL)) { #ifdef HAVE_COGL_GLES2 static const EGLint attribs[3] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; backend_egl->egl_context = eglCreateContext (backend_egl->edpy, configs[0], EGL_NO_CONTEXT, attribs); #else /* Seems some GLES implementations 1.x do not like attribs... */ backend_egl->egl_context = eglCreateContext (backend_egl->edpy, configs[0], EGL_NO_CONTEXT, NULL); #endif if (backend_egl->egl_context == EGL_NO_CONTEXT) { g_critical ("Unable to create a suitable EGL context"); CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED); return; } CLUTTER_NOTE (GL, "Created EGL Context"); } CLUTTER_NOTE (BACKEND, "Setting context"); /* eglnative can have only one stage */ status = eglMakeCurrent (backend_egl->edpy, stage_egl->egl_surface, stage_egl->egl_surface, backend_egl->egl_context); if (status != EGL_TRUE) { g_critical ("eglMakeCurrent failed"); CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED); return; } /* since we only have one size and it cannot change, we * just need to update the GL viewport now that we have * been realized */ CLUTTER_SET_PRIVATE_FLAGS (actor, CLUTTER_ACTOR_SYNC_MATRICES); } else { g_warning ("EGL Backend does not yet support offscreen rendering\n"); CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED); return; } }