| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "cc/surfaces/surface_id_allocator.h" | 9 #include "cc/surfaces/surface_id_allocator.h" |
| 10 #include "mojo/application/application_runner_chromium.h" | 10 #include "mojo/application/application_runner_chromium.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 class SurfacesApp : public ApplicationDelegate, | 29 class SurfacesApp : public ApplicationDelegate, |
| 30 public SurfaceClient, | 30 public SurfaceClient, |
| 31 public NativeViewportClient { | 31 public NativeViewportClient { |
| 32 public: | 32 public: |
| 33 SurfacesApp() : weak_factory_(this) {} | 33 SurfacesApp() : weak_factory_(this) {} |
| 34 virtual ~SurfacesApp() {} | 34 virtual ~SurfacesApp() {} |
| 35 | 35 |
| 36 // ApplicationDelegate implementation | 36 // ApplicationDelegate implementation |
| 37 virtual bool ConfigureIncomingConnection( | 37 virtual bool ConfigureIncomingConnection( |
| 38 ApplicationConnection* connection) OVERRIDE { | 38 ApplicationConnection* connection) override { |
| 39 connection->ConnectToService("mojo:mojo_native_viewport_service", | 39 connection->ConnectToService("mojo:mojo_native_viewport_service", |
| 40 &viewport_); | 40 &viewport_); |
| 41 viewport_.set_client(this); | 41 viewport_.set_client(this); |
| 42 | 42 |
| 43 connection->ConnectToService("mojo:mojo_surfaces_service", | 43 connection->ConnectToService("mojo:mojo_surfaces_service", |
| 44 &surfaces_service_); | 44 &surfaces_service_); |
| 45 surfaces_service_->CreateSurfaceConnection(base::Bind( | 45 surfaces_service_->CreateSurfaceConnection(base::Bind( |
| 46 &SurfacesApp::SurfaceConnectionCreated, base::Unretained(this))); | 46 &SurfacesApp::SurfaceConnectionCreated, base::Unretained(this))); |
| 47 | 47 |
| 48 size_ = gfx::Size(800, 600); | 48 size_ = gfx::Size(800, 600); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 allocator_.reset(new cc::SurfaceIdAllocator(id_namespace)); | 95 allocator_.reset(new cc::SurfaceIdAllocator(id_namespace)); |
| 96 | 96 |
| 97 onscreen_id_ = allocator_->GenerateId(); | 97 onscreen_id_ = allocator_->GenerateId(); |
| 98 embedder_->SetSurfaceId(onscreen_id_); | 98 embedder_->SetSurfaceId(onscreen_id_); |
| 99 surface_->CreateSurface(SurfaceId::From(onscreen_id_), Size::From(size_)); | 99 surface_->CreateSurface(SurfaceId::From(onscreen_id_), Size::From(size_)); |
| 100 viewport_->SubmittedFrame(SurfaceId::From(onscreen_id_)); | 100 viewport_->SubmittedFrame(SurfaceId::From(onscreen_id_)); |
| 101 Draw(10); | 101 Draw(10); |
| 102 } | 102 } |
| 103 | 103 |
| 104 // SurfaceClient implementation. | 104 // SurfaceClient implementation. |
| 105 virtual void ReturnResources(Array<ReturnedResourcePtr> resources) OVERRIDE { | 105 virtual void ReturnResources(Array<ReturnedResourcePtr> resources) override { |
| 106 DCHECK(!resources.size()); | 106 DCHECK(!resources.size()); |
| 107 } | 107 } |
| 108 // NativeViewportClient implementation. | 108 // NativeViewportClient implementation. |
| 109 virtual void OnSizeChanged(mojo::SizePtr size) OVERRIDE {} | 109 virtual void OnSizeChanged(mojo::SizePtr size) override {} |
| 110 virtual void OnDestroyed() OVERRIDE {} | 110 virtual void OnDestroyed() override {} |
| 111 virtual void OnEvent(mojo::EventPtr event, | 111 virtual void OnEvent(mojo::EventPtr event, |
| 112 const mojo::Callback<void()>& callback) OVERRIDE { | 112 const mojo::Callback<void()>& callback) override { |
| 113 callback.Run(); | 113 callback.Run(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 private: | 116 private: |
| 117 void OnCreatedNativeViewport(uint64_t native_viewport_id) {} | 117 void OnCreatedNativeViewport(uint64_t native_viewport_id) {} |
| 118 | 118 |
| 119 SurfacesServicePtr surfaces_service_; | 119 SurfacesServicePtr surfaces_service_; |
| 120 SurfacePtr surface_; | 120 SurfacePtr surface_; |
| 121 cc::SurfaceId onscreen_id_; | 121 cc::SurfaceId onscreen_id_; |
| 122 scoped_ptr<cc::SurfaceIdAllocator> allocator_; | 122 scoped_ptr<cc::SurfaceIdAllocator> allocator_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 135 DISALLOW_COPY_AND_ASSIGN(SurfacesApp); | 135 DISALLOW_COPY_AND_ASSIGN(SurfacesApp); |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 } // namespace examples | 138 } // namespace examples |
| 139 } // namespace mojo | 139 } // namespace mojo |
| 140 | 140 |
| 141 MojoResult MojoMain(MojoHandle shell_handle) { | 141 MojoResult MojoMain(MojoHandle shell_handle) { |
| 142 mojo::ApplicationRunnerChromium runner(new mojo::examples::SurfacesApp); | 142 mojo::ApplicationRunnerChromium runner(new mojo::examples::SurfacesApp); |
| 143 return runner.Run(shell_handle); | 143 return runner.Run(shell_handle); |
| 144 } | 144 } |
| OLD | NEW |