blob: e6ef88f937e8746c0d68093deda4f135bd572c9c [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]0f21e8582013-01-11 11:06:5615#include "base/memory/ref_counted.h"
[email protected]f1970082014-04-09 04:29:5616#include "base/memory/shared_memory.h"
jbauman68a139e2016-02-09 05:07:2917#include "base/memory/weak_ptr.h"
lfge6119aac2016-01-27 02:14:3118#include "cc/surfaces/surface_id.h"
[email protected]0f21e8582013-01-11 11:06:5619#include "content/common/content_export.h"
tfarinaebe974f02015-01-03 04:25:3220#include "ui/gfx/geometry/size.h"
[email protected]0f21e8582013-01-11 11:06:5621
[email protected]9f39c202013-06-18 16:06:4222namespace base {
23class SharedMemory;
24}
25
[email protected]0f21e8582013-01-11 11:06:5626namespace cc {
kenrbfc7c02c92015-05-29 22:20:5827struct SurfaceSequence;
28
[email protected]f5b4b0f2013-04-02 18:16:2829class CompositorFrame;
30class Layer;
[email protected]396fbb72013-01-23 02:33:4331class SolidColorLayer;
kenrbfc7c02c92015-05-29 22:20:5832class SurfaceLayer;
[email protected]0f21e8582013-01-11 11:06:5633}
34
[email protected]180ef242013-11-07 06:50:4635namespace blink {
[email protected]bffc8302014-01-23 20:52:1636class WebFrame;
[email protected]0f21e8582013-01-11 11:06:5637class WebPluginContainer;
38class WebLayer;
39}
40
[email protected]73405fb2013-12-11 04:59:3741namespace gfx {
42class Rect;
43class Size;
44}
45
[email protected]bffc8302014-01-23 20:52:1646struct FrameHostMsg_CompositorFrameSwappedACK_Params;
[email protected]bffc8302014-01-23 20:52:1647struct FrameHostMsg_ReclaimCompositorResources_Params;
48
[email protected]0f21e8582013-01-11 11:06:5649namespace content {
50
[email protected]94224ba62014-02-04 00:25:2451class BrowserPlugin;
[email protected]0d25cb62013-01-21 15:42:2152class BrowserPluginManager;
[email protected]e3244ed2014-06-20 20:04:2753class RenderFrameProxy;
jbauman38c178eaa2015-06-04 04:24:5454class ThreadSafeSender;
[email protected]0d25cb62013-01-21 15:42:2155
[email protected]bffc8302014-01-23 20:52:1656class CONTENT_EXPORT ChildFrameCompositingHelper
jbauman42dd9fb2016-02-05 01:07:1057 : public base::RefCounted<ChildFrameCompositingHelper> {
[email protected]0f21e8582013-01-11 11:06:5658 public:
[email protected]c092f5c2014-07-18 01:34:3359 static ChildFrameCompositingHelper* CreateForBrowserPlugin(
[email protected]94224ba62014-02-04 00:25:2460 const base::WeakPtr<BrowserPlugin>& browser_plugin);
[email protected]c092f5c2014-07-18 01:34:3361 static ChildFrameCompositingHelper* CreateForRenderFrameProxy(
62 RenderFrameProxy* render_frame_proxy);
[email protected]bffc8302014-01-23 20:52:1663
[email protected]0d25cb62013-01-21 15:42:2164 void OnContainerDestroy();
kenrbfc7c02c92015-05-29 22:20:5865 void OnSetSurface(const cc::SurfaceId& surface_id,
66 const gfx::Size& frame_size,
67 float scale_factor,
68 const cc::SurfaceSequence& sequence);
[email protected]69b79122013-02-14 19:16:4569 void UpdateVisibility(bool);
[email protected]f49722f2014-01-30 17:54:5070 void ChildFrameGone();
[email protected]b0030b72013-11-15 20:35:5371
lfge6119aac2016-01-27 02:14:3172 cc::SurfaceId surface_id() const { return surface_id_; }
73
[email protected]0d25cb62013-01-21 15:42:2174 protected:
75 // Friend RefCounted so that the dtor can be non-public.
[email protected]bffc8302014-01-23 20:52:1676 friend class base::RefCounted<ChildFrameCompositingHelper>;
77
[email protected]0f21e8582013-01-11 11:06:5678 private:
[email protected]94224ba62014-02-04 00:25:2479 ChildFrameCompositingHelper(
80 const base::WeakPtr<BrowserPlugin>& browser_plugin,
81 blink::WebFrame* frame,
[email protected]e3244ed2014-06-20 20:04:2782 RenderFrameProxy* render_frame_proxy,
[email protected]94224ba62014-02-04 00:25:2483 int host_routing_id);
[email protected]bffc8302014-01-23 20:52:1684
[email protected]bffc8302014-01-23 20:52:1685 virtual ~ChildFrameCompositingHelper();
[email protected]94224ba62014-02-04 00:25:2486
[email protected]94224ba62014-02-04 00:25:2487 blink::WebPluginContainer* GetContainer();
[email protected]94224ba62014-02-04 00:25:2488
[email protected]6d3a46e2013-11-25 23:08:5389 void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size,
90 float device_scale_factor,
91 cc::Layer* layer);
jbauman38c178eaa2015-06-04 04:24:5492 static void SatisfyCallback(scoped_refptr<ThreadSafeSender> sender,
93 int host_routing_id,
xlai92e65342016-06-30 15:58:5794 const cc::SurfaceSequence& sequence);
wjmaclean1e720d2f2015-07-14 16:09:5295 static void SatisfyCallbackBrowserPlugin(
96 scoped_refptr<ThreadSafeSender> sender,
97 int host_routing_id,
98 int browser_plugin_instance_id,
xlai92e65342016-06-30 15:58:5799 const cc::SurfaceSequence& sequence);
jbauman38c178eaa2015-06-04 04:24:54100 static void RequireCallback(scoped_refptr<ThreadSafeSender> sender,
101 int host_routing_id,
xlai92e65342016-06-30 15:58:57102 const cc::SurfaceId& id,
103 const cc::SurfaceSequence& sequence);
wjmaclean53032adf2015-06-15 16:49:22104 static void RequireCallbackBrowserPlugin(
105 scoped_refptr<ThreadSafeSender> sender,
106 int host_routing_id,
107 int browser_plugin_instance_id,
xlai92e65342016-06-30 15:58:57108 const cc::SurfaceId& id,
109 const cc::SurfaceSequence& sequence);
vmpstre87ffcaa2016-08-23 21:01:14110 void UpdateWebLayer(std::unique_ptr<blink::WebLayer> layer);
kenrbfc7c02c92015-05-29 22:20:58111
[email protected]0f21e8582013-01-11 11:06:56112 int host_routing_id_;
[email protected]0f21e8582013-01-11 11:06:56113
[email protected]c2bfe4e2013-01-16 01:10:20114 gfx::Size buffer_size_;
[email protected]c2bfe4e2013-01-16 01:10:20115
[email protected]bdca9be22014-02-18 00:37:49116 // 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]e3244ed2014-06-20 20:04:27120 RenderFrameProxy* render_frame_proxy_;
[email protected]bdca9be22014-02-18 00:37:49121
dchengcedca5612016-04-09 01:40:15122 std::unique_ptr<blink::WebLayer> web_layer_;
lfge6119aac2016-01-27 02:14:31123 cc::SurfaceId surface_id_;
[email protected]bffc8302014-01-23 20:52:16124 blink::WebFrame* frame_;
[email protected]0d25cb62013-01-21 15:42:21125
[email protected]bffc8302014-01-23 20:52:16126 DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper);
[email protected]0f21e8582013-01-11 11:06:56127};
128
129} // namespace content
130
[email protected]bffc8302014-01-23 20:52:16131#endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_