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

Side by Side Diff: examples/surfaces_app/child_impl.h

Issue 807733002: Split surface id and simplify connecting to surfaces service (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
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 EXAMPLES_SURFACES_APP_CHILD_IMPL_H_ 5 #ifndef EXAMPLES_SURFACES_APP_CHILD_IMPL_H_
6 #define EXAMPLES_SURFACES_APP_CHILD_IMPL_H_ 6 #define EXAMPLES_SURFACES_APP_CHILD_IMPL_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.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/memory/weak_ptr.h"
11 #include "cc/surfaces/surface_id.h" 11 #include "cc/surfaces/surface_id.h"
12 #include "cc/surfaces/surface_id_allocator.h" 12 #include "cc/surfaces/surface_id_allocator.h"
13 #include "examples/surfaces_app/child.mojom.h" 13 #include "examples/surfaces_app/child.mojom.h"
14 #include "mojo/public/cpp/bindings/string.h" 14 #include "mojo/public/cpp/bindings/string.h"
15 #include "mojo/services/surfaces/public/interfaces/surface_id.mojom.h" 15 #include "mojo/services/surfaces/public/interfaces/surface_id.mojom.h"
16 #include "mojo/services/surfaces/public/interfaces/surfaces.mojom.h" 16 #include "mojo/services/surfaces/public/interfaces/surfaces.mojom.h"
17 #include "mojo/services/surfaces/public/interfaces/surfaces_service.mojom.h" 17 #include "mojo/services/surfaces/public/interfaces/surfaces_service.mojom.h"
18 #include "third_party/skia/include/core/SkColor.h" 18 #include "third_party/skia/include/core/SkColor.h"
19 #include "ui/gfx/size.h" 19 #include "ui/gfx/size.h"
20 20
21 namespace cc { 21 namespace cc {
22 class CompositorFrame; 22 class CompositorFrame;
23 } 23 }
24 24
25 namespace mojo { 25 namespace mojo {
26 26
27 class ApplicationConnection; 27 class ApplicationConnection;
28 28
29 namespace surfaces {
30 class Surface;
31 }
32
33 namespace examples { 29 namespace examples {
34 30
35 // Simple example of a child app using surfaces. 31 // Simple example of a child app using surfaces.
36 class ChildImpl : public InterfaceImpl<Child>, public SurfaceClient { 32 class ChildImpl : public InterfaceImpl<Child>, public SurfaceClient {
37 public: 33 public:
38 class Context { 34 class Context {
39 public: 35 public:
40 virtual ApplicationConnection* ShellConnection( 36 virtual ApplicationConnection* ShellConnection(
41 const mojo::String& application_url) = 0; 37 const mojo::String& application_url) = 0;
42 }; 38 };
43 explicit ChildImpl(ApplicationConnection* surfaces_service_connection); 39 explicit ChildImpl(ApplicationConnection* surfaces_service_connection);
44 virtual ~ChildImpl(); 40 ~ChildImpl() override;
45
46 // SurfaceClient implementation
47 virtual void ReturnResources(
48 Array<ReturnedResourcePtr> resources) override;
49 41
50 private: 42 private:
43 // SurfaceClient implementation
44 void SetIdNamespace(uint32_t id_namespace) override;
45 void ReturnResources(Array<ReturnedResourcePtr> resources) override;
46
51 // Child implementation. 47 // Child implementation.
52 virtual void ProduceFrame( 48 void ProduceFrame(
53 ColorPtr color, 49 ColorPtr color,
54 SizePtr size, 50 SizePtr size,
55 const mojo::Callback<void(SurfaceIdPtr id)>& callback) override; 51 const mojo::Callback<void(SurfaceIdPtr id)>& callback) override;
56 52
57 void SurfaceConnectionCreated(SurfacePtr surface, uint32_t id_namespace);
58 void Draw();
59
60 SkColor color_;
61 gfx::Size size_;
62 scoped_ptr<cc::SurfaceIdAllocator> allocator_; 53 scoped_ptr<cc::SurfaceIdAllocator> allocator_;
63 SurfacesServicePtr surfaces_service_;
64 SurfacePtr surface_; 54 SurfacePtr surface_;
65 cc::SurfaceId id_; 55 cc::SurfaceId id_;
66 mojo::Callback<void(SurfaceIdPtr id)> produce_callback_;
67 base::WeakPtrFactory<ChildImpl> weak_factory_;
68 56
69 DISALLOW_COPY_AND_ASSIGN(ChildImpl); 57 DISALLOW_COPY_AND_ASSIGN(ChildImpl);
70 }; 58 };
71 59
72 } // namespace examples 60 } // namespace examples
73 } // namespace mojo 61 } // namespace mojo
74 62
75 #endif // EXAMPLES_SURFACES_APP_CHILD_IMPL_H_ 63 #endif // EXAMPLES_SURFACES_APP_CHILD_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698