blob: 77e17f08ed2322a218b581b555add2ab0faf96be [file] [log] [blame]
[email protected]bffc8302014-01-23 20:52:161// Copyright 2014 The Chromium Authors. All rights reserved.
[email protected]0f21e8582013-01-11 11:06:562// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]bffc8302014-01-23 20:52:165#ifndef CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_
6#define CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_
[email protected]0f21e8582013-01-11 11:06:567
avi1023d012015-12-25 02:39:148#include <stdint.h>
9
dchengcedca5612016-04-09 01:40:1510#include <memory>
[email protected]0f21e8582013-01-11 11:06:5611#include <string>
[email protected]9afdaef2013-09-26 07:24:3712#include <vector>
[email protected]0f21e8582013-01-11 11:06:5613
avi1023d012015-12-25 02:39:1414#include "base/macros.h"
[email protected]f1970082014-04-09 04:29:5615#include "base/memory/shared_memory.h"
jbauman68a139e2016-02-09 05:07:2916#include "base/memory/weak_ptr.h"
Fady Samuel509c2d52017-08-28 19:00:5817#include "cc/layers/surface_layer.h"
Fady Samuel644df1d2017-07-13 01:13:0218#include "components/viz/common/surfaces/surface_id.h"
Fady Samueldbd4b022017-07-14 02:06:4819#include "components/viz/common/surfaces/surface_reference_factory.h"
[email protected]0f21e8582013-01-11 11:06:5620#include "content/common/content_export.h"
tfarinaebe974f02015-01-03 04:25:3221#include "ui/gfx/geometry/size.h"
[email protected]0f21e8582013-01-11 11:06:5622
23namespace cc {
kenrbfc7c02c92015-05-29 22:20:5824struct SurfaceSequence;
25
[email protected]f5b4b0f2013-04-02 18:16:2826class Layer;
[email protected]0f21e8582013-01-11 11:06:5627}
28
[email protected]180ef242013-11-07 06:50:4629namespace blink {
[email protected]0f21e8582013-01-11 11:06:5630class WebLayer;
dcheng5cf543012016-11-24 17:13:3731class WebPluginContainer;
32class WebRemoteFrame;
[email protected]0f21e8582013-01-11 11:06:5633}
34
[email protected]73405fb2013-12-11 04:59:3735namespace gfx {
[email protected]73405fb2013-12-11 04:59:3736class Size;
37}
38
Fady Samuel1a21156e2017-07-13 04:57:2939namespace viz {
40class SurfaceInfo;
41}
42
[email protected]0f21e8582013-01-11 11:06:5643namespace content {
44
[email protected]94224ba62014-02-04 00:25:2445class BrowserPlugin;
[email protected]e3244ed2014-06-20 20:04:2746class RenderFrameProxy;
[email protected]0d25cb62013-01-21 15:42:2147
Ken Buchanane0b3819e2017-09-01 21:32:2948class CONTENT_EXPORT ChildFrameCompositingHelper {
[email protected]0f21e8582013-01-11 11:06:5649 public:
Ken Buchanane0b3819e2017-09-01 21:32:2950 virtual ~ChildFrameCompositingHelper();
51
[email protected]c092f5c2014-07-18 01:34:3352 static ChildFrameCompositingHelper* CreateForBrowserPlugin(
[email protected]94224ba62014-02-04 00:25:2453 const base::WeakPtr<BrowserPlugin>& browser_plugin);
[email protected]c092f5c2014-07-18 01:34:3354 static ChildFrameCompositingHelper* CreateForRenderFrameProxy(
55 RenderFrameProxy* render_frame_proxy);
[email protected]bffc8302014-01-23 20:52:1656
[email protected]0d25cb62013-01-21 15:42:2157 void OnContainerDestroy();
Fady Samuel509c2d52017-08-28 19:00:5858 void SetPrimarySurfaceInfo(const viz::SurfaceInfo& surface_info);
59 void SetFallbackSurfaceInfo(const viz::SurfaceInfo& surface_info,
60 const viz::SurfaceSequence& sequence);
[email protected]69b79122013-02-14 19:16:4561 void UpdateVisibility(bool);
[email protected]f49722f2014-01-30 17:54:5062 void ChildFrameGone();
[email protected]b0030b72013-11-15 20:35:5363
Fady Samuel509c2d52017-08-28 19:00:5864 const viz::SurfaceId& surface_id() const { return last_primary_surface_id_; }
lfge6119aac2016-01-27 02:14:3165
[email protected]0d25cb62013-01-21 15:42:2166 protected:
67 // Friend RefCounted so that the dtor can be non-public.
[email protected]bffc8302014-01-23 20:52:1668 friend class base::RefCounted<ChildFrameCompositingHelper>;
69
[email protected]0f21e8582013-01-11 11:06:5670 private:
[email protected]94224ba62014-02-04 00:25:2471 ChildFrameCompositingHelper(
72 const base::WeakPtr<BrowserPlugin>& browser_plugin,
dcheng5cf543012016-11-24 17:13:3773 blink::WebRemoteFrame* frame,
[email protected]e3244ed2014-06-20 20:04:2774 RenderFrameProxy* render_frame_proxy,
[email protected]94224ba62014-02-04 00:25:2475 int host_routing_id);
[email protected]bffc8302014-01-23 20:52:1676
[email protected]94224ba62014-02-04 00:25:2477 blink::WebPluginContainer* GetContainer();
[email protected]94224ba62014-02-04 00:25:2478
Fady Samuel509c2d52017-08-28 19:00:5879 void CheckSizeAndAdjustLayerProperties(const viz::SurfaceInfo& surface_info,
[email protected]6d3a46e2013-11-25 23:08:5380 cc::Layer* layer);
vmpstre87ffcaa2016-08-23 21:01:1481 void UpdateWebLayer(std::unique_ptr<blink::WebLayer> layer);
kenrbfc7c02c92015-05-29 22:20:5882
samans72b2a282016-12-17 02:44:1583 const int host_routing_id_;
[email protected]0f21e8582013-01-11 11:06:5684
Fady Samuel509c2d52017-08-28 19:00:5885 viz::SurfaceId last_primary_surface_id_;
86 gfx::Size last_surface_size_in_pixels_;
[email protected]c2bfe4e2013-01-16 01:10:2087
Fady Samuel3ff277d2017-08-29 17:55:5288 viz::SurfaceInfo fallback_surface_info_;
89
[email protected]bdca9be22014-02-18 00:37:4990 // 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.
samans72b2a282016-12-17 02:44:1593 const base::WeakPtr<BrowserPlugin> browser_plugin_;
94 RenderFrameProxy* const render_frame_proxy_;
[email protected]bdca9be22014-02-18 00:37:4995
Fady Samuel509c2d52017-08-28 19:00:5896 scoped_refptr<cc::SurfaceLayer> surface_layer_;
dchengcedca5612016-04-09 01:40:1597 std::unique_ptr<blink::WebLayer> web_layer_;
dcheng5cf543012016-11-24 17:13:3798 blink::WebRemoteFrame* frame_;
[email protected]0d25cb62013-01-21 15:42:2199
kylecharc1a739a2017-07-27 23:34:59100 // 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 Samueldbd4b022017-07-14 02:06:48105 scoped_refptr<viz::SurfaceReferenceFactory> surface_reference_factory_;
samans72b2a282016-12-17 02:44:15106
[email protected]bffc8302014-01-23 20:52:16107 DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper);
[email protected]0f21e8582013-01-11 11:06:56108};
109
110} // namespace content
111
[email protected]bffc8302014-01-23 20:52:16112#endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_