blob: d2d4e78cda2510a40c87334415d1d23c5db862c5 [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"
[email protected]0f21e8582013-01-11 11:06:5618#include "content/common/content_export.h"
tfarinaebe974f02015-01-03 04:25:3219#include "ui/gfx/geometry/size.h"
[email protected]0f21e8582013-01-11 11:06:5620
[email protected]9f39c202013-06-18 16:06:4221namespace base {
22class SharedMemory;
23}
24
[email protected]0f21e8582013-01-11 11:06:5625namespace cc {
kenrbfc7c02c92015-05-29 22:20:5826struct SurfaceId;
27struct 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
82 // cc::DelegatedFrameProviderClient implementation.
dcheng6d18e402014-10-21 12:32:5283 void UnusedResourcesAreAvailable() override;
[email protected]b0030b72013-11-15 20:35:5384
[email protected]0d25cb62013-01-21 15:42:2185 protected:
86 // Friend RefCounted so that the dtor can be non-public.
[email protected]bffc8302014-01-23 20:52:1687 friend class base::RefCounted<ChildFrameCompositingHelper>;
88
[email protected]0f21e8582013-01-11 11:06:5689 private:
[email protected]94224ba62014-02-04 00:25:2490 ChildFrameCompositingHelper(
91 const base::WeakPtr<BrowserPlugin>& browser_plugin,
92 blink::WebFrame* frame,
[email protected]e3244ed2014-06-20 20:04:2793 RenderFrameProxy* render_frame_proxy,
[email protected]94224ba62014-02-04 00:25:2494 int host_routing_id);
[email protected]bffc8302014-01-23 20:52:1695
[email protected]bffc8302014-01-23 20:52:1696 virtual ~ChildFrameCompositingHelper();
[email protected]94224ba62014-02-04 00:25:2497
98 BrowserPluginManager* GetBrowserPluginManager();
99 blink::WebPluginContainer* GetContainer();
100 int GetInstanceID();
101
[email protected]bffc8302014-01-23 20:52:16102 void SendCompositorFrameSwappedACKToBrowser(
103 FrameHostMsg_CompositorFrameSwappedACK_Params& params);
[email protected]bffc8302014-01-23 20:52:16104 void SendReclaimCompositorResourcesToBrowser(
105 FrameHostMsg_ReclaimCompositorResources_Params& params);
[email protected]6d3a46e2013-11-25 23:08:53106 void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size,
107 float device_scale_factor,
108 cc::Layer* layer);
[email protected]b0030b72013-11-15 20:35:53109 void SendReturnedDelegatedResources();
jbauman38c178eaa2015-06-04 04:24:54110 static void SatisfyCallback(scoped_refptr<ThreadSafeSender> sender,
111 int host_routing_id,
kenrbfc7c02c92015-05-29 22:20:58112 cc::SurfaceSequence sequence);
wjmaclean1e720d2f2015-07-14 16:09:52113 static void SatisfyCallbackBrowserPlugin(
114 scoped_refptr<ThreadSafeSender> sender,
115 int host_routing_id,
116 int browser_plugin_instance_id,
117 cc::SurfaceSequence sequence);
jbauman38c178eaa2015-06-04 04:24:54118 static void RequireCallback(scoped_refptr<ThreadSafeSender> sender,
119 int host_routing_id,
kenrbfc7c02c92015-05-29 22:20:58120 cc::SurfaceId id,
121 cc::SurfaceSequence sequence);
wjmaclean53032adf2015-06-15 16:49:22122 static void RequireCallbackBrowserPlugin(
123 scoped_refptr<ThreadSafeSender> sender,
124 int host_routing_id,
125 int browser_plugin_instance_id,
126 cc::SurfaceId id,
127 cc::SurfaceSequence sequence);
lfgfd437a272015-11-24 21:24:53128 void UpdateWebLayer(blink::WebLayer* layer);
kenrbfc7c02c92015-05-29 22:20:58129
[email protected]0f21e8582013-01-11 11:06:56130 int host_routing_id_;
[email protected]f5b4b0f2013-04-02 18:16:28131 int last_route_id_;
avi1023d012015-12-25 02:39:14132 uint32_t last_output_surface_id_;
[email protected]f5b4b0f2013-04-02 18:16:28133 int last_host_id_;
[email protected]0d25cb62013-01-21 15:42:21134 bool ack_pending_;
[email protected]6d3a46e2013-11-25 23:08:53135 bool opaque_;
[email protected]0f21e8582013-01-11 11:06:56136
[email protected]c2bfe4e2013-01-16 01:10:20137 gfx::Size buffer_size_;
[email protected]c2bfe4e2013-01-16 01:10:20138
[email protected]bdca9be22014-02-18 00:37:49139 // The lifetime of this weak pointer should be greater than the lifetime of
140 // other member objects, as they may access this pointer during their
141 // destruction.
142 base::WeakPtr<BrowserPlugin> browser_plugin_;
[email protected]e3244ed2014-06-20 20:04:27143 RenderFrameProxy* render_frame_proxy_;
[email protected]bdca9be22014-02-18 00:37:49144
[email protected]09f67382013-10-09 21:03:45145 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_;
146 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_;
147
[email protected]180ef242013-11-07 06:50:46148 scoped_ptr<blink::WebLayer> web_layer_;
[email protected]bffc8302014-01-23 20:52:16149 blink::WebFrame* frame_;
[email protected]0d25cb62013-01-21 15:42:21150
[email protected]bffc8302014-01-23 20:52:16151 DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper);
[email protected]0f21e8582013-01-11 11:06:56152};
153
154} // namespace content
155
[email protected]bffc8302014-01-23 20:52:16156#endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_