Commit b41afb53 authored by dnicoara@chromium.org's avatar dnicoara@chromium.org

Adding functionality to paint and signal buffer swap for ozone surface factory.

OZONE event factory should be a bit more verbose on error.

BUG=

Review URL: https://chromiumcodereview.appspot.com/23438002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220632 0039d316-1c4b-4281-b951-d872f2087c98
parent a0e73db0
...@@ -96,7 +96,7 @@ typedef void* EGLNativeDisplayType; ...@@ -96,7 +96,7 @@ typedef void* EGLNativeDisplayType;
#elif defined(USE_OZONE) #elif defined(USE_OZONE)
typedef int EGLNativeDisplayType; typedef intptr_t EGLNativeDisplayType;
typedef intptr_t EGLNativeWindowType; typedef intptr_t EGLNativeWindowType;
typedef intptr_t EGLNativePixmapType; typedef intptr_t EGLNativePixmapType;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ui/base/ozone/event_factory_ozone.h" #include "ui/base/ozone/event_factory_ozone.h"
#include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <linux/input.h> #include <linux/input.h>
#include <poll.h> #include <poll.h>
...@@ -45,8 +46,10 @@ void EventFactoryOzone::CreateStartupEventConverters() { ...@@ -45,8 +46,10 @@ void EventFactoryOzone::CreateStartupEventConverters() {
for (int id = 0; true; id++) { for (int id = 0; true; id++) {
std::string path = base::StringPrintf("/dev/input/event%d", id); std::string path = base::StringPrintf("/dev/input/event%d", id);
int fd = open(path.c_str(), O_RDONLY | O_NONBLOCK); int fd = open(path.c_str(), O_RDONLY | O_NONBLOCK);
if (fd < 0) if (fd < 0) {
DLOG(ERROR) << "Cannot open '" << path << "': " << strerror(errno);
break; break;
}
size_t evtype = 0; size_t evtype = 0;
COMPILE_ASSERT(sizeof(evtype) * 8 >= EV_MAX, evtype_wide_enough); COMPILE_ASSERT(sizeof(evtype) * 8 >= EV_MAX, evtype_wide_enough);
if (ioctl(fd, EVIOCGBIT(0, sizeof(evtype)), &evtype) == -1) { if (ioctl(fd, EVIOCGBIT(0, sizeof(evtype)), &evtype) == -1) {
......
...@@ -16,7 +16,7 @@ class SurfaceFactoryOzoneStub : public SurfaceFactoryOzone { ...@@ -16,7 +16,7 @@ class SurfaceFactoryOzoneStub : public SurfaceFactoryOzone {
SurfaceFactoryOzoneStub() {} SurfaceFactoryOzoneStub() {}
virtual ~SurfaceFactoryOzoneStub() {} virtual ~SurfaceFactoryOzoneStub() {}
virtual void InitializeHardware() OVERRIDE {} virtual HardwareState InitializeHardware() OVERRIDE { return INITIALIZED; }
virtual void ShutdownHardware() OVERRIDE {} virtual void ShutdownHardware() OVERRIDE {}
virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE { return 0; } virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE { return 0; }
virtual gfx::AcceleratedWidget RealizeAcceleratedWidget( virtual gfx::AcceleratedWidget RealizeAcceleratedWidget(
...@@ -61,6 +61,14 @@ gfx::Screen* SurfaceFactoryOzone::CreateDesktopScreen() { ...@@ -61,6 +61,14 @@ gfx::Screen* SurfaceFactoryOzone::CreateDesktopScreen() {
return NULL; return NULL;
} }
intptr_t SurfaceFactoryOzone::GetNativeDisplay() {
return 0;
}
bool SurfaceFactoryOzone::SchedulePageFlip(gfx::AcceleratedWidget) {
return true;
}
// static // static
SurfaceFactoryOzone* SurfaceFactoryOzone::CreateTestHelper() { SurfaceFactoryOzone* SurfaceFactoryOzone::CreateTestHelper() {
return new SurfaceFactoryOzoneStub; return new SurfaceFactoryOzoneStub;
......
...@@ -18,6 +18,12 @@ namespace ui { ...@@ -18,6 +18,12 @@ namespace ui {
class UI_EXPORT SurfaceFactoryOzone { class UI_EXPORT SurfaceFactoryOzone {
public: public:
// Describes the state of the hardware after initialization.
enum HardwareState {
INITIALIZED,
FAILED,
};
SurfaceFactoryOzone(); SurfaceFactoryOzone();
virtual ~SurfaceFactoryOzone(); virtual ~SurfaceFactoryOzone();
...@@ -35,15 +41,18 @@ class UI_EXPORT SurfaceFactoryOzone { ...@@ -35,15 +41,18 @@ class UI_EXPORT SurfaceFactoryOzone {
// This method implements gfx::Screen, particularly useful in Desktop Aura. // This method implements gfx::Screen, particularly useful in Desktop Aura.
virtual gfx::Screen* CreateDesktopScreen(); virtual gfx::Screen* CreateDesktopScreen();
// TODO(rjkroege): Add a status code if necessary.
// Configures the display hardware. Must be called from within the GPU // Configures the display hardware. Must be called from within the GPU
// process before the sandbox has been activated. // process before the sandbox has been activated.
virtual void InitializeHardware() = 0; virtual HardwareState InitializeHardware() = 0;
// Cleans up display hardware state. Call this from within the GPU process. // Cleans up display hardware state. Call this from within the GPU process.
// This method must be safe to run inside of the sandbox. // This method must be safe to run inside of the sandbox.
virtual void ShutdownHardware() = 0; virtual void ShutdownHardware() = 0;
// Returns the native EGL display. This is generally needed in creating
// EGL windows.
virtual intptr_t GetNativeDisplay();
// Obtains an AcceleratedWidget backed by a native Linux framebuffer. // Obtains an AcceleratedWidget backed by a native Linux framebuffer.
// The returned AcceleratedWidget is an opaque token that must realized // The returned AcceleratedWidget is an opaque token that must realized
// before it can be used to create a GL surface. // before it can be used to create a GL surface.
...@@ -65,6 +74,10 @@ class UI_EXPORT SurfaceFactoryOzone { ...@@ -65,6 +74,10 @@ class UI_EXPORT SurfaceFactoryOzone {
gfx::AcceleratedWidget w, gfx::AcceleratedWidget w,
const gfx::Rect& bounds) = 0; const gfx::Rect& bounds) = 0;
// Called after the appropriate GL swap buffers command. Used if extra work
// is needed to perform the actual buffer swap.
virtual bool SchedulePageFlip(gfx::AcceleratedWidget w);
// Returns a gfx::VsyncProvider for the provided AcceleratedWidget. Note // Returns a gfx::VsyncProvider for the provided AcceleratedWidget. Note
// that this may be called after we have entered the sandbox so if there are // that this may be called after we have entered the sandbox so if there are
// operations (e.g. opening a file descriptor providing vsync events) that // operations (e.g. opening a file descriptor providing vsync events) that
...@@ -81,5 +94,4 @@ class UI_EXPORT SurfaceFactoryOzone { ...@@ -81,5 +94,4 @@ class UI_EXPORT SurfaceFactoryOzone {
} // namespace ui } // namespace ui
#endif // UI_BASE_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_ #endif // UI_BASE_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_
...@@ -100,10 +100,6 @@ bool GLSurfaceEGL::InitializeOneOff() { ...@@ -100,10 +100,6 @@ bool GLSurfaceEGL::InitializeOneOff() {
if (initialized) if (initialized)
return true; return true;
#if defined (USE_OZONE)
ui::SurfaceFactoryOzone::GetInstance()->InitializeHardware();
#endif
#if defined(USE_X11) #if defined(USE_X11)
g_native_display = base::MessagePumpForUI::GetDefaultXDisplay(); g_native_display = base::MessagePumpForUI::GetDefaultXDisplay();
#elif defined(OS_WIN) #elif defined(OS_WIN)
...@@ -111,6 +107,16 @@ bool GLSurfaceEGL::InitializeOneOff() { ...@@ -111,6 +107,16 @@ bool GLSurfaceEGL::InitializeOneOff() {
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableD3D11)) { if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableD3D11)) {
g_native_display = EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE; g_native_display = EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE;
} }
#elif defined(USE_OZONE)
ui::SurfaceFactoryOzone* surface_factory =
ui::SurfaceFactoryOzone::GetInstance();
if (surface_factory->InitializeHardware() !=
ui::SurfaceFactoryOzone::INITIALIZED) {
LOG(ERROR) << "OZONE failed to initialize hardware";
return false;
}
g_native_display = reinterpret_cast<EGLNativeDisplayType>(
surface_factory->GetNativeDisplay());
#else #else
g_native_display = EGL_DEFAULT_DISPLAY; g_native_display = EGL_DEFAULT_DISPLAY;
#endif #endif
......
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