blob: 1f26c9fffe8e0a914a14d8663f0be4856b0053f6 [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
8#include <string>
[email protected]9afdaef2013-09-26 07:24:379#include <vector>
[email protected]0f21e8582013-01-11 11:06:5610
11#include "base/memory/ref_counted.h"
12#include "base/memory/scoped_ptr.h"
[email protected]f1970082014-04-09 04:29:5613#include "base/memory/shared_memory.h"
[email protected]b0030b72013-11-15 20:35:5314#include "cc/layers/delegated_frame_resource_collection.h"
[email protected]0f21e8582013-01-11 11:06:5615#include "content/common/content_export.h"
tfarinaebe974f02015-01-03 04:25:3216#include "ui/gfx/geometry/size.h"
[email protected]0f21e8582013-01-11 11:06:5617
[email protected]9f39c202013-06-18 16:06:4218namespace base {
19class SharedMemory;
20}
21
[email protected]0f21e8582013-01-11 11:06:5622namespace cc {
kenrbfc7c02c92015-05-29 22:20:5823struct SurfaceId;
24struct SurfaceSequence;
25
[email protected]f5b4b0f2013-04-02 18:16:2826class CompositorFrame;
27class Layer;
[email protected]396fbb72013-01-23 02:33:4328class SolidColorLayer;
kenrbfc7c02c92015-05-29 22:20:5829class SurfaceLayer;
[email protected]09f67382013-10-09 21:03:4530class DelegatedFrameProvider;
31class DelegatedFrameResourceCollection;
[email protected]f5b4b0f2013-04-02 18:16:2832class DelegatedRendererLayer;
[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
57 : public base::RefCounted<ChildFrameCompositingHelper>,
58 public cc::DelegatedFrameResourceCollectionClient {
[email protected]0f21e8582013-01-11 11:06:5659 public:
[email protected]c092f5c2014-07-18 01:34:3360 static ChildFrameCompositingHelper* CreateForBrowserPlugin(
[email protected]94224ba62014-02-04 00:25:2461 const base::WeakPtr<BrowserPlugin>& browser_plugin);
[email protected]c092f5c2014-07-18 01:34:3362 static ChildFrameCompositingHelper* CreateForRenderFrameProxy(
63 RenderFrameProxy* render_frame_proxy);
[email protected]bffc8302014-01-23 20:52:1664
[email protected]f5b4b0f2013-04-02 18:16:2865 void DidCommitCompositorFrame();
[email protected]0d25cb62013-01-21 15:42:2166 void OnContainerDestroy();
[email protected]f5b4b0f2013-04-02 18:16:2867 void OnCompositorFrameSwapped(scoped_ptr<cc::CompositorFrame> frame,
68 int route_id,
[email protected]53b4cc12013-07-18 23:02:3069 uint32 output_surface_id,
[email protected]f1970082014-04-09 04:29:5670 int host_id,
71 base::SharedMemoryHandle handle);
kenrbfc7c02c92015-05-29 22:20:5872 void OnSetSurface(const cc::SurfaceId& surface_id,
73 const gfx::Size& frame_size,
74 float scale_factor,
75 const cc::SurfaceSequence& sequence);
[email protected]69b79122013-02-14 19:16:4576 void UpdateVisibility(bool);
[email protected]f49722f2014-01-30 17:54:5077 void ChildFrameGone();
[email protected]b0030b72013-11-15 20:35:5378
79 // cc::DelegatedFrameProviderClient implementation.
dcheng6d18e402014-10-21 12:32:5280 void UnusedResourcesAreAvailable() override;
[email protected]b0030b72013-11-15 20:35:5381
[email protected]0d25cb62013-01-21 15:42:2182 protected:
83 // Friend RefCounted so that the dtor can be non-public.
[email protected]bffc8302014-01-23 20:52:1684 friend class base::RefCounted<ChildFrameCompositingHelper>;
85
[email protected]0f21e8582013-01-11 11:06:5686 private:
[email protected]94224ba62014-02-04 00:25:2487 ChildFrameCompositingHelper(
88 const base::WeakPtr<BrowserPlugin>& browser_plugin,
89 blink::WebFrame* frame,
[email protected]e3244ed2014-06-20 20:04:2790 RenderFrameProxy* render_frame_proxy,
[email protected]94224ba62014-02-04 00:25:2491 int host_routing_id);
[email protected]bffc8302014-01-23 20:52:1692
[email protected]bffc8302014-01-23 20:52:1693 virtual ~ChildFrameCompositingHelper();
[email protected]94224ba62014-02-04 00:25:2494
95 BrowserPluginManager* GetBrowserPluginManager();
96 blink::WebPluginContainer* GetContainer();
97 int GetInstanceID();
98
[email protected]bffc8302014-01-23 20:52:1699 void SendCompositorFrameSwappedACKToBrowser(
100 FrameHostMsg_CompositorFrameSwappedACK_Params& params);
[email protected]bffc8302014-01-23 20:52:16101 void SendReclaimCompositorResourcesToBrowser(
102 FrameHostMsg_ReclaimCompositorResources_Params& params);
[email protected]6d3a46e2013-11-25 23:08:53103 void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size,
104 float device_scale_factor,
105 cc::Layer* layer);
[email protected]b0030b72013-11-15 20:35:53106 void SendReturnedDelegatedResources();
jbauman38c178eaa2015-06-04 04:24:54107 static void SatisfyCallback(scoped_refptr<ThreadSafeSender> sender,
108 int host_routing_id,
kenrbfc7c02c92015-05-29 22:20:58109 cc::SurfaceSequence sequence);
wjmaclean1e720d2f2015-07-14 16:09:52110 static void SatisfyCallbackBrowserPlugin(
111 scoped_refptr<ThreadSafeSender> sender,
112 int host_routing_id,
113 int browser_plugin_instance_id,
114 cc::SurfaceSequence sequence);
jbauman38c178eaa2015-06-04 04:24:54115 static void RequireCallback(scoped_refptr<ThreadSafeSender> sender,
116 int host_routing_id,
kenrbfc7c02c92015-05-29 22:20:58117 cc::SurfaceId id,
118 cc::SurfaceSequence sequence);
wjmaclean53032adf2015-06-15 16:49:22119 static void RequireCallbackBrowserPlugin(
120 scoped_refptr<ThreadSafeSender> sender,
121 int host_routing_id,
122 int browser_plugin_instance_id,
123 cc::SurfaceId id,
124 cc::SurfaceSequence sequence);
lfgfd437a272015-11-24 21:24:53125 void UpdateWebLayer(blink::WebLayer* layer);
kenrbfc7c02c92015-05-29 22:20:58126
[email protected]0f21e8582013-01-11 11:06:56127 int host_routing_id_;
[email protected]f5b4b0f2013-04-02 18:16:28128 int last_route_id_;
[email protected]53b4cc12013-07-18 23:02:30129 uint32 last_output_surface_id_;
[email protected]f5b4b0f2013-04-02 18:16:28130 int last_host_id_;
[email protected]0d25cb62013-01-21 15:42:21131 bool ack_pending_;
[email protected]6d3a46e2013-11-25 23:08:53132 bool opaque_;
[email protected]0f21e8582013-01-11 11:06:56133
[email protected]c2bfe4e2013-01-16 01:10:20134 gfx::Size buffer_size_;
[email protected]c2bfe4e2013-01-16 01:10:20135
[email protected]bdca9be22014-02-18 00:37:49136 // The lifetime of this weak pointer should be greater than the lifetime of
137 // other member objects, as they may access this pointer during their
138 // destruction.
139 base::WeakPtr<BrowserPlugin> browser_plugin_;
[email protected]e3244ed2014-06-20 20:04:27140 RenderFrameProxy* render_frame_proxy_;
[email protected]bdca9be22014-02-18 00:37:49141
[email protected]09f67382013-10-09 21:03:45142 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_;
143 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_;
144
[email protected]180ef242013-11-07 06:50:46145 scoped_ptr<blink::WebLayer> web_layer_;
[email protected]bffc8302014-01-23 20:52:16146 blink::WebFrame* frame_;
[email protected]0d25cb62013-01-21 15:42:21147
[email protected]bffc8302014-01-23 20:52:16148 DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper);
[email protected]0f21e8582013-01-11 11:06:56149};
150
151} // namespace content
152
[email protected]bffc8302014-01-23 20:52:16153#endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_