[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 | |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 10 | #include <memory> |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 11 | #include <string> |
[email protected] | 9afdaef | 2013-09-26 07:24:37 | [diff] [blame] | 12 | #include <vector> |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 13 | |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 14 | #include "base/macros.h" |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 15 | #include "base/memory/ref_counted.h" |
[email protected] | f197008 | 2014-04-09 04:29:56 | [diff] [blame] | 16 | #include "base/memory/shared_memory.h" |
jbauman | 68a139e | 2016-02-09 05:07:29 | [diff] [blame] | 17 | #include "base/memory/weak_ptr.h" |
lfg | e6119aac | 2016-01-27 02:14:31 | [diff] [blame] | 18 | #include "cc/surfaces/surface_id.h" |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 19 | #include "content/common/content_export.h" |
tfarina | ebe974f0 | 2015-01-03 04:25:32 | [diff] [blame] | 20 | #include "ui/gfx/geometry/size.h" |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 21 | |
[email protected] | 9f39c20 | 2013-06-18 16:06:42 | [diff] [blame] | 22 | namespace base { |
| 23 | class SharedMemory; |
| 24 | } |
| 25 | |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 26 | namespace cc { |
kenrb | fc7c02c9 | 2015-05-29 22:20:58 | [diff] [blame] | 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] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 33 | } |
| 34 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 35 | namespace blink { |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 36 | class WebFrame; |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 37 | class WebPluginContainer; |
| 38 | class WebLayer; |
| 39 | } |
| 40 | |
[email protected] | 73405fb | 2013-12-11 04:59:37 | [diff] [blame] | 41 | namespace gfx { |
| 42 | class Rect; |
| 43 | class Size; |
| 44 | } |
| 45 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 46 | struct FrameHostMsg_CompositorFrameSwappedACK_Params; |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 47 | struct FrameHostMsg_ReclaimCompositorResources_Params; |
| 48 | |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 49 | namespace content { |
| 50 | |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 51 | class BrowserPlugin; |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 52 | class BrowserPluginManager; |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 53 | class RenderFrameProxy; |
jbauman | 38c178eaa | 2015-06-04 04:24:54 | [diff] [blame] | 54 | class ThreadSafeSender; |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 55 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 56 | class CONTENT_EXPORT ChildFrameCompositingHelper |
jbauman | 42dd9fb | 2016-02-05 01:07:10 | [diff] [blame] | 57 | : public base::RefCounted<ChildFrameCompositingHelper> { |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 58 | public: |
[email protected] | c092f5c | 2014-07-18 01:34:33 | [diff] [blame] | 59 | static ChildFrameCompositingHelper* CreateForBrowserPlugin( |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 60 | const base::WeakPtr<BrowserPlugin>& browser_plugin); |
[email protected] | c092f5c | 2014-07-18 01:34:33 | [diff] [blame] | 61 | static ChildFrameCompositingHelper* CreateForRenderFrameProxy( |
| 62 | RenderFrameProxy* render_frame_proxy); |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 63 | |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 64 | void OnContainerDestroy(); |
kenrb | fc7c02c9 | 2015-05-29 22:20:58 | [diff] [blame] | 65 | void OnSetSurface(const cc::SurfaceId& surface_id, |
| 66 | const gfx::Size& frame_size, |
| 67 | float scale_factor, |
| 68 | const cc::SurfaceSequence& sequence); |
[email protected] | 69b7912 | 2013-02-14 19:16:45 | [diff] [blame] | 69 | void UpdateVisibility(bool); |
[email protected] | f49722f | 2014-01-30 17:54:50 | [diff] [blame] | 70 | void ChildFrameGone(); |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 71 | |
lfg | e6119aac | 2016-01-27 02:14:31 | [diff] [blame] | 72 | cc::SurfaceId surface_id() const { return surface_id_; } |
| 73 | |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 74 | protected: |
| 75 | // Friend RefCounted so that the dtor can be non-public. |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 76 | friend class base::RefCounted<ChildFrameCompositingHelper>; |
| 77 | |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 78 | private: |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 79 | ChildFrameCompositingHelper( |
| 80 | const base::WeakPtr<BrowserPlugin>& browser_plugin, |
| 81 | blink::WebFrame* frame, |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 82 | RenderFrameProxy* render_frame_proxy, |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 83 | int host_routing_id); |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 84 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 85 | virtual ~ChildFrameCompositingHelper(); |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 86 | |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 87 | blink::WebPluginContainer* GetContainer(); |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 88 | |
[email protected] | 6d3a46e | 2013-11-25 23:08:53 | [diff] [blame] | 89 | void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size, |
| 90 | float device_scale_factor, |
| 91 | cc::Layer* layer); |
jbauman | 38c178eaa | 2015-06-04 04:24:54 | [diff] [blame] | 92 | static void SatisfyCallback(scoped_refptr<ThreadSafeSender> sender, |
| 93 | int host_routing_id, |
xlai | 92e6534 | 2016-06-30 15:58:57 | [diff] [blame] | 94 | const cc::SurfaceSequence& sequence); |
wjmaclean | 1e720d2f | 2015-07-14 16:09:52 | [diff] [blame] | 95 | static void SatisfyCallbackBrowserPlugin( |
| 96 | scoped_refptr<ThreadSafeSender> sender, |
| 97 | int host_routing_id, |
| 98 | int browser_plugin_instance_id, |
xlai | 92e6534 | 2016-06-30 15:58:57 | [diff] [blame] | 99 | const cc::SurfaceSequence& sequence); |
jbauman | 38c178eaa | 2015-06-04 04:24:54 | [diff] [blame] | 100 | static void RequireCallback(scoped_refptr<ThreadSafeSender> sender, |
| 101 | int host_routing_id, |
xlai | 92e6534 | 2016-06-30 15:58:57 | [diff] [blame] | 102 | const cc::SurfaceId& id, |
| 103 | const cc::SurfaceSequence& sequence); |
wjmaclean | 53032adf | 2015-06-15 16:49:22 | [diff] [blame] | 104 | static void RequireCallbackBrowserPlugin( |
| 105 | scoped_refptr<ThreadSafeSender> sender, |
| 106 | int host_routing_id, |
| 107 | int browser_plugin_instance_id, |
xlai | 92e6534 | 2016-06-30 15:58:57 | [diff] [blame] | 108 | const cc::SurfaceId& id, |
| 109 | const cc::SurfaceSequence& sequence); |
vmpstr | e87ffcaa | 2016-08-23 21:01:14 | [diff] [blame^] | 110 | void UpdateWebLayer(std::unique_ptr<blink::WebLayer> layer); |
kenrb | fc7c02c9 | 2015-05-29 22:20:58 | [diff] [blame] | 111 | |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 112 | int host_routing_id_; |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 113 | |
[email protected] | c2bfe4e | 2013-01-16 01:10:20 | [diff] [blame] | 114 | gfx::Size buffer_size_; |
[email protected] | c2bfe4e | 2013-01-16 01:10:20 | [diff] [blame] | 115 | |
[email protected] | bdca9be2 | 2014-02-18 00:37:49 | [diff] [blame] | 116 | // The lifetime of this weak pointer should be greater than the lifetime of |
| 117 | // other member objects, as they may access this pointer during their |
| 118 | // destruction. |
| 119 | base::WeakPtr<BrowserPlugin> browser_plugin_; |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 120 | RenderFrameProxy* render_frame_proxy_; |
[email protected] | bdca9be2 | 2014-02-18 00:37:49 | [diff] [blame] | 121 | |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 122 | std::unique_ptr<blink::WebLayer> web_layer_; |
lfg | e6119aac | 2016-01-27 02:14:31 | [diff] [blame] | 123 | cc::SurfaceId surface_id_; |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 124 | blink::WebFrame* frame_; |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 125 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 126 | DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper); |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 127 | }; |
| 128 | |
| 129 | } // namespace content |
| 130 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 131 | #endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_ |