[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] | f197008 | 2014-04-09 04:29:56 | [diff] [blame] | 15 | #include "base/memory/shared_memory.h" |
jbauman | 68a139e | 2016-02-09 05:07:29 | [diff] [blame] | 16 | #include "base/memory/weak_ptr.h" |
Fady Samuel | 509c2d5 | 2017-08-28 19:00:58 | [diff] [blame] | 17 | #include "cc/layers/surface_layer.h" |
Fady Samuel | 644df1d | 2017-07-13 01:13:02 | [diff] [blame] | 18 | #include "components/viz/common/surfaces/surface_id.h" |
Fady Samuel | dbd4b02 | 2017-07-14 02:06:48 | [diff] [blame] | 19 | #include "components/viz/common/surfaces/surface_reference_factory.h" |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 20 | #include "content/common/content_export.h" |
tfarina | ebe974f0 | 2015-01-03 04:25:32 | [diff] [blame] | 21 | #include "ui/gfx/geometry/size.h" |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 22 | |
23 | namespace cc { | ||||
kenrb | fc7c02c9 | 2015-05-29 22:20:58 | [diff] [blame] | 24 | struct SurfaceSequence; |
25 | |||||
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 26 | class Layer; |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 27 | } |
28 | |||||
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 29 | namespace blink { |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 30 | class WebLayer; |
dcheng | 5cf54301 | 2016-11-24 17:13:37 | [diff] [blame] | 31 | class WebPluginContainer; |
32 | class WebRemoteFrame; | ||||
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 33 | } |
34 | |||||
[email protected] | 73405fb | 2013-12-11 04:59:37 | [diff] [blame] | 35 | namespace gfx { |
[email protected] | 73405fb | 2013-12-11 04:59:37 | [diff] [blame] | 36 | class Size; |
37 | } | ||||
38 | |||||
Fady Samuel | 1a21156e | 2017-07-13 04:57:29 | [diff] [blame] | 39 | namespace viz { |
40 | class SurfaceInfo; | ||||
41 | } | ||||
42 | |||||
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 43 | namespace content { |
44 | |||||
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 45 | class BrowserPlugin; |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 46 | class RenderFrameProxy; |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 47 | |
Ken Buchanan | e0b3819e | 2017-09-01 21:32:29 | [diff] [blame] | 48 | class CONTENT_EXPORT ChildFrameCompositingHelper { |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 49 | public: |
Ken Buchanan | e0b3819e | 2017-09-01 21:32:29 | [diff] [blame] | 50 | virtual ~ChildFrameCompositingHelper(); |
51 | |||||
[email protected] | c092f5c | 2014-07-18 01:34:33 | [diff] [blame] | 52 | static ChildFrameCompositingHelper* CreateForBrowserPlugin( |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 53 | const base::WeakPtr<BrowserPlugin>& browser_plugin); |
[email protected] | c092f5c | 2014-07-18 01:34:33 | [diff] [blame] | 54 | static ChildFrameCompositingHelper* CreateForRenderFrameProxy( |
55 | RenderFrameProxy* render_frame_proxy); | ||||
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 56 | |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 57 | void OnContainerDestroy(); |
Fady Samuel | 509c2d5 | 2017-08-28 19:00:58 | [diff] [blame] | 58 | void SetPrimarySurfaceInfo(const viz::SurfaceInfo& surface_info); |
59 | void SetFallbackSurfaceInfo(const viz::SurfaceInfo& surface_info, | ||||
60 | const viz::SurfaceSequence& sequence); | ||||
[email protected] | 69b7912 | 2013-02-14 19:16:45 | [diff] [blame] | 61 | void UpdateVisibility(bool); |
[email protected] | f49722f | 2014-01-30 17:54:50 | [diff] [blame] | 62 | void ChildFrameGone(); |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 63 | |
Fady Samuel | 509c2d5 | 2017-08-28 19:00:58 | [diff] [blame] | 64 | const viz::SurfaceId& surface_id() const { return last_primary_surface_id_; } |
lfg | e6119aac | 2016-01-27 02:14:31 | [diff] [blame] | 65 | |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 66 | protected: |
67 | // Friend RefCounted so that the dtor can be non-public. | ||||
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 68 | friend class base::RefCounted<ChildFrameCompositingHelper>; |
69 | |||||
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 70 | private: |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 71 | ChildFrameCompositingHelper( |
72 | const base::WeakPtr<BrowserPlugin>& browser_plugin, | ||||
dcheng | 5cf54301 | 2016-11-24 17:13:37 | [diff] [blame] | 73 | blink::WebRemoteFrame* frame, |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 74 | RenderFrameProxy* render_frame_proxy, |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 75 | int host_routing_id); |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 76 | |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 77 | blink::WebPluginContainer* GetContainer(); |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 78 | |
Fady Samuel | 509c2d5 | 2017-08-28 19:00:58 | [diff] [blame] | 79 | void CheckSizeAndAdjustLayerProperties(const viz::SurfaceInfo& surface_info, |
[email protected] | 6d3a46e | 2013-11-25 23:08:53 | [diff] [blame] | 80 | cc::Layer* layer); |
vmpstr | e87ffcaa | 2016-08-23 21:01:14 | [diff] [blame] | 81 | void UpdateWebLayer(std::unique_ptr<blink::WebLayer> layer); |
kenrb | fc7c02c9 | 2015-05-29 22:20:58 | [diff] [blame] | 82 | |
samans | 72b2a28 | 2016-12-17 02:44:15 | [diff] [blame] | 83 | const int host_routing_id_; |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 84 | |
Fady Samuel | 509c2d5 | 2017-08-28 19:00:58 | [diff] [blame] | 85 | viz::SurfaceId last_primary_surface_id_; |
86 | gfx::Size last_surface_size_in_pixels_; | ||||
[email protected] | c2bfe4e | 2013-01-16 01:10:20 | [diff] [blame] | 87 | |
Fady Samuel | 3ff277d | 2017-08-29 17:55:52 | [diff] [blame] | 88 | viz::SurfaceInfo fallback_surface_info_; |
89 | |||||
[email protected] | bdca9be2 | 2014-02-18 00:37:49 | [diff] [blame] | 90 | // The lifetime of this weak pointer should be greater than the lifetime of |
91 | // other member objects, as they may access this pointer during their | ||||
92 | // destruction. | ||||
samans | 72b2a28 | 2016-12-17 02:44:15 | [diff] [blame] | 93 | const base::WeakPtr<BrowserPlugin> browser_plugin_; |
94 | RenderFrameProxy* const render_frame_proxy_; | ||||
[email protected] | bdca9be2 | 2014-02-18 00:37:49 | [diff] [blame] | 95 | |
Fady Samuel | 509c2d5 | 2017-08-28 19:00:58 | [diff] [blame] | 96 | scoped_refptr<cc::SurfaceLayer> surface_layer_; |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 97 | std::unique_ptr<blink::WebLayer> web_layer_; |
dcheng | 5cf54301 | 2016-11-24 17:13:37 | [diff] [blame] | 98 | blink::WebRemoteFrame* frame_; |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 99 | |
kylechar | c1a739a | 2017-07-27 23:34:59 | [diff] [blame] | 100 | // If surface references are enabled use a stub reference factory. |
101 | // TODO(kylechar): Remove variable along with surface sequences. | ||||
102 | // See https://crbug.com/676384. | ||||
103 | bool enable_surface_references_; | ||||
104 | |||||
Fady Samuel | dbd4b02 | 2017-07-14 02:06:48 | [diff] [blame] | 105 | scoped_refptr<viz::SurfaceReferenceFactory> surface_reference_factory_; |
samans | 72b2a28 | 2016-12-17 02:44:15 | [diff] [blame] | 106 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 107 | DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper); |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 108 | }; |
109 | |||||
110 | } // namespace content | ||||
111 | |||||
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 112 | #endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_ |