[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 5 | #ifndef CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_ |
| 6 | #define CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_ |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 7 | |
| 8 | #include <string> |
[email protected] | 9afdaef | 2013-09-26 07:24:37 | [diff] [blame] | 9 | #include <vector> |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 10 | |
| 11 | #include "base/memory/ref_counted.h" |
| 12 | #include "base/memory/scoped_ptr.h" |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 13 | #include "cc/layers/delegated_frame_resource_collection.h" |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 14 | #include "content/common/content_export.h" |
[email protected] | c049b2e | 2013-06-11 04:39:30 | [diff] [blame] | 15 | #include "gpu/command_buffer/common/mailbox.h" |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 16 | #include "ui/gfx/size.h" |
| 17 | |
[email protected] | 9f39c20 | 2013-06-18 16:06:42 | [diff] [blame] | 18 | namespace base { |
| 19 | class SharedMemory; |
| 20 | } |
| 21 | |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 22 | namespace cc { |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 23 | class CompositorFrame; |
[email protected] | 73405fb | 2013-12-11 04:59:37 | [diff] [blame] | 24 | class CopyOutputResult; |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 25 | class Layer; |
[email protected] | 396fbb7 | 2013-01-23 02:33:43 | [diff] [blame] | 26 | class SolidColorLayer; |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 27 | class TextureLayer; |
[email protected] | 09f6738 | 2013-10-09 21:03:45 | [diff] [blame] | 28 | class DelegatedFrameProvider; |
| 29 | class DelegatedFrameResourceCollection; |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 30 | class DelegatedRendererLayer; |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 31 | } |
| 32 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 33 | namespace blink { |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 34 | class WebFrame; |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 35 | class WebPluginContainer; |
| 36 | class WebLayer; |
| 37 | } |
| 38 | |
[email protected] | 73405fb | 2013-12-11 04:59:37 | [diff] [blame] | 39 | namespace gfx { |
| 40 | class Rect; |
| 41 | class Size; |
| 42 | } |
| 43 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 44 | struct FrameHostMsg_CompositorFrameSwappedACK_Params; |
| 45 | struct FrameHostMsg_BuffersSwappedACK_Params; |
| 46 | struct FrameHostMsg_ReclaimCompositorResources_Params; |
| 47 | |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 48 | namespace content { |
| 49 | |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 50 | class BrowserPluginManager; |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 51 | class RenderFrameImpl; |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 52 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 53 | class CONTENT_EXPORT ChildFrameCompositingHelper |
| 54 | : public base::RefCounted<ChildFrameCompositingHelper>, |
| 55 | public cc::DelegatedFrameResourceCollectionClient { |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 56 | public: |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 57 | static ChildFrameCompositingHelper* CreateCompositingHelperForBrowserPlugin( |
| 58 | blink::WebPluginContainer* container, |
| 59 | BrowserPluginManager* manager, |
| 60 | int instance_id, |
| 61 | int host_routing_id); |
| 62 | static ChildFrameCompositingHelper* CreateCompositingHelperForRenderFrame( |
| 63 | blink::WebFrame* frame, |
| 64 | RenderFrameImpl* render_frame, |
| 65 | int host_routing_id); |
| 66 | |
[email protected] | 73405fb | 2013-12-11 04:59:37 | [diff] [blame] | 67 | void CopyFromCompositingSurface(int request_id, |
| 68 | gfx::Rect source_rect, |
| 69 | gfx::Size dest_size); |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 70 | void DidCommitCompositorFrame(); |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 71 | void EnableCompositing(bool); |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 72 | void OnContainerDestroy(); |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 73 | void OnBuffersSwapped(const gfx::Size& size, |
[email protected] | 06666c0 | 2013-03-07 19:32:30 | [diff] [blame] | 74 | const std::string& mailbox_name, |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 75 | int gpu_route_id, |
[email protected] | 19fa81a0 | 2013-03-04 18:23:32 | [diff] [blame] | 76 | int gpu_host_id, |
| 77 | float device_scale_factor); |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 78 | void OnCompositorFrameSwapped(scoped_ptr<cc::CompositorFrame> frame, |
| 79 | int route_id, |
[email protected] | 53b4cc1 | 2013-07-18 23:02:30 | [diff] [blame] | 80 | uint32 output_surface_id, |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 81 | int host_id); |
[email protected] | 69b7912 | 2013-02-14 19:16:45 | [diff] [blame] | 82 | void UpdateVisibility(bool); |
[email protected] | f49722f | 2014-01-30 17:54:50 | [diff] [blame] | 83 | void ChildFrameGone(); |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 84 | |
| 85 | // cc::DelegatedFrameProviderClient implementation. |
| 86 | virtual void UnusedResourcesAreAvailable() OVERRIDE; |
[email protected] | 6d3a46e | 2013-11-25 23:08:53 | [diff] [blame] | 87 | void SetContentsOpaque(bool); |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 88 | |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 89 | protected: |
| 90 | // Friend RefCounted so that the dtor can be non-public. |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 91 | friend class base::RefCounted<ChildFrameCompositingHelper>; |
| 92 | |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 93 | private: |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 94 | ChildFrameCompositingHelper(blink::WebPluginContainer* container, |
| 95 | blink::WebFrame* frame, |
| 96 | BrowserPluginManager* manager, |
| 97 | RenderFrameImpl* render_frame, |
| 98 | int instance_id, |
| 99 | int host_routing_id); |
| 100 | |
[email protected] | 9f39c20 | 2013-06-18 16:06:42 | [diff] [blame] | 101 | enum SwapBuffersType { |
[email protected] | c049b2e | 2013-06-11 04:39:30 | [diff] [blame] | 102 | TEXTURE_IMAGE_TRANSPORT, |
[email protected] | 9f39c20 | 2013-06-18 16:06:42 | [diff] [blame] | 103 | GL_COMPOSITOR_FRAME, |
| 104 | SOFTWARE_COMPOSITOR_FRAME, |
[email protected] | c049b2e | 2013-06-11 04:39:30 | [diff] [blame] | 105 | }; |
[email protected] | 9f39c20 | 2013-06-18 16:06:42 | [diff] [blame] | 106 | struct SwapBuffersInfo { |
| 107 | SwapBuffersInfo(); |
| 108 | |
[email protected] | c049b2e | 2013-06-11 04:39:30 | [diff] [blame] | 109 | gpu::Mailbox name; |
[email protected] | 9f39c20 | 2013-06-18 16:06:42 | [diff] [blame] | 110 | SwapBuffersType type; |
[email protected] | c049b2e | 2013-06-11 04:39:30 | [diff] [blame] | 111 | gfx::Size size; |
| 112 | int route_id; |
[email protected] | 53b4cc1 | 2013-07-18 23:02:30 | [diff] [blame] | 113 | uint32 output_surface_id; |
[email protected] | c049b2e | 2013-06-11 04:39:30 | [diff] [blame] | 114 | int host_id; |
[email protected] | 9f39c20 | 2013-06-18 16:06:42 | [diff] [blame] | 115 | unsigned software_frame_id; |
| 116 | base::SharedMemory* shared_memory; |
[email protected] | c049b2e | 2013-06-11 04:39:30 | [diff] [blame] | 117 | }; |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 118 | virtual ~ChildFrameCompositingHelper(); |
| 119 | void SendCompositorFrameSwappedACKToBrowser( |
| 120 | FrameHostMsg_CompositorFrameSwappedACK_Params& params); |
| 121 | void SendBuffersSwappedACKToBrowser( |
| 122 | FrameHostMsg_BuffersSwappedACK_Params& params); |
| 123 | void SendReclaimCompositorResourcesToBrowser( |
| 124 | FrameHostMsg_ReclaimCompositorResources_Params& params); |
[email protected] | 6d3a46e | 2013-11-25 23:08:53 | [diff] [blame] | 125 | void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size, |
| 126 | float device_scale_factor, |
| 127 | cc::Layer* layer); |
[email protected] | 9f39c20 | 2013-06-18 16:06:42 | [diff] [blame] | 128 | void OnBuffersSwappedPrivate(const SwapBuffersInfo& mailbox, |
[email protected] | c049b2e | 2013-06-11 04:39:30 | [diff] [blame] | 129 | unsigned sync_point, |
| 130 | float device_scale_factor); |
[email protected] | 9f39c20 | 2013-06-18 16:06:42 | [diff] [blame] | 131 | void MailboxReleased(SwapBuffersInfo mailbox, |
[email protected] | 7ba3ca7 | 2013-04-11 06:37:25 | [diff] [blame] | 132 | unsigned sync_point, |
| 133 | bool lost_resource); |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 134 | void SendReturnedDelegatedResources(); |
[email protected] | 73405fb | 2013-12-11 04:59:37 | [diff] [blame] | 135 | void CopyFromCompositingSurfaceHasResult( |
| 136 | int request_id, |
| 137 | gfx::Size dest_size, |
| 138 | scoped_ptr<cc::CopyOutputResult> result); |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 139 | |
[email protected] | cc8ed21 | 2013-02-07 22:31:03 | [diff] [blame] | 140 | int instance_id_; |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 141 | int host_routing_id_; |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 142 | int last_route_id_; |
[email protected] | 53b4cc1 | 2013-07-18 23:02:30 | [diff] [blame] | 143 | uint32 last_output_surface_id_; |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 144 | int last_host_id_; |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 145 | bool last_mailbox_valid_; |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 146 | bool ack_pending_; |
[email protected] | 9afdaef | 2013-09-26 07:24:37 | [diff] [blame] | 147 | bool software_ack_pending_; |
[email protected] | 6d3a46e | 2013-11-25 23:08:53 | [diff] [blame] | 148 | bool opaque_; |
[email protected] | 9afdaef | 2013-09-26 07:24:37 | [diff] [blame] | 149 | std::vector<unsigned> unacked_software_frames_; |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 150 | |
[email protected] | c2bfe4e | 2013-01-16 01:10:20 | [diff] [blame] | 151 | gfx::Size buffer_size_; |
[email protected] | c2bfe4e | 2013-01-16 01:10:20 | [diff] [blame] | 152 | |
[email protected] | 09f6738 | 2013-10-09 21:03:45 | [diff] [blame] | 153 | scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_; |
| 154 | scoped_refptr<cc::DelegatedFrameProvider> frame_provider_; |
| 155 | |
[email protected] | 396fbb7 | 2013-01-23 02:33:43 | [diff] [blame] | 156 | scoped_refptr<cc::SolidColorLayer> background_layer_; |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 157 | scoped_refptr<cc::TextureLayer> texture_layer_; |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 158 | scoped_refptr<cc::DelegatedRendererLayer> delegated_layer_; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 159 | scoped_ptr<blink::WebLayer> web_layer_; |
| 160 | blink::WebPluginContainer* container_; |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 161 | blink::WebFrame* frame_; |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 162 | |
| 163 | scoped_refptr<BrowserPluginManager> browser_plugin_manager_; |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 164 | RenderFrameImpl* render_frame_; |
| 165 | |
| 166 | DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper); |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 167 | }; |
| 168 | |
| 169 | } // namespace content |
| 170 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 171 | #endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_ |