static DFBResult mesaDeallocateBuffer( CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceBuffer *buffer, CoreSurfaceAllocation *allocation, void *alloc_data ) { MesaPoolData *data = pool_data; MesaAllocationData *alloc = alloc_data; MesaPoolLocalData *local = pool_local; (void)data; D_DEBUG_AT( Mesa_Surfaces, "%s( %p )\n", __FUNCTION__, buffer ); D_MAGIC_ASSERT( pool, CoreSurfacePool ); D_MAGIC_ASSERT( data, MesaPoolData ); D_MAGIC_ASSERT( alloc, MesaAllocationData ); drmModeRmFB( local->mesa->fd, alloc->fb_id ); eglDestroyImageKHR( local->mesa->dpy, alloc->image ); gbm_bo_destroy( alloc->bo ); D_MAGIC_CLEAR( alloc ); return DFB_OK; }
static EGLBoolean dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf); int i; if (!_eglPutSurface(surf)) return EGL_TRUE; (*dri2_dpy->core->destroyDrawable)(dri2_surf->dri_drawable); for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) { if (dri2_surf->color_buffers[i].bo) gbm_bo_destroy(dri2_surf->color_buffers[i].bo); } for (i = 0; i < __DRI_BUFFER_COUNT; i++) { if (dri2_surf->dri_buffers[i]) dri2_dpy->dri2->releaseBuffer(dri2_dpy->dri_screen, dri2_surf->dri_buffers[i]); } free(surf); return EGL_TRUE; }
static PixmapPtr xwl_dri3_pixmap_from_fd(ScreenPtr screen, int fd, CARD16 width, CARD16 height, CARD16 stride, CARD8 depth, CARD8 bpp) { struct xwl_screen *xwl_screen = xwl_screen_get(screen); struct gbm_import_fd_data data; struct gbm_bo *bo; PixmapPtr pixmap; if (width == 0 || height == 0 || depth < 15 || bpp != BitsPerPixel(depth) || stride < width * bpp / 8) return NULL; data.fd = fd; data.width = width; data.height = height; data.stride = stride; data.format = gbm_format_for_depth(depth); bo = gbm_bo_import(xwl_screen->gbm, GBM_BO_IMPORT_FD, &data, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); if (bo == NULL) return NULL; pixmap = xwl_glamor_create_pixmap_for_bo(screen, bo, depth); if (pixmap == NULL) { gbm_bo_destroy(bo); return NULL; } return pixmap; }
void QEglFSKmsGbmScreen::destroySurface() { if (m_gbm_bo_current) { gbm_bo_destroy(m_gbm_bo_current); m_gbm_bo_current = Q_NULLPTR; } if (m_gbm_bo_next) { gbm_bo_destroy(m_gbm_bo_next); m_gbm_bo_next = Q_NULLPTR; } if (m_gbm_surface) { gbm_surface_destroy(m_gbm_surface); m_gbm_surface = Q_NULLPTR; } }
RenderingBackendGBM::Surface::~Surface() { for (auto& it : m_lockedBuffers) { m_client.destroyBuffer(it.first); gbm_bo_destroy(it.second); } if (m_surface) gbm_surface_destroy(m_surface); }
QOpenWFDOutputBuffer::~QOpenWFDOutputBuffer() { wfdDestroySource(mPort->device()->handle(),mWfdSource); if (!mPort->device()->eglDestroyImage(mPort->device()->eglDisplay(),mEglImage)) { qDebug() << "could not delete eglImage"; } gbm_bo_destroy(mGbm_buffer); glDeleteRenderbuffers(1, &mRbo); }
QT_BEGIN_NAMESPACE QKmsCursor::QKmsCursor(QKmsScreen *screen) : m_screen(screen), m_graphicsBufferManager(screen->device()->gbmDevice()), m_moved(false) { gbm_bo *bo = gbm_bo_create(m_graphicsBufferManager, 64, 64, GBM_BO_FORMAT_ARGB8888, GBM_BO_USE_CURSOR_64X64 | GBM_BO_USE_RENDERING); m_eglImage = eglCreateImageKHR(m_screen->device()->eglDisplay(), 0, EGL_NATIVE_PIXMAP_KHR, bo, 0); gbm_bo_destroy(bo); m_cursorImage = new QPlatformCursorImage(0, 0, 0, 0, 0, 0); }
~Impl() override { /* destroy framebuffers */ for (auto& framebuffer : framebuffers_) { glDeleteFramebuffers(1, &framebuffer.gl_fb); glDeleteTextures(1, &framebuffer.gl_tex); egl_.DestroyImageKHR(egl_.display, framebuffer.image); drmModeRmFB(drm_->GetFD(), framebuffer.fb_id); close(framebuffer.fd); gbm_bo_destroy(framebuffer.bo); } eglDestroyContext(egl_.display, egl_.context); eglTerminate(egl_.display); gbm_device_destroy(gbm_); }
static Bool xwl_glamor_destroy_pixmap(PixmapPtr pixmap) { struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen); struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap); if (xwl_pixmap && pixmap->refcnt == 1) { if (xwl_pixmap->buffer) wl_buffer_destroy(xwl_pixmap->buffer); eglDestroyImageKHR(xwl_screen->egl_display, xwl_pixmap->image); gbm_bo_destroy(xwl_pixmap->bo); free(xwl_pixmap); } return glamor_destroy_pixmap(pixmap); }
void amdgpu_bo_unref(struct amdgpu_buffer **buffer) { struct amdgpu_buffer *buf = *buffer; buf->ref_count--; if (buf->ref_count) { return; } amdgpu_bo_unmap(buf); if (buf->flags & AMDGPU_BO_FLAGS_GBM) { gbm_bo_destroy(buf->bo.gbm); } else { amdgpu_bo_free(buf->bo.amdgpu); } free(buf); *buffer = NULL; }
void DisplayOzone::Buffer::reset() { if (mHasDRMFB) { int fd = gbm_device_get_fd(mDisplay->mGBM); drmModeRmFB(fd, mDRMFB); mHasDRMFB = false; } FunctionsGL *gl = mDisplay->mFunctionsGL; gl->deleteRenderbuffers(1, &mColorBuffer); mColorBuffer = 0; gl->deleteRenderbuffers(1, &mDSBuffer); mDSBuffer = 0; // Here we might destroy the GL framebuffer (mGLFB) but unlike every other resource in Buffer, // it does not get destroyed (and recreated) because when it is the default framebuffer for // an ANGLE surface then ANGLE expects it to have the same lifetime as that surface. if (mImage != EGL_NO_IMAGE_KHR) { mDisplay->mEGL->destroyImageKHR(mImage); mImage = EGL_NO_IMAGE_KHR; } if (mTexture) { gl->deleteTextures(1, &mTexture); mTexture = 0; } if (mDMABuf >= 0) { close(mDMABuf); mDMABuf = -1; } if (mBO) { gbm_bo_destroy(mBO); mBO = nullptr; } }
static void _cogl_winsys_onscreen_deinit (CoglOnscreen *onscreen) { CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); CoglContext *context = framebuffer->context; CoglRenderer *renderer = context->display->renderer; CoglRendererEGL *egl_renderer = renderer->winsys; CoglRendererKMS *kms_renderer = egl_renderer->platform; CoglOnscreenEGL *egl_onscreen = onscreen->winsys; CoglOnscreenKMS *kms_onscreen; int i; /* If we never successfully allocated then there's nothing to do */ if (egl_onscreen == NULL) return; kms_onscreen = egl_onscreen->platform; context->glBindFramebuffer (GL_FRAMEBUFFER_EXT, kms_onscreen->fb); context->glFramebufferRenderbuffer (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, 0); context->glDeleteRenderbuffers(2, kms_onscreen->color_rb); context->glFramebufferRenderbuffer (GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0); context->glDeleteRenderbuffers(1, &kms_onscreen->depth_rb); for (i = 0; i < 2; i++) { drmModeRmFB (kms_renderer->fd, kms_onscreen->fb_id[i]); _cogl_egl_destroy_image (context, kms_onscreen->image[i]); gbm_bo_destroy (kms_onscreen->bo[i]); } g_slice_free (CoglOnscreenKMS, kms_onscreen); g_slice_free (CoglOnscreenEGL, onscreen->winsys); onscreen->winsys = NULL; }
unsigned int glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h) { ScrnInfoPtr scrn = xf86ScreenToScrn(screen); struct glamor_egl_screen_private *glamor_egl; EGLImageKHR image; GLuint texture; #ifdef GLAMOR_HAS_GBM struct gbm_bo *bo; EGLNativePixmapType native_pixmap; glamor_egl = glamor_egl_get_screen_private(scrn); bo = gbm_bo_create(glamor_egl->gbm, w, h, GBM_FORMAT_ARGB8888, GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT); if (!bo) return 0; /* If the following assignment raises an error or a warning * then that means EGLNativePixmapType is not struct gbm_bo * * on your platform: This code won't work and you should not * compile with dri3 support enabled */ native_pixmap = bo; image = eglCreateImageKHR(glamor_egl->display, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, native_pixmap, NULL); gbm_bo_destroy(bo); if (image == EGL_NO_IMAGE_KHR) return 0; glamor_create_texture_from_image(glamor_egl, image, &texture); eglDestroyImageKHR(glamor_egl->display, image); return texture; #else return 0; /* this path should never happen */ #endif }
int glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen, PixmapPtr pixmap, unsigned int tex, Bool want_name, CARD16 *stride, CARD32 *size) { #ifdef GLAMOR_HAS_GBM ScrnInfoPtr scrn = xf86ScreenToScrn(screen); struct glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); struct glamor_egl_screen_private *glamor_egl; EGLImageKHR image; struct gbm_bo *bo; int fd = -1; EGLint attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_GL_TEXTURE_LEVEL_KHR, 0, EGL_NONE }; glamor_egl = glamor_egl_get_screen_private(scrn); glamor_get_context(glamor_priv); image = dixLookupPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key); if (image == EGL_NO_IMAGE_KHR || image == NULL) { image = eglCreateImageKHR(glamor_egl->display, glamor_egl->context, EGL_GL_TEXTURE_2D_KHR, (EGLClientBuffer) (uintptr_t) tex, attribs); if (image == EGL_NO_IMAGE_KHR) goto failure; dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key, image); glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM); } bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_EGL_IMAGE, image, 0); if (!bo) goto failure; pixmap->devKind = gbm_bo_get_stride(bo); if (want_name) { if (glamor_egl->has_gem) glamor_get_name_from_bo(glamor_egl->fd, bo, &fd); } else { if (glamor_get_fd_from_bo(glamor_egl->fd, bo, &fd)) { *stride = pixmap->devKind; *size = pixmap->devKind * gbm_bo_get_height(bo); } } gbm_bo_destroy(bo); failure: glamor_put_context(glamor_priv); return fd; #else return -1; #endif }
PixmapPtr glamor_egl_dri3_pixmap_from_fd(ScreenPtr screen, int fd, CARD16 width, CARD16 height, CARD16 stride, CARD8 depth, CARD8 bpp) { #ifdef GLAMOR_HAS_GBM ScrnInfoPtr scrn = xf86ScreenToScrn(screen); struct glamor_egl_screen_private *glamor_egl; struct gbm_bo *bo; EGLImageKHR image; PixmapPtr pixmap; Bool ret = FALSE; EGLint attribs[] = { EGL_WIDTH, 0, EGL_HEIGHT, 0, EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_ARGB8888, EGL_DMA_BUF_PLANE0_FD_EXT, 0, EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0, EGL_DMA_BUF_PLANE0_PITCH_EXT, 0, EGL_NONE }; glamor_egl = glamor_egl_get_screen_private(scrn); if (!glamor_egl->dri3_capable) return NULL; if (bpp != 32 || !(depth == 24 || depth == 32) || width == 0 || height == 0) return NULL; attribs[1] = width; attribs[3] = height; attribs[7] = fd; attribs[11] = stride; image = eglCreateImageKHR(glamor_egl->display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attribs); if (image == EGL_NO_IMAGE_KHR) return NULL; /* EGL_EXT_image_dma_buf_import can impose restrictions on the * usage of the image. Use gbm_bo to bypass the limitations. */ bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_EGL_IMAGE, image, 0); eglDestroyImageKHR(glamor_egl->display, image); if (!bo) return NULL; pixmap = screen->CreatePixmap(screen, 0, 0, depth, 0); screen->ModifyPixmapHeader(pixmap, width, height, 0, 0, stride, NULL); ret = glamor_egl_create_textured_pixmap_from_gbm_bo(pixmap, bo); gbm_bo_destroy(bo); if (ret) return pixmap; else { screen->DestroyPixmap(pixmap); return NULL; } #else return NULL; #endif }
uint32_t update_buffer_nativesurface(struct ivi_share_nativesurface *p_nativesurface) { if (NULL == p_nativesurface || NULL == p_nativesurface->surface) { return IVI_SHAREBUFFER_NOT_AVAILABLE; } struct drm_backend *backend = (struct drm_backend*)p_nativesurface->surface->compositor->backend; if (NULL == backend) { return IVI_SHAREBUFFER_NOT_AVAILABLE; } struct weston_buffer *buffer = p_nativesurface->surface->buffer_ref.buffer; if (!buffer) { return IVI_SHAREBUFFER_NOT_AVAILABLE; } struct gbm_bo *bo = gbm_bo_import(backend->gbm, GBM_BO_IMPORT_WL_BUFFER, buffer->legacy_buffer, GBM_BO_USE_SCANOUT); if (!bo) { weston_log("failed to import gbm_bo\n"); return IVI_SHAREBUFFER_INVALID; } struct drm_gem_flink flink = {0}; flink.handle = gbm_bo_get_handle(bo).u32; if (drmIoctl(gbm_device_get_fd(backend->gbm), DRM_IOCTL_GEM_FLINK, &flink) != 0) { weston_log("gem_flink: returned non-zero failed\n"); gbm_bo_destroy(bo); return IVI_SHAREBUFFER_INVALID; } uint32_t name = flink.name; uint32_t width = gbm_bo_get_width(bo); uint32_t height = gbm_bo_get_height(bo); uint32_t stride = gbm_bo_get_stride(bo); uint32_t format = IVI_SHARE_SURFACE_FORMAT_ARGB8888; uint32_t ret = IVI_SHAREBUFFER_STABLE; if (name != p_nativesurface->name) { ret |= IVI_SHAREBUFFER_DAMAGE; } if (width != p_nativesurface->width) { ret |= IVI_SHAREBUFFER_CONFIGURE; } if (height != p_nativesurface->height) { ret |= IVI_SHAREBUFFER_CONFIGURE; } if (stride != p_nativesurface->stride) { ret |= IVI_SHAREBUFFER_CONFIGURE; } p_nativesurface->name = name; p_nativesurface->width = width; p_nativesurface->height = height; p_nativesurface->stride = stride; p_nativesurface->format = format; gbm_bo_destroy(bo); return ret; }
QKmsCursor::~QKmsCursor() { drmModeSetCursor(m_screen->device()->fd(), m_screen->crtcId(), 0, 0, 0); gbm_bo_destroy(m_cursorBufferObject); }