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; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 const base::WeakPtr<BrowserPlugin>& browser_plugin); | 59 const base::WeakPtr<BrowserPlugin>& browser_plugin); |
61 static ChildFrameCompositingHelper* CreateForRenderFrameProxy( | 60 static ChildFrameCompositingHelper* CreateForRenderFrameProxy( |
62 RenderFrameProxy* render_frame_proxy); | 61 RenderFrameProxy* render_frame_proxy); |
63 | 62 |
64 void CopyFromCompositingSurface(int request_id, | 63 void CopyFromCompositingSurface(int request_id, |
65 gfx::Rect source_rect, | 64 gfx::Rect source_rect, |
66 gfx::Size dest_size); | 65 gfx::Size dest_size); |
67 void DidCommitCompositorFrame(); | 66 void DidCommitCompositorFrame(); |
68 void EnableCompositing(bool); | 67 void EnableCompositing(bool); |
69 void OnContainerDestroy(); | 68 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, | 69 void OnCompositorFrameSwapped(scoped_ptr<cc::CompositorFrame> frame, |
76 int route_id, | 70 int route_id, |
77 uint32 output_surface_id, | 71 uint32 output_surface_id, |
78 int host_id, | 72 int host_id, |
79 base::SharedMemoryHandle handle); | 73 base::SharedMemoryHandle handle); |
80 void UpdateVisibility(bool); | 74 void UpdateVisibility(bool); |
81 void ChildFrameGone(); | 75 void ChildFrameGone(); |
82 | 76 |
83 // cc::DelegatedFrameProviderClient implementation. | 77 // cc::DelegatedFrameProviderClient implementation. |
84 virtual void UnusedResourcesAreAvailable() OVERRIDE; | 78 virtual void UnusedResourcesAreAvailable() OVERRIDE; |
85 void SetContentsOpaque(bool); | 79 void SetContentsOpaque(bool); |
86 | 80 |
87 protected: | 81 protected: |
88 // Friend RefCounted so that the dtor can be non-public. | 82 // Friend RefCounted so that the dtor can be non-public. |
89 friend class base::RefCounted<ChildFrameCompositingHelper>; | 83 friend class base::RefCounted<ChildFrameCompositingHelper>; |
90 | 84 |
91 private: | 85 private: |
92 ChildFrameCompositingHelper( | 86 ChildFrameCompositingHelper( |
93 const base::WeakPtr<BrowserPlugin>& browser_plugin, | 87 const base::WeakPtr<BrowserPlugin>& browser_plugin, |
94 blink::WebFrame* frame, | 88 blink::WebFrame* frame, |
95 RenderFrameProxy* render_frame_proxy, | 89 RenderFrameProxy* render_frame_proxy, |
96 int host_routing_id); | 90 int host_routing_id); |
97 | 91 |
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(); | 92 virtual ~ChildFrameCompositingHelper(); |
116 | 93 |
117 BrowserPluginManager* GetBrowserPluginManager(); | 94 BrowserPluginManager* GetBrowserPluginManager(); |
118 blink::WebPluginContainer* GetContainer(); | 95 blink::WebPluginContainer* GetContainer(); |
119 int GetInstanceID(); | 96 int GetInstanceID(); |
120 | 97 |
121 void SendCompositorFrameSwappedACKToBrowser( | 98 void SendCompositorFrameSwappedACKToBrowser( |
122 FrameHostMsg_CompositorFrameSwappedACK_Params& params); | 99 FrameHostMsg_CompositorFrameSwappedACK_Params& params); |
123 void SendBuffersSwappedACKToBrowser( | |
124 FrameHostMsg_BuffersSwappedACK_Params& params); | |
125 void SendReclaimCompositorResourcesToBrowser( | 100 void SendReclaimCompositorResourcesToBrowser( |
126 FrameHostMsg_ReclaimCompositorResources_Params& params); | 101 FrameHostMsg_ReclaimCompositorResources_Params& params); |
127 void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size, | 102 void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size, |
128 float device_scale_factor, | 103 float device_scale_factor, |
129 cc::Layer* layer); | 104 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(); | 105 void SendReturnedDelegatedResources(); |
137 void CopyFromCompositingSurfaceHasResult( | 106 void CopyFromCompositingSurfaceHasResult( |
138 int request_id, | 107 int request_id, |
139 gfx::Size dest_size, | 108 gfx::Size dest_size, |
140 scoped_ptr<cc::CopyOutputResult> result); | 109 scoped_ptr<cc::CopyOutputResult> result); |
141 | 110 |
142 int host_routing_id_; | 111 int host_routing_id_; |
143 int last_route_id_; | 112 int last_route_id_; |
144 uint32 last_output_surface_id_; | 113 uint32 last_output_surface_id_; |
145 int last_host_id_; | 114 int last_host_id_; |
146 bool last_mailbox_valid_; | |
147 bool ack_pending_; | 115 bool ack_pending_; |
148 bool software_ack_pending_; | |
149 bool opaque_; | 116 bool opaque_; |
150 std::vector<unsigned> unacked_software_frames_; | |
151 | 117 |
152 gfx::Size buffer_size_; | 118 gfx::Size buffer_size_; |
153 | 119 |
154 // The lifetime of this weak pointer should be greater than the lifetime of | 120 // 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 | 121 // other member objects, as they may access this pointer during their |
156 // destruction. | 122 // destruction. |
157 base::WeakPtr<BrowserPlugin> browser_plugin_; | 123 base::WeakPtr<BrowserPlugin> browser_plugin_; |
158 RenderFrameProxy* render_frame_proxy_; | 124 RenderFrameProxy* render_frame_proxy_; |
159 | 125 |
160 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_; | 126 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_; |
161 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_; | 127 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_; |
162 | 128 |
163 scoped_refptr<cc::SolidColorLayer> background_layer_; | 129 scoped_refptr<cc::SolidColorLayer> background_layer_; |
164 scoped_refptr<cc::TextureLayer> texture_layer_; | 130 scoped_refptr<cc::TextureLayer> texture_layer_; |
165 scoped_refptr<cc::DelegatedRendererLayer> delegated_layer_; | 131 scoped_refptr<cc::DelegatedRendererLayer> delegated_layer_; |
166 scoped_ptr<blink::WebLayer> web_layer_; | 132 scoped_ptr<blink::WebLayer> web_layer_; |
167 blink::WebFrame* frame_; | 133 blink::WebFrame* frame_; |
168 | 134 |
169 DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper); | 135 DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper); |
170 }; | 136 }; |
171 | 137 |
172 } // namespace content | 138 } // namespace content |
173 | 139 |
174 #endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_ | 140 #endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_ |
OLD | NEW |