OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_H_ | 5 #ifndef CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_FRAME_SINK_H_ |
6 #define CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_H_ | 6 #define CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_FRAME_SINK_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/cancelable_callback.h" | 13 #include "base/cancelable_callback.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
18 #include "cc/output/compositor_frame.h" | 18 #include "cc/output/compositor_frame.h" |
| 19 #include "cc/output/compositor_frame_sink.h" |
19 #include "cc/output/managed_memory_policy.h" | 20 #include "cc/output/managed_memory_policy.h" |
20 #include "cc/output/output_surface.h" | |
21 #include "cc/surfaces/display_client.h" | 21 #include "cc/surfaces/display_client.h" |
22 #include "cc/surfaces/surface_factory_client.h" | 22 #include "cc/surfaces/surface_factory_client.h" |
23 #include "ipc/ipc_message.h" | 23 #include "ipc/ipc_message.h" |
24 #include "ui/gfx/transform.h" | 24 #include "ui/gfx/transform.h" |
25 | 25 |
26 namespace cc { | 26 namespace cc { |
27 class ContextProvider; | 27 class ContextProvider; |
28 class CompositorFrameMetadata; | 28 class CompositorFrameMetadata; |
29 class Display; | 29 class Display; |
30 class SurfaceFactory; | 30 class SurfaceFactory; |
31 class SurfaceIdAllocator; | 31 class SurfaceIdAllocator; |
32 class SurfaceManager; | 32 class SurfaceManager; |
33 } | 33 } |
34 | 34 |
35 namespace IPC { | 35 namespace IPC { |
36 class Message; | 36 class Message; |
37 class Sender; | 37 class Sender; |
38 } | 38 } |
39 | 39 |
40 namespace content { | 40 namespace content { |
41 | 41 |
42 class FrameSwapMessageQueue; | 42 class FrameSwapMessageQueue; |
43 class SynchronousCompositorRegistry; | 43 class SynchronousCompositorRegistry; |
44 class WebGraphicsContext3DCommandBufferImpl; | 44 class WebGraphicsContext3DCommandBufferImpl; |
45 | 45 |
46 class SynchronousCompositorOutputSurfaceClient { | 46 class SynchronousCompositorFrameSinkClient { |
47 public: | 47 public: |
48 virtual void DidActivatePendingTree() = 0; | 48 virtual void DidActivatePendingTree() = 0; |
49 virtual void Invalidate() = 0; | 49 virtual void Invalidate() = 0; |
50 virtual void SwapBuffers(uint32_t output_surface_id, | 50 virtual void SwapBuffers(uint32_t compositor_frame_sink_id, |
51 cc::CompositorFrame frame) = 0; | 51 cc::CompositorFrame frame) = 0; |
52 | 52 |
53 protected: | 53 protected: |
54 virtual ~SynchronousCompositorOutputSurfaceClient() {} | 54 virtual ~SynchronousCompositorFrameSinkClient() {} |
55 }; | 55 }; |
56 | 56 |
57 // Specialization of the output surface that adapts it to implement the | 57 // Specialization of the output surface that adapts it to implement the |
58 // content::SynchronousCompositor public API. This class effects an "inversion | 58 // content::SynchronousCompositor public API. This class effects an "inversion |
59 // of control" - enabling drawing to be orchestrated by the embedding | 59 // of control" - enabling drawing to be orchestrated by the embedding |
60 // layer, instead of driven by the compositor internals - hence it holds two | 60 // layer, instead of driven by the compositor internals - hence it holds two |
61 // 'client' pointers (|client_| in the OutputSurface baseclass and | 61 // 'client' pointers (|client_| in the CompositorFrameSink baseclass and |
62 // |delegate_|) which represent the consumers of the two roles in plays. | 62 // |delegate_|) which represent the consumers of the two roles in plays. |
63 // This class can be created only on the main thread, but then becomes pinned | 63 // This class can be created only on the main thread, but then becomes pinned |
64 // to a fixed thread when BindToClient is called. | 64 // to a fixed thread when BindToClient is called. |
65 class SynchronousCompositorOutputSurface | 65 class SynchronousCompositorFrameSink |
66 : NON_EXPORTED_BASE(public cc::OutputSurface), | 66 : NON_EXPORTED_BASE(public cc::CompositorFrameSink), |
67 public cc::SurfaceFactoryClient { | 67 public cc::SurfaceFactoryClient { |
68 public: | 68 public: |
69 SynchronousCompositorOutputSurface( | 69 SynchronousCompositorFrameSink( |
70 scoped_refptr<cc::ContextProvider> context_provider, | 70 scoped_refptr<cc::ContextProvider> context_provider, |
71 scoped_refptr<cc::ContextProvider> worker_context_provider, | 71 scoped_refptr<cc::ContextProvider> worker_context_provider, |
72 int routing_id, | 72 int routing_id, |
73 uint32_t output_surface_id, | 73 uint32_t compositor_frame_sink_id, |
74 std::unique_ptr<cc::BeginFrameSource> begin_frame_source, | 74 std::unique_ptr<cc::BeginFrameSource> begin_frame_source, |
75 SynchronousCompositorRegistry* registry, | 75 SynchronousCompositorRegistry* registry, |
76 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue); | 76 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue); |
77 ~SynchronousCompositorOutputSurface() override; | 77 ~SynchronousCompositorFrameSink() override; |
78 | 78 |
79 void SetSyncClient(SynchronousCompositorOutputSurfaceClient* compositor); | 79 void SetSyncClient(SynchronousCompositorFrameSinkClient* compositor); |
80 bool OnMessageReceived(const IPC::Message& message); | 80 bool OnMessageReceived(const IPC::Message& message); |
81 | 81 |
82 // OutputSurface. | 82 // cc::CompositorFrameSink implementation. |
83 bool BindToClient(cc::OutputSurfaceClient* surface_client) override; | 83 bool BindToClient(cc::CompositorFrameSinkClient* sink_client) override; |
84 void DetachFromClient() override; | 84 void DetachFromClient() override; |
85 void Reshape(const gfx::Size& size, | 85 void Reshape(const gfx::Size& size, |
86 float scale_factor, | 86 float scale_factor, |
87 const gfx::ColorSpace& color_space, | 87 const gfx::ColorSpace& color_space, |
88 bool has_alpha) override; | 88 bool has_alpha) override; |
89 void SwapBuffers(cc::CompositorFrame frame) override; | 89 void SwapBuffers(cc::CompositorFrame frame) override; |
90 void Invalidate() override; | 90 void Invalidate() override; |
91 void BindFramebuffer() override; | 91 void BindFramebuffer() override; |
92 uint32_t GetFramebufferCopyTextureFormat() override; | 92 uint32_t GetFramebufferCopyTextureFormat() override; |
93 | 93 |
(...skipping 15 matching lines...) Expand all Loading... |
109 bool Send(IPC::Message* message); | 109 bool Send(IPC::Message* message); |
110 void DidActivatePendingTree(); | 110 void DidActivatePendingTree(); |
111 void DeliverMessages(); | 111 void DeliverMessages(); |
112 bool CalledOnValidThread() const; | 112 bool CalledOnValidThread() const; |
113 | 113 |
114 void CancelFallbackTick(); | 114 void CancelFallbackTick(); |
115 void FallbackTickFired(); | 115 void FallbackTickFired(); |
116 | 116 |
117 // IPC handlers. | 117 // IPC handlers. |
118 void SetMemoryPolicy(size_t bytes_limit); | 118 void SetMemoryPolicy(size_t bytes_limit); |
119 void OnReclaimResources(uint32_t output_surface_id, | 119 void OnReclaimResources(uint32_t compositor_frame_sink_id, |
120 const cc::ReturnedResourceArray& resources); | 120 const cc::ReturnedResourceArray& resources); |
121 | 121 |
122 const int routing_id_; | 122 const int routing_id_; |
123 const uint32_t output_surface_id_; | 123 const uint32_t compositor_frame_sink_id_; |
124 SynchronousCompositorRegistry* const registry_; // Not owned. | 124 SynchronousCompositorRegistry* const registry_; // Not owned. |
125 IPC::Sender* const sender_; // Not owned. | 125 IPC::Sender* const sender_; // Not owned. |
126 bool registered_ = false; | 126 bool registered_ = false; |
127 | 127 |
128 // Not owned. | 128 // Not owned. |
129 SynchronousCompositorOutputSurfaceClient* sync_client_ = nullptr; | 129 SynchronousCompositorFrameSinkClient* sync_client_ = nullptr; |
130 | 130 |
131 // Only valid (non-NULL) during a DemandDrawSw() call. | 131 // Only valid (non-NULL) during a DemandDrawSw() call. |
132 SkCanvas* current_sw_canvas_ = nullptr; | 132 SkCanvas* current_sw_canvas_ = nullptr; |
133 | 133 |
134 cc::ManagedMemoryPolicy memory_policy_; | 134 cc::ManagedMemoryPolicy memory_policy_; |
135 bool in_software_draw_ = false; | 135 bool in_software_draw_ = false; |
136 bool did_swap_ = false; | 136 bool did_swap_ = false; |
137 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_; | 137 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_; |
138 | 138 |
139 base::CancelableClosure fallback_tick_; | 139 base::CancelableClosure fallback_tick_; |
(...skipping 12 matching lines...) Expand all Loading... |
152 // is owned/destroyed on the compositor thread. | 152 // is owned/destroyed on the compositor thread. |
153 std::unique_ptr<cc::SurfaceManager> surface_manager_; | 153 std::unique_ptr<cc::SurfaceManager> surface_manager_; |
154 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; | 154 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; |
155 cc::SurfaceId delegated_surface_id_; | 155 cc::SurfaceId delegated_surface_id_; |
156 // Uses surface_manager_. | 156 // Uses surface_manager_. |
157 std::unique_ptr<cc::SurfaceFactory> surface_factory_; | 157 std::unique_ptr<cc::SurfaceFactory> surface_factory_; |
158 StubDisplayClient display_client_; | 158 StubDisplayClient display_client_; |
159 // Uses surface_manager_. | 159 // Uses surface_manager_. |
160 std::unique_ptr<cc::Display> display_; | 160 std::unique_ptr<cc::Display> display_; |
161 // Owned by |display_|. | 161 // Owned by |display_|. |
162 SoftwareOutputSurface* software_output_surface_ = nullptr; | 162 SoftwareOutputSurface* software_compositor_frame_sink_ = nullptr; |
163 std::unique_ptr<cc::BeginFrameSource> begin_frame_source_; | 163 std::unique_ptr<cc::BeginFrameSource> begin_frame_source_; |
164 | 164 |
165 base::ThreadChecker thread_checker_; | 165 base::ThreadChecker thread_checker_; |
166 | 166 |
167 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorOutputSurface); | 167 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorFrameSink); |
168 }; | 168 }; |
169 | 169 |
170 } // namespace content | 170 } // namespace content |
171 | 171 |
172 #endif // CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_H_ | 172 #endif // CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_FRAME_SINK_H_ |
OLD | NEW |