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

Unified Diff: ui/ozone/platform/drm/gpu/gbm_buffer_base.cc

Issue 1285183008: Ozone integration. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: add missing license header Created 5 years, 4 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/drm/gpu/gbm_buffer_base.h ('k') | ui/ozone/platform/drm/gpu/gbm_device.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/drm/gpu/gbm_buffer_base.cc
diff --git a/ui/ozone/platform/drm/gpu/gbm_buffer_base.cc b/ui/ozone/platform/drm/gpu/gbm_buffer_base.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c283a64db2c8a6ea2a6fa60a5cb09971ad3b8fed
--- /dev/null
+++ b/ui/ozone/platform/drm/gpu/gbm_buffer_base.cc
@@ -0,0 +1,52 @@
+// 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/drm/gpu/gbm_buffer_base.h"
+
+#include <gbm.h>
+
+#include "base/logging.h"
+#include "ui/ozone/platform/drm/gpu/drm_device.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;
+
+} // namespace
+
+GbmBufferBase::GbmBufferBase(const scoped_refptr<DrmDevice>& drm,
+ gbm_bo* bo,
+ bool scanout)
+ : drm_(drm), bo_(bo) {
+ if (scanout &&
+ !drm_->AddFramebuffer(gbm_bo_get_width(bo), gbm_bo_get_height(bo),
+ kColorDepth, kPixelDepth, gbm_bo_get_stride(bo),
+ gbm_bo_get_handle(bo).u32, &framebuffer_))
+ PLOG(ERROR) << "Failed to register buffer";
+}
+
+GbmBufferBase::~GbmBufferBase() {
+ if (framebuffer_)
+ drm_->RemoveFramebuffer(framebuffer_);
+}
+
+uint32_t GbmBufferBase::GetFramebufferId() const {
+ return framebuffer_;
+}
+
+uint32_t GbmBufferBase::GetHandle() const {
+ return gbm_bo_get_handle(bo_).u32;
+}
+
+gfx::Size GbmBufferBase::GetSize() const {
+ return gfx::Size(gbm_bo_get_width(bo_), gbm_bo_get_height(bo_));
+}
+
+} // namespace ui
« no previous file with comments | « ui/ozone/platform/drm/gpu/gbm_buffer_base.h ('k') | ui/ozone/platform/drm/gpu/gbm_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698