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 MOJO_CC_OUTPUT_SURFACE_MOJO_H_ | 5 #ifndef MOJO_CC_OUTPUT_SURFACE_MOJO_H_ |
6 #define MOJO_CC_OUTPUT_SURFACE_MOJO_H_ | 6 #define MOJO_CC_OUTPUT_SURFACE_MOJO_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "cc/output/output_surface.h" | 9 #include "cc/output/output_surface.h" |
10 #include "cc/surfaces/surface_id.h" | 10 #include "cc/surfaces/surface_id.h" |
11 #include "components/view_manager/public/interfaces/surfaces.mojom.h" | 11 #include "components/view_manager/public/cpp/surface.h" |
| 12 #include "components/view_manager/public/cpp/surface_client.h" |
12 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" | 13 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" |
13 | 14 |
| 15 namespace uip { |
| 16 class Surface; |
| 17 } |
| 18 |
14 namespace mojo { | 19 namespace mojo { |
15 | 20 |
16 class OutputSurfaceMojoClient { | 21 class OutputSurfaceMojo : public cc::OutputSurface, |
| 22 public uip::SurfaceClient { |
17 public: | 23 public: |
18 virtual ~OutputSurfaceMojoClient() {} | 24 OutputSurfaceMojo(const scoped_refptr<cc::ContextProvider>& context_provider, |
19 | 25 scoped_ptr<uip::Surface> surface); |
20 virtual void DidCreateSurface(cc::SurfaceId id) = 0; | 26 ~OutputSurfaceMojo() override; |
21 }; | |
22 | |
23 class OutputSurfaceMojo : public cc::OutputSurface, | |
24 public mojo::ResourceReturner { | |
25 public: | |
26 OutputSurfaceMojo(OutputSurfaceMojoClient* client, | |
27 const scoped_refptr<cc::ContextProvider>& context_provider, | |
28 ScopedMessagePipeHandle surface_handle); | |
29 | |
30 // mojo::ResourceReturner implementation. | |
31 void ReturnResources(mojo::Array<ReturnedResourcePtr>) override; | |
32 | 27 |
33 // cc::OutputSurface implementation. | 28 // cc::OutputSurface implementation. |
34 void SwapBuffers(cc::CompositorFrame* frame) override; | 29 void SwapBuffers(cc::CompositorFrame* frame) override; |
35 bool BindToClient(cc::OutputSurfaceClient* client) override; | 30 bool BindToClient(cc::OutputSurfaceClient* client) override; |
36 | 31 |
37 protected: | 32 private: |
38 ~OutputSurfaceMojo() override; | 33 // uip::SurfaceObserver implementation: |
| 34 void OnResourcesReturned( |
| 35 uip::Surface* surface, |
| 36 mojo::Array<mojo::ReturnedResourcePtr> resources) override; |
39 | 37 |
40 private: | 38 scoped_ptr<uip::Surface> surface_; |
41 void SetIdNamespace(uint32_t id_namespace); | |
42 | |
43 OutputSurfaceMojoClient* output_surface_mojo_client_; | |
44 ScopedMessagePipeHandle surface_handle_; | |
45 SurfacePtr surface_; | |
46 uint32_t id_namespace_; | |
47 uint32_t local_id_; | |
48 gfx::Size surface_size_; | |
49 mojo::Binding<mojo::ResourceReturner> binding_; | |
50 | 39 |
51 DISALLOW_COPY_AND_ASSIGN(OutputSurfaceMojo); | 40 DISALLOW_COPY_AND_ASSIGN(OutputSurfaceMojo); |
52 }; | 41 }; |
53 } | 42 } |
54 | 43 |
55 #endif // MOJO_CC_OUTPUT_SURFACE_MOJO_H_ | 44 #endif // MOJO_CC_OUTPUT_SURFACE_MOJO_H_ |
OLD | NEW |