Commit 7cf286c8 authored by kylechar's avatar kylechar Committed by Commit bot

Move GL one-off initialization code.

Move GL one-off initialization from //ui/gl to //ui/gl/init. Create a
new class GLInitializer to contain the platform specific initialization
methods and add platform specific implementation in a conditionally
included file per platform. Remove the existing one-off initialization
code in GLSurface and from platform specific GLSurface files.

This change is part of step two from the associated bug.

BUG=611142

Review-Url: https://codereview.chromium.org/2024953002
Cr-Commit-Position: refs/heads/master@{#397839}
parent 3f560170
......@@ -37,8 +37,8 @@ struct GL_EXPORT GLWindowSystemBindingInfo {
bool direct_rendering;
};
void GL_EXPORT
GetAllowedGLImplementations(std::vector<GLImplementation>* impls);
GL_EXPORT void GetAllowedGLImplementations(
std::vector<GLImplementation>* impls);
#if defined(OS_WIN)
typedef void* (WINAPI *GLGetProcAddressProc)(const char* name);
......@@ -55,11 +55,11 @@ GL_EXPORT bool InitializeDynamicGLBindings(GLImplementation implementation,
GLContext* context);
// Initialize Debug logging wrappers for GL bindings.
void InitializeDebugGLBindings();
GL_EXPORT void InitializeDebugGLBindings();
// Initialize stub methods for drawing operations in the GL bindings. The
// null draw bindings default to enabled, so that draw operations do nothing.
void InitializeNullDrawGLBindings();
GL_EXPORT void InitializeNullDrawGLBindings();
// TODO(danakj): Remove this when all test suites are using null-draw.
GL_EXPORT bool HasInitializedNullDrawGLBindings();
......@@ -95,10 +95,10 @@ GL_EXPORT GLImplementation GetGLImplementation();
GL_EXPORT bool HasDesktopGLFeatures();
// Get the GL implementation with a given name.
GLImplementation GetNamedGLImplementation(const std::string& name);
GL_EXPORT GLImplementation GetNamedGLImplementation(const std::string& name);
// Get the name of a GL implementation.
const char* GetGLImplementationName(GLImplementation implementation);
GL_EXPORT const char* GetGLImplementationName(GLImplementation implementation);
// Add a native library to those searched for GL entry points.
void AddGLNativeLibrary(base::NativeLibrary library);
......
......@@ -24,75 +24,6 @@ base::LazyInstance<base::ThreadLocalPointer<GLSurface> >::Leaky
current_surface_ = LAZY_INSTANCE_INITIALIZER;
} // namespace
// static
bool GLSurface::InitializeOneOff() {
DCHECK_EQ(kGLImplementationNone, GetGLImplementation());
TRACE_EVENT0("gpu,startup", "GLSurface::InitializeOneOff");
std::vector<GLImplementation> allowed_impls;
GetAllowedGLImplementations(&allowed_impls);
DCHECK(!allowed_impls.empty());
base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
// The default implementation is always the first one in list.
GLImplementation impl = allowed_impls[0];
bool fallback_to_osmesa = false;
if (cmd->HasSwitch(switches::kOverrideUseGLWithOSMesaForTests)) {
impl = kGLImplementationOSMesaGL;
} else if (cmd->HasSwitch(switches::kUseGL)) {
std::string requested_implementation_name =
cmd->GetSwitchValueASCII(switches::kUseGL);
if (requested_implementation_name == "any") {
fallback_to_osmesa = true;
} else if (requested_implementation_name ==
kGLImplementationSwiftShaderName ||
requested_implementation_name == kGLImplementationANGLEName) {
impl = kGLImplementationEGLGLES2;
} else {
impl = GetNamedGLImplementation(requested_implementation_name);
if (!ContainsValue(allowed_impls, impl)) {
LOG(ERROR) << "Requested GL implementation is not available.";
return false;
}
}
}
bool gpu_service_logging = cmd->HasSwitch(switches::kEnableGPUServiceLogging);
bool disable_gl_drawing = cmd->HasSwitch(switches::kDisableGLDrawingForTests);
return InitializeOneOffImplementation(
impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing);
}
// static
bool GLSurface::InitializeOneOffImplementation(GLImplementation impl,
bool fallback_to_osmesa,
bool gpu_service_logging,
bool disable_gl_drawing) {
bool initialized =
InitializeStaticGLBindings(impl) && InitializeOneOffInternal();
if (!initialized && fallback_to_osmesa) {
ClearGLBindings();
initialized = InitializeStaticGLBindings(kGLImplementationOSMesaGL) &&
InitializeOneOffInternal();
}
if (!initialized)
ClearGLBindings();
if (initialized) {
DVLOG(1) << "Using "
<< GetGLImplementationName(GetGLImplementation())
<< " GL implementation.";
if (gpu_service_logging)
InitializeDebugGLBindings();
if (disable_gl_drawing)
InitializeNullDrawGLBindings();
}
return initialized;
}
GLSurface::GLSurface() {}
bool GLSurface::Initialize() {
......
......@@ -128,10 +128,6 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> {
// the calling thread (i.e. same thread CommitOverlayPlanesAsync is called).
virtual void CommitOverlayPlanesAsync(const SwapCompletionCallback& callback);
// Initialize GL bindings.
// DEPRECATED(kylechar): Use gl::init::InitializeGLOneOff from gl_factory.h.
static bool InitializeOneOff();
// Called after a context is made current with this surface. Returns false
// on error.
virtual bool OnMakeCurrent(GLContext* context);
......@@ -226,11 +222,7 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> {
protected:
virtual ~GLSurface();
static bool InitializeOneOffImplementation(GLImplementation impl,
bool fallback_to_osmesa,
bool gpu_service_logging,
bool disable_gl_drawing);
static bool InitializeOneOffInternal();
static void SetCurrent(GLSurface* surface);
static bool ExtensionsContain(const char* extensions, const char* name);
......@@ -238,7 +230,6 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> {
private:
friend class base::RefCounted<GLSurface>;
friend class GLContext;
friend class GLSurfaceTestSupport;
DISALLOW_COPY_AND_ASSIGN(GLSurface);
};
......
......@@ -15,20 +15,6 @@
namespace gl {
// static
bool GLSurface::InitializeOneOffInternal() {
switch (GetGLImplementation()) {
case kGLImplementationEGLGLES2:
if (!GLSurfaceEGL::InitializeOneOff()) {
LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
return false;
}
default:
break;
}
return true;
}
// static
scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
gfx::AcceleratedWidget window) {
......
......@@ -4,8 +4,6 @@
#include "ui/gl/gl_surface.h"
#include <OpenGL/CGLRenderers.h>
#include <memory>
#include "base/logging.h"
......@@ -17,7 +15,6 @@
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface_osmesa.h"
#include "ui/gl/gl_surface_stub.h"
#include "ui/gl/gpu_switching_manager.h"
namespace gl {
namespace {
......@@ -52,64 +49,8 @@ class GL_EXPORT NoOpGLSurface : public GLSurface {
DISALLOW_COPY_AND_ASSIGN(NoOpGLSurface);
};
// static
bool InitializeOneOffForSandbox() {
static bool initialized = false;
if (initialized)
return true;
// This is called from the sandbox warmup code on Mac OS X.
// GPU-related stuff is very slow without this, probably because
// the sandbox prevents loading graphics drivers or some such.
std::vector<CGLPixelFormatAttribute> attribs;
if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) {
// Avoid switching to the discrete GPU just for this pixel
// format selection.
attribs.push_back(kCGLPFAAllowOfflineRenderers);
}
if (GetGLImplementation() == kGLImplementationAppleGL) {
attribs.push_back(kCGLPFARendererID);
attribs.push_back(static_cast<CGLPixelFormatAttribute>(
kCGLRendererGenericFloatID));
}
attribs.push_back(static_cast<CGLPixelFormatAttribute>(0));
CGLPixelFormatObj format;
GLint num_pixel_formats;
if (CGLChoosePixelFormat(&attribs.front(),
&format,
&num_pixel_formats) != kCGLNoError) {
LOG(ERROR) << "Error choosing pixel format.";
return false;
}
if (!format) {
LOG(ERROR) << "format == 0.";
return false;
}
CGLReleasePixelFormat(format);
DCHECK_NE(num_pixel_formats, 0);
initialized = true;
return true;
}
} // namespace
bool GLSurface::InitializeOneOffInternal() {
switch (GetGLImplementation()) {
case kGLImplementationDesktopGL:
case kGLImplementationDesktopGLCoreProfile:
case kGLImplementationAppleGL:
if (!InitializeOneOffForSandbox()) {
LOG(ERROR) << "GLSurfaceCGL::InitializeOneOff failed.";
return false;
}
break;
default:
break;
}
return true;
}
scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
gfx::AcceleratedWidget window) {
TRACE_EVENT0("gpu", "GLSurface::CreateViewGLSurface");
......
......@@ -684,24 +684,6 @@ scoped_refptr<GLSurface> CreateViewGLSurfaceOzoneSurfacelessSurfaceImpl(
} // namespace
// static
bool GLSurface::InitializeOneOffInternal() {
switch (GetGLImplementation()) {
case kGLImplementationEGLGLES2:
if (!GLSurfaceEGL::InitializeOneOff()) {
LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
return false;
}
return true;
case kGLImplementationOSMesaGL:
case kGLImplementationMockGL:
return true;
default:
return false;
}
}
// static
scoped_refptr<GLSurface> GLSurface::CreateSurfacelessViewGLSurface(
gfx::AcceleratedWidget window) {
......
......@@ -53,35 +53,6 @@ class NativeViewGLSurfaceOSMesa : public GLSurfaceOSMesa {
DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceOSMesa);
};
// Helper routine that does one-off initialization like determining the
// pixel format.
bool GLSurface::InitializeOneOffInternal() {
VSyncProviderWin::InitializeOneOff();
switch (GetGLImplementation()) {
case kGLImplementationDesktopGL:
if (!GLSurfaceWGL::InitializeOneOff()) {
LOG(ERROR) << "GLSurfaceWGL::InitializeOneOff failed.";
return false;
}
break;
case kGLImplementationEGLGLES2:
if (!GLSurfaceEGL::InitializeOneOff()) {
LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
return false;
}
break;
case kGLImplementationNone:
case kGLImplementationDesktopGLCoreProfile:
case kGLImplementationAppleGL:
NOTREACHED();
case kGLImplementationOSMesaGL:
case kGLImplementationMockGL:
break;
}
return true;
}
NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa(
gfx::AcceleratedWidget window)
: GLSurfaceOSMesa(SURFACE_OSMESA_RGBA, gfx::Size(1, 1)),
......
......@@ -22,37 +22,6 @@
namespace gl {
namespace {
} // namespace
bool GLSurface::InitializeOneOffInternal() {
switch (GetGLImplementation()) {
case kGLImplementationDesktopGL:
if (!GLSurfaceGLX::InitializeOneOff()) {
LOG(ERROR) << "GLSurfaceGLX::InitializeOneOff failed.";
return false;
}
break;
case kGLImplementationOSMesaGL:
if (!GLSurfaceOSMesaX11::InitializeOneOff()) {
LOG(ERROR) << "GLSurfaceOSMesaX11::InitializeOneOff failed.";
return false;
}
break;
case kGLImplementationEGLGLES2:
if (!GLSurfaceEGL::InitializeOneOff()) {
LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
return false;
}
break;
default:
break;
}
return true;
}
scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
gfx::AcceleratedWidget window) {
TRACE_EVENT0("gpu", "GLSurface::CreateViewGLSurface");
......
......@@ -2,13 +2,19 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/ui.gni")
component("init") {
output_name = "gl_init"
public = [
"gl_factory.h",
]
sources = [
"gl_factory.cc",
"gl_factory.h",
"gl_init_export.h",
"gl_initializer.h",
]
defines = [ "GL_INIT_IMPLEMENTATION" ]
......@@ -20,4 +26,18 @@ component("init") {
public_deps = [
"//ui/gl",
]
if (is_android) {
sources += [ "gl_initializer_android.cc" ]
} else if (is_win) {
sources += [ "gl_initializer_win.cc" ]
} else if (is_mac) {
sources += [ "gl_initializer_mac.cc" ]
libs = [ "OpenGL.framework" ]
} else if (use_x11) {
sources += [ "gl_initializer_x11.cc" ]
} else if (use_ozone) {
sources += [ "gl_initializer_ozone.cc" ]
}
}
......@@ -4,23 +4,91 @@
#include "ui/gl/init/gl_factory.h"
#include <string>
#include <vector>
#include "base/command_line.h"
#include "base/logging.h"
#include "base/trace_event/trace_event.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_share_group.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/init/gl_initializer.h"
namespace gl {
namespace init {
// TODO(kylechar): This file should be replaced with a platform specific
// version for X11, Ozone, Windows, Mac and Android. The implementation of each
// factory function should be moved into that file and the original static
// methods should be removed from GLSurface and GLContext. This file can then
// be deleted.
bool InitializeGLOneOff() {
return GLSurface::InitializeOneOff();
TRACE_EVENT0("gpu,startup", "gl::init::InitializeOneOff");
DCHECK_EQ(kGLImplementationNone, GetGLImplementation());
std::vector<GLImplementation> allowed_impls;
GetAllowedGLImplementations(&allowed_impls);
DCHECK(!allowed_impls.empty());
base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
// The default implementation is always the first one in list.
GLImplementation impl = allowed_impls[0];
bool fallback_to_osmesa = false;
if (cmd->HasSwitch(switches::kOverrideUseGLWithOSMesaForTests)) {
impl = kGLImplementationOSMesaGL;
} else if (cmd->HasSwitch(switches::kUseGL)) {
std::string requested_implementation_name =
cmd->GetSwitchValueASCII(switches::kUseGL);
if (requested_implementation_name == "any") {
fallback_to_osmesa = true;
} else if (requested_implementation_name ==
kGLImplementationSwiftShaderName ||
requested_implementation_name == kGLImplementationANGLEName) {
impl = kGLImplementationEGLGLES2;
} else {
impl = GetNamedGLImplementation(requested_implementation_name);
if (!ContainsValue(allowed_impls, impl)) {
LOG(ERROR) << "Requested GL implementation is not available.";
return false;
}
}
}
bool gpu_service_logging = cmd->HasSwitch(switches::kEnableGPUServiceLogging);
bool disable_gl_drawing = cmd->HasSwitch(switches::kDisableGLDrawingForTests);
return InitializeGLOneOffImplementation(
impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing);
}
bool InitializeGLOneOffImplementation(GLImplementation impl,
bool fallback_to_osmesa,
bool gpu_service_logging,
bool disable_gl_drawing) {
bool initialized =
InitializeStaticGLBindings(impl) && InitializeGLOneOffPlatform();
if (!initialized && fallback_to_osmesa) {
ClearGLBindings();
initialized = InitializeStaticGLBindings(kGLImplementationOSMesaGL) &&
InitializeGLOneOffPlatform();
}
if (!initialized)
ClearGLBindings();
if (initialized) {
DVLOG(1) << "Using " << GetGLImplementationName(GetGLImplementation())
<< " GL implementation.";
if (gpu_service_logging)
InitializeDebugGLBindings();
if (disable_gl_drawing)
InitializeNullDrawGLBindings();
}
return initialized;
}
// TODO(kylechar): The functions below should be replaced with a platform
// specific version for X11, Ozone, Windows, Mac and Android. The implementation
// of each function should be moved into a platform specific file and the
// original static functions should be removed from GLSurface and GLContext.
scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group,
GLSurface* compatible_surface,
GpuPreference gpu_preference) {
......
......@@ -8,6 +8,7 @@
#include "base/memory/ref_counted.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gpu_preference.h"
#include "ui/gl/init/gl_init_export.h"
......@@ -22,6 +23,13 @@ namespace init {
// Initialize GL bindings.
GL_INIT_EXPORT bool InitializeGLOneOff();
// Initialize GL bindings using the provided parameters. This might be required
// for use in tests, otherwise use InitializeGLOneOff() instead.
GL_INIT_EXPORT bool InitializeGLOneOffImplementation(GLImplementation impl,
bool fallback_to_osmesa,
bool gpu_service_logging,
bool disable_gl_drawing);
// Create a GL context that is compatible with the given surface. |share_group|,
// if non-NULL, is a group of contexts which the internally created OpenGL
// context shares textures and other resources.
......
......@@ -21,10 +21,25 @@
'GL_INIT_IMPLEMENTATION',
],
'sources': [
'gl_initializer.h',
'gl_initializer_android.cc',
'gl_initializer_mac.cc',
'gl_initializer_ozone.cc',
'gl_initializer_win.cc',
'gl_initializer_x11.cc',
'gl_factory.cc',
'gl_factory.h',
'gl_init_export.h',
],
'conditions': [
['OS=="mac"', {
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/OpenGL.framework',
],
},
}],
],
},
],
}
// Copyright 2016 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.
#ifndef UI_GL_INIT_GL_INITIALIZER_H_
#define UI_GL_INIT_GL_INITIALIZER_H_
namespace gl {
namespace init {
// Performs platform dependent one-off GL initialization, calling into the
// appropriate GLSurface code to initialize it. To perform one-off GL
// initialization you should use InitializeGLOneOff() or for tests possibly
// InitializeGLOneOffImplementation() instead of this.
bool InitializeGLOneOffPlatform();
} // namespace init
} // namespace gl
#endif // UI_GL_INIT_GL_INITIALIZER_H_
// Copyright 2016 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/gl/init/gl_initializer.h"
#include "base/logging.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface_egl.h"
namespace gl {
namespace init {
bool InitializeGLOneOffPlatform() {
switch (GetGLImplementation()) {
case kGLImplementationEGLGLES2:
if (!GLSurfaceEGL::InitializeOneOff()) {
LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
return false;
}
return true;
default:
return true;
}
}
} // namespace init
} // namespace gl
// Copyright 2016 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/gl/init/gl_initializer.h"
#include <OpenGL/CGLRenderers.h>
#include <vector>
#include "base/logging.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/gpu_switching_manager.h"
namespace gl {
namespace init {
namespace {
bool InitializeOneOffForSandbox() {
static bool initialized = false;
if (initialized)
return true;
// This is called from the sandbox warmup code on Mac OS X.
// GPU-related stuff is very slow without this, probably because
// the sandbox prevents loading graphics drivers or some such.
std::vector<CGLPixelFormatAttribute> attribs;
if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) {
// Avoid switching to the discrete GPU just for this pixel
// format selection.
attribs.push_back(kCGLPFAAllowOfflineRenderers);
}
if (GetGLImplementation() == kGLImplementationAppleGL) {
attribs.push_back(kCGLPFARendererID);
attribs.push_back(
static_cast<CGLPixelFormatAttribute>(kCGLRendererGenericFloatID));
}
attribs.push_back(static_cast<CGLPixelFormatAttribute>(0));
CGLPixelFormatObj format;
GLint num_pixel_formats;
if (CGLChoosePixelFormat(&attribs.front(), &format, &num_pixel_formats) !=
kCGLNoError) {
LOG(ERROR) << "Error choosing pixel format.";
return false;
}
if (!format) {
LOG(ERROR) << "format == 0.";
return false;
}
CGLReleasePixelFormat(format);
DCHECK_NE(num_pixel_formats, 0);
initialized = true;
return true;
}
} // namespace
bool InitializeGLOneOffPlatform() {
switch (GetGLImplementation()) {
case kGLImplementationDesktopGL:
case kGLImplementationDesktopGLCoreProfile:
case kGLImplementationAppleGL:
if (!InitializeOneOffForSandbox()) {
LOG(ERROR) << "GLSurfaceCGL::InitializeOneOff failed.";
return false;
}
return true;
default:
return true;
}
}
} // namespace init
} // namespace gl
// Copyright 2016 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/gl/init/gl_initializer.h"
#include "base/logging.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface_egl.h"
namespace gl {
namespace init {
bool InitializeGLOneOffPlatform() {
switch (GetGLImplementation()) {
case kGLImplementationEGLGLES2:
if (!GLSurfaceEGL::InitializeOneOff()) {
LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
return false;
}
return true;
case kGLImplementationOSMesaGL:
case kGLImplementationMockGL:
return true;
default:
return false;
}
}
} // namespace init
} // namespace gl
// Copyright 2016 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/gl/init/gl_initializer.h"
#include "base/logging.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface_egl.h"
#include "ui/gl/gl_surface_wgl.h"
#include "ui/gl/vsync_provider_win.h"
namespace gl {
namespace init {
bool InitializeGLOneOffPlatform() {
VSyncProviderWin::InitializeOneOff();
switch (GetGLImplementation()) {
case kGLImplementationDesktopGL:
if (!GLSurfaceWGL::InitializeOneOff()) {
LOG(ERROR) << "GLSurfaceWGL::InitializeOneOff failed.";
return false;
}
break;
case kGLImplementationEGLGLES2:
if (!GLSurfaceEGL::InitializeOneOff()) {
LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
return false;
}
break;
case kGLImplementationOSMesaGL:
case kGLImplementationMockGL:
break;
default:
NOTREACHED();
}
return true;
}
} // namespace init
} // namespace gl
// Copyright 2016 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/gl/init/gl_initializer.h"
#include "base/logging.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface_egl.h"
#include "ui/gl/gl_surface_glx.h"
#include "ui/gl/gl_surface_osmesa_x11.h"
namespace gl {
namespace init {
bool InitializeGLOneOffPlatform() {
switch (GetGLImplementation()) {
case kGLImplementationDesktopGL:
if (!GLSurfaceGLX::InitializeOneOff()) {
LOG(ERROR) << "GLSurfaceGLX::InitializeOneOff failed.";
return false;
}
return true;
case kGLImplementationOSMesaGL:
if (!GLSurfaceOSMesaX11::InitializeOneOff()) {
LOG(ERROR) << "GLSurfaceOSMesaX11::InitializeOneOff failed.";
return false;
}
return true;
case kGLImplementationEGLGLES2:
if (!GLSurfaceEGL::InitializeOneOff()) {
LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
return false;
}
return true;
default:
return true;
}
}
} // namespace init
} // namespace gl
......@@ -4,13 +4,15 @@
#include "ui/gl/test/gl_surface_test_support.h"
#include <vector>
#include "base/command_line.h"
#include "base/logging.h"
#include "build/build_config.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/gl_switches.h"
#include "ui/gl/init/gl_factory.h"
#if defined(USE_X11)
#include <X11/Xlib.h>
......@@ -57,7 +59,7 @@ void GLSurfaceTestSupport::InitializeOneOff() {
bool gpu_service_logging = false;
bool disable_gl_drawing = true;
CHECK(GLSurface::InitializeOneOffImplementation(
CHECK(init::InitializeGLOneOffImplementation(
impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing));
}
......@@ -75,7 +77,7 @@ void GLSurfaceTestSupport::InitializeOneOffImplementation(
bool gpu_service_logging = false;
bool disable_gl_drawing = false;
CHECK(GLSurface::InitializeOneOffImplementation(
CHECK(init::InitializeGLOneOffImplementation(
impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing));
}
......
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