[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] | f197008 | 2014-04-09 04:29:56 | [diff] [blame] | 13 | #include "base/memory/shared_memory.h" |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 14 | #include "cc/layers/delegated_frame_resource_collection.h" |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 15 | #include "content/common/content_export.h" |
| 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] | 09f6738 | 2013-10-09 21:03:45 | [diff] [blame] | 27 | class DelegatedFrameProvider; |
| 28 | class DelegatedFrameResourceCollection; |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 29 | class DelegatedRendererLayer; |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 30 | } |
| 31 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 32 | namespace blink { |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 33 | class WebFrame; |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 34 | class WebPluginContainer; |
| 35 | class WebLayer; |
| 36 | } |
| 37 | |
[email protected] | 73405fb | 2013-12-11 04:59:37 | [diff] [blame] | 38 | namespace gfx { |
| 39 | class Rect; |
| 40 | class Size; |
| 41 | } |
| 42 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 43 | struct FrameHostMsg_CompositorFrameSwappedACK_Params; |
| 44 | struct FrameHostMsg_BuffersSwappedACK_Params; |
| 45 | struct FrameHostMsg_ReclaimCompositorResources_Params; |
| 46 | |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 47 | namespace content { |
| 48 | |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 49 | class BrowserPlugin; |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 50 | class BrowserPluginManager; |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 51 | class RenderFrameProxy; |
[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] | c092f5c | 2014-07-18 01:34:33 | [diff] [blame] | 57 | static ChildFrameCompositingHelper* CreateForBrowserPlugin( |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 58 | const base::WeakPtr<BrowserPlugin>& browser_plugin); |
[email protected] | c092f5c | 2014-07-18 01:34:33 | [diff] [blame] | 59 | static ChildFrameCompositingHelper* CreateForRenderFrameProxy( |
| 60 | RenderFrameProxy* render_frame_proxy); |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 61 | |
[email protected] | 73405fb | 2013-12-11 04:59:37 | [diff] [blame] | 62 | void CopyFromCompositingSurface(int request_id, |
| 63 | gfx::Rect source_rect, |
| 64 | gfx::Size dest_size); |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 65 | void DidCommitCompositorFrame(); |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 66 | void EnableCompositing(bool); |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 67 | void OnContainerDestroy(); |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 68 | void OnCompositorFrameSwapped(scoped_ptr<cc::CompositorFrame> frame, |
| 69 | int route_id, |
[email protected] | 53b4cc1 | 2013-07-18 23:02:30 | [diff] [blame] | 70 | uint32 output_surface_id, |
[email protected] | f197008 | 2014-04-09 04:29:56 | [diff] [blame] | 71 | int host_id, |
| 72 | base::SharedMemoryHandle handle); |
[email protected] | 69b7912 | 2013-02-14 19:16:45 | [diff] [blame] | 73 | void UpdateVisibility(bool); |
[email protected] | f49722f | 2014-01-30 17:54:50 | [diff] [blame] | 74 | void ChildFrameGone(); |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 75 | |
| 76 | // cc::DelegatedFrameProviderClient implementation. |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame^] | 77 | void UnusedResourcesAreAvailable() override; |
[email protected] | 6d3a46e | 2013-11-25 23:08:53 | [diff] [blame] | 78 | void SetContentsOpaque(bool); |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 79 | |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 80 | protected: |
| 81 | // Friend RefCounted so that the dtor can be non-public. |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 82 | friend class base::RefCounted<ChildFrameCompositingHelper>; |
| 83 | |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 84 | private: |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 85 | ChildFrameCompositingHelper( |
| 86 | const base::WeakPtr<BrowserPlugin>& browser_plugin, |
| 87 | blink::WebFrame* frame, |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 88 | RenderFrameProxy* render_frame_proxy, |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 89 | int host_routing_id); |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 90 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 91 | virtual ~ChildFrameCompositingHelper(); |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 92 | |
| 93 | BrowserPluginManager* GetBrowserPluginManager(); |
| 94 | blink::WebPluginContainer* GetContainer(); |
| 95 | int GetInstanceID(); |
| 96 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 97 | void SendCompositorFrameSwappedACKToBrowser( |
| 98 | FrameHostMsg_CompositorFrameSwappedACK_Params& params); |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 99 | void SendReclaimCompositorResourcesToBrowser( |
| 100 | FrameHostMsg_ReclaimCompositorResources_Params& params); |
[email protected] | 6d3a46e | 2013-11-25 23:08:53 | [diff] [blame] | 101 | void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size, |
| 102 | float device_scale_factor, |
| 103 | cc::Layer* layer); |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 104 | void SendReturnedDelegatedResources(); |
[email protected] | 73405fb | 2013-12-11 04:59:37 | [diff] [blame] | 105 | void CopyFromCompositingSurfaceHasResult( |
| 106 | int request_id, |
| 107 | gfx::Size dest_size, |
| 108 | scoped_ptr<cc::CopyOutputResult> result); |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 109 | |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 110 | int host_routing_id_; |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 111 | int last_route_id_; |
[email protected] | 53b4cc1 | 2013-07-18 23:02:30 | [diff] [blame] | 112 | uint32 last_output_surface_id_; |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 113 | int last_host_id_; |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 114 | bool ack_pending_; |
[email protected] | 6d3a46e | 2013-11-25 23:08:53 | [diff] [blame] | 115 | bool opaque_; |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 116 | |
[email protected] | c2bfe4e | 2013-01-16 01:10:20 | [diff] [blame] | 117 | gfx::Size buffer_size_; |
[email protected] | c2bfe4e | 2013-01-16 01:10:20 | [diff] [blame] | 118 | |
[email protected] | bdca9be2 | 2014-02-18 00:37:49 | [diff] [blame] | 119 | // The lifetime of this weak pointer should be greater than the lifetime of |
| 120 | // other member objects, as they may access this pointer during their |
| 121 | // destruction. |
| 122 | base::WeakPtr<BrowserPlugin> browser_plugin_; |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 123 | RenderFrameProxy* render_frame_proxy_; |
[email protected] | bdca9be2 | 2014-02-18 00:37:49 | [diff] [blame] | 124 | |
[email protected] | 09f6738 | 2013-10-09 21:03:45 | [diff] [blame] | 125 | scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_; |
| 126 | scoped_refptr<cc::DelegatedFrameProvider> frame_provider_; |
| 127 | |
[email protected] | 396fbb7 | 2013-01-23 02:33:43 | [diff] [blame] | 128 | scoped_refptr<cc::SolidColorLayer> background_layer_; |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 129 | scoped_refptr<cc::DelegatedRendererLayer> delegated_layer_; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 130 | scoped_ptr<blink::WebLayer> web_layer_; |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 131 | blink::WebFrame* frame_; |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 132 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 133 | DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper); |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 134 | }; |
| 135 | |
| 136 | } // namespace content |
| 137 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 138 | #endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_ |