Commit 6f459b4e authored by kylechar's avatar kylechar Committed by Commit bot

Convert Ozone GBM to use GLOzone.

Add GLOzoneEGLGbm and remove old API calls.

BUG=643368

Review-Url: https://codereview.chromium.org/2327813002
Cr-Commit-Position: refs/heads/master@{#418857}
parent 6d73ab5e
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ui/gfx/buffer_format_util.h" #include "ui/gfx/buffer_format_util.h"
#include "ui/gl/gl_surface_egl.h" #include "ui/gl/gl_surface_egl.h"
#include "ui/ozone/common/egl_util.h" #include "ui/ozone/common/egl_util.h"
#include "ui/ozone/common/gl_ozone_egl.h"
#include "ui/ozone/platform/drm/common/drm_util.h" #include "ui/ozone/platform/drm/common/drm_util.h"
#include "ui/ozone/platform/drm/gpu/drm_thread_proxy.h" #include "ui/ozone/platform/drm/gpu/drm_thread_proxy.h"
#include "ui/ozone/platform/drm/gpu/drm_window_proxy.h" #include "ui/ozone/platform/drm/gpu/drm_window_proxy.h"
...@@ -28,8 +29,50 @@ ...@@ -28,8 +29,50 @@
namespace ui { namespace ui {
namespace {
class GLOzoneEGLGbm : public GLOzoneEGL {
public:
GLOzoneEGLGbm(GbmSurfaceFactory* surface_factory, DrmThreadProxy* drm_thread)
: surface_factory_(surface_factory), drm_thread_(drm_thread) {}
~GLOzoneEGLGbm() override {}
scoped_refptr<gl::GLSurface> CreateViewGLSurface(
gfx::AcceleratedWidget window) override {
return gl::InitializeGLSurface(new GbmSurface(
surface_factory_, drm_thread_->CreateDrmWindowProxy(window), window));
}
scoped_refptr<gl::GLSurface> CreateSurfacelessViewGLSurface(
gfx::AcceleratedWidget window) override {
return gl::InitializeGLSurface(new GbmSurfaceless(
surface_factory_, drm_thread_->CreateDrmWindowProxy(window), window));
}
scoped_refptr<gl::GLSurface> CreateOffscreenGLSurface(
const gfx::Size& size) override {
DCHECK_EQ(size.width(), 0);
DCHECK_EQ(size.height(), 0);
return gl::InitializeGLSurface(new gl::SurfacelessEGL(size));
}
protected:
intptr_t GetNativeDisplay() override { return EGL_DEFAULT_DISPLAY; }
bool LoadGLES2Bindings() override { return LoadDefaultEGLGLES2Bindings(); }
private:
GbmSurfaceFactory* surface_factory_;
DrmThreadProxy* drm_thread_;
DISALLOW_COPY_AND_ASSIGN(GLOzoneEGLGbm);
};
} // namespace
GbmSurfaceFactory::GbmSurfaceFactory(DrmThreadProxy* drm_thread) GbmSurfaceFactory::GbmSurfaceFactory(DrmThreadProxy* drm_thread)
: drm_thread_(drm_thread) {} : egl_implementation_(new GLOzoneEGLGbm(this, drm_thread)),
drm_thread_(drm_thread) {}
GbmSurfaceFactory::~GbmSurfaceFactory() { GbmSurfaceFactory::~GbmSurfaceFactory() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
...@@ -54,58 +97,23 @@ GbmSurfaceless* GbmSurfaceFactory::GetSurface( ...@@ -54,58 +97,23 @@ GbmSurfaceless* GbmSurfaceFactory::GetSurface(
return it->second; return it->second;
} }
scoped_refptr<gl::GLSurface> GbmSurfaceFactory::CreateViewGLSurface( std::vector<gl::GLImplementation>
gl::GLImplementation implementation, GbmSurfaceFactory::GetAllowedGLImplementations() {
gfx::AcceleratedWidget widget) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
std::vector<gl::GLImplementation> impls;
if (implementation != gl::kGLImplementationEGLGLES2) { impls.push_back(gl::kGLImplementationEGLGLES2);
NOTREACHED(); impls.push_back(gl::kGLImplementationOSMesaGL);
return nullptr; return impls;
}
return gl::InitializeGLSurface(
new GbmSurface(this, drm_thread_->CreateDrmWindowProxy(widget), widget));
} }
scoped_refptr<gl::GLSurface> GbmSurfaceFactory::CreateSurfacelessViewGLSurface( GLOzone* GbmSurfaceFactory::GetGLOzone(gl::GLImplementation implementation) {
gl::GLImplementation implementation,
gfx::AcceleratedWidget widget) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
switch (implementation) {
if (implementation != gl::kGLImplementationEGLGLES2) { case gl::kGLImplementationEGLGLES2:
NOTREACHED(); return egl_implementation_.get();
default:
return nullptr; return nullptr;
} }
return gl::InitializeGLSurface(new GbmSurfaceless(
this, drm_thread_->CreateDrmWindowProxy(widget), widget));
}
scoped_refptr<gl::GLSurface> GbmSurfaceFactory::CreateOffscreenGLSurface(
gl::GLImplementation implementation,
const gfx::Size& size) {
DCHECK(thread_checker_.CalledOnValidThread());
if (implementation != gl::kGLImplementationEGLGLES2) {
NOTREACHED();
return nullptr;
}
DCHECK_EQ(size.width(), 0);
DCHECK_EQ(size.height(), 0);
return gl::InitializeGLSurface(new gl::SurfacelessEGL(size));
}
intptr_t GbmSurfaceFactory::GetNativeDisplay() {
DCHECK(thread_checker_.CalledOnValidThread());
return EGL_DEFAULT_DISPLAY;
}
bool GbmSurfaceFactory::LoadEGLGLES2Bindings() {
DCHECK(thread_checker_.CalledOnValidThread());
return LoadDefaultEGLGLES2Bindings();
} }
std::unique_ptr<SurfaceOzoneCanvas> GbmSurfaceFactory::CreateCanvasForWidget( std::unique_ptr<SurfaceOzoneCanvas> GbmSurfaceFactory::CreateCanvasForWidget(
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "ui/gl/gl_implementation.h" #include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
#include "ui/ozone/common/gl_ozone_egl.h"
#include "ui/ozone/public/surface_factory_ozone.h" #include "ui/ozone/public/surface_factory_ozone.h"
namespace ui { namespace ui {
...@@ -33,20 +34,11 @@ class GbmSurfaceFactory : public SurfaceFactoryOzone { ...@@ -33,20 +34,11 @@ class GbmSurfaceFactory : public SurfaceFactoryOzone {
GbmSurfaceless* GetSurface(gfx::AcceleratedWidget widget) const; GbmSurfaceless* GetSurface(gfx::AcceleratedWidget widget) const;
// SurfaceFactoryOzone: // SurfaceFactoryOzone:
scoped_refptr<gl::GLSurface> CreateViewGLSurface( std::vector<gl::GLImplementation> GetAllowedGLImplementations() override;
gl::GLImplementation implementation, GLOzone* GetGLOzone(gl::GLImplementation implementation) override;
gfx::AcceleratedWidget widget) override;
scoped_refptr<gl::GLSurface> CreateSurfacelessViewGLSurface(
gl::GLImplementation implementation,
gfx::AcceleratedWidget widget) override;
scoped_refptr<gl::GLSurface> CreateOffscreenGLSurface(
gl::GLImplementation implementation,
const gfx::Size& size) override;
intptr_t GetNativeDisplay() override;
std::vector<gfx::BufferFormat> GetScanoutFormats( std::vector<gfx::BufferFormat> GetScanoutFormats(
gfx::AcceleratedWidget widget) override; gfx::AcceleratedWidget widget) override;
bool LoadEGLGLES2Bindings() override;
std::unique_ptr<SurfaceOzoneCanvas> CreateCanvasForWidget( std::unique_ptr<SurfaceOzoneCanvas> CreateCanvasForWidget(
gfx::AcceleratedWidget widget) override; gfx::AcceleratedWidget widget) override;
scoped_refptr<ui::NativePixmap> CreateNativePixmap( scoped_refptr<ui::NativePixmap> CreateNativePixmap(
...@@ -61,6 +53,8 @@ class GbmSurfaceFactory : public SurfaceFactoryOzone { ...@@ -61,6 +53,8 @@ class GbmSurfaceFactory : public SurfaceFactoryOzone {
const gfx::NativePixmapHandle& handle) override; const gfx::NativePixmapHandle& handle) override;
private: private:
std::unique_ptr<GLOzone> egl_implementation_;
base::ThreadChecker thread_checker_; base::ThreadChecker thread_checker_;
DrmThreadProxy* drm_thread_; DrmThreadProxy* drm_thread_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment