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 CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_ | 5 #ifndef CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_ |
6 #define CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_ | 6 #define CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/shared_memory.h" | 13 #include "base/memory/shared_memory.h" |
14 #include "cc/layers/delegated_frame_resource_collection.h" | 14 #include "cc/layers/delegated_frame_resource_collection.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 #include "gpu/command_buffer/common/mailbox.h" | |
17 #include "ui/gfx/size.h" | 16 #include "ui/gfx/size.h" |
18 | 17 |
19 namespace base { | 18 namespace base { |
20 class SharedMemory; | 19 class SharedMemory; |
21 } | 20 } |
22 | 21 |
23 namespace cc { | 22 namespace cc { |
24 class CompositorFrame; | 23 class CompositorFrame; |
25 class CopyOutputResult; | 24 class CopyOutputResult; |
26 class Layer; | 25 class Layer; |
27 class SolidColorLayer; | 26 class SolidColorLayer; |
28 class TextureLayer; | |
29 class DelegatedFrameProvider; | 27 class DelegatedFrameProvider; |
30 class DelegatedFrameResourceCollection; | 28 class DelegatedFrameResourceCollection; |
31 class DelegatedRendererLayer; | 29 class DelegatedRendererLayer; |
32 } | 30 } |
33 | 31 |
34 namespace blink { | 32 namespace blink { |
35 class WebFrame; | 33 class WebFrame; |
36 class WebPluginContainer; | 34 class WebPluginContainer; |
37 class WebLayer; | 35 class WebLayer; |
38 } | 36 } |
(...skipping 21 matching lines...) Expand all Loading... |
60 const base::WeakPtr<BrowserPlugin>& browser_plugin); | 58 const base::WeakPtr<BrowserPlugin>& browser_plugin); |
61 static ChildFrameCompositingHelper* CreateForRenderFrameProxy( | 59 static ChildFrameCompositingHelper* CreateForRenderFrameProxy( |
62 RenderFrameProxy* render_frame_proxy); | 60 RenderFrameProxy* render_frame_proxy); |
63 | 61 |
64 void CopyFromCompositingSurface(int request_id, | 62 void CopyFromCompositingSurface(int request_id, |
65 gfx::Rect source_rect, | 63 gfx::Rect source_rect, |
66 gfx::Size dest_size); | 64 gfx::Size dest_size); |
67 void DidCommitCompositorFrame(); | 65 void DidCommitCompositorFrame(); |
68 void EnableCompositing(bool); | 66 void EnableCompositing(bool); |
69 void OnContainerDestroy(); | 67 void OnContainerDestroy(); |
70 void OnBuffersSwapped(const gfx::Size& size, | |
71 const gpu::Mailbox& mailbox, | |
72 int gpu_route_id, | |
73 int gpu_host_id, | |
74 float device_scale_factor); | |
75 void OnCompositorFrameSwapped(scoped_ptr<cc::CompositorFrame> frame, | 68 void OnCompositorFrameSwapped(scoped_ptr<cc::CompositorFrame> frame, |
76 int route_id, | 69 int route_id, |
77 uint32 output_surface_id, | 70 uint32 output_surface_id, |
78 int host_id, | 71 int host_id, |
79 base::SharedMemoryHandle handle); | 72 base::SharedMemoryHandle handle); |
80 void UpdateVisibility(bool); | 73 void UpdateVisibility(bool); |
81 void ChildFrameGone(); | 74 void ChildFrameGone(); |
82 | 75 |
83 // cc::DelegatedFrameProviderClient implementation. | 76 // cc::DelegatedFrameProviderClient implementation. |
84 virtual void UnusedResourcesAreAvailable() OVERRIDE; | 77 virtual void UnusedResourcesAreAvailable() OVERRIDE; |
85 void SetContentsOpaque(bool); | 78 void SetContentsOpaque(bool); |
86 | 79 |
87 protected: | 80 protected: |
88 // Friend RefCounted so that the dtor can be non-public. | 81 // Friend RefCounted so that the dtor can be non-public. |
89 friend class base::RefCounted<ChildFrameCompositingHelper>; | 82 friend class base::RefCounted<ChildFrameCompositingHelper>; |
90 | 83 |
91 private: | 84 private: |
92 ChildFrameCompositingHelper( | 85 ChildFrameCompositingHelper( |
93 const base::WeakPtr<BrowserPlugin>& browser_plugin, | 86 const base::WeakPtr<BrowserPlugin>& browser_plugin, |
94 blink::WebFrame* frame, | 87 blink::WebFrame* frame, |
95 RenderFrameProxy* render_frame_proxy, | 88 RenderFrameProxy* render_frame_proxy, |
96 int host_routing_id); | 89 int host_routing_id); |
97 | 90 |
98 enum SwapBuffersType { | |
99 TEXTURE_IMAGE_TRANSPORT, | |
100 GL_COMPOSITOR_FRAME, | |
101 SOFTWARE_COMPOSITOR_FRAME, | |
102 }; | |
103 struct SwapBuffersInfo { | |
104 SwapBuffersInfo(); | |
105 | |
106 gpu::Mailbox name; | |
107 SwapBuffersType type; | |
108 gfx::Size size; | |
109 int route_id; | |
110 uint32 output_surface_id; | |
111 int host_id; | |
112 unsigned software_frame_id; | |
113 base::SharedMemory* shared_memory; | |
114 }; | |
115 virtual ~ChildFrameCompositingHelper(); | 91 virtual ~ChildFrameCompositingHelper(); |
116 | 92 |
117 BrowserPluginManager* GetBrowserPluginManager(); | 93 BrowserPluginManager* GetBrowserPluginManager(); |
118 blink::WebPluginContainer* GetContainer(); | 94 blink::WebPluginContainer* GetContainer(); |
119 int GetInstanceID(); | 95 int GetInstanceID(); |
120 | 96 |
121 void SendCompositorFrameSwappedACKToBrowser( | 97 void SendCompositorFrameSwappedACKToBrowser( |
122 FrameHostMsg_CompositorFrameSwappedACK_Params& params); | 98 FrameHostMsg_CompositorFrameSwappedACK_Params& params); |
123 void SendBuffersSwappedACKToBrowser( | |
124 FrameHostMsg_BuffersSwappedACK_Params& params); | |
125 void SendReclaimCompositorResourcesToBrowser( | 99 void SendReclaimCompositorResourcesToBrowser( |
126 FrameHostMsg_ReclaimCompositorResources_Params& params); | 100 FrameHostMsg_ReclaimCompositorResources_Params& params); |
127 void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size, | 101 void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size, |
128 float device_scale_factor, | 102 float device_scale_factor, |
129 cc::Layer* layer); | 103 cc::Layer* layer); |
130 void OnBuffersSwappedPrivate(const SwapBuffersInfo& mailbox, | |
131 unsigned sync_point, | |
132 float device_scale_factor); | |
133 void MailboxReleased(SwapBuffersInfo mailbox, | |
134 unsigned sync_point, | |
135 bool lost_resource); | |
136 void SendReturnedDelegatedResources(); | 104 void SendReturnedDelegatedResources(); |
137 void CopyFromCompositingSurfaceHasResult( | 105 void CopyFromCompositingSurfaceHasResult( |
138 int request_id, | 106 int request_id, |
139 gfx::Size dest_size, | 107 gfx::Size dest_size, |
140 scoped_ptr<cc::CopyOutputResult> result); | 108 scoped_ptr<cc::CopyOutputResult> result); |
141 | 109 |
142 int host_routing_id_; | 110 int host_routing_id_; |
143 int last_route_id_; | 111 int last_route_id_; |
144 uint32 last_output_surface_id_; | 112 uint32 last_output_surface_id_; |
145 int last_host_id_; | 113 int last_host_id_; |
146 bool last_mailbox_valid_; | |
147 bool ack_pending_; | 114 bool ack_pending_; |
148 bool software_ack_pending_; | |
149 bool opaque_; | 115 bool opaque_; |
150 std::vector<unsigned> unacked_software_frames_; | |
151 | 116 |
152 gfx::Size buffer_size_; | 117 gfx::Size buffer_size_; |
153 | 118 |
154 // The lifetime of this weak pointer should be greater than the lifetime of | 119 // The lifetime of this weak pointer should be greater than the lifetime of |
155 // other member objects, as they may access this pointer during their | 120 // other member objects, as they may access this pointer during their |
156 // destruction. | 121 // destruction. |
157 base::WeakPtr<BrowserPlugin> browser_plugin_; | 122 base::WeakPtr<BrowserPlugin> browser_plugin_; |
158 RenderFrameProxy* render_frame_proxy_; | 123 RenderFrameProxy* render_frame_proxy_; |
159 | 124 |
160 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_; | 125 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_; |
161 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_; | 126 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_; |
162 | 127 |
163 scoped_refptr<cc::SolidColorLayer> background_layer_; | 128 scoped_refptr<cc::SolidColorLayer> background_layer_; |
164 scoped_refptr<cc::TextureLayer> texture_layer_; | |
165 scoped_refptr<cc::DelegatedRendererLayer> delegated_layer_; | 129 scoped_refptr<cc::DelegatedRendererLayer> delegated_layer_; |
166 scoped_ptr<blink::WebLayer> web_layer_; | 130 scoped_ptr<blink::WebLayer> web_layer_; |
167 blink::WebFrame* frame_; | 131 blink::WebFrame* frame_; |
168 | 132 |
169 DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper); | 133 DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper); |
170 }; | 134 }; |
171 | 135 |
172 } // namespace content | 136 } // namespace content |
173 | 137 |
174 #endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_ | 138 #endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_ |
OLD | NEW |