| Index: mojo/services/native_viewport/native_viewport_service.cc
|
| diff --git a/mojo/services/native_viewport/native_viewport_service.cc b/mojo/services/native_viewport/native_viewport_service.cc
|
| index 5625aa13935485f8b2a6cbcb47a8dd95c4a53ae5..3c98329fa54fbe14da20c2c422b366ac81173907 100644
|
| --- a/mojo/services/native_viewport/native_viewport_service.cc
|
| +++ b/mojo/services/native_viewport/native_viewport_service.cc
|
| @@ -34,15 +34,20 @@ class NativeViewportImpl
|
| public NativeViewportDelegate {
|
| public:
|
| NativeViewportImpl()
|
| - : widget_(gfx::kNullAcceleratedWidget),
|
| + : client_(NULL),
|
| + widget_(gfx::kNullAcceleratedWidget),
|
| waiting_for_event_ack_(false) {}
|
| virtual ~NativeViewportImpl() {}
|
|
|
| + virtual void SetClient(NativeViewportClient* client) OVERRIDE {
|
| + client_ = client;
|
| + }
|
| +
|
| virtual void Create(const Rect& bounds) OVERRIDE {
|
| native_viewport_ =
|
| services::NativeViewport::Create(context(), this);
|
| native_viewport_->Init(bounds);
|
| - client()->OnCreated();
|
| + client_->OnCreated();
|
| OnBoundsChanged(bounds);
|
| }
|
|
|
| @@ -68,17 +73,13 @@ class NativeViewportImpl
|
|
|
| virtual void CreateGLES2Context(ScopedMessagePipeHandle client_handle)
|
| OVERRIDE {
|
| - if (command_buffer_ || command_buffer_handle_.is_valid()) {
|
| + if (command_buffer_.get() || command_buffer_handle_.is_valid()) {
|
| LOG(ERROR) << "Can't create multiple contexts on a NativeViewport";
|
| return;
|
| }
|
|
|
| - // TODO(darin):
|
| - // CreateGLES2Context should accept a ScopedCommandBufferClientHandle once
|
| - // it is possible to import interface definitions from another module. For
|
| - // now, we just kludge it.
|
| - command_buffer_handle_.reset(
|
| - InterfaceHandle<CommandBufferClient>(client_handle.release().value()));
|
| + // TODO(darin): CreateGLES2Context should accept a |CommandBufferPtr*|.
|
| + command_buffer_handle_ = client_handle.Pass();
|
|
|
| CreateCommandBufferIfNeeded();
|
| }
|
| @@ -96,8 +97,9 @@ class NativeViewportImpl
|
| gfx::Size size = native_viewport_->GetSize();
|
| if (size.IsEmpty())
|
| return;
|
| - command_buffer_.reset(new CommandBufferImpl(
|
| - command_buffer_handle_.Pass(), widget_, native_viewport_->GetSize()));
|
| + command_buffer_.Bind(
|
| + new CommandBufferImpl(widget_, native_viewport_->GetSize()));
|
| + command_buffer_.ConfigureStub(command_buffer_handle_.Pass());
|
| }
|
|
|
| virtual bool OnEvent(ui::Event* ui_event) OVERRIDE {
|
| @@ -147,9 +149,9 @@ class NativeViewportImpl
|
| event.set_key_data(key_data.Finish());
|
| }
|
|
|
| - client()->OnEvent(event.Finish(),
|
| - base::Bind(&NativeViewportImpl::AckEvent,
|
| - base::Unretained(this)));
|
| + client_->OnEvent(event.Finish(),
|
| + base::Bind(&NativeViewportImpl::AckEvent,
|
| + base::Unretained(this)));
|
| waiting_for_event_ack_ = true;
|
| return false;
|
| }
|
| @@ -163,20 +165,21 @@ class NativeViewportImpl
|
| virtual void OnBoundsChanged(const gfx::Rect& bounds) OVERRIDE {
|
| CreateCommandBufferIfNeeded();
|
| AllocationScope scope;
|
| - client()->OnBoundsChanged(bounds);
|
| + client_->OnBoundsChanged(bounds);
|
| }
|
|
|
| virtual void OnDestroyed() OVERRIDE {
|
| command_buffer_.reset();
|
| - client()->OnDestroyed();
|
| + client_->OnDestroyed();
|
| base::MessageLoop::current()->Quit();
|
| }
|
|
|
| private:
|
| + NativeViewportClient* client_;
|
| gfx::AcceleratedWidget widget_;
|
| scoped_ptr<services::NativeViewport> native_viewport_;
|
| - ScopedCommandBufferClientHandle command_buffer_handle_;
|
| - scoped_ptr<CommandBufferImpl> command_buffer_;
|
| + ScopedMessagePipeHandle command_buffer_handle_;
|
| + CommandBufferPtr command_buffer_;
|
| bool waiting_for_event_ack_;
|
| };
|
|
|
| @@ -186,7 +189,7 @@ class NativeViewportImpl
|
|
|
| MOJO_NATIVE_VIEWPORT_EXPORT mojo::Application*
|
| CreateNativeViewportService(mojo::shell::Context* context,
|
| - mojo::ScopedShellHandle shell_handle) {
|
| + mojo::ScopedMessagePipeHandle shell_handle) {
|
| mojo::Application* app = new mojo::Application(shell_handle.Pass());
|
| app->AddServiceConnector(
|
| new mojo::ServiceConnector<mojo::services::NativeViewportImpl,
|
|
|