Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(700)

Side by Side Diff: mojo/examples/surfaces_app/child_gl_impl.h

Issue 504443002: Update mojo surfaces bindings and mojo/cc/ glue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
10 #include "base/time/time.h" 11 #include "base/time/time.h"
11 #include "cc/surfaces/surface_id.h" 12 #include "cc/surfaces/surface_id.h"
12 #include "cc/surfaces/surface_id_allocator.h" 13 #include "cc/surfaces/surface_id_allocator.h"
13 #include "mojo/examples/sample_app/spinning_cube.h" 14 #include "mojo/examples/sample_app/spinning_cube.h"
14 #include "mojo/examples/surfaces_app/child.mojom.h" 15 #include "mojo/examples/surfaces_app/child.mojom.h"
15 #include "mojo/public/c/gles2/gles2.h" 16 #include "mojo/public/c/gles2/gles2.h"
16 #include "mojo/public/cpp/bindings/string.h" 17 #include "mojo/public/cpp/bindings/string.h"
17 #include "mojo/services/public/interfaces/surfaces/surface_id.mojom.h" 18 #include "mojo/services/public/interfaces/surfaces/surface_id.mojom.h"
18 #include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h" 19 #include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h"
20 #include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h"
19 #include "third_party/skia/include/core/SkColor.h" 21 #include "third_party/skia/include/core/SkColor.h"
20 #include "ui/gfx/size.h" 22 #include "ui/gfx/size.h"
21 23
22 namespace cc { 24 namespace cc {
23 class CompositorFrame; 25 class CompositorFrame;
24 } 26 }
25 27
26 namespace mojo { 28 namespace mojo {
27 29
28 class ApplicationConnection; 30 class ApplicationConnection;
29 31
30 namespace examples { 32 namespace examples {
31 33
32 // Simple example of a child app using surfaces + GL. 34 // Simple example of a child app using surfaces + GL.
33 class ChildGLImpl : public InterfaceImpl<Child>, public SurfaceClient { 35 class ChildGLImpl : public InterfaceImpl<Child>, public SurfaceClient {
34 public: 36 public:
35 ChildGLImpl(ApplicationConnection* surfaces_service_connection, 37 ChildGLImpl(ApplicationConnection* surfaces_service_connection,
36 CommandBufferPtr command_buffer); 38 CommandBufferPtr command_buffer);
37 virtual ~ChildGLImpl(); 39 virtual ~ChildGLImpl();
38 40
39 // SurfaceClient implementation 41 // SurfaceClient implementation
40 virtual void SetIdNamespace(uint32_t id_namespace) OVERRIDE;
41 virtual void ReturnResources(Array<ReturnedResourcePtr> resources) OVERRIDE; 42 virtual void ReturnResources(Array<ReturnedResourcePtr> resources) OVERRIDE;
42 43
43 private: 44 private:
44 // Child implementation. 45 // Child implementation.
45 virtual void ProduceFrame( 46 virtual void ProduceFrame(
46 ColorPtr color, 47 ColorPtr color,
47 SizePtr size, 48 SizePtr size,
48 const mojo::Callback<void(SurfaceIdPtr id)>& callback) OVERRIDE; 49 const mojo::Callback<void(SurfaceIdPtr id)>& callback) OVERRIDE;
49 50
51 void SurfaceConnectionCreated(SurfacePtr surface, uint32_t id_namespace);
50 void AllocateSurface(); 52 void AllocateSurface();
51 void Draw(); 53 void Draw();
52 54
53 SkColor color_; 55 SkColor color_;
54 gfx::Size size_; 56 gfx::Size size_;
55 scoped_ptr<cc::SurfaceIdAllocator> allocator_; 57 scoped_ptr<cc::SurfaceIdAllocator> allocator_;
58 SurfacesServicePtr surfaces_service_;
56 SurfacePtr surface_; 59 SurfacePtr surface_;
57 MojoGLES2Context context_; 60 MojoGLES2Context context_;
58 cc::SurfaceId id_; 61 cc::SurfaceId id_;
59 ::examples::SpinningCube cube_; 62 ::examples::SpinningCube cube_;
60 Callback<void(SurfaceIdPtr id)> produce_callback_; 63 Callback<void(SurfaceIdPtr id)> produce_callback_;
61 base::TimeTicks start_time_; 64 base::TimeTicks start_time_;
62 uint32_t next_resource_id_; 65 uint32_t next_resource_id_;
63 base::hash_map<uint32_t, GLuint> id_to_tex_map_; 66 base::hash_map<uint32_t, GLuint> id_to_tex_map_;
67 base::WeakPtrFactory<ChildGLImpl> weak_factory_;
64 68
65 DISALLOW_COPY_AND_ASSIGN(ChildGLImpl); 69 DISALLOW_COPY_AND_ASSIGN(ChildGLImpl);
66 }; 70 };
67 71
68 } // namespace examples 72 } // namespace examples
69 } // namespace mojo 73 } // namespace mojo
70 74
71 #endif // MOJO_EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_ 75 #endif // MOJO_EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698