}
bool Gralloc1BufferHandler::ReleaseBuffer(HWCNativeHandle handle) {
- if (!ReleaseGraphicsBuffer(handle))
+ if (!ReleaseGraphicsBuffer(handle, fd_))
return false;
gralloc1_device_t *gralloc1_dvc =
}
bool GrallocBufferHandler::ReleaseBuffer(HWCNativeHandle handle) {
- return ReleaseGraphicsBuffer(handle);
+ return ReleaseGraphicsBuffer(handle, fd_);
}
void GrallocBufferHandler::DestroyHandle(HWCNativeHandle handle) {
buffer_handle_t handle_ = NULL;
android::sp<android::GraphicBuffer> buffer_ = NULL;
native_handle_t* imported_handle_ = NULL;
+ uint32_t gem_handle_ = 0;
bool hwc_buffer_ = false;
};
return true;
}
-static bool ReleaseGraphicsBuffer(HWCNativeHandle handle) {
+static bool ReleaseGraphicsBuffer(HWCNativeHandle handle, int fd) {
if (!handle)
return false;
handle->buffer_.clear();
}
+ if (handle->gem_handle_ > 0) {
+ struct drm_gem_close gem_close;
+ memset(&gem_close, 0, sizeof(gem_close));
+ gem_close.handle = handle->gem_handle_;
+ int ret = drmIoctl(fd, DRM_IOCTL_GEM_CLOSE, &gem_close);
+ if (ret)
+ ETRACE("Failed to close gem handle %d", ret);
+ }
+
+ handle->gem_handle_ = 0;
+
return true;
}
bo->height = gr_handle->height;
bo->prime_fd = gr_handle->fds[0];
- uint32_t id;
+ uint32_t id = 0;
if (drmPrimeFDToHandle(fd, bo->prime_fd, &id)) {
ETRACE("drmPrimeFDToHandle failed.");
return false;
bo->usage |= hwcomposer::kLayerNormal;
}
+ handle->gem_handle_ = id;
+
return true;
}
#endif