[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 | |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame^] | 8 | #include <stdint.h> |
| 9 | |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 10 | #include <string> |
[email protected] | 9afdaef | 2013-09-26 07:24:37 | [diff] [blame] | 11 | #include <vector> |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 12 | |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame^] | 13 | #include "base/macros.h" |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 14 | #include "base/memory/ref_counted.h" |
| 15 | #include "base/memory/scoped_ptr.h" |
[email protected] | f197008 | 2014-04-09 04:29:56 | [diff] [blame] | 16 | #include "base/memory/shared_memory.h" |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 17 | #include "cc/layers/delegated_frame_resource_collection.h" |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 18 | #include "content/common/content_export.h" |
tfarina | ebe974f0 | 2015-01-03 04:25:32 | [diff] [blame] | 19 | #include "ui/gfx/geometry/size.h" |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 20 | |
[email protected] | 9f39c20 | 2013-06-18 16:06:42 | [diff] [blame] | 21 | namespace base { |
| 22 | class SharedMemory; |
| 23 | } |
| 24 | |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 25 | namespace cc { |
kenrb | fc7c02c9 | 2015-05-29 22:20:58 | [diff] [blame] | 26 | struct SurfaceId; |
| 27 | struct SurfaceSequence; |
| 28 | |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 29 | class CompositorFrame; |
| 30 | class Layer; |
[email protected] | 396fbb7 | 2013-01-23 02:33:43 | [diff] [blame] | 31 | class SolidColorLayer; |
kenrb | fc7c02c9 | 2015-05-29 22:20:58 | [diff] [blame] | 32 | class SurfaceLayer; |
[email protected] | 09f6738 | 2013-10-09 21:03:45 | [diff] [blame] | 33 | class DelegatedFrameProvider; |
| 34 | class DelegatedFrameResourceCollection; |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 35 | class DelegatedRendererLayer; |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 36 | } |
| 37 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 38 | namespace blink { |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 39 | class WebFrame; |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 40 | class WebPluginContainer; |
| 41 | class WebLayer; |
| 42 | } |
| 43 | |
[email protected] | 73405fb | 2013-12-11 04:59:37 | [diff] [blame] | 44 | namespace gfx { |
| 45 | class Rect; |
| 46 | class Size; |
| 47 | } |
| 48 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 49 | struct FrameHostMsg_CompositorFrameSwappedACK_Params; |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 50 | struct FrameHostMsg_ReclaimCompositorResources_Params; |
| 51 | |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 52 | namespace content { |
| 53 | |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 54 | class BrowserPlugin; |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 55 | class BrowserPluginManager; |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 56 | class RenderFrameProxy; |
jbauman | 38c178eaa | 2015-06-04 04:24:54 | [diff] [blame] | 57 | class ThreadSafeSender; |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 58 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 59 | class CONTENT_EXPORT ChildFrameCompositingHelper |
| 60 | : public base::RefCounted<ChildFrameCompositingHelper>, |
| 61 | public cc::DelegatedFrameResourceCollectionClient { |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 62 | public: |
[email protected] | c092f5c | 2014-07-18 01:34:33 | [diff] [blame] | 63 | static ChildFrameCompositingHelper* CreateForBrowserPlugin( |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 64 | const base::WeakPtr<BrowserPlugin>& browser_plugin); |
[email protected] | c092f5c | 2014-07-18 01:34:33 | [diff] [blame] | 65 | static ChildFrameCompositingHelper* CreateForRenderFrameProxy( |
| 66 | RenderFrameProxy* render_frame_proxy); |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 67 | |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 68 | void DidCommitCompositorFrame(); |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 69 | void OnContainerDestroy(); |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 70 | void OnCompositorFrameSwapped(scoped_ptr<cc::CompositorFrame> frame, |
| 71 | int route_id, |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame^] | 72 | uint32_t output_surface_id, |
[email protected] | f197008 | 2014-04-09 04:29:56 | [diff] [blame] | 73 | int host_id, |
| 74 | base::SharedMemoryHandle handle); |
kenrb | fc7c02c9 | 2015-05-29 22:20:58 | [diff] [blame] | 75 | void OnSetSurface(const cc::SurfaceId& surface_id, |
| 76 | const gfx::Size& frame_size, |
| 77 | float scale_factor, |
| 78 | const cc::SurfaceSequence& sequence); |
[email protected] | 69b7912 | 2013-02-14 19:16:45 | [diff] [blame] | 79 | void UpdateVisibility(bool); |
[email protected] | f49722f | 2014-01-30 17:54:50 | [diff] [blame] | 80 | void ChildFrameGone(); |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 81 | |
| 82 | // cc::DelegatedFrameProviderClient implementation. |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 83 | void UnusedResourcesAreAvailable() override; |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 84 | |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 85 | protected: |
| 86 | // Friend RefCounted so that the dtor can be non-public. |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 87 | friend class base::RefCounted<ChildFrameCompositingHelper>; |
| 88 | |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 89 | private: |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 90 | ChildFrameCompositingHelper( |
| 91 | const base::WeakPtr<BrowserPlugin>& browser_plugin, |
| 92 | blink::WebFrame* frame, |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 93 | RenderFrameProxy* render_frame_proxy, |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 94 | int host_routing_id); |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 95 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 96 | virtual ~ChildFrameCompositingHelper(); |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 97 | |
| 98 | BrowserPluginManager* GetBrowserPluginManager(); |
| 99 | blink::WebPluginContainer* GetContainer(); |
| 100 | int GetInstanceID(); |
| 101 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 102 | void SendCompositorFrameSwappedACKToBrowser( |
| 103 | FrameHostMsg_CompositorFrameSwappedACK_Params& params); |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 104 | void SendReclaimCompositorResourcesToBrowser( |
| 105 | FrameHostMsg_ReclaimCompositorResources_Params& params); |
[email protected] | 6d3a46e | 2013-11-25 23:08:53 | [diff] [blame] | 106 | void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size, |
| 107 | float device_scale_factor, |
| 108 | cc::Layer* layer); |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 109 | void SendReturnedDelegatedResources(); |
jbauman | 38c178eaa | 2015-06-04 04:24:54 | [diff] [blame] | 110 | static void SatisfyCallback(scoped_refptr<ThreadSafeSender> sender, |
| 111 | int host_routing_id, |
kenrb | fc7c02c9 | 2015-05-29 22:20:58 | [diff] [blame] | 112 | cc::SurfaceSequence sequence); |
wjmaclean | 1e720d2f | 2015-07-14 16:09:52 | [diff] [blame] | 113 | static void SatisfyCallbackBrowserPlugin( |
| 114 | scoped_refptr<ThreadSafeSender> sender, |
| 115 | int host_routing_id, |
| 116 | int browser_plugin_instance_id, |
| 117 | cc::SurfaceSequence sequence); |
jbauman | 38c178eaa | 2015-06-04 04:24:54 | [diff] [blame] | 118 | static void RequireCallback(scoped_refptr<ThreadSafeSender> sender, |
| 119 | int host_routing_id, |
kenrb | fc7c02c9 | 2015-05-29 22:20:58 | [diff] [blame] | 120 | cc::SurfaceId id, |
| 121 | cc::SurfaceSequence sequence); |
wjmaclean | 53032adf | 2015-06-15 16:49:22 | [diff] [blame] | 122 | static void RequireCallbackBrowserPlugin( |
| 123 | scoped_refptr<ThreadSafeSender> sender, |
| 124 | int host_routing_id, |
| 125 | int browser_plugin_instance_id, |
| 126 | cc::SurfaceId id, |
| 127 | cc::SurfaceSequence sequence); |
lfg | fd437a27 | 2015-11-24 21:24:53 | [diff] [blame] | 128 | void UpdateWebLayer(blink::WebLayer* layer); |
kenrb | fc7c02c9 | 2015-05-29 22:20:58 | [diff] [blame] | 129 | |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 130 | int host_routing_id_; |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 131 | int last_route_id_; |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame^] | 132 | uint32_t last_output_surface_id_; |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 133 | int last_host_id_; |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 134 | bool ack_pending_; |
[email protected] | 6d3a46e | 2013-11-25 23:08:53 | [diff] [blame] | 135 | bool opaque_; |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 136 | |
[email protected] | c2bfe4e | 2013-01-16 01:10:20 | [diff] [blame] | 137 | gfx::Size buffer_size_; |
[email protected] | c2bfe4e | 2013-01-16 01:10:20 | [diff] [blame] | 138 | |
[email protected] | bdca9be2 | 2014-02-18 00:37:49 | [diff] [blame] | 139 | // The lifetime of this weak pointer should be greater than the lifetime of |
| 140 | // other member objects, as they may access this pointer during their |
| 141 | // destruction. |
| 142 | base::WeakPtr<BrowserPlugin> browser_plugin_; |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 143 | RenderFrameProxy* render_frame_proxy_; |
[email protected] | bdca9be2 | 2014-02-18 00:37:49 | [diff] [blame] | 144 | |
[email protected] | 09f6738 | 2013-10-09 21:03:45 | [diff] [blame] | 145 | scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_; |
| 146 | scoped_refptr<cc::DelegatedFrameProvider> frame_provider_; |
| 147 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 148 | scoped_ptr<blink::WebLayer> web_layer_; |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 149 | blink::WebFrame* frame_; |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 150 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 151 | DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper); |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 152 | }; |
| 153 | |
| 154 | } // namespace content |
| 155 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 156 | #endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_ |