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 |
index 1ffd179820fd6340ec52574a7985e77189949255..3590321fcd3914b545d0090bc6d9fdb0c4219feb 100644 |
--- a/ui/ozone/platform/dri/ozone_platform_gbm.cc |
+++ b/ui/ozone/platform/dri/ozone_platform_gbm.cc |
@@ -14,6 +14,7 @@ |
#include "ui/ozone/ozone_platform.h" |
#include "ui/ozone/platform/dri/cursor_factory_evdev_dri.h" |
#include "ui/ozone/platform/dri/dri_wrapper.h" |
+#include "ui/ozone/platform/dri/gbm_buffer.h" |
#include "ui/ozone/platform/dri/gbm_surface.h" |
#include "ui/ozone/platform/dri/gbm_surface_factory.h" |
#include "ui/ozone/platform/dri/gpu_platform_support_gbm.h" |
@@ -54,7 +55,7 @@ class GbmSurfaceGenerator : public ScanoutSurfaceGenerator { |
return new GbmSurface(device_, dri_, size); |
} |
- private: |
+ protected: |
DriWrapper* dri_; // Not owned. |
// HACK: gbm drivers have broken linkage |
@@ -65,9 +66,25 @@ class GbmSurfaceGenerator : public ScanoutSurfaceGenerator { |
DISALLOW_COPY_AND_ASSIGN(GbmSurfaceGenerator); |
}; |
+class GbmEglImageSurfaceGenerator : public GbmSurfaceGenerator { |
+ public: |
+ GbmEglImageSurfaceGenerator(DriWrapper* dri) : GbmSurfaceGenerator(dri) {} |
+ virtual ~GbmEglImageSurfaceGenerator() {} |
+ |
+ virtual ScanoutSurface* Create(const gfx::Size& size) OVERRIDE { |
+ GbmBuffer* buffer = new GbmBuffer(device_, dri_, size); |
+ if (!buffer->InitializeBuffer(SurfaceFactoryOzone::RGBA_8888, true)) { |
+ ScanoutSurface* surf = buffer; |
alexst (slow to review)
2014/07/08 17:22:32
Why the temp assignment here?
achaulk
2014/07/08 18:16:37
GbmBuffer is non-deletable because of the refcount
alexst (slow to review)
2014/07/08 21:28:37
I see. It's subtle, though, can we make something
achaulk
2014/07/08 21:36:12
I suppose that works just as well. We already have
achaulk
2014/07/08 21:38:52
I spoke too soon. Compiler says no
../../base/mac
|
+ delete surf; |
+ return NULL; |
+ } |
+ return buffer; |
+ } |
+}; |
+ |
class OzonePlatformGbm : public OzonePlatform { |
public: |
- OzonePlatformGbm() { |
+ OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) { |
base::AtExitManager::RegisterTask( |
base::Bind(&base::DeletePointer<OzonePlatformGbm>, this)); |
} |
@@ -104,7 +121,7 @@ class OzonePlatformGbm : public OzonePlatform { |
vt_manager_.reset(new VirtualTerminalManager()); |
// Needed since the browser process creates the accelerated widgets and that |
// happens through SFO. |
- surface_factory_ozone_.reset(new GbmSurfaceFactory()); |
+ surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); |
device_manager_ = CreateDeviceManager(); |
gpu_platform_support_host_.reset(new GpuPlatformSupportHostGbm()); |
@@ -116,11 +133,14 @@ class OzonePlatformGbm : public OzonePlatform { |
virtual void InitializeGPU() OVERRIDE { |
dri_.reset(new DriWrapper(kDefaultGraphicsCardPath)); |
- surface_generator_.reset(new GbmSurfaceGenerator(dri_.get())); |
+ if (use_surfaceless_) |
+ surface_generator_.reset(new GbmEglImageSurfaceGenerator(dri_.get())); |
+ else |
+ surface_generator_.reset(new GbmSurfaceGenerator(dri_.get())); |
screen_manager_.reset(new ScreenManager(dri_.get(), |
surface_generator_.get())); |
if (!surface_factory_ozone_) |
- surface_factory_ozone_.reset(new GbmSurfaceFactory()); |
+ surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); |
surface_factory_ozone_->InitializeGpu(dri_.get(), |
surface_generator_->device(), |
@@ -131,6 +151,7 @@ class OzonePlatformGbm : public OzonePlatform { |
} |
private: |
+ bool use_surfaceless_; |
scoped_ptr<VirtualTerminalManager> vt_manager_; |
scoped_ptr<DriWrapper> dri_; |
scoped_ptr<GbmSurfaceGenerator> surface_generator_; |
@@ -149,6 +170,11 @@ class OzonePlatformGbm : public OzonePlatform { |
} // namespace |
-OzonePlatform* CreateOzonePlatformGbm() { return new OzonePlatformGbm; } |
+OzonePlatform* CreateOzonePlatformGbm() { |
+ return new OzonePlatformGbm(false); |
+} |
+OzonePlatform* CreateOzonePlatformGbmEglImage() { |
+ return new OzonePlatformGbm(true); |
+} |
} // namespace ui |