Commit 09d09f46 authored by Yuly Novikov's avatar Yuly Novikov Committed by Commit Bot

Conditionally link ANGLE statically into Android Chrome

When use_static_angle is set

BUG=726002

Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I4d716a48002f03af29a0280cd9207460e470143d
Reviewed-on: https://chromium-review.googlesource.com/822952Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524226}
parent a05fe420
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import("//testing/libfuzzer/fuzzer_test.gni") import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni") import("//testing/test.gni")
import("//build/config/ui.gni") import("//build/config/ui.gni")
import("//ui/gl/features.gni")
config("gpu_implementation") { config("gpu_implementation") {
defines = [ "GPU_IMPLEMENTATION" ] defines = [ "GPU_IMPLEMENTATION" ]
...@@ -34,83 +35,85 @@ component("gpu_util") { ...@@ -34,83 +35,85 @@ component("gpu_util") {
] ]
} }
shared_library("command_buffer_gles2") { if (!use_static_angle) {
sources = [ shared_library("command_buffer_gles2") {
# TODO(hendrikw): Move egl out of gles2_conform_support. sources = [
"gles2_conform_support/egl/config.cc", # TODO(hendrikw): Move egl out of gles2_conform_support.
"gles2_conform_support/egl/config.h", "gles2_conform_support/egl/config.cc",
"gles2_conform_support/egl/context.cc", "gles2_conform_support/egl/config.h",
"gles2_conform_support/egl/context.h", "gles2_conform_support/egl/context.cc",
"gles2_conform_support/egl/display.cc", "gles2_conform_support/egl/context.h",
"gles2_conform_support/egl/display.h", "gles2_conform_support/egl/display.cc",
"gles2_conform_support/egl/egl.cc", "gles2_conform_support/egl/display.h",
"gles2_conform_support/egl/surface.cc", "gles2_conform_support/egl/egl.cc",
"gles2_conform_support/egl/surface.h", "gles2_conform_support/egl/surface.cc",
"gles2_conform_support/egl/test_support.cc", "gles2_conform_support/egl/surface.h",
"gles2_conform_support/egl/test_support.h", "gles2_conform_support/egl/test_support.cc",
"gles2_conform_support/egl/thread_state.cc", "gles2_conform_support/egl/test_support.h",
"gles2_conform_support/egl/thread_state.h", "gles2_conform_support/egl/thread_state.cc",
] "gles2_conform_support/egl/thread_state.h",
]
deps = [ deps = [
":gpu", ":gpu",
"//base", "//base",
"//build/config:exe_and_shlib_deps", "//build/config:exe_and_shlib_deps",
"//gpu/command_buffer/client:gles2_c_lib", "//gpu/command_buffer/client:gles2_c_lib",
"//gpu/command_buffer/client:gles2_implementation", "//gpu/command_buffer/client:gles2_implementation",
"//gpu/command_buffer/common:gles2_utils", "//gpu/command_buffer/common:gles2_utils",
"//ui/gl:gl", "//ui/gl:gl",
] ]
defines = [ defines = [
"COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY", "COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY",
"EGLAPIENTRY=", "EGLAPIENTRY=",
] ]
if (is_android) { if (is_android) {
configs -= [ "//build/config/android:hide_all_but_jni_onload" ] configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
} }
if (current_os == "win") { if (current_os == "win") {
defines += [ "EGLAPI=__declspec(dllexport)" ] defines += [ "EGLAPI=__declspec(dllexport)" ]
} else { } else {
defines += [ "EGLAPI=__attribute__((visibility(\"default\")))" ] defines += [ "EGLAPI=__attribute__((visibility(\"default\")))" ]
}
} }
}
test("command_buffer_gles2_tests") {
sources = [
"command_buffer/tests/command_buffer_gles2_tests_main.cc",
"command_buffer/tests/egl_test.cc",
]
deps = [ test("command_buffer_gles2_tests") {
":command_buffer_gles2", sources = [
"//base", "command_buffer/tests/command_buffer_gles2_tests_main.cc",
"//base/test:test_support", "command_buffer/tests/egl_test.cc",
"//base/third_party/dynamic_annotations", ]
"//testing/gmock",
"//testing/gtest",
]
defines = [
"COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY",
"EGLAPIENTRY=",
]
if (current_os == "win") {
defines += [ "EGLAPI=__declspec(dllimport)" ]
} else {
defines += [ "EGLAPI=" ]
}
libs = [] deps = [
":command_buffer_gles2",
"//base",
"//base/test:test_support",
"//base/third_party/dynamic_annotations",
"//testing/gmock",
"//testing/gtest",
]
if (is_android) { defines = [
libs += [ "android" ] "COMMAND_BUFFER_GLES_LIB_SUPPORT_ONLY",
deps += [ "//ui/android:ui_java" ] "EGLAPIENTRY=",
} ]
if (is_linux && !is_component_build) { if (current_os == "win") {
configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ] defines += [ "EGLAPI=__declspec(dllimport)" ]
} else {
defines += [ "EGLAPI=" ]
}
libs = []
if (is_android) {
libs += [ "android" ]
deps += [ "//ui/android:ui_java" ]
}
if (is_linux && !is_component_build) {
configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
}
} }
} } # if (!use_static_angle)
static_library("test_support") { static_library("test_support") {
testonly = true testonly = true
......
...@@ -130,6 +130,7 @@ source_set("config_sources") { ...@@ -130,6 +130,7 @@ source_set("config_sources") {
"//base", "//base",
"//third_party/re2", "//third_party/re2",
"//ui/gl", "//ui/gl",
"//ui/gl:gl_features",
"//ui/gl/init", "//ui/gl/init",
] ]
......
...@@ -22,8 +22,13 @@ ...@@ -22,8 +22,13 @@
#include "ui/gl/egl_util.h" #include "ui/gl/egl_util.h"
#include "ui/gl/gl_bindings.h" #include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h" #include "ui/gl/gl_context.h"
#include "ui/gl/gl_features.h"
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
#if BUILDFLAG(USE_STATIC_ANGLE)
#include <EGL/egl.h>
#endif // BUILDFLAG(USE_STATIC_ANGLE)
namespace { namespace {
std::pair<std::string, size_t> GetVersionFromString( std::pair<std::string, size_t> GetVersionFromString(
...@@ -68,6 +73,12 @@ std::string GetDriverVersionFromString(const std::string& version_string) { ...@@ -68,6 +73,12 @@ std::string GetDriverVersionFromString(const std::string& version_string) {
} }
gpu::CollectInfoResult CollectDriverInfo(gpu::GPUInfo* gpu_info) { gpu::CollectInfoResult CollectDriverInfo(gpu::GPUInfo* gpu_info) {
#if BUILDFLAG(USE_STATIC_ANGLE)
#pragma push_macro("eglGetProcAddress")
#undef eglGetProcAddress
#define LOOKUP_FUNC(x) \
auto x##Fn = reinterpret_cast<gl::x##Proc>(eglGetProcAddress(#x))
#else // BUILDFLAG(USE_STATIC_ANGLE)
// Go through the process of loading GL libs and initializing an EGL // Go through the process of loading GL libs and initializing an EGL
// context so that we can get GL vendor/version/renderer strings. // context so that we can get GL vendor/version/renderer strings.
base::NativeLibrary gles_library, egl_library; base::NativeLibrary gles_library, egl_library;
...@@ -112,6 +123,7 @@ gpu::CollectInfoResult CollectDriverInfo(gpu::GPUInfo* gpu_info) { ...@@ -112,6 +123,7 @@ gpu::CollectInfoResult CollectDriverInfo(gpu::GPUInfo* gpu_info) {
}; };
#define LOOKUP_FUNC(x) auto x##Fn = reinterpret_cast<gl::x##Proc>(get_func(#x)) #define LOOKUP_FUNC(x) auto x##Fn = reinterpret_cast<gl::x##Proc>(get_func(#x))
#endif // BUILDFLAG(USE_STATIC_ANGLE)
LOOKUP_FUNC(eglGetError); LOOKUP_FUNC(eglGetError);
LOOKUP_FUNC(eglQueryString); LOOKUP_FUNC(eglQueryString);
...@@ -131,6 +143,9 @@ gpu::CollectInfoResult CollectDriverInfo(gpu::GPUInfo* gpu_info) { ...@@ -131,6 +143,9 @@ gpu::CollectInfoResult CollectDriverInfo(gpu::GPUInfo* gpu_info) {
LOOKUP_FUNC(glGetIntegerv); LOOKUP_FUNC(glGetIntegerv);
#undef LOOKUP_FUNC #undef LOOKUP_FUNC
#if BUILDFLAG(USE_STATIC_ANGLE)
#pragma pop_macro("eglGetProcAddress")
#endif // BUILDFLAG(USE_STATIC_ANGLE)
EGLDisplay curr_display = eglGetCurrentDisplayFn(); EGLDisplay curr_display = eglGetCurrentDisplayFn();
EGLContext curr_context = eglGetCurrentContextFn(); EGLContext curr_context = eglGetCurrentContextFn();
......
...@@ -6,6 +6,7 @@ import("//build/buildflag_header.gni") ...@@ -6,6 +6,7 @@ import("//build/buildflag_header.gni")
import("//build/config/chrome_build.gni") import("//build/config/chrome_build.gni")
import("//build/config/linux/pkg_config.gni") import("//build/config/linux/pkg_config.gni")
import("//build/config/ui.gni") import("//build/config/ui.gni")
import("//ui/gl/features.gni")
import("//ui/ozone/ozone.gni") import("//ui/ozone/ozone.gni")
import("//testing/test.gni") import("//testing/test.gni")
...@@ -25,7 +26,10 @@ if (is_android) { ...@@ -25,7 +26,10 @@ if (is_android) {
buildflag_header("gl_features") { buildflag_header("gl_features") {
header = "gl_features.h" header = "gl_features.h"
flags = [ "ENABLE_SWIFTSHADER=$enable_swiftshader" ] flags = [
"ENABLE_SWIFTSHADER=$enable_swiftshader",
"USE_STATIC_ANGLE=$use_static_angle",
]
} }
config("gl_config") { config("gl_config") {
...@@ -196,6 +200,10 @@ component("gl") { ...@@ -196,6 +200,10 @@ component("gl") {
"gl_image_ahardwarebuffer.cc", "gl_image_ahardwarebuffer.cc",
"gl_image_ahardwarebuffer.h", "gl_image_ahardwarebuffer.h",
] ]
if (use_static_angle) {
deps += [ "//third_party/angle:libEGL_static" ]
}
} }
if (is_posix) { if (is_posix) {
......
# Copyright 2017 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.
declare_args() {
# Whether ANGLE should be linked statically
# False by default, enabling currently supported only on Android
use_static_angle = false
}
...@@ -36,6 +36,7 @@ component("init") { ...@@ -36,6 +36,7 @@ component("init") {
"gl_factory_android.cc", "gl_factory_android.cc",
"gl_initializer_android.cc", "gl_initializer_android.cc",
] ]
deps += [ "//ui/gl:gl_features" ]
} else if (is_win) { } else if (is_win) {
sources += [ sources += [
"gl_factory_win.cc", "gl_factory_win.cc",
......
...@@ -11,17 +11,28 @@ ...@@ -11,17 +11,28 @@
#include "base/native_library.h" #include "base/native_library.h"
#include "ui/gl/gl_bindings.h" #include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_egl_api_implementation.h" #include "ui/gl/gl_egl_api_implementation.h"
#include "ui/gl/gl_features.h"
#include "ui/gl/gl_gl_api_implementation.h" #include "ui/gl/gl_gl_api_implementation.h"
#include "ui/gl/gl_implementation_osmesa.h" #include "ui/gl/gl_implementation_osmesa.h"
#include "ui/gl/gl_osmesa_api_implementation.h" #include "ui/gl/gl_osmesa_api_implementation.h"
#include "ui/gl/gl_surface_egl.h" #include "ui/gl/gl_surface_egl.h"
#if BUILDFLAG(USE_STATIC_ANGLE)
#include <EGL/egl.h>
#endif // BUILDFLAG(USE_STATIC_ANGLE)
namespace gl { namespace gl {
namespace init { namespace init {
namespace { namespace {
bool InitializeStaticEGLInternal() { bool InitializeStaticEGLInternal() {
#if BUILDFLAG(USE_STATIC_ANGLE)
#pragma push_macro("eglGetProcAddress")
#undef eglGetProcAddress
SetGLGetProcAddressProc(&eglGetProcAddress);
#pragma pop_macro("eglGetProcAddress")
#else // BUILDFLAG(USE_STATIC_ANGLE)
base::NativeLibrary gles_library = LoadLibraryAndPrintError("libGLESv2.so"); base::NativeLibrary gles_library = LoadLibraryAndPrintError("libGLESv2.so");
if (!gles_library) if (!gles_library)
return false; return false;
...@@ -45,6 +56,7 @@ bool InitializeStaticEGLInternal() { ...@@ -45,6 +56,7 @@ bool InitializeStaticEGLInternal() {
SetGLGetProcAddressProc(get_proc_address); SetGLGetProcAddressProc(get_proc_address);
AddGLNativeLibrary(egl_library); AddGLNativeLibrary(egl_library);
AddGLNativeLibrary(gles_library); AddGLNativeLibrary(gles_library);
#endif // BUILDFLAG(USE_STATIC_ANGLE)
SetGLImplementation(kGLImplementationEGLGLES2); SetGLImplementation(kGLImplementationEGLGLES2);
InitializeStaticGLBindingsGL(); InitializeStaticGLBindingsGL();
......
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