| Index: ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc
|
| diff --git a/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc b/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc
|
| index 8c547f8da6de5ad6994fef0044c27e5db5903242..a04bc5c4f85bcb8dbe80007038c9033a9d05461d 100644
|
| --- a/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc
|
| +++ b/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc
|
| @@ -58,46 +58,42 @@
|
|
|
| // static
|
| std::unique_ptr<ClientNativePixmap> ClientNativePixmapDmaBuf::ImportFromDmabuf(
|
| - const gfx::NativePixmapHandle& handle,
|
| - const gfx::Size& size) {
|
| - return base::WrapUnique(new ClientNativePixmapDmaBuf(handle, size));
|
| + int dmabuf_fd,
|
| + const gfx::Size& size,
|
| + int stride) {
|
| + DCHECK_GE(dmabuf_fd, 0);
|
| + base::CheckedNumeric<size_t> map_size = stride;
|
| + map_size *= size.height();
|
| + if (!map_size.IsValid())
|
| + return nullptr;
|
| + return base::WrapUnique(new ClientNativePixmapDmaBuf(dmabuf_fd, size, stride,
|
| + map_size.ValueOrDie()));
|
| }
|
|
|
| -ClientNativePixmapDmaBuf::ClientNativePixmapDmaBuf(
|
| - const gfx::NativePixmapHandle& handle,
|
| - const gfx::Size& size)
|
| - : pixmap_handle_(handle), size_(size), data_{0} {
|
| +ClientNativePixmapDmaBuf::ClientNativePixmapDmaBuf(int dmabuf_fd,
|
| + const gfx::Size& size,
|
| + int stride,
|
| + size_t map_size)
|
| + : dmabuf_fd_(dmabuf_fd), map_size_(map_size), size_(size), stride_(stride) {
|
| TRACE_EVENT0("drm", "ClientNativePixmapDmaBuf");
|
| - // TODO(dcastagna): support multiple fds.
|
| - DCHECK_EQ(1u, handle.fds.size());
|
| - DCHECK_GE(handle.fds.front().fd, 0);
|
| - dmabuf_fd_.reset(handle.fds.front().fd);
|
| -
|
| - DCHECK_GE(handle.planes.back().size, 0u);
|
| - size_t map_size = handle.planes.back().offset + handle.planes.back().size;
|
| - data_ = mmap(nullptr, map_size, (PROT_READ | PROT_WRITE), MAP_SHARED,
|
| - dmabuf_fd_.get(), 0);
|
| + data_ = mmap(nullptr, map_size_, (PROT_READ | PROT_WRITE), MAP_SHARED,
|
| + dmabuf_fd, 0);
|
| if (data_ == MAP_FAILED) {
|
| PLOG(ERROR) << "Failed mmap().";
|
| - base::TerminateBecauseOutOfMemory(map_size);
|
| + base::TerminateBecauseOutOfMemory(map_size_);
|
| }
|
| }
|
|
|
| ClientNativePixmapDmaBuf::~ClientNativePixmapDmaBuf() {
|
| TRACE_EVENT0("drm", "~ClientNativePixmapDmaBuf");
|
| - size_t map_size =
|
| - pixmap_handle_.planes.back().offset + pixmap_handle_.planes.back().size;
|
| - int ret = munmap(data_, map_size);
|
| + int ret = munmap(data_, map_size_);
|
| DCHECK(!ret);
|
| }
|
|
|
| -bool ClientNativePixmapDmaBuf::Map() {
|
| +void* ClientNativePixmapDmaBuf::Map() {
|
| TRACE_EVENT0("drm", "DmaBuf:Map");
|
| - if (data_ != nullptr) {
|
| - PrimeSyncStart(dmabuf_fd_.get());
|
| - return true;
|
| - }
|
| - return false;
|
| + PrimeSyncStart(dmabuf_fd_.get());
|
| + return data_;
|
| }
|
|
|
| void ClientNativePixmapDmaBuf::Unmap() {
|
| @@ -105,15 +101,8 @@
|
| PrimeSyncEnd(dmabuf_fd_.get());
|
| }
|
|
|
| -void* ClientNativePixmapDmaBuf::GetMemoryAddress(size_t plane) const {
|
| - DCHECK_LT(plane, pixmap_handle_.planes.size());
|
| - uint8_t* address = reinterpret_cast<uint8_t*>(data_);
|
| - return address + pixmap_handle_.planes[plane].offset;
|
| -}
|
| -
|
| -int ClientNativePixmapDmaBuf::GetStride(size_t plane) const {
|
| - DCHECK_LT(plane, pixmap_handle_.planes.size());
|
| - return pixmap_handle_.planes[plane].stride;
|
| +void ClientNativePixmapDmaBuf::GetStride(int* stride) const {
|
| + *stride = stride_;
|
| }
|
|
|
| } // namespace ui
|
|
|