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 @@
#include "ui/gfx/buffer_format_util.h"
#include "ui/gl/gl_surface_egl.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/gpu/drm_thread_proxy.h"
#include "ui/ozone/platform/drm/gpu/drm_window_proxy.h"
......@@ -28,8 +29,50 @@
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)
: drm_thread_(drm_thread) {}
: egl_implementation_(new GLOzoneEGLGbm(this, drm_thread)),
drm_thread_(drm_thread) {}
GbmSurfaceFactory::~GbmSurfaceFactory() {
DCHECK(thread_checker_.CalledOnValidThread());
......@@ -54,58 +97,23 @@ GbmSurfaceless* GbmSurfaceFactory::GetSurface(
return it->second;
}
scoped_refptr<gl::GLSurface> GbmSurfaceFactory::CreateViewGLSurface(
gl::GLImplementation implementation,
gfx::AcceleratedWidget widget) {
DCHECK(thread_checker_.CalledOnValidThread());
if (implementation != gl::kGLImplementationEGLGLES2) {
NOTREACHED();
return nullptr;
}
return gl::InitializeGLSurface(
new GbmSurface(this, drm_thread_->CreateDrmWindowProxy(widget), widget));
}
scoped_refptr<gl::GLSurface> GbmSurfaceFactory::CreateSurfacelessViewGLSurface(
gl::GLImplementation implementation,
gfx::AcceleratedWidget widget) {
std::vector<gl::GLImplementation>
GbmSurfaceFactory::GetAllowedGLImplementations() {
DCHECK(thread_checker_.CalledOnValidThread());
if (implementation != gl::kGLImplementationEGLGLES2) {
NOTREACHED();
return nullptr;
}
return gl::InitializeGLSurface(new GbmSurfaceless(
this, drm_thread_->CreateDrmWindowProxy(widget), widget));
std::vector<gl::GLImplementation> impls;
impls.push_back(gl::kGLImplementationEGLGLES2);
impls.push_back(gl::kGLImplementationOSMesaGL);
return impls;
}
scoped_refptr<gl::GLSurface> GbmSurfaceFactory::CreateOffscreenGLSurface(
gl::GLImplementation implementation,
const gfx::Size& size) {
GLOzone* GbmSurfaceFactory::GetGLOzone(gl::GLImplementation implementation) {
DCHECK(thread_checker_.CalledOnValidThread());
if (implementation != gl::kGLImplementationEGLGLES2) {
NOTREACHED();
return nullptr;
switch (implementation) {
case gl::kGLImplementationEGLGLES2:
return egl_implementation_.get();
default:
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(
......
......@@ -15,6 +15,7 @@
#include "base/threading/thread_checker.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h"
#include "ui/ozone/common/gl_ozone_egl.h"
#include "ui/ozone/public/surface_factory_ozone.h"
namespace ui {
......@@ -33,20 +34,11 @@ class GbmSurfaceFactory : public SurfaceFactoryOzone {
GbmSurfaceless* GetSurface(gfx::AcceleratedWidget widget) const;
// SurfaceFactoryOzone:
scoped_refptr<gl::GLSurface> CreateViewGLSurface(
gl::GLImplementation implementation,
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;
std::vector<gl::GLImplementation> GetAllowedGLImplementations() override;
GLOzone* GetGLOzone(gl::GLImplementation implementation) override;
intptr_t GetNativeDisplay() override;
std::vector<gfx::BufferFormat> GetScanoutFormats(
gfx::AcceleratedWidget widget) override;
bool LoadEGLGLES2Bindings() override;
std::unique_ptr<SurfaceOzoneCanvas> CreateCanvasForWidget(
gfx::AcceleratedWidget widget) override;
scoped_refptr<ui::NativePixmap> CreateNativePixmap(
......@@ -61,6 +53,8 @@ class GbmSurfaceFactory : public SurfaceFactoryOzone {
const gfx::NativePixmapHandle& handle) override;
private:
std::unique_ptr<GLOzone> egl_implementation_;
base::ThreadChecker thread_checker_;
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