OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SKY_VIEWER_COMPOSITOR_SURFACE_HOLDER_H_ | |
6 #define SKY_VIEWER_COMPOSITOR_SURFACE_HOLDER_H_ | |
7 | |
8 #include "base/callback_forward.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/memory/weak_ptr.h" | |
11 #include "mojo/public/cpp/bindings/binding.h" | |
12 #include "mojo/services/surfaces/public/interfaces/surface_id.mojom.h" | |
13 #include "mojo/services/surfaces/public/interfaces/surfaces.mojom.h" | |
14 #include "ui/gfx/geometry/rect.h" | |
15 | |
16 namespace mojo { | |
17 class Shell; | |
18 } | |
19 | |
20 namespace sky { | |
21 class SurfaceAllocator; | |
22 | |
23 class SurfaceHolder : public mojo::ResourceReturner { | |
24 public: | |
25 class Client { | |
26 public: | |
27 virtual void OnSurfaceIdAvailable(mojo::SurfaceIdPtr surface_id) = 0; | |
28 virtual void ReturnResources( | |
29 mojo::Array<mojo::ReturnedResourcePtr> resources) = 0; | |
30 | |
31 protected: | |
32 virtual ~Client(); | |
33 }; | |
34 | |
35 explicit SurfaceHolder(Client* client, mojo::Shell* shell); | |
36 ~SurfaceHolder() override; | |
37 | |
38 void SetSize(const gfx::Size& size); | |
39 void SubmitFrame(mojo::FramePtr frame, const base::Closure& callback); | |
40 | |
41 private: | |
42 // mojo::ResourceReturner | |
43 void ReturnResources( | |
44 mojo::Array<mojo::ReturnedResourcePtr> resources) override; | |
45 | |
46 void SetIdNamespace(uint32_t id_namespace); | |
47 void SetQualifiedId(); | |
48 | |
49 Client* client_; | |
50 gfx::Size size_; | |
51 uint32_t id_namespace_; | |
52 uint32_t local_id_; | |
53 mojo::SurfacePtr surface_; | |
54 mojo::Binding<mojo::ResourceReturner> returner_binding_; | |
55 | |
56 base::WeakPtrFactory<SurfaceHolder> weak_factory_; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(SurfaceHolder); | |
59 }; | |
60 | |
61 } // namespace sky | |
62 | |
63 #endif // SKY_VIEWER_COMPOSITOR_SURFACE_HOLDER_H_ | |
OLD | NEW |