From bcc13e8937e1306089b2b7b1a911d49b46bc0a90 Mon Sep 17 00:00:00 2001 From: Arnaud Renevier Date: Wed, 13 May 2015 10:59:22 -0700 Subject: [PATCH] ozone integration Implement a subset of ozone porting layer needed to get chromium GL layer working. When using ozone, chromium uses surfaces and contexts based on egl, and does not use x11 anymore. So this is a first step towards enabling wayland on chromium-efl Reviewed by: Antonio Gomes, DaeHyun Ko, Hyunhak Kim Change-Id: I7c3b810b14bd071434f3b23c7a56b1aff61abc38 Signed-off-by: Arnaud Renevier Signed-off-by: Antonio Gomes --- tizen_src/build/gyp_chromiumefl.sh | 5 +- tizen_src/build/system.gyp | 21 +++++ .../content/common/cursors/webcursor_efl.cc | 24 ------ tizen_src/chromium_impl/content/content_efl.gypi | 1 + tizen_src/chromium_impl/efl/init.cc | 8 ++ tizen_src/chromium_impl/ui/gl/efl_pixmap.cc | 1 - tizen_src/chromium_impl/ui/gl/efl_pixmap.h | 4 + .../ui/ozone/media_ozone_platform_efl.cc | 26 ++++++ tizen_src/chromium_impl/ui/ozone/ozone_efl.gyp | 28 +++++++ .../chromium_impl/ui/ozone/ozone_platform_efl.cc | 73 ++++++++++++++++ .../chromium_impl/ui/ozone/ozone_platform_efl.h | 43 ++++++++++ .../chromium_impl/ui/ozone/surface_factory_efl.cc | 98 ++++++++++++++++++++++ .../chromium_impl/ui/ozone/surface_factory_efl.h | 25 ++++++ tizen_src/chromium_impl/ui/ui_efl.gypi | 11 +++ tizen_src/ewk/efl_integration/ewk_global_data.cc | 5 ++ tizen_src/supplement.gypi | 10 +++ 16 files changed, 356 insertions(+), 27 deletions(-) create mode 100644 tizen_src/chromium_impl/ui/ozone/media_ozone_platform_efl.cc create mode 100644 tizen_src/chromium_impl/ui/ozone/ozone_efl.gyp create mode 100644 tizen_src/chromium_impl/ui/ozone/ozone_platform_efl.cc create mode 100644 tizen_src/chromium_impl/ui/ozone/ozone_platform_efl.h create mode 100644 tizen_src/chromium_impl/ui/ozone/surface_factory_efl.cc create mode 100644 tizen_src/chromium_impl/ui/ozone/surface_factory_efl.h diff --git a/tizen_src/build/gyp_chromiumefl.sh b/tizen_src/build/gyp_chromiumefl.sh index 05b103d..a18572a 100755 --- a/tizen_src/build/gyp_chromiumefl.sh +++ b/tizen_src/build/gyp_chromiumefl.sh @@ -60,6 +60,9 @@ COMMON_GYP_PARAMETERS=" -Dproprietary_codecs=1 -Duse_aura=0 -Duse_efl=1 + -Duse_ozone=1 + -Dozone_auto_platforms=0 + -Dozone_platform_wayland=0 -Duse_gnome_keyring=0 -Duse_openssl=1 -Duse_openssl_certs=1 @@ -137,13 +140,11 @@ add_wayland_flags() { if [ "$use_wayland" == "1" ]; then ADDITIONAL_GYP_PARAMETERS+="-Duse_wayland=1 -Dwayland_bringup=1 - -Duse_x11=0 -Dtizen_multimedia_pixmap_support=0 " else ADDITIONAL_GYP_PARAMETERS+="-Duse_wayland=0 -Dwayland_bringup=0 - -Duse_x11=1 " fi } diff --git a/tizen_src/build/system.gyp b/tizen_src/build/system.gyp index 8fb5d98..bc215a0 100644 --- a/tizen_src/build/system.gyp +++ b/tizen_src/build/system.gyp @@ -410,6 +410,27 @@ ], }, # libtbm { + 'target_name': 'x11', + 'type': 'none', + 'conditions': [ + ['use_wayland==0', { + 'direct_dependent_settings': { + 'cflags': [ + ' #include -#include #include namespace gfx { diff --git a/tizen_src/chromium_impl/ui/gl/efl_pixmap.h b/tizen_src/chromium_impl/ui/gl/efl_pixmap.h index bc37b82..3b36063 100644 --- a/tizen_src/chromium_impl/ui/gl/efl_pixmap.h +++ b/tizen_src/chromium_impl/ui/gl/efl_pixmap.h @@ -14,6 +14,10 @@ #include "ui/gfx/geometry/size.h" #include "ui/gl/gl_bindings.h" +#if !defined(WAYLAND_BRINGUP) +#include +#endif + namespace gfx { class NativeBuffer; diff --git a/tizen_src/chromium_impl/ui/ozone/media_ozone_platform_efl.cc b/tizen_src/chromium_impl/ui/ozone/media_ozone_platform_efl.cc new file mode 100644 index 0000000..1b307e7 --- /dev/null +++ b/tizen_src/chromium_impl/ui/ozone/media_ozone_platform_efl.cc @@ -0,0 +1,26 @@ +// Copyright (c) 2015 Samsung Electronics. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "media/ozone/media_ozone_platform.h" + +namespace media { + +namespace { + +class MediaOzonePlatformEfl : public MediaOzonePlatform { + public: + MediaOzonePlatformEfl() {} + ~MediaOzonePlatformEfl() override {} + + private: + DISALLOW_COPY_AND_ASSIGN(MediaOzonePlatformEfl); +}; + +} // namespace + +MediaOzonePlatform* CreateMediaOzonePlatformEfl() { + return new MediaOzonePlatformEfl; +} + +} // namespace media diff --git a/tizen_src/chromium_impl/ui/ozone/ozone_efl.gyp b/tizen_src/chromium_impl/ui/ozone/ozone_efl.gyp new file mode 100644 index 0000000..47d2786 --- /dev/null +++ b/tizen_src/chromium_impl/ui/ozone/ozone_efl.gyp @@ -0,0 +1,28 @@ +# Copyright (c) 2015 Samsung Electronics. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'target_defaults': { + 'include_dirs': [ + '<(DEPTH)', + ], + }, + + 'targets': [ + { + 'target_name': 'ozone_efl', + 'type': 'static_library', + 'dependencies': [ + '<(DEPTH)/tizen_src/build/system.gyp:ecore-x', + ], + 'sources': [ + 'media_ozone_platform_efl.cc', + 'ozone_platform_efl.h', + 'ozone_platform_efl.cc', + 'surface_factory_efl.h', + 'surface_factory_efl.cc', + ], + }, + ], +} diff --git a/tizen_src/chromium_impl/ui/ozone/ozone_platform_efl.cc b/tizen_src/chromium_impl/ui/ozone/ozone_platform_efl.cc new file mode 100644 index 0000000..fe94e74 --- /dev/null +++ b/tizen_src/chromium_impl/ui/ozone/ozone_platform_efl.cc @@ -0,0 +1,73 @@ +// Copyright (c) 2015 Samsung Electronics. 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/ozone/ozone_platform_efl.h" + +#include "base/logging.h" +#include "ui/display/types/native_display_delegate.h" +#include "ui/ozone/public/gpu_platform_support.h" +#include "ui/ozone/public/gpu_platform_support_host.h" +#include "ui/ozone/public/system_input_injector.h" +#include "ui/ozone/surface_factory_efl.h" +#include "ui/platform_window/platform_window.h" + +namespace ui { + +OzonePlatformEfl::OzonePlatformEfl() + : OzonePlatform() { + surface_factory_.reset(new SurfaceFactoryEfl); +} + +SurfaceFactoryOzone* OzonePlatformEfl::GetSurfaceFactoryOzone() { + return surface_factory_.get(); +} + +CursorFactoryOzone* OzonePlatformEfl::GetCursorFactoryOzone() { + NOTIMPLEMENTED(); + return NULL; +} + +InputController* OzonePlatformEfl::GetInputController() { + NOTIMPLEMENTED(); + return NULL; +} + +GpuPlatformSupport* OzonePlatformEfl::GetGpuPlatformSupport() { + return gpu_platform_.get(); +} + +GpuPlatformSupportHost* OzonePlatformEfl::GetGpuPlatformSupportHost() { + return gpu_platform_host_.get(); +} + +scoped_ptr OzonePlatformEfl::CreateSystemInputInjector() { + NOTIMPLEMENTED(); + return NULL; +} + +scoped_ptr OzonePlatformEfl::CreatePlatformWindow( + PlatformWindowDelegate* delegate, + const gfx::Rect& bounds) { + NOTIMPLEMENTED(); + return NULL; +} + +scoped_ptr OzonePlatformEfl::CreateNativeDisplayDelegate() { + NOTIMPLEMENTED(); + return NULL; +} + +void OzonePlatformEfl::InitializeUI() { + gpu_platform_host_.reset(CreateStubGpuPlatformSupportHost()); +} + +void OzonePlatformEfl::InitializeGPU() { + gpu_platform_.reset(CreateStubGpuPlatformSupport()); +} + +OzonePlatform* CreateOzonePlatformEfl() { + return new OzonePlatformEfl; +} + +} // namespace ui diff --git a/tizen_src/chromium_impl/ui/ozone/ozone_platform_efl.h b/tizen_src/chromium_impl/ui/ozone/ozone_platform_efl.h new file mode 100644 index 0000000..ea03d08 --- /dev/null +++ b/tizen_src/chromium_impl/ui/ozone/ozone_platform_efl.h @@ -0,0 +1,43 @@ +// Copyright (c) 2015 Samsung Electronics. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef OZONE_OZONE_PLATFORM_EFL_H_ +#define OZONE_OZONE_PLATFORM_EFL_H_ + +#include "ui/ozone/public/ozone_platform.h" + +#include "base/memory/scoped_ptr.h" + +namespace ui { + +class OzonePlatformEfl : public OzonePlatform { + public: + OzonePlatformEfl(); + + SurfaceFactoryOzone* GetSurfaceFactoryOzone() override; + CursorFactoryOzone* GetCursorFactoryOzone() override; + InputController* GetInputController() override; + GpuPlatformSupport* GetGpuPlatformSupport() override; + GpuPlatformSupportHost* GetGpuPlatformSupportHost() override; + scoped_ptr CreateSystemInputInjector() override; + scoped_ptr CreatePlatformWindow( + PlatformWindowDelegate* delegate, + const gfx::Rect& bounds) override; + scoped_ptr + CreateNativeDisplayDelegate() override; + + private: + void InitializeUI() override; + void InitializeGPU() override; + + scoped_ptr surface_factory_; + scoped_ptr gpu_platform_; + scoped_ptr gpu_platform_host_; + + DISALLOW_COPY_AND_ASSIGN(OzonePlatformEfl); +}; + +} // namespace ui + +#endif // OZONE_OZONE_PLATFORM_EFL_H_ diff --git a/tizen_src/chromium_impl/ui/ozone/surface_factory_efl.cc b/tizen_src/chromium_impl/ui/ozone/surface_factory_efl.cc new file mode 100644 index 0000000..2ea364d --- /dev/null +++ b/tizen_src/chromium_impl/ui/ozone/surface_factory_efl.cc @@ -0,0 +1,98 @@ +// Copyright (c) 2015 Samsung Electronics. 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/ozone/surface_factory_efl.h" + +#if !defined(WAYLAND_BRINGUP) +#include +#else +#include +#endif +#include +#include + +#include "base/files/file_path.h" +#include "ui/gl/gl_implementation.h" + +namespace { + +const char kEGLLibraryName[] = "libEGL.so"; +const char kGLESv2LibraryName[] = "libGLESv2.so"; + +base::NativeLibrary LoadLibrary(const base::FilePath& filename) { + base::NativeLibraryLoadError error; + base::NativeLibrary library = base::LoadNativeLibrary(filename, &error); + if (!library) { + LOG(ERROR) << "Failed to load " << filename.MaybeAsASCII() + << ": " << error.ToString(); + return NULL; + } + return library; +} + +base::NativeLibrary LoadLibrary(const char* filename) { + return LoadLibrary(base::FilePath(filename)); +} + +} + +namespace ui { + +SurfaceFactoryEfl::SurfaceFactoryEfl() + : SurfaceFactoryOzone() { +} + +bool SurfaceFactoryEfl::LoadEGLGLES2Bindings( + AddGLLibraryCallback add_gl_library, + SetGLGetProcAddressProcCallback set_gl_get_proc_address) { + base::NativeLibrary egl_library = LoadLibrary(kEGLLibraryName); + if (!egl_library) + return false; + + base::NativeLibrary gles_library = LoadLibrary(kGLESv2LibraryName); + if (!gles_library) + return false; + + gfx::GLGetProcAddressProc get_proc_address = + reinterpret_cast( + base::GetFunctionPointerFromNativeLibrary( + egl_library, "eglGetProcAddress")); + if (!get_proc_address) { + LOG(ERROR) << "eglGetProcAddress not found."; + base::UnloadNativeLibrary(egl_library); + base::UnloadNativeLibrary(gles_library); + return false; + } + + gfx::SetGLGetProcAddressProc(get_proc_address); + gfx::AddGLNativeLibrary(egl_library); + gfx::AddGLNativeLibrary(gles_library); + + return true; +} + +intptr_t SurfaceFactoryEfl::GetNativeDisplay() { +#if !defined(WAYLAND_BRINGUP) + return reinterpret_cast(ecore_x_display_get()); +#endif + return 0; +} + +const int32* SurfaceFactoryEfl::GetEGLSurfaceProperties( + const int32* desired_list) { + static const EGLint kConfigAttribs[] = { + EGL_BUFFER_SIZE, 32, + EGL_ALPHA_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_RED_SIZE, 8, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_NONE + }; + return kConfigAttribs; +} + +} // namespace ui + diff --git a/tizen_src/chromium_impl/ui/ozone/surface_factory_efl.h b/tizen_src/chromium_impl/ui/ozone/surface_factory_efl.h new file mode 100644 index 0000000..32e7966 --- /dev/null +++ b/tizen_src/chromium_impl/ui/ozone/surface_factory_efl.h @@ -0,0 +1,25 @@ +// Copyright (c) 2015 Samsung Electronics. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef OZONE_SURFACE_FACTORY_EFL +#define OZONE_SURFACE_FACTORY_EFL + +#include "ui/ozone/public/surface_factory_ozone.h" + +namespace ui { + +class SurfaceFactoryEfl : public ui::SurfaceFactoryOzone { + public: + SurfaceFactoryEfl(); + + bool LoadEGLGLES2Bindings( + AddGLLibraryCallback add_gl_library, + SetGLGetProcAddressProcCallback set_gl_get_proc_address) override; + intptr_t GetNativeDisplay() override; + const int32* GetEGLSurfaceProperties(const int32* desired_list) override; +}; + +} // namespace ui + +#endif // OZONE_SURFACE_FACTORY_EFL diff --git a/tizen_src/chromium_impl/ui/ui_efl.gypi b/tizen_src/chromium_impl/ui/ui_efl.gypi index 8469437..f78b4a7 100644 --- a/tizen_src/chromium_impl/ui/ui_efl.gypi +++ b/tizen_src/chromium_impl/ui/ui_efl.gypi @@ -36,6 +36,17 @@ '<(DEPTH)/tizen_src/chromium_impl/ui/ui_targets_efl.gyp:ui_events_source_inject', ], }, + + 'conditions': [ + ['use_ozone==1', { + 'variables': { + 'external_ozone_platform_deps': [ + '<(DEPTH)/tizen_src/chromium_impl/ui/ozone/ozone_efl.gyp:ozone_efl', + ], + }, + }], # use_ozone==1 + ], # conditions + 'target_defaults': { 'target_conditions': [ diff --git a/tizen_src/ewk/efl_integration/ewk_global_data.cc b/tizen_src/ewk/efl_integration/ewk_global_data.cc index 91e339b..9624531 100644 --- a/tizen_src/ewk/efl_integration/ewk_global_data.cc +++ b/tizen_src/ewk/efl_integration/ewk_global_data.cc @@ -25,6 +25,7 @@ #include "efl/window_factory.h" #include "eweb_view.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/ozone/public/ozone_platform.h" #include "command_line_efl.h" #include "content_main_delegate_efl.h" @@ -106,6 +107,10 @@ EwkGlobalData* EwkGlobalData::GetInstance() { content::MainFunctionParams main_funtion_params = CommandLineEfl::GetDefaultPortParams(); +#if defined(USE_OZONE) + ui::OzonePlatform::InitializeForUI(); +#endif + instance_->content_main_runner_->Initialize(params); instance_->browser_main_runner_->Initialize(main_funtion_params); diff --git a/tizen_src/supplement.gypi b/tizen_src/supplement.gypi index abacd7d..3f79faa 100644 --- a/tizen_src/supplement.gypi +++ b/tizen_src/supplement.gypi @@ -36,6 +36,16 @@ 'chromium_impl/chromium_impl.gypi', ], + 'conditions': [ + ['use_ozone==1', { + 'variables': { + 'external_ozone_platforms': [ + 'efl', + ], + }, + }], # use_ozone==1 + ], + 'target_defaults': { 'include_dirs': [ -- 2.7.4