| 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/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "cc/surfaces/surface_id_allocator.h" | 8 #include "cc/surfaces/surface_id_allocator.h" |
| 9 #include "mojo/examples/surfaces_app/child.mojom.h" | 9 #include "mojo/examples/surfaces_app/child.mojom.h" |
| 10 #include "mojo/examples/surfaces_app/embedder.h" | 10 #include "mojo/examples/surfaces_app/embedder.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 &viewport_); | 39 &viewport_); |
| 40 viewport_.set_client(this); | 40 viewport_.set_client(this); |
| 41 | 41 |
| 42 connection->ConnectToService("mojo:mojo_surfaces_service", | 42 connection->ConnectToService("mojo:mojo_surfaces_service", |
| 43 &surfaces_service_); | 43 &surfaces_service_); |
| 44 surfaces_service_->CreateSurfaceConnection(base::Bind( | 44 surfaces_service_->CreateSurfaceConnection(base::Bind( |
| 45 &SurfacesApp::SurfaceConnectionCreated, base::Unretained(this))); | 45 &SurfacesApp::SurfaceConnectionCreated, base::Unretained(this))); |
| 46 | 46 |
| 47 size_ = gfx::Size(800, 600); | 47 size_ = gfx::Size(800, 600); |
| 48 | 48 |
| 49 viewport_->Create(Rect::From(gfx::Rect(gfx::Point(10, 10), size_))); | 49 viewport_->Create(Size::From(size_)); |
| 50 viewport_->Show(); | 50 viewport_->Show(); |
| 51 | 51 |
| 52 child_size_ = gfx::Size(size_.width() / 3, size_.height() / 2); | 52 child_size_ = gfx::Size(size_.width() / 3, size_.height() / 2); |
| 53 connection->ConnectToService("mojo:mojo_surfaces_child_app", &child_one_); | 53 connection->ConnectToService("mojo:mojo_surfaces_child_app", &child_one_); |
| 54 connection->ConnectToService("mojo:mojo_surfaces_child_gl_app", | 54 connection->ConnectToService("mojo:mojo_surfaces_child_gl_app", |
| 55 &child_two_); | 55 &child_two_); |
| 56 child_one_->ProduceFrame(Color::From(SK_ColorBLUE), | 56 child_one_->ProduceFrame(Color::From(SK_ColorBLUE), |
| 57 Size::From(child_size_), | 57 Size::From(child_size_), |
| 58 base::Bind(&SurfacesApp::ChildOneProducedFrame, | 58 base::Bind(&SurfacesApp::ChildOneProducedFrame, |
| 59 base::Unretained(this))); | 59 base::Unretained(this))); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 viewport_->SubmittedFrame(SurfaceId::From(onscreen_id_)); | 97 viewport_->SubmittedFrame(SurfaceId::From(onscreen_id_)); |
| 98 Draw(10); | 98 Draw(10); |
| 99 } | 99 } |
| 100 | 100 |
| 101 // SurfaceClient implementation. | 101 // SurfaceClient implementation. |
| 102 virtual void ReturnResources(Array<ReturnedResourcePtr> resources) OVERRIDE { | 102 virtual void ReturnResources(Array<ReturnedResourcePtr> resources) OVERRIDE { |
| 103 DCHECK(!resources.size()); | 103 DCHECK(!resources.size()); |
| 104 } | 104 } |
| 105 // NativeViewportClient implementation. | 105 // NativeViewportClient implementation. |
| 106 virtual void OnCreated(uint64_t native_viewport_id) OVERRIDE {} | 106 virtual void OnCreated(uint64_t native_viewport_id) OVERRIDE {} |
| 107 virtual void OnBoundsChanged(mojo::RectPtr bounds) OVERRIDE {} | 107 virtual void OnBoundsChanged(mojo::SizePtr bounds) OVERRIDE {} |
| 108 virtual void OnDestroyed() OVERRIDE {} | 108 virtual void OnDestroyed() OVERRIDE {} |
| 109 virtual void OnEvent(mojo::EventPtr event, | 109 virtual void OnEvent(mojo::EventPtr event, |
| 110 const mojo::Callback<void()>& callback) OVERRIDE { | 110 const mojo::Callback<void()>& callback) OVERRIDE { |
| 111 callback.Run(); | 111 callback.Run(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 SurfacesServicePtr surfaces_service_; | 115 SurfacesServicePtr surfaces_service_; |
| 116 SurfacePtr surface_; | 116 SurfacePtr surface_; |
| 117 cc::SurfaceId onscreen_id_; | 117 cc::SurfaceId onscreen_id_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 129 DISALLOW_COPY_AND_ASSIGN(SurfacesApp); | 129 DISALLOW_COPY_AND_ASSIGN(SurfacesApp); |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 } // namespace examples | 132 } // namespace examples |
| 133 } // namespace mojo | 133 } // namespace mojo |
| 134 | 134 |
| 135 MojoResult MojoMain(MojoHandle shell_handle) { | 135 MojoResult MojoMain(MojoHandle shell_handle) { |
| 136 mojo::ApplicationRunnerChromium runner(new mojo::examples::SurfacesApp); | 136 mojo::ApplicationRunnerChromium runner(new mojo::examples::SurfacesApp); |
| 137 return runner.Run(shell_handle); | 137 return runner.Run(shell_handle); |
| 138 } | 138 } |
| OLD | NEW |