Chromium Code Reviews| 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 EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_ | 5 #ifndef EXAMPLES_GANESH_APP_PAINTER_H_ |
| 6 #define EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_ | 6 #define EXAMPLES_GANESH_APP_PAINTER_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/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "cc/surfaces/surface_id.h" | 13 #include "cc/surfaces/surface_id.h" |
| 14 #include "cc/surfaces/surface_id_allocator.h" | 14 #include "cc/surfaces/surface_id_allocator.h" |
| 15 #include "examples/sample_app/spinning_cube.h" | 15 #include "examples/sample_app/spinning_cube.h" |
|
jamesr
2014/11/14 00:36:42
don't need
| |
| 16 #include "examples/surfaces_app/child.mojom.h" | 16 #include "examples/surfaces_app/child.mojom.h" |
| 17 #include "mojo/public/c/gles2/gles2.h" | 17 #include "mojo/public/c/gles2/gles2.h" |
| 18 #include "mojo/public/cpp/bindings/string.h" | 18 #include "mojo/public/cpp/bindings/string.h" |
|
jamesr
2014/11/14 00:36:42
don't need
| |
| 19 #include "mojo/services/public/interfaces/geometry/geometry.mojom.h" | |
| 20 #include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom. h" | |
| 19 #include "mojo/services/public/interfaces/surfaces/surface_id.mojom.h" | 21 #include "mojo/services/public/interfaces/surfaces/surface_id.mojom.h" |
| 20 #include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h" | 22 #include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h" |
| 21 #include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h" | 23 #include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h" |
| 24 #include "skia/ext/refptr.h" | |
| 22 #include "third_party/skia/include/core/SkColor.h" | 25 #include "third_party/skia/include/core/SkColor.h" |
|
jamesr
2014/11/14 00:36:42
can move to .cc
| |
| 26 #include "third_party/skia/include/core/SkSurface.h" | |
|
jamesr
2014/11/14 00:36:42
can move to .cc
| |
| 27 #include "third_party/skia/include/gpu/GrContext.h" | |
| 23 #include "ui/gfx/size.h" | 28 #include "ui/gfx/size.h" |
| 24 | 29 |
| 25 namespace cc { | 30 namespace cc { |
| 26 class CompositorFrame; | 31 class CompositorFrame; |
|
jamesr
2014/11/14 00:36:42
not used
| |
| 27 } | 32 } |
| 28 | 33 |
| 29 namespace mojo { | 34 namespace mojo { |
| 30 | 35 |
| 31 class ApplicationConnection; | 36 class ApplicationConnection; |
| 32 | 37 |
| 33 namespace examples { | 38 namespace examples { |
| 34 | 39 |
| 35 // Simple example of a child app using surfaces + GL. | 40 class Painter : public InterfaceImpl<Child>, public SurfaceClient { |
| 36 class ChildGLImpl : public InterfaceImpl<Child>, public SurfaceClient { | |
| 37 public: | 41 public: |
| 38 ChildGLImpl(ApplicationConnection* surfaces_service_connection, | 42 Painter(ApplicationConnection* surfaces_service_connection, |
| 39 CommandBufferPtr command_buffer); | 43 CommandBufferPtr command_buffer); |
| 40 virtual ~ChildGLImpl(); | 44 ~Painter(); |
| 41 | 45 |
| 42 // SurfaceClient implementation | 46 // SurfaceClient implementation |
| 43 virtual void ReturnResources(Array<ReturnedResourcePtr> resources) override; | 47 virtual void ReturnResources(Array<ReturnedResourcePtr> resources) override; |
| 44 | 48 |
| 45 private: | 49 private: |
| 46 // Child implementation. | 50 // Child implementation. |
| 47 virtual void ProduceFrame( | 51 virtual void ProduceFrame( |
| 48 ColorPtr color, | 52 ColorPtr color, |
| 49 SizePtr size, | 53 SizePtr size, |
| 50 const mojo::Callback<void(SurfaceIdPtr id)>& callback) override; | 54 const mojo::Callback<void(SurfaceIdPtr id)>& callback) override; |
| 51 | 55 |
| 52 void SurfaceConnectionCreated(SurfacePtr surface, uint32_t id_namespace); | 56 void SurfaceConnectionCreated(SurfacePtr surface, uint32_t id_namespace); |
| 53 void AllocateSurface(); | 57 void AllocateSurface(); |
| 54 void Draw(); | 58 void Draw(); |
| 55 | 59 |
| 56 SkColor color_; | 60 skia::RefPtr<GrContext> gr_context_; |
| 61 | |
| 57 gfx::Size size_; | 62 gfx::Size size_; |
| 58 scoped_ptr<cc::SurfaceIdAllocator> allocator_; | 63 scoped_ptr<cc::SurfaceIdAllocator> allocator_; |
| 59 SurfacesServicePtr surfaces_service_; | 64 SurfacesServicePtr surfaces_service_; |
| 60 SurfacePtr surface_; | 65 SurfacePtr surface_; |
| 61 MojoGLES2Context context_; | 66 MojoGLES2Context context_; |
| 62 cc::SurfaceId id_; | 67 cc::SurfaceId id_; |
| 63 ::examples::SpinningCube cube_; | 68 ::examples::SpinningCube cube_; |
| 64 Callback<void(SurfaceIdPtr id)> produce_callback_; | 69 Callback<void(SurfaceIdPtr id)> produce_callback_; |
| 65 base::TimeTicks start_time_; | 70 base::TimeTicks start_time_; |
| 66 uint32_t next_resource_id_; | 71 uint32_t next_resource_id_; |
| 67 base::hash_map<uint32_t, GLuint> id_to_tex_map_; | 72 base::hash_map<uint32_t, GLuint> id_to_tex_map_; |
| 68 base::WeakPtrFactory<ChildGLImpl> weak_factory_; | |
| 69 | 73 |
| 70 DISALLOW_COPY_AND_ASSIGN(ChildGLImpl); | 74 base::WeakPtrFactory<Painter> weak_factory_; |
| 75 | |
| 76 MOJO_DISALLOW_COPY_AND_ASSIGN(Painter); | |
| 71 }; | 77 }; |
| 72 | 78 |
| 73 } // namespace examples | 79 } // namespace examples |
| 74 } // namespace mojo | 80 } // namespace mojo |
| 75 | 81 |
| 76 #endif // EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_ | 82 #endif // EXAMPLES_GANESH_APP_PAINTER_H_ |
| OLD | NEW |