Index: ui/ozone/platform/dri/dri_buffer.cc |
diff --git a/ui/ozone/platform/dri/dri_buffer.cc b/ui/ozone/platform/dri/dri_buffer.cc |
index 1933fe6d01eaaa57805c5fad704fa8ae9149fc27..6fab6863b188c6da81f6d291078dbb4fead8dade 100644 |
--- a/ui/ozone/platform/dri/dri_buffer.cc |
+++ b/ui/ozone/platform/dri/dri_buffer.cc |
@@ -4,14 +4,7 @@ |
#include "ui/ozone/platform/dri/dri_buffer.h" |
-#include <errno.h> |
-#include <sys/mman.h> |
-#include <sys/types.h> |
-#include <xf86drm.h> |
- |
#include "base/logging.h" |
-#include "third_party/skia/include/core/SkCanvas.h" |
-#include "ui/ozone/platform/dri/dri_util.h" |
#include "ui/ozone/platform/dri/dri_wrapper.h" |
namespace ui { |
@@ -39,40 +32,6 @@ uint8_t GetColorDepth(SkColorType type) { |
} |
} |
-void DestroyDumbBuffer(int fd, uint32_t handle) { |
- struct drm_mode_destroy_dumb destroy_request; |
- memset(&destroy_request, 0, sizeof(destroy_request)); |
- destroy_request.handle = handle; |
- drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_request); |
-} |
- |
-bool CreateDumbBuffer(int fd, |
- const SkImageInfo& info, |
- uint32_t* handle, |
- uint32_t* stride) { |
- struct drm_mode_create_dumb request; |
- memset(&request, 0, sizeof(request)); |
- request.width = info.width(); |
- request.height = info.height(); |
- request.bpp = info.bytesPerPixel() << 3; |
- request.flags = 0; |
- |
- if (drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &request) < 0) { |
- VLOG(2) << "Cannot create dumb buffer (" << errno << ") " |
- << strerror(errno); |
- return false; |
- } |
- |
- // The driver may choose to align the last row as well. We don't care about |
- // the last alignment bits since they aren't used for display purposes, so |
- // just check that the expected size is <= to what the driver allocated. |
- DCHECK_LE(info.getSafeSize(request.pitch), request.size); |
- |
- *handle = request.handle; |
- *stride = request.pitch; |
- return true; |
-} |
- |
} // namespace |
DriBuffer::DriBuffer(DriWrapper* dri) |
@@ -90,23 +49,13 @@ DriBuffer::~DriBuffer() { |
if (!pixels) |
return; |
- munmap(pixels, info.getSafeSize(stride_)); |
- DestroyDumbBuffer(dri_->get_fd(), handle_); |
+ dri_->DestroyDumbBuffer(info, handle_, stride_, pixels); |
} |
bool DriBuffer::Initialize(const SkImageInfo& info) { |
void* pixels = NULL; |
- if (!CreateDumbBuffer(dri_->get_fd(), info, &handle_, &stride_)) { |
- VLOG(2) << "Cannot allocate drm dumb buffer"; |
- return false; |
- } |
- |
- if (!MapDumbBuffer(dri_->get_fd(), |
- handle_, |
- info.getSafeSize(stride_), |
- &pixels)) { |
- VLOG(2) << "Cannot map drm dumb buffer"; |
- DestroyDumbBuffer(dri_->get_fd(), handle_); |
+ if (!dri_->CreateDumbBuffer(info, &handle_, &stride_, &pixels)) { |
+ VLOG(2) << "Cannot create drm dumb buffer"; |
return false; |
} |