Skip to content

Instantly share code, notes, and snippets.

@tiagovignatti
Created June 24, 2014 21:03
Show Gist options
  • Save tiagovignatti/4b6c176ef09cbe7c4039 to your computer and use it in GitHub Desktop.
Save tiagovignatti/4b6c176ef09cbe7c4039 to your computer and use it in GitHub Desktop.
diff --git a/ui/ozone/platform/dri/buffer_data.cc b/ui/ozone/platform/dri/buffer_data.cc
index a2ea1b3..d070e54 100644
--- a/ui/ozone/platform/dri/buffer_data.cc
+++ b/ui/ozone/platform/dri/buffer_data.cc
@@ -14,8 +14,7 @@ namespace ui {
// Pixel configuration for the current buffer format.
// TODO(dnicoara) These will need to change once we query the hardware for
// supported configurations.
-const uint8_t kColorDepth = 24;
-const uint8_t kPixelDepth = 32;
+const uint32_t kBufferFormat = GBM_FORMAT_XRGB8888;
BufferData::BufferData(DriWrapper* dri, gbm_bo* buffer)
: dri_(dri),
@@ -24,13 +23,12 @@ BufferData::BufferData(DriWrapper* dri, gbm_bo* buffer)
// Register the buffer with the controller. This will allow us to scan out the
// buffer once we're done drawing into it. If we can't register the buffer
// then there's no point in having BufferData associated with it.
- if (!dri_->AddFramebuffer(gbm_bo_get_width(buffer),
- gbm_bo_get_height(buffer),
- kColorDepth,
- kPixelDepth,
- gbm_bo_get_stride(buffer),
- handle_,
- &framebuffer_)) {
+ if (!dri_->AddFramebuffer2(gbm_bo_get_width(buffer),
+ gbm_bo_get_height(buffer),
+ kBufferFormat,
+ gbm_bo_get_stride(buffer),
+ handle_,
+ &framebuffer_)) {
LOG(ERROR) << "Failed to register buffer";
}
}
diff --git a/ui/ozone/platform/dri/dri_wrapper.cc b/ui/ozone/platform/dri/dri_wrapper.cc
index 5231bd0..0c089ed 100644
--- a/ui/ozone/platform/dri/dri_wrapper.cc
+++ b/ui/ozone/platform/dri/dri_wrapper.cc
@@ -74,6 +74,29 @@ bool DriWrapper::AddFramebuffer(uint32_t width,
framebuffer);
}
+bool DriWrapper::AddFramebuffer2(uint32_t width,
+ uint32_t height,
+ uint32_t format,
+ uint32_t stride,
+ uint32_t handle,
+ uint32_t* framebuffer) {
+ uint32_t handles[4] = { handle, 0, 0, 0 };
+ uint32_t pitches[4] = { stride, 0, 0, 0 };
+ uint32_t offsets[4] = { 0, 0, 0, 0 };
+ CHECK(fd_ >= 0);
+ bool ret = !drmModeAddFB2(fd_,
+ width,
+ height,
+ format,
+ handles,
+ pitches,
+ offsets,
+ framebuffer,
+ 0);
+ LOG(ERROR) << "drm_mode_add_fb2 ret: " << ret << " fb: " << *framebuffer << " " << handle << " " << stride;
+ return ret;
+}
+
bool DriWrapper::RemoveFramebuffer(uint32_t framebuffer) {
CHECK(fd_ >= 0);
return !drmModeRmFB(fd_, framebuffer);
@@ -83,6 +106,7 @@ bool DriWrapper::PageFlip(uint32_t crtc_id,
uint32_t framebuffer,
void* data) {
CHECK(fd_ >= 0);
+ LOG(ERROR) << "flipping: " << crtc_id << " " << framebuffer;
return !drmModePageFlip(fd_,
crtc_id,
framebuffer,
diff --git a/ui/ozone/platform/dri/dri_wrapper.h b/ui/ozone/platform/dri/dri_wrapper.h
index 014d143..0f6c345 100644
--- a/ui/ozone/platform/dri/dri_wrapper.h
+++ b/ui/ozone/platform/dri/dri_wrapper.h
@@ -61,6 +61,15 @@ class OZONE_EXPORT DriWrapper {
uint32_t handle,
uint32_t* framebuffer);
+ // Register a buffer with the CRTC and buffer formats. On successful
+ // registration, the CRTC will assign a framebuffer ID to |framebuffer|.
+ virtual bool AddFramebuffer2(uint32_t width,
+ uint32_t height,
+ uint32_t format,
+ uint32_t stride,
+ uint32_t handle,
+ uint32_t* framebuffer);
+
// Deregister the given |framebuffer|.
virtual bool RemoveFramebuffer(uint32_t framebuffer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment