static cairo_bool_t _cairo_gl_ensure_depth_stencil_buffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { cairo_gl_dispatch_t *dispatch = &ctx->dispatch; if (surface->depth_stencil) return TRUE; _cairo_gl_ensure_framebuffer (ctx, surface); dispatch->GenRenderbuffers (1, &surface->depth_stencil); dispatch->BindRenderbuffer (GL_RENDERBUFFER, surface->depth_stencil); dispatch->RenderbufferStorage (GL_RENDERBUFFER, _get_depth_stencil_format (ctx), surface->width, surface->height); dispatch->FramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, surface->depth_stencil); dispatch->FramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, surface->depth_stencil); if (dispatch->CheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { dispatch->DeleteRenderbuffers (1, &surface->depth_stencil); surface->depth_stencil = 0; return FALSE; } return TRUE; }
static cairo_bool_t _cairo_gl_ensure_msaa_depth_stencil_buffer (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface) { cairo_gl_dispatch_t *dispatch = &ctx->dispatch; if (surface->msaa_depth_stencil) return TRUE; _cairo_gl_ensure_framebuffer (ctx, surface); #if CAIRO_HAS_GL_SURFACE if (ctx->gl_flavor == CAIRO_GL_FLAVOR_DESKTOP) _cairo_gl_ensure_multisampling (ctx, surface); #endif dispatch->GenRenderbuffers (1, &surface->msaa_depth_stencil); dispatch->BindRenderbuffer (GL_RENDERBUFFER, surface->msaa_depth_stencil); dispatch->RenderbufferStorageMultisample (GL_RENDERBUFFER, ctx->num_samples, _get_depth_stencil_format (ctx), surface->width, surface->height); #if CAIRO_HAS_GL_SURFACE if (ctx->gl_flavor == CAIRO_GL_FLAVOR_DESKTOP) { dispatch->FramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, surface->msaa_depth_stencil); } #endif #if CAIRO_HAS_GLESV2_SURFACE if (ctx->gl_flavor == CAIRO_GL_FLAVOR_ES) { dispatch->FramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, surface->msaa_depth_stencil); dispatch->FramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, surface->msaa_depth_stencil); } #endif if (dispatch->CheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { dispatch->DeleteRenderbuffers (1, &surface->msaa_depth_stencil); surface->msaa_depth_stencil = 0; return FALSE; } return TRUE; }
static void _cairo_gl_replace_depth_stencil_buffer (cairo_gl_context_t *ctx, int width, int height) { cairo_gl_dispatch_t *dispatch = &ctx->dispatch; if (ctx->shared_depth_stencil) dispatch->DeleteRenderbuffers (1, &ctx->shared_depth_stencil); dispatch->GenRenderbuffers (1, &ctx->shared_depth_stencil); dispatch->BindRenderbuffer (GL_RENDERBUFFER, ctx->shared_depth_stencil); dispatch->RenderbufferStorage (GL_RENDERBUFFER, _get_depth_stencil_format (ctx), width, height); ctx->shared_depth_stencil_width = width; ctx->shared_depth_stencil_height = height; }