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

Unified Diff: ui/ozone/platform/drm/gpu/gbm_surface_factory.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_surface_factory.h ('k') | ui/ozone/platform/drm/gpu/gbm_surfaceless.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_surface_factory.cc
diff --git a/ui/ozone/platform/drm/gpu/gbm_surface_factory.cc b/ui/ozone/platform/drm/gpu/gbm_surface_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f4828611e091c488c31c746e28d23ec04b1509df
--- /dev/null
+++ b/ui/ozone/platform/drm/gpu/gbm_surface_factory.cc
@@ -0,0 +1,158 @@
+// 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_surface_factory.h"
+
+#include <gbm.h>
+
+#include "base/files/file_path.h"
+#include "third_party/khronos/EGL/egl.h"
+#include "ui/ozone/common/egl_util.h"
+#include "ui/ozone/platform/drm/gpu/drm_device_manager.h"
+#include "ui/ozone/platform/drm/gpu/drm_window.h"
+#include "ui/ozone/platform/drm/gpu/gbm_buffer.h"
+#include "ui/ozone/platform/drm/gpu/gbm_device.h"
+#include "ui/ozone/platform/drm/gpu/gbm_surface.h"
+#include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h"
+#include "ui/ozone/platform/drm/gpu/hardware_display_controller.h"
+#include "ui/ozone/platform/drm/gpu/screen_manager.h"
+#include "ui/ozone/public/native_pixmap.h"
+#include "ui/ozone/public/surface_ozone_canvas.h"
+#include "ui/ozone/public/surface_ozone_egl.h"
+
+namespace ui {
+
+GbmSurfaceFactory::GbmSurfaceFactory(bool allow_surfaceless)
+ : DrmSurfaceFactory(NULL), allow_surfaceless_(allow_surfaceless) {
+}
+
+GbmSurfaceFactory::~GbmSurfaceFactory() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+}
+
+void GbmSurfaceFactory::InitializeGpu(DrmDeviceManager* drm_device_manager,
+ ScreenManager* screen_manager) {
+ drm_device_manager_ = drm_device_manager;
+ screen_manager_ = screen_manager;
+}
+
+intptr_t GbmSurfaceFactory::GetNativeDisplay() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ auto primary_device = drm_device_manager_->GetDrmDevice(
+ gfx::kNullAcceleratedWidget);
+ DCHECK(primary_device.get());
+ auto gbm_device = static_cast<GbmDevice*>(primary_device.get());
+ return reinterpret_cast<EGLNativeDisplayType>(gbm_device->device());
+}
+
+const int32* GbmSurfaceFactory::GetEGLSurfaceProperties(
+ const int32* desired_list) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ static const int32 kConfigAttribs[] = {EGL_BUFFER_SIZE,
+ 32,
+ EGL_ALPHA_SIZE,
+ 8,
+ EGL_BLUE_SIZE,
+ 8,
+ EGL_GREEN_SIZE,
+ 8,
+ EGL_RED_SIZE,
+ 8,
+ EGL_RENDERABLE_TYPE,
+ EGL_OPENGL_ES2_BIT,
+ EGL_SURFACE_TYPE,
+ EGL_WINDOW_BIT,
+ EGL_NONE};
+
+ return kConfigAttribs;
+}
+
+bool GbmSurfaceFactory::LoadEGLGLES2Bindings(
+ AddGLLibraryCallback add_gl_library,
+ SetGLGetProcAddressProcCallback set_gl_get_proc_address) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ return LoadDefaultEGLGLES2Bindings(add_gl_library, set_gl_get_proc_address);
+}
+
+scoped_ptr<SurfaceOzoneCanvas> GbmSurfaceFactory::CreateCanvasForWidget(
+ gfx::AcceleratedWidget widget) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ LOG(FATAL) << "Software rendering mode is not supported with GBM platform";
+ return nullptr;
+}
+
+scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget(
+ gfx::AcceleratedWidget widget) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget);
+ DCHECK(gbm);
+
+ scoped_ptr<GbmSurface> surface(
+ new GbmSurface(screen_manager_->GetWindow(widget), gbm));
+ if (!surface->Initialize())
+ return nullptr;
+
+ return surface.Pass();
+}
+
+scoped_ptr<SurfaceOzoneEGL>
+GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget(
+ gfx::AcceleratedWidget widget) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (!allow_surfaceless_)
+ return nullptr;
+
+ return make_scoped_ptr(new GbmSurfaceless(screen_manager_->GetWindow(widget),
+ drm_device_manager_));
+}
+
+scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap(
+ gfx::AcceleratedWidget widget,
+ gfx::Size size,
+ BufferFormat format,
+ BufferUsage usage) {
+ if (usage == MAP)
+ return nullptr;
+
+ scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget);
+ DCHECK(gbm);
+
+ scoped_refptr<GbmBuffer> buffer =
+ GbmBuffer::CreateBuffer(gbm, format, size, true);
+ if (!buffer.get())
+ return nullptr;
+
+ scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer, screen_manager_));
+ if (!pixmap->Initialize())
+ return nullptr;
+
+ return pixmap;
+}
+
+bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ return allow_surfaceless_;
+}
+
+bool GbmSurfaceFactory::CanCreateNativePixmap(BufferUsage usage) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ switch (usage) {
+ case MAP:
+ return false;
+ case PERSISTENT_MAP:
+ return false;
+ case SCANOUT:
+ return true;
+ }
+ NOTREACHED();
+ return false;
+}
+
+scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice(
+ gfx::AcceleratedWidget widget) {
+ return static_cast<GbmDevice*>(
+ drm_device_manager_->GetDrmDevice(widget).get());
+}
+
+} // namespace ui
« no previous file with comments | « ui/ozone/platform/drm/gpu/gbm_surface_factory.h ('k') | ui/ozone/platform/drm/gpu/gbm_surfaceless.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698