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

Side by Side Diff: components/mus/public/cpp/window_surface.h

Issue 1484533002: mus: Introduce AttachSurface to allow creating Surface prior to OnEmbed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Sadrul's comments Created 5 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
« no previous file with comments | « components/mus/public/cpp/window.h ('k') | components/mus/public/interfaces/window_tree.mojom » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 COMPONENTS_MUS_PUBLIC_CPP_WINDOW_SURFACE_H_ 5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_WINDOW_SURFACE_H_
6 #define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_SURFACE_H_ 6 #define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_SURFACE_H_
7 7
8 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
9 #include "base/observer_list.h" 10 #include "base/observer_list.h"
11 #include "base/threading/thread_checker.h"
10 #include "components/mus/public/interfaces/compositor_frame.mojom.h" 12 #include "components/mus/public/interfaces/compositor_frame.mojom.h"
11 #include "mojo/public/cpp/bindings/binding.h" 13 #include "mojo/public/cpp/bindings/binding.h"
12 #include "mojo/public/cpp/bindings/interface_ptr_info.h" 14 #include "mojo/public/cpp/bindings/interface_ptr_info.h"
13 15
14 namespace mus { 16 namespace mus {
15 17
18 class WindowSurfaceBinding;
16 class WindowSurfaceClient; 19 class WindowSurfaceClient;
17 class Window; 20 class Window;
18 21
19 // A WindowSurface is wrapper to simplify submitting CompositorFrames to Views, 22 // A WindowSurface is wrapper to simplify submitting CompositorFrames to
20 // and receiving ReturnedResources. 23 // Windows, and receiving ReturnedResources.
21 class WindowSurface : public mojom::SurfaceClient { 24 class WindowSurface : public mojom::SurfaceClient {
22 public: 25 public:
26 // static
27 static scoped_ptr<WindowSurface> Create(
28 scoped_ptr<WindowSurfaceBinding>* surface_binding);
29
23 ~WindowSurface() override; 30 ~WindowSurface() override;
24 31
25 // Called to indicate that the current thread has assumed control of this 32 // Called to indicate that the current thread has assumed control of this
26 // object. 33 // object.
27 void BindToThread(); 34 void BindToThread();
28 35
29 void SubmitCompositorFrame(mojom::CompositorFramePtr frame, 36 void SubmitCompositorFrame(mojom::CompositorFramePtr frame,
30 const mojo::Closure& callback); 37 const mojo::Closure& callback);
31 38
32 void set_client(WindowSurfaceClient* client) { client_ = client; } 39 void set_client(WindowSurfaceClient* client) { client_ = client; }
33 40
34 private: 41 private:
35 friend class Window; 42 friend class Window;
36 43
37 WindowSurface(mojo::InterfacePtrInfo<mojom::Surface> surface_info, 44 WindowSurface(mojo::InterfacePtrInfo<mojom::Surface> surface_info,
38 mojo::InterfaceRequest<mojom::SurfaceClient> client_request); 45 mojo::InterfaceRequest<mojom::SurfaceClient> client_request);
39 46
40 // SurfaceClient implementation: 47 // SurfaceClient implementation:
41 void ReturnResources( 48 void ReturnResources(
42 mojo::Array<mojom::ReturnedResourcePtr> resources) override; 49 mojo::Array<mojom::ReturnedResourcePtr> resources) override;
43 50
44 WindowSurfaceClient* client_; 51 WindowSurfaceClient* client_;
45 mojo::InterfacePtrInfo<mojom::Surface> surface_info_; 52 mojo::InterfacePtrInfo<mojom::Surface> surface_info_;
46 mojo::InterfaceRequest<mojom::SurfaceClient> client_request_; 53 mojo::InterfaceRequest<mojom::SurfaceClient> client_request_;
47 mojom::SurfacePtr surface_; 54 mojom::SurfacePtr surface_;
48 scoped_ptr<mojo::Binding<mojom::SurfaceClient>> client_binding_; 55 scoped_ptr<mojo::Binding<mojom::SurfaceClient>> client_binding_;
49 bool bound_to_thread_; 56 scoped_ptr<base::ThreadChecker> thread_checker_;
57
58 DISALLOW_COPY_AND_ASSIGN(WindowSurface);
59 };
60
61 // A WindowSurfaceBinding is a bundle of mojo interfaces that are to be used by
62 // or implemented by the Mus window server when passed into
63 // Window::AttachSurface. WindowSurfaceBinding has no standalone functionality.
64 class WindowSurfaceBinding {
65 public:
66 ~WindowSurfaceBinding();
67
68 private:
69 friend class WindowSurface;
70 friend class Window;
71
72 WindowSurfaceBinding(mojo::InterfaceRequest<mojom::Surface> surface_request,
73 mojom::SurfaceClientPtr surface_client);
74
75 mojo::InterfaceRequest<mojom::Surface> surface_request_;
76 mojom::SurfaceClientPtr surface_client_;
77
78 DISALLOW_COPY_AND_ASSIGN(WindowSurfaceBinding);
50 }; 79 };
51 80
52 } // namespace mus 81 } // namespace mus
53 82
54 #endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_SURFACE_H_ 83 #endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_SURFACE_H_
OLDNEW
« no previous file with comments | « components/mus/public/cpp/window.h ('k') | components/mus/public/interfaces/window_tree.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698