Commit 9401b48e authored by spang@chromium.org's avatar spang@chromium.org

ozone: egltest: Convert to PlatformWindow

BUG=392280
TEST=built with chromeos==1 use_ozone==1 & ran egltest on X11
NOTRY=true

Review URL: https://codereview.chromium.org/387943002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283906 0039d316-1c4b-4281-b951-d872f2087c98
parent ba1a94a0
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#include "library_loaders/libeglplatform_shim.h" #include "library_loaders/libeglplatform_shim.h"
#include "ui/events/ozone/device/device_manager.h" #include "ui/events/ozone/device/device_manager.h"
#include "ui/events/ozone/evdev/event_factory_evdev.h" #include "ui/events/ozone/evdev/event_factory_evdev.h"
#include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/gfx/vsync_provider.h" #include "ui/gfx/vsync_provider.h"
#include "ui/ozone/common/window/platform_window_compat.h"
#include "ui/ozone/public/cursor_factory_ozone.h" #include "ui/ozone/public/cursor_factory_ozone.h"
#include "ui/ozone/public/gpu_platform_support.h" #include "ui/ozone/public/gpu_platform_support.h"
#include "ui/ozone/public/gpu_platform_support_host.h" #include "ui/ozone/public/gpu_platform_support_host.h"
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include "ui/ozone/public/ozone_switches.h" #include "ui/ozone/public/ozone_switches.h"
#include "ui/ozone/public/surface_factory_ozone.h" #include "ui/ozone/public/surface_factory_ozone.h"
#include "ui/ozone/public/surface_ozone_egl.h" #include "ui/ozone/public/surface_ozone_egl.h"
#include "ui/platform_window/platform_window.h"
#include "ui/platform_window/platform_window_delegate.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "ui/ozone/common/chromeos/native_display_delegate_ozone.h" #include "ui/ozone/common/chromeos/native_display_delegate_ozone.h"
...@@ -46,6 +48,103 @@ std::string GetShimLibraryName() { ...@@ -46,6 +48,103 @@ std::string GetShimLibraryName() {
return kEglplatformShimDefault; return kEglplatformShimDefault;
} }
class EgltestWindow : public PlatformWindow, public PlatformEventDispatcher {
public:
EgltestWindow(PlatformWindowDelegate* delegate,
LibeglplatformShimLoader* eglplatform_shim,
const gfx::Rect& bounds);
virtual ~EgltestWindow();
// PlatformWindow:
virtual gfx::Rect GetBounds() OVERRIDE;
virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
virtual void Show() OVERRIDE;
virtual void Hide() OVERRIDE;
virtual void Close() OVERRIDE;
virtual void SetCapture() OVERRIDE;
virtual void ReleaseCapture() OVERRIDE;
virtual void ToggleFullscreen() OVERRIDE;
virtual void Maximize() OVERRIDE;
virtual void Minimize() OVERRIDE;
virtual void Restore() OVERRIDE;
// PlatformEventDispatcher:
virtual bool CanDispatchEvent(const PlatformEvent& event) OVERRIDE;
virtual uint32_t DispatchEvent(const PlatformEvent& event) OVERRIDE;
private:
PlatformWindowDelegate* delegate_;
LibeglplatformShimLoader* eglplatform_shim_;
gfx::Rect bounds_;
ShimNativeWindowId window_id_;
DISALLOW_COPY_AND_ASSIGN(EgltestWindow);
};
EgltestWindow::EgltestWindow(PlatformWindowDelegate* delegate,
LibeglplatformShimLoader* eglplatform_shim,
const gfx::Rect& bounds)
: delegate_(delegate),
eglplatform_shim_(eglplatform_shim),
bounds_(bounds),
window_id_(SHIM_NO_WINDOW_ID) {
window_id_ = eglplatform_shim_->ShimCreateWindow();
delegate_->OnAcceleratedWidgetAvailable(window_id_);
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::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() {
}
bool EgltestWindow::CanDispatchEvent(const ui::PlatformEvent& ne) {
return true;
}
uint32_t EgltestWindow::DispatchEvent(const ui::PlatformEvent& ne) {
ui::Event* event = static_cast<ui::Event*>(ne);
delegate_->DispatchEvent(event);
return ui::POST_DISPATCH_STOP_PROPAGATION;
}
// EGL surface wrapper for libeglplatform_shim. // EGL surface wrapper for libeglplatform_shim.
// //
// This just manages the native window lifetime using // This just manages the native window lifetime using
...@@ -94,12 +193,8 @@ class SurfaceOzoneEgltest : public SurfaceOzoneEGL { ...@@ -94,12 +193,8 @@ class SurfaceOzoneEgltest : public SurfaceOzoneEGL {
class SurfaceFactoryEgltest : public ui::SurfaceFactoryOzone { class SurfaceFactoryEgltest : public ui::SurfaceFactoryOzone {
public: public:
SurfaceFactoryEgltest(LibeglplatformShimLoader* eglplatform_shim) SurfaceFactoryEgltest(LibeglplatformShimLoader* eglplatform_shim)
: eglplatform_shim_(eglplatform_shim), window_id_(SHIM_NO_WINDOW_ID) {} : eglplatform_shim_(eglplatform_shim) {}
virtual ~SurfaceFactoryEgltest() { DestroySingleWindow(); } virtual ~SurfaceFactoryEgltest() {}
// Create the window.
bool CreateSingleWindow();
void DestroySingleWindow();
// SurfaceFactoryOzone: // SurfaceFactoryOzone:
virtual HardwareState InitializeHardware() OVERRIDE; virtual HardwareState InitializeHardware() OVERRIDE;
...@@ -116,21 +211,8 @@ class SurfaceFactoryEgltest : public ui::SurfaceFactoryOzone { ...@@ -116,21 +211,8 @@ class SurfaceFactoryEgltest : public ui::SurfaceFactoryOzone {
private: private:
LibeglplatformShimLoader* eglplatform_shim_; LibeglplatformShimLoader* eglplatform_shim_;
// TODO(spang): Remove once we have a windowing API. This limits to 1 window.
ShimNativeWindowId window_id_;
}; };
bool SurfaceFactoryEgltest::CreateSingleWindow() {
window_id_ = eglplatform_shim_->ShimCreateWindow();
return (window_id_ != SHIM_NO_WINDOW_ID);
}
void SurfaceFactoryEgltest::DestroySingleWindow() {
if (window_id_ != SHIM_NO_WINDOW_ID)
CHECK(eglplatform_shim_->ShimDestroyWindow(window_id_));
}
SurfaceFactoryEgltest::HardwareState SurfaceFactoryEgltest::HardwareState
SurfaceFactoryEgltest::InitializeHardware() { SurfaceFactoryEgltest::InitializeHardware() {
return INITIALIZED; return INITIALIZED;
...@@ -144,9 +226,8 @@ intptr_t SurfaceFactoryEgltest::GetNativeDisplay() { ...@@ -144,9 +226,8 @@ intptr_t SurfaceFactoryEgltest::GetNativeDisplay() {
} }
gfx::AcceleratedWidget SurfaceFactoryEgltest::GetAcceleratedWidget() { gfx::AcceleratedWidget SurfaceFactoryEgltest::GetAcceleratedWidget() {
if (window_id_ == SHIM_NO_WINDOW_ID && !CreateSingleWindow()) NOTREACHED();
LOG(FATAL) << "failed to create window"; return gfx::kNullAcceleratedWidget;
return window_id_;
} }
scoped_ptr<SurfaceOzoneEGL> SurfaceFactoryEgltest::CreateEGLSurfaceForWidget( scoped_ptr<SurfaceOzoneEGL> SurfaceFactoryEgltest::CreateEGLSurfaceForWidget(
...@@ -265,7 +346,7 @@ class OzonePlatformEgltest : public OzonePlatform { ...@@ -265,7 +346,7 @@ class OzonePlatformEgltest : public OzonePlatform {
PlatformWindowDelegate* delegate, PlatformWindowDelegate* delegate,
const gfx::Rect& bounds) OVERRIDE { const gfx::Rect& bounds) OVERRIDE {
return make_scoped_ptr<PlatformWindow>( return make_scoped_ptr<PlatformWindow>(
new PlatformWindowCompat(delegate, bounds)); new EgltestWindow(delegate, &eglplatform_shim_, bounds));
} }
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
......
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