| 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 #ifndef MOJO_EXAMPLES_SURFACES_APP_CHILD_IMPL_H_ | 5 #ifndef MOJO_EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_ |
| 6 #define MOJO_EXAMPLES_SURFACES_APP_CHILD_IMPL_H_ | 6 #define MOJO_EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/containers/hash_tables.h" |
| 8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/time/time.h" |
| 9 #include "cc/surfaces/surface_id.h" | 11 #include "cc/surfaces/surface_id.h" |
| 10 #include "cc/surfaces/surface_id_allocator.h" | 12 #include "cc/surfaces/surface_id_allocator.h" |
| 13 #include "mojo/examples/sample_app/spinning_cube.h" |
| 11 #include "mojo/examples/surfaces_app/child.mojom.h" | 14 #include "mojo/examples/surfaces_app/child.mojom.h" |
| 15 #include "mojo/public/c/gles2/gles2.h" |
| 12 #include "mojo/public/cpp/bindings/string.h" | 16 #include "mojo/public/cpp/bindings/string.h" |
| 13 #include "mojo/services/public/interfaces/surfaces/surface_id.mojom.h" | 17 #include "mojo/services/public/interfaces/surfaces/surface_id.mojom.h" |
| 14 #include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h" | 18 #include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h" |
| 15 #include "third_party/skia/include/core/SkColor.h" | 19 #include "third_party/skia/include/core/SkColor.h" |
| 16 #include "ui/gfx/size.h" | 20 #include "ui/gfx/size.h" |
| 17 | 21 |
| 18 namespace cc { | 22 namespace cc { |
| 19 class CompositorFrame; | 23 class CompositorFrame; |
| 20 } | 24 } |
| 21 | 25 |
| 22 namespace mojo { | 26 namespace mojo { |
| 23 | 27 |
| 24 class ApplicationConnection; | 28 class ApplicationConnection; |
| 25 | 29 |
| 26 namespace surfaces { | |
| 27 class Surface; | |
| 28 } | |
| 29 | |
| 30 namespace examples { | 30 namespace examples { |
| 31 | 31 |
| 32 // Simple example of a child app using surfaces. | 32 // Simple example of a child app using surfaces + GL. |
| 33 class ChildImpl : public InterfaceImpl<Child>, public SurfaceClient { | 33 class ChildGLImpl : public InterfaceImpl<Child>, public SurfaceClient { |
| 34 public: | 34 public: |
| 35 class Context { | 35 ChildGLImpl(ApplicationConnection* surfaces_service_connection, |
| 36 public: | 36 CommandBufferPtr command_buffer); |
| 37 virtual ApplicationConnection* ShellConnection( | 37 virtual ~ChildGLImpl(); |
| 38 const mojo::String& application_url) = 0; | |
| 39 }; | |
| 40 explicit ChildImpl(ApplicationConnection* surfaces_service_connection); | |
| 41 virtual ~ChildImpl(); | |
| 42 | 38 |
| 43 // SurfaceClient implementation | 39 // SurfaceClient implementation |
| 44 virtual void SetIdNamespace(uint32_t id_namespace) OVERRIDE; | 40 virtual void SetIdNamespace(uint32_t id_namespace) OVERRIDE; |
| 45 virtual void ReturnResources( | 41 virtual void ReturnResources(Array<ReturnedResourcePtr> resources) OVERRIDE; |
| 46 Array<ReturnedResourcePtr> resources) OVERRIDE; | |
| 47 | 42 |
| 48 private: | 43 private: |
| 49 // Child implementation. | 44 // Child implementation. |
| 50 virtual void ProduceFrame( | 45 virtual void ProduceFrame( |
| 51 ColorPtr color, | 46 ColorPtr color, |
| 52 SizePtr size, | 47 SizePtr size, |
| 53 const mojo::Callback<void(SurfaceIdPtr id)>& callback) OVERRIDE; | 48 const mojo::Callback<void(SurfaceIdPtr id)>& callback) OVERRIDE; |
| 54 | 49 |
| 50 void AllocateSurface(); |
| 55 void Draw(); | 51 void Draw(); |
| 56 | 52 |
| 57 SkColor color_; | 53 SkColor color_; |
| 58 gfx::Size size_; | 54 gfx::Size size_; |
| 59 scoped_ptr<cc::SurfaceIdAllocator> allocator_; | 55 scoped_ptr<cc::SurfaceIdAllocator> allocator_; |
| 60 SurfacePtr surface_; | 56 SurfacePtr surface_; |
| 57 MojoGLES2Context context_; |
| 61 cc::SurfaceId id_; | 58 cc::SurfaceId id_; |
| 62 mojo::Callback<void(SurfaceIdPtr id)> produce_callback_; | 59 ::examples::SpinningCube cube_; |
| 60 Callback<void(SurfaceIdPtr id)> produce_callback_; |
| 61 base::TimeTicks start_time_; |
| 62 uint32_t next_resource_id_; |
| 63 base::hash_map<uint32_t, GLuint> id_to_tex_map_; |
| 63 | 64 |
| 64 DISALLOW_COPY_AND_ASSIGN(ChildImpl); | 65 DISALLOW_COPY_AND_ASSIGN(ChildGLImpl); |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 } // namespace examples | 68 } // namespace examples |
| 68 } // namespace mojo | 69 } // namespace mojo |
| 69 | 70 |
| 70 #endif // MOJO_EXAMPLES_SURFACES_APP_CHILD_IMPL_H_ | 71 #endif // MOJO_EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_ |
| OLD | NEW |