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

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

Issue 365193003: Change NativeBufferOzone to be an object and move the overlay calls to the surface object. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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
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
new file mode 100644
index 0000000000000000000000000000000000000000..f50e53163f18a2a1230eb2320cdd3e6a38d49b29
--- /dev/null
+++ b/ui/ozone/platform/dri/gbm_buffer.cc
@@ -0,0 +1,115 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/ozone/platform/dri/gbm_buffer.h"
+
+#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) {
+ case SurfaceFactoryOzone::UNKNOWN:
+ return 0;
+ // TODO(alexst): Setting this to XRGB for now to allow presentation
+ // as a primary plane but disallowing overlay transparency. Address this
+ // to allow both use cases.
+ case SurfaceFactoryOzone::RGBA_8888:
+ return GBM_FORMAT_XRGB8888;
+ case SurfaceFactoryOzone::RGB_888:
+ return GBM_FORMAT_RGB888;
+ }
+ return 0;
+}
+}
+
+GbmBuffer::GbmBuffer(gbm_device* device, DriWrapper* dri,
alexst (slow to review) 2014/07/03 18:30:32 nit: these fit in 80chars
achaulk 2014/07/03 19:49:43 Done.
+ const gfx::Size& size)
+ : gbm_device_(device),
+ bo_(NULL),
+ handle_(0),
+ framebuffer_(0),
+ dri_(dri),
+ size_(size) {}
+
+GbmBuffer::~GbmBuffer() {
+ if (framebuffer_)
+ dri_->RemoveFramebuffer(framebuffer_);
+ if (bo_)
+ gbm_bo_destroy(bo_);
+}
+
+bool GbmBuffer::InitializeBuffer(SurfaceFactoryOzone::BufferFormat format,
+ 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 (!dri_->AddFramebuffer(size_.width(),
dnicoara 2014/07/03 18:30:16 Should skip this is the buffer isn't a scanout buf
achaulk 2014/07/03 19:49:43 Done.
+ 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::SwapBuffers() {
+ NOTREACHED();
+}
+
+void* GbmBuffer::native_handle() OVERRIDE {
+ return bo_;
+}
+
+int GbmBuffer::dma_buf_fd() OVERRIDE {
+ return -1;
+}
+
+//static
alexst (slow to review) 2014/07/03 18:30:32 nit: space after //
achaulk 2014/07/03 19:49:43 Done.
+GbmBuffer* GbmBuffer::GetFromNative(NativeBufferOzone buffer) {
+ gbm_bo* bo = reinterpret_cast<gbm_bo*>(buffer);
+ return static_cast<GbmBuffer*>(gbm_bo_get_user_data(bo));
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698