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_GL_IMPL_H_ | 5 #ifndef MOJO_EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_ |
6 #define MOJO_EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_ | 6 #define MOJO_EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_ |
7 | 7 |
8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
| 9 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
12 #include "cc/surfaces/surface_id.h" | 13 #include "cc/surfaces/surface_id.h" |
13 #include "cc/surfaces/surface_id_allocator.h" | 14 #include "cc/surfaces/surface_id_allocator.h" |
14 #include "mojo/examples/sample_app/spinning_cube.h" | 15 #include "mojo/examples/sample_app/spinning_cube.h" |
15 #include "mojo/examples/surfaces_app/child.mojom.h" | 16 #include "mojo/examples/surfaces_app/child.mojom.h" |
16 #include "mojo/public/c/gles2/gles2.h" | 17 #include "mojo/public/c/gles2/gles2.h" |
17 #include "mojo/public/cpp/bindings/string.h" | 18 #include "mojo/public/cpp/bindings/string.h" |
18 #include "mojo/services/public/interfaces/surfaces/surface_id.mojom.h" | 19 #include "mojo/services/public/interfaces/surfaces/surface_id.mojom.h" |
(...skipping 13 matching lines...) Expand all Loading... |
32 namespace examples { | 33 namespace examples { |
33 | 34 |
34 // Simple example of a child app using surfaces + GL. | 35 // Simple example of a child app using surfaces + GL. |
35 class ChildGLImpl : public InterfaceImpl<Child>, public SurfaceClient { | 36 class ChildGLImpl : public InterfaceImpl<Child>, public SurfaceClient { |
36 public: | 37 public: |
37 ChildGLImpl(ApplicationConnection* surfaces_service_connection, | 38 ChildGLImpl(ApplicationConnection* surfaces_service_connection, |
38 CommandBufferPtr command_buffer); | 39 CommandBufferPtr command_buffer); |
39 virtual ~ChildGLImpl(); | 40 virtual ~ChildGLImpl(); |
40 | 41 |
41 // SurfaceClient implementation | 42 // SurfaceClient implementation |
42 virtual void ReturnResources(Array<ReturnedResourcePtr> resources) OVERRIDE; | 43 virtual void ReturnResources(Array<ReturnedResourcePtr> resources) override; |
43 | 44 |
44 private: | 45 private: |
45 // Child implementation. | 46 // Child implementation. |
46 virtual void ProduceFrame( | 47 virtual void ProduceFrame( |
47 ColorPtr color, | 48 ColorPtr color, |
48 SizePtr size, | 49 SizePtr size, |
49 const mojo::Callback<void(SurfaceIdPtr id)>& callback) OVERRIDE; | 50 const mojo::Callback<void(SurfaceIdPtr id)>& callback) override; |
50 | 51 |
51 void SurfaceConnectionCreated(SurfacePtr surface, uint32_t id_namespace); | 52 void SurfaceConnectionCreated(SurfacePtr surface, uint32_t id_namespace); |
52 void AllocateSurface(); | 53 void AllocateSurface(); |
53 void Draw(); | 54 void Draw(); |
54 | 55 |
55 SkColor color_; | 56 SkColor color_; |
56 gfx::Size size_; | 57 gfx::Size size_; |
57 scoped_ptr<cc::SurfaceIdAllocator> allocator_; | 58 scoped_ptr<cc::SurfaceIdAllocator> allocator_; |
58 SurfacesServicePtr surfaces_service_; | 59 SurfacesServicePtr surfaces_service_; |
59 SurfacePtr surface_; | 60 SurfacePtr surface_; |
60 MojoGLES2Context context_; | 61 MojoGLES2Context context_; |
61 cc::SurfaceId id_; | 62 cc::SurfaceId id_; |
62 ::examples::SpinningCube cube_; | 63 ::examples::SpinningCube cube_; |
63 Callback<void(SurfaceIdPtr id)> produce_callback_; | 64 Callback<void(SurfaceIdPtr id)> produce_callback_; |
64 base::TimeTicks start_time_; | 65 base::TimeTicks start_time_; |
65 uint32_t next_resource_id_; | 66 uint32_t next_resource_id_; |
66 base::hash_map<uint32_t, GLuint> id_to_tex_map_; | 67 base::hash_map<uint32_t, GLuint> id_to_tex_map_; |
67 base::WeakPtrFactory<ChildGLImpl> weak_factory_; | 68 base::WeakPtrFactory<ChildGLImpl> weak_factory_; |
68 | 69 |
69 DISALLOW_COPY_AND_ASSIGN(ChildGLImpl); | 70 DISALLOW_COPY_AND_ASSIGN(ChildGLImpl); |
70 }; | 71 }; |
71 | 72 |
72 } // namespace examples | 73 } // namespace examples |
73 } // namespace mojo | 74 } // namespace mojo |
74 | 75 |
75 #endif // MOJO_EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_ | 76 #endif // MOJO_EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_ |
OLD | NEW |