0

Delete Ozone egltest platform.

The Ozone X11 platform implements a more complete X11 backend for Ozone
and egltest is unused at this point. Delete the egltest code and all the
accompanying parts of GYP and GN build files.

BUG=none

Review-Url: https://codereview.chromium.org/2167243002
Cr-Commit-Position: refs/heads/master@{#406918}
This commit is contained in:
kylechar
2016-07-21 11:42:21 -07:00
committed by Commit bot
parent d3b350b39b
commit 3f2b800844
15 changed files with 7 additions and 851 deletions

@ -1563,9 +1563,7 @@
# Ozone platforms to include in the build.
'ozone_platform_caca%': 0,
'ozone_platform_cast%': 0,
'ozone_platform_egltest%': 0,
'ozone_platform_gbm%': 0,
'ozone_platform_ozonex%': 0,
'ozone_platform_headless%': 0,
'ozone_platform_wayland%': 0,
@ -2357,12 +2355,11 @@
'ozone_platform_cast%': 1,
'conditions': [
# For desktop non-audio Chromecast builds, run with
# --ozone-platform=egltest
# --ozone-platform=x11
# TODO(slan|halliwell): Make the default platform "cast" on
# desktop non-audio builds too.
['is_cast_desktop_build==1 and disable_display==0', {
'ozone_platform_egltest%': 1,
'ozone_platform_ozonex%': 1,
# Use GN instead.
}, {
'ozone_platform%': 'cast',
}],
@ -2370,7 +2367,6 @@
}, { # chromecast!=1
# Build all platforms whose deps are in install-build-deps.sh.
# Only these platforms will be compile tested by buildbots.
'ozone_platform_egltest%': 1,
'conditions': [
['chromeos==1', {
'ozone_platform_gbm%': 1,

@ -193,7 +193,7 @@
},
], # targets
}],
[ 'use_x11==1 or ozone_platform_ozonex==1', {
[ 'use_x11==1', {
# Hide X11 and related dependencies when use_x11=0
'targets': [
{

@ -25,7 +25,7 @@ ninja -C out/Debug cast_shell
```
```shell
out/Debug/cast_shell --ozone-platform=egltest http://google.com
out/Debug/cast_shell --ozone-platform=x11 http://google.com
```
## Building/running cast\_shell\_apk (Android)

@ -349,7 +349,7 @@
'keycodes/events_keycodes.gyp:keycodes_x11',
],
}],
['use_x11==1 or ozone_platform_ozonex==1', {
['use_x11==1', {
'dependencies': [
'x/events_x.gyp:events_x',
],

@ -19,11 +19,6 @@ ozone_platform_deps = []
# Extra dependencies to pull into ozone_unittests for built platforms.
ozone_platform_test_deps = []
if (ozone_platform_egltest) {
ozone_platforms += [ "egltest" ]
ozone_platform_deps += [ "platform/egltest" ]
}
if (ozone_platform_headless) {
ozone_platforms += [ "headless" ]
ozone_platform_deps += [ "platform/headless" ]

@ -24,9 +24,7 @@ declare_args() {
# Enable individual platforms.
ozone_platform_caca = false
ozone_platform_cast = false
ozone_platform_egltest = false
ozone_platform_gbm = false
ozone_platform_ozonex = false
ozone_platform_headless = false
ozone_platform_x11 = false
ozone_platform_wayland = false
@ -61,6 +59,6 @@ declare_args() {
}
assert(use_ozone || !(ozone_platform_caca || ozone_platform_cast ||
ozone_platform_egltest || ozone_platform_gbm ||
ozone_platform_ozonex || ozone_platform_headless),
ozone_platform_gbm || ozone_platform_headless ||
ozone_platform_x11 || ozone_platform_wayland),
"Must set use_ozone to select ozone platforms")

@ -266,11 +266,6 @@
'platform/cast/cast.gypi',
],
}],
['<(ozone_platform_egltest) == 1', {
'includes': [
'platform/egltest/egltest.gypi',
],
}],
['<(ozone_platform_gbm) == 1', {
'includes': [
'platform/drm/gbm.gypi',

@ -1,79 +0,0 @@
# Copyright 2014 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.
import("//tools/generate_library_loader/generate_library_loader.gni")
import("//ui/ozone/ozone.gni")
visibility = [ "//ui/ozone/*" ]
source_set("egltest") {
sources = [
"client_native_pixmap_factory_egltest.cc",
"client_native_pixmap_factory_egltest.h",
"ozone_platform_egltest.cc",
"ozone_platform_egltest.h",
]
configs += [ "//third_party/khronos:khronos_headers" ]
deps = [
":eglplatform_shim",
"//base",
"//ui/events",
"//ui/events/devices",
"//ui/events/ozone:events_ozone",
"//ui/events/ozone:events_ozone_evdev",
"//ui/events/ozone:events_ozone_layout",
"//ui/events/platform",
"//ui/gfx",
"//ui/ozone:ozone_base",
"//ui/ozone/common",
"//ui/platform_window",
]
}
generate_library_loader("eglplatform_shim") {
name = "LibeglplatformShimLoader"
output_h = "libeglplatform_shim.h"
output_cc = "libeglplatform_shim_loader.cc"
header = "\"ui/ozone/platform/egltest/eglplatform_shim.h\""
functions = [
"ShimQueryString",
"ShimInitialize",
"ShimTerminate",
"ShimCreateWindow",
"ShimQueryWindow",
"ShimDestroyWindow",
"ShimGetNativeDisplay",
"ShimGetNativeWindow",
"ShimReleaseNativeWindow",
]
}
# TODO(spang): eglplatform_shim_x11 should become a loadable_module once
# support lands: http://crbug.com/380327. Until then, it is not valid on
# platforms other than Linux.
# GYP version: "ui/ozone/platform/egltest/egltest.gypi:eglplatform_shim_x11"
if (is_linux && ozone_platform_ozonex) {
shared_library("eglplatform_shim_x11") {
output_name = "libeglplatform_shim"
output_extension = "so.1"
sources = [
"eglplatform_shim.h",
"eglplatform_shim_xeleven.cc",
]
configs += [ "//build/config/linux:x11" ]
deps = [
"//build/config/sanitizers:deps",
]
visibility += [ "//chromecast/*" ]
}
}

@ -1,15 +0,0 @@
// Copyright 2015 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/ozone/platform/egltest/client_native_pixmap_factory_egltest.h"
#include "ui/ozone/common/stub_client_native_pixmap_factory.h"
namespace ui {
ClientNativePixmapFactory* CreateClientNativePixmapFactoryEgltest() {
return CreateStubClientNativePixmapFactory();
}
} // namespace ui

@ -1,17 +0,0 @@
// Copyright 2015 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_OZONE_PLATFORM_EGLTEST_CLIENT_NATIVE_PIXMAP_FACTORY_EGLTEST_H_
#define UI_OZONE_PLATFORM_EGLTEST_CLIENT_NATIVE_PIXMAP_FACTORY_EGLTEST_H_
namespace ui {
class ClientNativePixmapFactory;
// Constructor hook for use in constructor_list.cc
ClientNativePixmapFactory* CreateClientNativePixmapFactoryEgltest();
} // namespace ui
#endif // UI_OZONE_PLATFORM_EGLTEST_CLIENT_NATIVE_PIXMAP_FACTORY_EGLTEST_H_

@ -1,58 +0,0 @@
// Copyright 2014 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 __eglplatform_shim_h_
#define __eglplatform_shim_h_
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define SHIM_EXPORT __attribute__((visibility("default")))
// Simple integral native window identifier.
// NB: Unlike EGLNativeWindowType, this will be shipped between processes.
typedef int ShimNativeWindowId;
#define SHIM_NO_WINDOW_ID ((ShimNativeWindowId)0)
// Opaque versions of EGL types (as used by ozone).
typedef intptr_t ShimEGLNativeDisplayType;
typedef intptr_t ShimEGLNativeWindowType;
// QueryString targets
#define SHIM_EGL_LIBRARY 0x1001
#define SHIM_GLES_LIBRARY 0x1002
// CreateWindow / QueryWindow attributes
#define SHIM_WINDOW_WIDTH 0x0001
#define SHIM_WINDOW_HEIGHT 0x0002
// Query global implementation information.
SHIM_EXPORT const char* ShimQueryString(int name);
// Init/terminate library.
SHIM_EXPORT bool ShimInitialize(void);
SHIM_EXPORT bool ShimTerminate(void);
// Create window handle & query window properties (called from browser process).
SHIM_EXPORT ShimNativeWindowId ShimCreateWindow(void);
SHIM_EXPORT bool ShimQueryWindow(ShimNativeWindowId window_id,
int attribute,
int* value);
SHIM_EXPORT bool ShimDestroyWindow(ShimNativeWindowId window_id);
// Manage actual EGL platform objects (called from GPU process).
SHIM_EXPORT ShimEGLNativeDisplayType ShimGetNativeDisplay(void);
SHIM_EXPORT ShimEGLNativeWindowType
ShimGetNativeWindow(ShimNativeWindowId native_window_id);
SHIM_EXPORT bool ShimReleaseNativeWindow(ShimEGLNativeWindowType native_window);
#ifdef __cplusplus
}
#endif
#endif /* __eglplatform_shim_h */

@ -1,106 +0,0 @@
// Copyright 2014 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/ozone/platform/egltest/eglplatform_shim.h"
#include <string.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#ifdef __cplusplus
extern "C" {
#endif
Display* g_display;
const int kDefaultX = 0;
const int kDefaultY = 0;
const int kDefaultWidth = 1280;
const int kDefaultHeight = 720;
const int kDefaultBorderWidth = 0;
const char* ShimQueryString(int name) {
switch (name) {
case SHIM_EGL_LIBRARY:
return "libEGL.so.1";
case SHIM_GLES_LIBRARY:
return "libGLESv2.so.2";
default:
return NULL;
}
}
bool ShimInitialize(void) {
g_display = XOpenDisplay(NULL);
return g_display != NULL;
}
bool ShimTerminate(void) {
XCloseDisplay(g_display);
return true;
}
ShimNativeWindowId ShimCreateWindow(void) {
XSetWindowAttributes swa;
memset(&swa, 0, sizeof(swa));
swa.event_mask = 0;
Window window = XCreateWindow(g_display,
DefaultRootWindow(g_display),
kDefaultX,
kDefaultY,
kDefaultWidth,
kDefaultHeight,
kDefaultBorderWidth,
CopyFromParent,
InputOutput,
CopyFromParent,
CWEventMask,
&swa);
XMapWindow(g_display, window);
XStoreName(g_display, window, "EGL test");
XFlush(g_display);
return window;
}
bool ShimQueryWindow(ShimNativeWindowId window_id, int attribute, int* value) {
XWindowAttributes window_attributes;
switch (attribute) {
case SHIM_WINDOW_WIDTH:
XGetWindowAttributes(g_display, window_id, &window_attributes);
*value = window_attributes.width;
return true;
case SHIM_WINDOW_HEIGHT:
XGetWindowAttributes(g_display, window_id, &window_attributes);
*value = window_attributes.height;
return true;
default:
return false;
}
}
bool ShimDestroyWindow(ShimNativeWindowId window_id) {
XDestroyWindow(g_display, window_id);
return true;
}
ShimEGLNativeDisplayType ShimGetNativeDisplay(void) {
return reinterpret_cast<ShimEGLNativeDisplayType>(g_display);
}
ShimEGLNativeWindowType ShimGetNativeWindow(
ShimNativeWindowId native_window_id) {
return native_window_id;
}
bool ShimReleaseNativeWindow(ShimEGLNativeWindowType native_window) {
return true;
}
#ifdef __cplusplus
}
#endif

@ -1,115 +0,0 @@
# Copyright 2014 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.
{
'variables': {
'internal_ozone_platform_deps': [
'ozone_platform_egltest',
],
'internal_ozone_platforms': [
'egltest'
],
},
'targets': [
{
'target_name': 'ozone_platform_egltest',
'type': 'static_library',
'defines': [
'OZONE_IMPLEMENTATION',
],
'dependencies': [
'ozone.gyp:ozone_base',
'ozone.gyp:ozone_common',
'../../base/base.gyp:base',
'../../third_party/khronos/khronos.gyp:khronos_headers',
'../events/devices/events_devices.gyp:events_devices',
'../events/events.gyp:events',
'../events/ozone/events_ozone.gyp:events_ozone_evdev',
'../events/ozone/events_ozone.gyp:events_ozone_layout',
'../events/platform/events_platform.gyp:events_platform',
'../gfx/gfx.gyp:gfx',
'eglplatform_shim',
],
'sources': [
'client_native_pixmap_factory_egltest.cc',
'client_native_pixmap_factory_egltest.h',
'ozone_platform_egltest.cc',
'ozone_platform_egltest.h',
],
},
{
'target_name': 'eglplatform_shim',
'type': 'static_library',
'dependencies': [
'../../third_party/khronos/khronos.gyp:khronos_headers',
],
'direct_dependent_settings': {
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)',
],
},
'include_dirs': [
'../../../..',
],
'hard_dependency': 1,
'actions': [
{
'variables': {
'output_cc': '<(INTERMEDIATE_DIR)/libeglplatform_shim_loader.cc',
'output_h': '<(SHARED_INTERMEDIATE_DIR)/library_loaders/libeglplatform_shim.h',
'generator': '../../tools/generate_library_loader/generate_library_loader.py',
},
'action_name': 'generate_libeglplatform_shim_loader',
'inputs': [
'<(generator)',
],
'outputs': [
'<(output_h)',
'<(output_cc)',
],
'action': ['python',
'<(generator)',
'--name', 'LibeglplatformShimLoader',
'--output-h', '<(output_h)',
'--output-cc', '<(output_cc)',
'--header', '"ui/ozone/platform/egltest/eglplatform_shim.h"',
'ShimQueryString',
'ShimInitialize',
'ShimTerminate',
'ShimCreateWindow',
'ShimQueryWindow',
'ShimDestroyWindow',
'ShimGetNativeDisplay',
'ShimGetNativeWindow',
'ShimReleaseNativeWindow',
],
'message': 'Generating libeglplatform_shim library loader',
'process_outputs_as_sources': 1,
},
],
},
],
'conditions': [
['ozone_platform_ozonex == 1', {
'targets': [
{
'target_name': 'eglplatform_shim_x11',
'type': 'loadable_module',
'product_name': 'eglplatform_shim',
'product_extension': 'so.1',
'include_dirs': [
'../../../..',
],
'dependencies': [
'../../build/linux/system.gyp:x11',
],
'sources': [
'eglplatform_shim.h',
'eglplatform_shim_xeleven.cc',
],
},
],
}],
],
}

@ -1,421 +0,0 @@
// Copyright 2014 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/ozone/platform/egltest/ozone_platform_egltest.h"
#include <stdint.h>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/environment.h"
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/path_service.h"
#include "base/threading/thread_checker.h"
#include "library_loaders/libeglplatform_shim.h"
#include "third_party/khronos/EGL/egl.h"
#include "ui/events/devices/device_data_manager.h"
#include "ui/events/event.h"
#include "ui/events/ozone/device/device_manager.h"
#include "ui/events/ozone/evdev/event_factory_evdev.h"
#include "ui/events/ozone/events_ozone.h"
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
#include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h"
#include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/gfx/vsync_provider.h"
#include "ui/ozone/common/egl_util.h"
#include "ui/ozone/common/native_display_delegate_ozone.h"
#include "ui/ozone/common/stub_overlay_manager.h"
#include "ui/ozone/public/cursor_factory_ozone.h"
#include "ui/ozone/public/gpu_platform_support.h"
#include "ui/ozone/public/gpu_platform_support_host.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/ozone_switches.h"
#include "ui/ozone/public/surface_factory_ozone.h"
#include "ui/ozone/public/surface_ozone_egl.h"
#include "ui/ozone/public/system_input_injector.h"
#include "ui/platform_window/platform_window.h"
#include "ui/platform_window/platform_window_delegate.h"
namespace ui {
namespace {
const char kEglplatformShim[] = "EGLPLATFORM_SHIM";
const char kEglplatformShimDefault[] = "libeglplatform_shim.so.1";
const char kDefaultEglSoname[] = "libEGL.so.1";
const char kDefaultGlesSoname[] = "libGLESv2.so.2";
// Get the library soname to load.
std::string GetShimLibraryName() {
std::string library;
std::unique_ptr<base::Environment> env(base::Environment::Create());
if (env->GetVar(kEglplatformShim, &library))
return library;
return kEglplatformShimDefault;
}
// Touch events are reported in device coordinates. This scales the event to the
// window's coordinate space.
void ScaleTouchEvent(TouchEvent* event, const gfx::SizeF& size) {
for (const auto& device :
DeviceDataManager::GetInstance()->GetTouchscreenDevices()) {
if (device.id == event->source_device_id()) {
gfx::SizeF touchscreen_size = gfx::SizeF(device.size);
gfx::Transform transform;
transform.Scale(size.width() / touchscreen_size.width(),
size.height() / touchscreen_size.height());
event->UpdateForRootTransform(transform);
return;
}
}
}
class EgltestWindow : public PlatformWindow, public PlatformEventDispatcher {
public:
EgltestWindow(PlatformWindowDelegate* delegate,
LibeglplatformShimLoader* eglplatform_shim,
EventFactoryEvdev* event_factory,
const gfx::Rect& bounds);
~EgltestWindow() override;
// PlatformWindow:
gfx::Rect GetBounds() override;
void SetBounds(const gfx::Rect& bounds) override;
void SetTitle(const base::string16& title) override;
void Show() override;
void Hide() override;
void Close() override;
void SetCapture() override;
void ReleaseCapture() override;
void ToggleFullscreen() override;
void Maximize() override;
void Minimize() override;
void Restore() override;
void SetCursor(PlatformCursor cursor) override;
void MoveCursorTo(const gfx::Point& location) override;
void ConfineCursorToBounds(const gfx::Rect& bounds) override;
PlatformImeController* GetPlatformImeController() override;
// PlatformEventDispatcher:
bool CanDispatchEvent(const PlatformEvent& event) override;
uint32_t DispatchEvent(const PlatformEvent& event) override;
private:
PlatformWindowDelegate* delegate_;
LibeglplatformShimLoader* eglplatform_shim_;
EventFactoryEvdev* event_factory_;
gfx::Rect bounds_;
ShimNativeWindowId window_id_;
DISALLOW_COPY_AND_ASSIGN(EgltestWindow);
};
EgltestWindow::EgltestWindow(PlatformWindowDelegate* delegate,
LibeglplatformShimLoader* eglplatform_shim,
EventFactoryEvdev* event_factory,
const gfx::Rect& bounds)
: delegate_(delegate),
eglplatform_shim_(eglplatform_shim),
event_factory_(event_factory),
bounds_(bounds),
window_id_(SHIM_NO_WINDOW_ID) {
window_id_ = eglplatform_shim_->ShimCreateWindow();
delegate_->OnAcceleratedWidgetAvailable(window_id_, 1.f);
ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
}
EgltestWindow::~EgltestWindow() {
ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
if (window_id_ != SHIM_NO_WINDOW_ID)
eglplatform_shim_->ShimDestroyWindow(window_id_);
}
gfx::Rect EgltestWindow::GetBounds() {
return bounds_;
}
void EgltestWindow::SetBounds(const gfx::Rect& bounds) {
bounds_ = bounds;
delegate_->OnBoundsChanged(bounds);
}
void EgltestWindow::SetTitle(const base::string16& title) {
}
void EgltestWindow::Show() {
}
void EgltestWindow::Hide() {
}
void EgltestWindow::Close() {
}
void EgltestWindow::SetCapture() {
}
void EgltestWindow::ReleaseCapture() {
}
void EgltestWindow::ToggleFullscreen() {
}
void EgltestWindow::Maximize() {
}
void EgltestWindow::Minimize() {
}
void EgltestWindow::Restore() {
}
void EgltestWindow::SetCursor(PlatformCursor cursor) {
}
void EgltestWindow::MoveCursorTo(const gfx::Point& location) {
event_factory_->WarpCursorTo(window_id_, gfx::PointF(location));
}
void EgltestWindow::ConfineCursorToBounds(const gfx::Rect& bounds) {
}
PlatformImeController* EgltestWindow::GetPlatformImeController() {
return nullptr;
}
bool EgltestWindow::CanDispatchEvent(const ui::PlatformEvent& ne) {
return true;
}
uint32_t EgltestWindow::DispatchEvent(const ui::PlatformEvent& native_event) {
DCHECK(native_event);
Event* event = static_cast<Event*>(native_event);
if (event->IsTouchEvent()) {
ScaleTouchEvent(static_cast<TouchEvent*>(event),
gfx::SizeF(bounds_.size()));
}
DispatchEventFromNativeUiEvent(
native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent,
base::Unretained(delegate_)));
return ui::POST_DISPATCH_STOP_PROPAGATION;
}
// EGL surface wrapper for libeglplatform_shim.
//
// This just manages the native window lifetime using
// ShimGetNativeWindow & ShimReleaseNativeWindow.
class SurfaceOzoneEgltest : public SurfaceOzoneEGL {
public:
SurfaceOzoneEgltest(ShimNativeWindowId window_id,
LibeglplatformShimLoader* eglplatform_shim)
: eglplatform_shim_(eglplatform_shim) {
native_window_ = eglplatform_shim_->ShimGetNativeWindow(window_id);
}
~SurfaceOzoneEgltest() override {
bool ret = eglplatform_shim_->ShimReleaseNativeWindow(native_window_);
DCHECK(ret);
}
intptr_t GetNativeWindow() override { return native_window_; }
bool OnSwapBuffers() override { return true; }
void OnSwapBuffersAsync(const SwapCompletionCallback& callback) override {
callback.Run(gfx::SwapResult::SWAP_ACK);
}
bool ResizeNativeWindow(const gfx::Size& viewport_size) override {
return true;
}
std::unique_ptr<gfx::VSyncProvider> CreateVSyncProvider() override {
return nullptr;
}
void* /* EGLConfig */ GetEGLSurfaceConfig(
const EglConfigCallbacks& egl) override {
EGLint broken_props[] = {
EGL_RENDERABLE_TYPE,
EGL_OPENGL_ES2_BIT,
EGL_SURFACE_TYPE,
EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
EGL_NONE,
};
return ChooseEGLConfig(egl, broken_props);
}
private:
LibeglplatformShimLoader* eglplatform_shim_;
intptr_t native_window_;
};
// EGL surface factory for libeglplatform_shim.
//
// This finds the right EGL/GLES2 libraries for loading, and creates
// a single native window via ShimCreateWindow for drawing
// into.
class SurfaceFactoryEgltest : public ui::SurfaceFactoryOzone {
public:
SurfaceFactoryEgltest(LibeglplatformShimLoader* eglplatform_shim)
: eglplatform_shim_(eglplatform_shim) {}
~SurfaceFactoryEgltest() override {
DCHECK(thread_checker_.CalledOnValidThread());
}
// SurfaceFactoryOzone:
intptr_t GetNativeDisplay() override;
std::unique_ptr<SurfaceOzoneEGL> CreateEGLSurfaceForWidget(
gfx::AcceleratedWidget widget) override;
bool LoadEGLGLES2Bindings(
AddGLLibraryCallback add_gl_library,
SetGLGetProcAddressProcCallback set_gl_get_proc_address) override;
private:
LibeglplatformShimLoader* eglplatform_shim_;
base::ThreadChecker thread_checker_;
};
intptr_t SurfaceFactoryEgltest::GetNativeDisplay() {
DCHECK(thread_checker_.CalledOnValidThread());
return eglplatform_shim_->ShimGetNativeDisplay();
}
std::unique_ptr<SurfaceOzoneEGL>
SurfaceFactoryEgltest::CreateEGLSurfaceForWidget(
gfx::AcceleratedWidget widget) {
DCHECK(thread_checker_.CalledOnValidThread());
return base::WrapUnique<SurfaceOzoneEGL>(
new SurfaceOzoneEgltest(widget, eglplatform_shim_));
}
bool SurfaceFactoryEgltest::LoadEGLGLES2Bindings(
AddGLLibraryCallback add_gl_library,
SetGLGetProcAddressProcCallback set_gl_get_proc_address) {
DCHECK(thread_checker_.CalledOnValidThread());
const char* egl_soname = eglplatform_shim_->ShimQueryString(SHIM_EGL_LIBRARY);
const char* gles_soname =
eglplatform_shim_->ShimQueryString(SHIM_GLES_LIBRARY);
if (!egl_soname)
egl_soname = kDefaultEglSoname;
if (!gles_soname)
gles_soname = kDefaultGlesSoname;
return ::ui::LoadEGLGLES2Bindings(add_gl_library, set_gl_get_proc_address,
egl_soname, gles_soname);
}
// Test platform for EGL.
//
// This is a tiny EGL-based platform. Creation of the native window is
// handled by a separate library called eglplatform_shim.so.1 because
// this itself is platform specific and we want to test out multiple
// hardware platforms.
class OzonePlatformEgltest : public OzonePlatform {
public:
OzonePlatformEgltest() : shim_initialized_(false) {}
~OzonePlatformEgltest() override {
if (shim_initialized_)
eglplatform_shim_.ShimTerminate();
}
void LoadShim() {
std::string library = GetShimLibraryName();
if (eglplatform_shim_.Load(library))
return;
base::FilePath module_path;
if (!PathService::Get(base::DIR_MODULE, &module_path))
LOG(ERROR) << "failed to get DIR_MODULE from PathService";
base::FilePath library_path = module_path.Append(library);
if (eglplatform_shim_.Load(library_path.value()))
return;
LOG(FATAL) << "failed to load " << library;
}
void Initialize() {
LoadShim();
shim_initialized_ = eglplatform_shim_.ShimInitialize();
}
// OzonePlatform:
ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override {
return surface_factory_ozone_.get();
}
OverlayManagerOzone* GetOverlayManager() override {
return overlay_manager_.get();
}
CursorFactoryOzone* GetCursorFactoryOzone() override {
return cursor_factory_ozone_.get();
}
InputController* GetInputController() override {
return event_factory_ozone_->input_controller();
}
GpuPlatformSupport* GetGpuPlatformSupport() override {
return gpu_platform_support_.get();
}
GpuPlatformSupportHost* GetGpuPlatformSupportHost() override {
return gpu_platform_support_host_.get();
}
std::unique_ptr<SystemInputInjector> CreateSystemInputInjector() override {
return nullptr; // no input injection support.
}
std::unique_ptr<PlatformWindow> CreatePlatformWindow(
PlatformWindowDelegate* delegate,
const gfx::Rect& bounds) override {
return base::WrapUnique<PlatformWindow>(new EgltestWindow(
delegate, &eglplatform_shim_, event_factory_ozone_.get(), bounds));
}
std::unique_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
override {
return base::WrapUnique(new NativeDisplayDelegateOzone());
}
void InitializeUI() override {
device_manager_ = CreateDeviceManager();
overlay_manager_.reset(new StubOverlayManager());
KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(
base::WrapUnique(new StubKeyboardLayoutEngine()));
event_factory_ozone_.reset(new EventFactoryEvdev(
NULL, device_manager_.get(),
KeyboardLayoutEngineManager::GetKeyboardLayoutEngine()));
cursor_factory_ozone_.reset(new CursorFactoryOzone());
gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost());
}
void InitializeGPU() override {
surface_factory_ozone_.reset(new SurfaceFactoryEgltest(&eglplatform_shim_));
gpu_platform_support_.reset(CreateStubGpuPlatformSupport());
}
private:
LibeglplatformShimLoader eglplatform_shim_;
std::unique_ptr<DeviceManager> device_manager_;
std::unique_ptr<SurfaceFactoryEgltest> surface_factory_ozone_;
std::unique_ptr<EventFactoryEvdev> event_factory_ozone_;
std::unique_ptr<CursorFactoryOzone> cursor_factory_ozone_;
std::unique_ptr<GpuPlatformSupport> gpu_platform_support_;
std::unique_ptr<GpuPlatformSupportHost> gpu_platform_support_host_;
std::unique_ptr<OverlayManagerOzone> overlay_manager_;
bool shim_initialized_;
DISALLOW_COPY_AND_ASSIGN(OzonePlatformEgltest);
};
} // namespace
OzonePlatform* CreateOzonePlatformEgltest() {
OzonePlatformEgltest* platform = new OzonePlatformEgltest;
platform->Initialize();
return platform;
}
} // namespace ui

@ -1,17 +0,0 @@
// Copyright 2014 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_OZONE_PLATFORM_TEST_OZONE_PLATFORM_EGLTEST_H_
#define UI_OZONE_PLATFORM_TEST_OZONE_PLATFORM_EGLTEST_H_
namespace ui {
class OzonePlatform;
// Constructor hook for use in ozone_platform_list.cc
OzonePlatform* CreateOzonePlatformEgltest();
} // namespace ui
#endif // UI_OZONE_PLATFORM_TEST_OZONE_PLATFORM_EGLTEST_H_