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

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

Issue 106633002: GBM Ozone implementation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 7 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/ozone_platform_gbm.h ('k') | ui/ozone/platform/dri/scanout_surface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/dri/ozone_platform_gbm.cc
diff --git a/ui/ozone/platform/dri/ozone_platform_gbm.cc b/ui/ozone/platform/dri/ozone_platform_gbm.cc
new file mode 100644
index 0000000000000000000000000000000000000000..46e3bac4f2c6cc3fb9e5ced777896db81ccc1113
--- /dev/null
+++ b/ui/ozone/platform/dri/ozone_platform_gbm.cc
@@ -0,0 +1,114 @@
+// 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/ozone_platform_gbm.h"
+
+#include <stdlib.h>
+#include <gbm.h>
+
+#include "ui/base/cursor/ozone/cursor_factory_ozone.h"
+#include "ui/events/ozone/device/device_manager.h"
+#include "ui/events/ozone/evdev/event_factory_evdev.h"
+#include "ui/ozone/ozone_platform.h"
+#include "ui/ozone/platform/dri/dri_wrapper.h"
+#include "ui/ozone/platform/dri/gbm_surface.h"
+#include "ui/ozone/platform/dri/gbm_surface_factory.h"
+#include "ui/ozone/platform/dri/scanout_surface.h"
+#include "ui/ozone/platform/dri/screen_manager.h"
+
+#if defined(OS_CHROMEOS)
+#include "ui/ozone/common/chromeos/native_display_delegate_ozone.h"
+#endif
+
+namespace ui {
+
+namespace {
+
+const char kDefaultGraphicsCardPath[] = "/dev/dri/card0";
+
+class GbmSurfaceGenerator : public ScanoutSurfaceGenerator {
+ public:
+ GbmSurfaceGenerator(DriWrapper* dri)
+ : dri_(dri),
+ device_(gbm_create_device(dri_->get_fd())) {}
+ virtual ~GbmSurfaceGenerator() {
+ gbm_device_destroy(device_);
+ }
+
+ gbm_device* device() const { return device_; }
+
+ virtual ScanoutSurface* Create(const gfx::Size& size) OVERRIDE {
+ return new GbmSurface(device_, dri_, size);
+ }
+
+ private:
+ DriWrapper* dri_; // Not owned.
+
+ gbm_device* device_;
+
+ DISALLOW_COPY_AND_ASSIGN(GbmSurfaceGenerator);
+};
+
+class OzonePlatformGbm : public OzonePlatform {
+ public:
+ OzonePlatformGbm() {}
+ virtual ~OzonePlatformGbm() {}
+
+ // OzonePlatform:
+ virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE {
+ return surface_factory_ozone_.get();
+ }
+ virtual EventFactoryOzone* GetEventFactoryOzone() OVERRIDE {
+ return event_factory_ozone_.get();
+ }
+ virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE {
+ return cursor_factory_ozone_.get();
+ }
+#if defined(OS_CHROMEOS)
+ virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
+ OVERRIDE {
+ return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone());
+ }
+#endif
+ virtual void InitializeUI() OVERRIDE {
+ // Needed since the browser process creates the accelerated widgets and that
+ // happens through SFO.
+ surface_factory_ozone_.reset(new GbmSurfaceFactory(NULL, NULL, NULL));
+
+ device_manager_ = CreateDeviceManager();
+ cursor_factory_ozone_.reset(new CursorFactoryOzone());
+ event_factory_ozone_.reset(new EventFactoryEvdev(
+ NULL, device_manager_.get()));
+ }
+
+ virtual void InitializeGPU() OVERRIDE {
+ dri_.reset(new DriWrapper(kDefaultGraphicsCardPath));
+ surface_generator_.reset(new GbmSurfaceGenerator(dri_.get()));
+ screen_manager_.reset(new ScreenManager(dri_.get(),
+ surface_generator_.get()));
+ surface_factory_ozone_.reset(
+ new GbmSurfaceFactory(dri_.get(),
+ surface_generator_->device(),
+ screen_manager_.get()));
+ }
+
+ private:
+ scoped_ptr<DriWrapper> dri_;
+ scoped_ptr<GbmSurfaceGenerator> surface_generator_;
+ // TODO(dnicoara) Move ownership of |screen_manager_| to NDD.
+ scoped_ptr<ScreenManager> screen_manager_;
+ scoped_ptr<DeviceManager> device_manager_;
+
+ scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_;
+ scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_;
+ scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
+
+ DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm);
+};
+
+} // namespace
+
+OzonePlatform* CreateOzonePlatformGbm() { return new OzonePlatformGbm; }
+
+} // namespace ui
« no previous file with comments | « ui/ozone/platform/dri/ozone_platform_gbm.h ('k') | ui/ozone/platform/dri/scanout_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698