Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Unified Diff: ui/ozone/demo/egl_demo.cc

Issue 397103002: ozone: Port egl_demo on top of PlatformWindow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add check for widget availability Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/demo/egl_demo.cc
diff --git a/ui/ozone/demo/egl_demo.cc b/ui/ozone/demo/egl_demo.cc
index 00084fc2ca757b3918a72f2e990ba2d87ce7071e..b5f7d3ca7e269053ddd16cc3200a246efee11520 100644
--- a/ui/ozone/demo/egl_demo.cc
+++ b/ui/ozone/demo/egl_demo.cc
@@ -4,25 +4,70 @@
#include "base/at_exit.h"
#include "base/command_line.h"
+#include "base/message_loop/message_loop.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_surface.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/surface_factory_ozone.h"
+#include "ui/platform_window/platform_window.h"
+#include "ui/platform_window/platform_window_delegate.h"
+
+const int kTestWindowWidth = 800;
+const int kTestWindowHeight = 600;
+
+class DemoWindow : public ui::PlatformWindowDelegate {
+ public:
+ DemoWindow() : widget_(gfx::kNullAcceleratedWidget), have_widget_(false) {
+ platform_window_ = ui::OzonePlatform::GetInstance()->CreatePlatformWindow(
+ this, gfx::Rect(kTestWindowWidth, kTestWindowHeight));
+ }
+ virtual ~DemoWindow() {}
+
+ gfx::AcceleratedWidget GetAcceleratedWidget() {
+ // TODO(spang): We should start rendering asynchronously.
+ CHECK(have_widget_) << "widget not available synchronously";
dnicoara 2014/07/16 19:57:29 nit: You could just CHECK against kNullAccelerated
+ return widget_;
+ }
+
+ // PlatformWindowDelegate:
+ virtual void OnBoundsChanged(const gfx::Rect& new_bounds) OVERRIDE {}
+ virtual void OnDamageRect(const gfx::Rect& damaged_region) OVERRIDE {}
+ virtual void DispatchEvent(ui::Event* event) OVERRIDE {}
+ virtual void OnCloseRequest() OVERRIDE {}
+ virtual void OnClosed() OVERRIDE {}
+ virtual void OnWindowStateChanged(
+ ui::PlatformWindowState new_state) OVERRIDE {}
+ virtual void OnLostCapture() OVERRIDE {}
+ virtual void OnAcceleratedWidgetAvailable(
+ gfx::AcceleratedWidget widget) OVERRIDE {
+ have_widget_ = true;
+ widget_ = widget;
+ }
+
+ private:
+ scoped_ptr<ui::PlatformWindow> platform_window_;
+ gfx::AcceleratedWidget widget_;
+ bool have_widget_;
+
+ DISALLOW_COPY_AND_ASSIGN(DemoWindow);
+};
int main(int argc, char** argv) {
CommandLine::Init(argc, argv);
base::AtExitManager exit_manager;
+ base::MessageLoopForUI message_loop;
+
ui::OzonePlatform::InitializeForUI();
if (!gfx::GLSurface::InitializeOneOff())
LOG(FATAL) << "Failed to initialize GL";
- gfx::AcceleratedWidget widget =
- ui::SurfaceFactoryOzone::GetInstance()->GetAcceleratedWidget();
+ DemoWindow window;
+
scoped_refptr<gfx::GLSurface> surface =
- gfx::GLSurface::CreateViewGLSurface(widget);
+ gfx::GLSurface::CreateViewGLSurface(window.GetAcceleratedWidget());
if (!surface)
LOG(FATAL) << "Failed to create GL surface";
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698