blob: 707955cafa8b7ef7cc15f3241f040e3fb25bd0ad [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
[email protected]0f21e8582013-01-11 11:06:5610#include <string>
[email protected]9afdaef2013-09-26 07:24:3711#include <vector>
[email protected]0f21e8582013-01-11 11:06:5612
avi1023d012015-12-25 02:39:1413#include "base/macros.h"
[email protected]0f21e8582013-01-11 11:06:5614#include "base/memory/ref_counted.h"
15#include "base/memory/scoped_ptr.h"
[email protected]f1970082014-04-09 04:29:5616#include "base/memory/shared_memory.h"
[email protected]b0030b72013-11-15 20:35:5317#include "cc/layers/delegated_frame_resource_collection.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]09f67382013-10-09 21:03:4533class DelegatedFrameProvider;
34class DelegatedFrameResourceCollection;
[email protected]f5b4b0f2013-04-02 18:16:2835class DelegatedRendererLayer;
[email protected]0f21e8582013-01-11 11:06:5636}
37
[email protected]180ef242013-11-07 06:50:4638namespace blink {
[email protected]bffc8302014-01-23 20:52:1639class WebFrame;
[email protected]0f21e8582013-01-11 11:06:5640class WebPluginContainer;
41class WebLayer;
42}
43
[email protected]73405fb2013-12-11 04:59:3744namespace gfx {
45class Rect;
46class Size;
47}
48
[email protected]bffc8302014-01-23 20:52:1649struct FrameHostMsg_CompositorFrameSwappedACK_Params;
[email protected]bffc8302014-01-23 20:52:1650struct FrameHostMsg_ReclaimCompositorResources_Params;
51
[email protected]0f21e8582013-01-11 11:06:5652namespace content {
53
[email protected]94224ba62014-02-04 00:25:2454class BrowserPlugin;
[email protected]0d25cb62013-01-21 15:42:2155class BrowserPluginManager;
[email protected]e3244ed2014-06-20 20:04:2756class RenderFrameProxy;
jbauman38c178eaa2015-06-04 04:24:5457class ThreadSafeSender;
[email protected]0d25cb62013-01-21 15:42:2158
[email protected]bffc8302014-01-23 20:52:1659class CONTENT_EXPORT ChildFrameCompositingHelper
60 : public base::RefCounted<ChildFrameCompositingHelper>,
61 public cc::DelegatedFrameResourceCollectionClient {
[email protected]0f21e8582013-01-11 11:06:5662 public:
[email protected]c092f5c2014-07-18 01:34:3363 static ChildFrameCompositingHelper* CreateForBrowserPlugin(
[email protected]94224ba62014-02-04 00:25:2464 const base::WeakPtr<BrowserPlugin>& browser_plugin);
[email protected]c092f5c2014-07-18 01:34:3365 static ChildFrameCompositingHelper* CreateForRenderFrameProxy(
66 RenderFrameProxy* render_frame_proxy);
[email protected]bffc8302014-01-23 20:52:1667
[email protected]f5b4b0f2013-04-02 18:16:2868 void DidCommitCompositorFrame();
[email protected]0d25cb62013-01-21 15:42:2169 void OnContainerDestroy();
[email protected]f5b4b0f2013-04-02 18:16:2870 void OnCompositorFrameSwapped(scoped_ptr<cc::CompositorFrame> frame,
71 int route_id,
avi1023d012015-12-25 02:39:1472 uint32_t output_surface_id,
[email protected]f1970082014-04-09 04:29:5673 int host_id,
74 base::SharedMemoryHandle handle);
kenrbfc7c02c92015-05-29 22:20:5875 void OnSetSurface(const cc::SurfaceId& surface_id,
76 const gfx::Size& frame_size,
77 float scale_factor,
78 const cc::SurfaceSequence& sequence);
[email protected]69b79122013-02-14 19:16:4579 void UpdateVisibility(bool);
[email protected]f49722f2014-01-30 17:54:5080 void ChildFrameGone();
[email protected]b0030b72013-11-15 20:35:5381
lfge6119aac2016-01-27 02:14:3182 cc::SurfaceId surface_id() const { return surface_id_; }
83
[email protected]b0030b72013-11-15 20:35:5384 // cc::DelegatedFrameProviderClient implementation.
dcheng6d18e402014-10-21 12:32:5285 void UnusedResourcesAreAvailable() override;
[email protected]b0030b72013-11-15 20:35:5386
[email protected]0d25cb62013-01-21 15:42:2187 protected:
88 // Friend RefCounted so that the dtor can be non-public.
[email protected]bffc8302014-01-23 20:52:1689 friend class base::RefCounted<ChildFrameCompositingHelper>;
90
[email protected]0f21e8582013-01-11 11:06:5691 private:
[email protected]94224ba62014-02-04 00:25:2492 ChildFrameCompositingHelper(
93 const base::WeakPtr<BrowserPlugin>& browser_plugin,
94 blink::WebFrame* frame,
[email protected]e3244ed2014-06-20 20:04:2795 RenderFrameProxy* render_frame_proxy,
[email protected]94224ba62014-02-04 00:25:2496 int host_routing_id);
[email protected]bffc8302014-01-23 20:52:1697
[email protected]bffc8302014-01-23 20:52:1698 virtual ~ChildFrameCompositingHelper();
[email protected]94224ba62014-02-04 00:25:2499
100 BrowserPluginManager* GetBrowserPluginManager();
101 blink::WebPluginContainer* GetContainer();
102 int GetInstanceID();
103
[email protected]bffc8302014-01-23 20:52:16104 void SendCompositorFrameSwappedACKToBrowser(
105 FrameHostMsg_CompositorFrameSwappedACK_Params& params);
[email protected]bffc8302014-01-23 20:52:16106 void SendReclaimCompositorResourcesToBrowser(
107 FrameHostMsg_ReclaimCompositorResources_Params& params);
[email protected]6d3a46e2013-11-25 23:08:53108 void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size,
109 float device_scale_factor,
110 cc::Layer* layer);
[email protected]b0030b72013-11-15 20:35:53111 void SendReturnedDelegatedResources();
jbauman38c178eaa2015-06-04 04:24:54112 static void SatisfyCallback(scoped_refptr<ThreadSafeSender> sender,
113 int host_routing_id,
kenrbfc7c02c92015-05-29 22:20:58114 cc::SurfaceSequence sequence);
wjmaclean1e720d2f2015-07-14 16:09:52115 static void SatisfyCallbackBrowserPlugin(
116 scoped_refptr<ThreadSafeSender> sender,
117 int host_routing_id,
118 int browser_plugin_instance_id,
119 cc::SurfaceSequence sequence);
jbauman38c178eaa2015-06-04 04:24:54120 static void RequireCallback(scoped_refptr<ThreadSafeSender> sender,
121 int host_routing_id,
kenrbfc7c02c92015-05-29 22:20:58122 cc::SurfaceId id,
123 cc::SurfaceSequence sequence);
wjmaclean53032adf2015-06-15 16:49:22124 static void RequireCallbackBrowserPlugin(
125 scoped_refptr<ThreadSafeSender> sender,
126 int host_routing_id,
127 int browser_plugin_instance_id,
128 cc::SurfaceId id,
129 cc::SurfaceSequence sequence);
lfgfd437a272015-11-24 21:24:53130 void UpdateWebLayer(blink::WebLayer* layer);
kenrbfc7c02c92015-05-29 22:20:58131
[email protected]0f21e8582013-01-11 11:06:56132 int host_routing_id_;
[email protected]f5b4b0f2013-04-02 18:16:28133 int last_route_id_;
avi1023d012015-12-25 02:39:14134 uint32_t last_output_surface_id_;
[email protected]f5b4b0f2013-04-02 18:16:28135 int last_host_id_;
[email protected]0d25cb62013-01-21 15:42:21136 bool ack_pending_;
[email protected]6d3a46e2013-11-25 23:08:53137 bool opaque_;
[email protected]0f21e8582013-01-11 11:06:56138
[email protected]c2bfe4e2013-01-16 01:10:20139 gfx::Size buffer_size_;
[email protected]c2bfe4e2013-01-16 01:10:20140
[email protected]bdca9be22014-02-18 00:37:49141 // The lifetime of this weak pointer should be greater than the lifetime of
142 // other member objects, as they may access this pointer during their
143 // destruction.
144 base::WeakPtr<BrowserPlugin> browser_plugin_;
[email protected]e3244ed2014-06-20 20:04:27145 RenderFrameProxy* render_frame_proxy_;
[email protected]bdca9be22014-02-18 00:37:49146
[email protected]09f67382013-10-09 21:03:45147 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_;
148 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_;
149
[email protected]180ef242013-11-07 06:50:46150 scoped_ptr<blink::WebLayer> web_layer_;
lfge6119aac2016-01-27 02:14:31151 cc::SurfaceId surface_id_;
[email protected]bffc8302014-01-23 20:52:16152 blink::WebFrame* frame_;
[email protected]0d25cb62013-01-21 15:42:21153
[email protected]bffc8302014-01-23 20:52:16154 DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper);
[email protected]0f21e8582013-01-11 11:06:56155};
156
157} // namespace content
158
[email protected]bffc8302014-01-23 20:52:16159#endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_