OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 BLIMP_CLIENT_CORE_COMPOSITOR_DELEGATED_OUTPUT_SURFACE_H_ | |
6 #define BLIMP_CLIENT_CORE_COMPOSITOR_DELEGATED_OUTPUT_SURFACE_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/weak_ptr.h" | |
10 #include "blimp/client/core/compositor/blimp_output_surface.h" | |
11 #include "cc/output/output_surface.h" | |
12 | |
13 namespace base { | |
14 class SingleThreadTaskRunner; | |
15 } // namespace base | |
16 | |
17 namespace cc { | |
18 class ContextProvider; | |
19 } // namespace cc | |
20 | |
21 namespace blimp { | |
22 namespace client { | |
23 | |
24 class DelegatedOutputSurface : public cc::OutputSurface, | |
25 public BlimpOutputSurface { | |
26 public: | |
27 DelegatedOutputSurface( | |
28 scoped_refptr<cc::ContextProvider> compositor_context_provider, | |
29 scoped_refptr<cc::ContextProvider> worker_context_provider, | |
30 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | |
31 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner, | |
32 BlimpOutputSurfaceClient* client); | |
33 | |
34 ~DelegatedOutputSurface() override; | |
35 | |
36 // cc::OutputSurface implementation. | |
37 uint32_t GetFramebufferCopyTextureFormat() override; | |
38 bool BindToClient(cc::OutputSurfaceClient* client) override; | |
39 void SwapBuffers(cc::CompositorFrame frame) override; | |
40 void DetachFromClient() override; | |
41 | |
42 // BlimpOutputSurface implementation. | |
43 void ReclaimCompositorResources( | |
44 const cc::ReturnedResourceArray& resources) override; | |
45 | |
46 protected: | |
47 // called on compositor thread. | |
David Trainor- moved to gerrit
2016/08/24 23:09:33
called -> Called
Khushal
2016/08/25 02:35:39
Removed.
| |
48 virtual void ReclaimResourcesOnCompositorThread( | |
49 const cc::ReturnedResourceArray& resources); | |
50 | |
51 private: | |
52 // Called on main thread. | |
53 void BindOnMainThread( | |
54 base::WeakPtr<DelegatedOutputSurface> output_surface_weak_ptr); | |
55 void SwapBuffersOnMainThread(cc::CompositorFrame frame); | |
56 void DetachOnMainThread(); | |
57 | |
58 bool IsMainThread() const; | |
59 bool IsCompositorThread() const; | |
60 | |
61 struct MainThreadOnly { | |
62 MainThreadOnly(DelegatedOutputSurface* output_surface, | |
63 BlimpOutputSurfaceClient* client); | |
64 ~MainThreadOnly(); | |
65 | |
66 BlimpOutputSurfaceClient* client; | |
67 // Used to post tasks to the OutputSurface on the compositor thread. | |
68 base::WeakPtr<DelegatedOutputSurface> output_surface_weak_ptr; | |
69 | |
70 base::WeakPtrFactory<DelegatedOutputSurface> weak_ptr_factory; | |
71 }; | |
72 | |
73 struct CompositorThreadOnly { | |
74 CompositorThreadOnly( | |
75 DelegatedOutputSurface* output_surface, | |
76 base::WeakPtr<DelegatedOutputSurface> output_surface_weak_ptr); | |
77 ~CompositorThreadOnly(); | |
78 | |
79 bool bound_to_client; | |
80 | |
81 // Used to post tasks to the OutputSurface on the main thread. | |
82 base::WeakPtr<DelegatedOutputSurface> output_surface_weak_ptr; | |
83 | |
84 base::WeakPtrFactory<DelegatedOutputSurface> weak_ptr_factory; | |
85 }; | |
86 | |
87 MainThreadOnly& main(); | |
88 CompositorThreadOnly& compositor(); | |
89 | |
90 MainThreadOnly main_thread_only_; | |
91 CompositorThreadOnly compositor_thread_only_; | |
92 | |
93 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | |
94 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; | |
95 | |
96 DISALLOW_COPY_AND_ASSIGN(DelegatedOutputSurface); | |
97 }; | |
98 | |
99 } // namespace client | |
100 } // namespace blimp | |
101 | |
102 #endif // BLIMP_CLIENT_CORE_COMPOSITOR_DELEGATED_OUTPUT_SURFACE_H_ | |
OLD | NEW |