Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: ui/ozone/platform/dri/gbm_buffer.cc

Issue 393233005: [Ozone-DRI] Convert HardwareDisplayController to use scanout buffers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/ozone/platform/dri/gbm_buffer.h ('k') | ui/ozone/platform/dri/gbm_surface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/dri/gbm_buffer.cc
diff --git a/ui/ozone/platform/dri/gbm_buffer.cc b/ui/ozone/platform/dri/gbm_buffer.cc
index 53c0f25e3b93aa6783637ebb26254515c3bf2184..79e8b3b53968c7c9740726082b51883c30080e8e 100644
--- a/ui/ozone/platform/dri/gbm_buffer.cc
+++ b/ui/ozone/platform/dri/gbm_buffer.cc
@@ -7,16 +7,10 @@
#include <gbm.h>
#include "base/logging.h"
-#include "ui/ozone/platform/dri/dri_wrapper.h"
-#include "ui/ozone/platform/dri/hardware_display_controller.h"
namespace ui {
+
namespace {
-// 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;
int GetGbmFormatFromBufferFormat(SurfaceFactoryOzone::BufferFormat fmt) {
switch (fmt) {
@@ -32,87 +26,55 @@ int GetGbmFormatFromBufferFormat(SurfaceFactoryOzone::BufferFormat fmt) {
}
return 0;
}
-}
-GbmBuffer::GbmBuffer(gbm_device* device, DriWrapper* dri, const gfx::Size& size)
- : gbm_device_(device),
- bo_(NULL),
- handle_(0),
- framebuffer_(0),
- dri_(dri),
- size_(size) {
+} // namespace
+
+GbmBuffer::GbmBuffer(DriWrapper* dri, gbm_bo* bo, bool scanout)
+ : GbmBufferBase(dri, bo, scanout) {
}
GbmBuffer::~GbmBuffer() {
- if (framebuffer_)
- dri_->RemoveFramebuffer(framebuffer_);
- if (bo_)
- gbm_bo_destroy(bo_);
+ if (bo())
+ gbm_bo_destroy(bo());
}
-bool GbmBuffer::InitializeBuffer(SurfaceFactoryOzone::BufferFormat format,
- bool scanout) {
+// static
+scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer(
+ DriWrapper* dri,
+ gbm_device* device,
+ SurfaceFactoryOzone::BufferFormat format,
+ const gfx::Size& size,
+ bool scanout) {
unsigned flags = GBM_BO_USE_RENDERING;
if (scanout)
flags |= GBM_BO_USE_SCANOUT;
- bo_ = gbm_bo_create(gbm_device_,
- size_.width(),
- size_.height(),
- GetGbmFormatFromBufferFormat(format),
- flags);
- if (!bo_)
- return false;
-
- gbm_bo_set_user_data(bo_, this, NULL);
- handle_ = gbm_bo_get_handle(bo_).u32;
-
- if (scanout &&
- !dri_->AddFramebuffer(size_.width(),
- size_.height(),
- kColorDepth,
- kPixelDepth,
- gbm_bo_get_stride(bo_),
- handle_,
- &framebuffer_)) {
- return false;
- }
- return true;
-}
-
-bool GbmBuffer::Initialize() {
- return bo_ != NULL;
-}
-
-uint32_t GbmBuffer::GetFramebufferId() const {
- return framebuffer_;
-}
-
-uint32_t GbmBuffer::GetHandle() const {
- return handle_;
-}
-
-gfx::Size GbmBuffer::Size() const {
- return size_;
-}
-
-void GbmBuffer::PreSwapBuffers() {
-}
-
-void GbmBuffer::SwapBuffers() {
+ gbm_bo* bo = gbm_bo_create(device,
+ size.width(),
+ size.height(),
+ GetGbmFormatFromBufferFormat(format),
+ flags);
+ if (!bo)
+ return NULL;
+
+ scoped_refptr<GbmBuffer> buffer(new GbmBuffer(dri, bo, scanout));
+ if (scanout && !buffer->GetFramebufferId())
+ return NULL;
+
+ return buffer;
}
-GbmPixmap::GbmPixmap(gbm_device* device, DriWrapper* dri, const gfx::Size& size)
- : buffer_(device, dri, size) {
+GbmPixmap::GbmPixmap(scoped_refptr<GbmBuffer> buffer) : buffer_(buffer) {
}
GbmPixmap::~GbmPixmap() {
}
void* GbmPixmap::GetEGLClientBuffer() {
- return buffer_.bo();
+ return buffer_->bo();
}
int GbmPixmap::GetDmaBufFd() {
+ NOTIMPLEMENTED();
return -1;
}
« no previous file with comments | « ui/ozone/platform/dri/gbm_buffer.h ('k') | ui/ozone/platform/dri/gbm_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698