diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-13 17:54:29 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-13 17:54:29 +0000 |
commit | 06863b392d7cf2165ac9cd5b1bb8a4df8d55dc97 (patch) | |
tree | bdc44af44c5270128e7cf7906eec6598f5756cee /mojo/examples/compositor_app | |
parent | 58712c69eaff92ebf41d44757c93ac453d195ed5 (diff) | |
download | chromium_src-06863b392d7cf2165ac9cd5b1bb8a4df8d55dc97.zip chromium_src-06863b392d7cf2165ac9cd5b1bb8a4df8d55dc97.tar.gz chromium_src-06863b392d7cf2165ac9cd5b1bb8a4df8d55dc97.tar.bz2 |
Change mojo demo apps to use Application.
BUG=None
R=darin@chromium.org, ben
Review URL: https://codereview.chromium.org/162213002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251076 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/examples/compositor_app')
-rw-r--r-- | mojo/examples/compositor_app/compositor_app.cc | 85 |
1 files changed, 31 insertions, 54 deletions
diff --git a/mojo/examples/compositor_app/compositor_app.cc b/mojo/examples/compositor_app/compositor_app.cc index dce027c..05ffa71 100644 --- a/mojo/examples/compositor_app/compositor_app.cc +++ b/mojo/examples/compositor_app/compositor_app.cc @@ -10,6 +10,7 @@ #include "mojo/public/bindings/allocation_scope.h" #include "mojo/public/bindings/remote_ptr.h" #include "mojo/public/gles2/gles2_cpp.h" +#include "mojo/public/shell/application.h" #include "mojo/public/system/core.h" #include "mojo/public/system/macros.h" #include "mojo/services/native_viewport/geometry_conversions.h" @@ -30,67 +31,46 @@ namespace mojo { namespace examples { -class SampleApp : public ShellClient { +class SampleApp : public Application, public NativeViewportClient { public: - explicit SampleApp(ScopedShellHandle shell_handle) - : shell_(shell_handle.Pass(), this) { - InterfacePipe<NativeViewport, AnyInterface> pipe; + explicit SampleApp(MojoHandle shell_handle) : Application(shell_handle) { + InterfacePipe<NativeViewport, AnyInterface> viewport_pipe; AllocationScope scope; - shell_->Connect("mojo:mojo_native_viewport_service", - pipe.handle_to_peer.Pass()); - - native_viewport_client_.reset( - new NativeViewportClientImpl(pipe.handle_to_self.Pass())); + shell()->Connect("mojo:mojo_native_viewport_service", + viewport_pipe.handle_to_peer.Pass()); + + viewport_.reset(viewport_pipe.handle_to_self.Pass(), this); + viewport_->Create(gfx::Rect(10, 10, 800, 600)); + viewport_->Show(); + ScopedMessagePipeHandle gles2_handle; + ScopedMessagePipeHandle gles2_client_handle; + CreateMessagePipe(&gles2_handle, &gles2_client_handle); + + viewport_->CreateGLES2Context(gles2_client_handle.Pass()); + host_.reset(new CompositorHost(gles2_handle.Pass())); } - virtual void AcceptConnection(const mojo::String& url, - ScopedMessagePipeHandle handle) MOJO_OVERRIDE { - NOTREACHED() << "SampleApp can't be connected to."; + virtual void OnCreated() MOJO_OVERRIDE { } - private: - class NativeViewportClientImpl : public NativeViewportClient { - public: - explicit NativeViewportClientImpl( - ScopedNativeViewportHandle viewport_handle) - : viewport_(viewport_handle.Pass(), this) { - AllocationScope allocation; - viewport_->Create(gfx::Rect(10, 10, 800, 600)); - viewport_->Show(); - ScopedMessagePipeHandle gles2_handle; - ScopedMessagePipeHandle gles2_client_handle; - CreateMessagePipe(&gles2_handle, &gles2_client_handle); - - viewport_->CreateGLES2Context(gles2_client_handle.Pass()); - host_.reset(new CompositorHost(gles2_handle.Pass())); - } - - virtual ~NativeViewportClientImpl() {} - - virtual void OnCreated() MOJO_OVERRIDE { - } - - virtual void OnDestroyed() MOJO_OVERRIDE { - base::MessageLoop::current()->Quit(); - } + virtual void OnDestroyed() MOJO_OVERRIDE { + base::MessageLoop::current()->Quit(); + } - virtual void OnBoundsChanged(const Rect& bounds) MOJO_OVERRIDE { - host_->SetSize(bounds.size()); - } + virtual void OnBoundsChanged(const Rect& bounds) MOJO_OVERRIDE { + host_->SetSize(bounds.size()); + } - virtual void OnEvent(const Event& event) MOJO_OVERRIDE { - if (!event.location().is_null()) { - viewport_->AckEvent(event); - } + virtual void OnEvent(const Event& event) MOJO_OVERRIDE { + if (!event.location().is_null()) { + viewport_->AckEvent(event); } + } - private: - RemotePtr<NativeViewport> viewport_; - scoped_ptr<CompositorHost> host_; - }; - RemotePtr<Shell> shell_; - scoped_ptr<NativeViewportClientImpl> native_viewport_client_; + private: + RemotePtr<NativeViewport> viewport_; + scoped_ptr<CompositorHost> host_; }; } // namespace examples @@ -101,10 +81,7 @@ extern "C" SAMPLE_APP_EXPORT MojoResult CDECL MojoMain( base::MessageLoop loop; mojo::GLES2Initializer gles2; - mojo::examples::SampleApp app( - mojo::MakeScopedHandle(mojo::ShellHandle(shell_handle)).Pass()); - + mojo::examples::SampleApp app(shell_handle); loop.Run(); - return MOJO_RESULT_OK; } |