blob: 3bb4c28b8a935771bbecb8e316f920a409a90100 [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"
16#include "ui/gfx/size.h"
17
[email protected]9f39c202013-06-18 16:06:4218namespace base {
19class SharedMemory;
20}
21
[email protected]0f21e8582013-01-11 11:06:5622namespace cc {
[email protected]f5b4b0f2013-04-02 18:16:2823class CompositorFrame;
[email protected]73405fb2013-12-11 04:59:3724class CopyOutputResult;
[email protected]f5b4b0f2013-04-02 18:16:2825class Layer;
[email protected]396fbb72013-01-23 02:33:4326class SolidColorLayer;
[email protected]09f67382013-10-09 21:03:4527class DelegatedFrameProvider;
28class DelegatedFrameResourceCollection;
[email protected]f5b4b0f2013-04-02 18:16:2829class DelegatedRendererLayer;
[email protected]0f21e8582013-01-11 11:06:5630}
31
[email protected]180ef242013-11-07 06:50:4632namespace blink {
[email protected]bffc8302014-01-23 20:52:1633class WebFrame;
[email protected]0f21e8582013-01-11 11:06:5634class WebPluginContainer;
35class WebLayer;
36}
37
[email protected]73405fb2013-12-11 04:59:3738namespace gfx {
39class Rect;
40class Size;
41}
42
[email protected]bffc8302014-01-23 20:52:1643struct FrameHostMsg_CompositorFrameSwappedACK_Params;
44struct FrameHostMsg_BuffersSwappedACK_Params;
45struct FrameHostMsg_ReclaimCompositorResources_Params;
46
[email protected]0f21e8582013-01-11 11:06:5647namespace content {
48
[email protected]94224ba62014-02-04 00:25:2449class BrowserPlugin;
[email protected]0d25cb62013-01-21 15:42:2150class BrowserPluginManager;
[email protected]e3244ed2014-06-20 20:04:2751class RenderFrameProxy;
[email protected]0d25cb62013-01-21 15:42:2152
[email protected]bffc8302014-01-23 20:52:1653class CONTENT_EXPORT ChildFrameCompositingHelper
54 : public base::RefCounted<ChildFrameCompositingHelper>,
55 public cc::DelegatedFrameResourceCollectionClient {
[email protected]0f21e8582013-01-11 11:06:5656 public:
[email protected]c092f5c2014-07-18 01:34:3357 static ChildFrameCompositingHelper* CreateForBrowserPlugin(
[email protected]94224ba62014-02-04 00:25:2458 const base::WeakPtr<BrowserPlugin>& browser_plugin);
[email protected]c092f5c2014-07-18 01:34:3359 static ChildFrameCompositingHelper* CreateForRenderFrameProxy(
60 RenderFrameProxy* render_frame_proxy);
[email protected]bffc8302014-01-23 20:52:1661
[email protected]73405fb2013-12-11 04:59:3762 void CopyFromCompositingSurface(int request_id,
63 gfx::Rect source_rect,
64 gfx::Size dest_size);
[email protected]f5b4b0f2013-04-02 18:16:2865 void DidCommitCompositorFrame();
[email protected]0f21e8582013-01-11 11:06:5666 void EnableCompositing(bool);
[email protected]0d25cb62013-01-21 15:42:2167 void OnContainerDestroy();
[email protected]f5b4b0f2013-04-02 18:16:2868 void OnCompositorFrameSwapped(scoped_ptr<cc::CompositorFrame> frame,
69 int route_id,
[email protected]53b4cc12013-07-18 23:02:3070 uint32 output_surface_id,
[email protected]f1970082014-04-09 04:29:5671 int host_id,
72 base::SharedMemoryHandle handle);
[email protected]69b79122013-02-14 19:16:4573 void UpdateVisibility(bool);
[email protected]f49722f2014-01-30 17:54:5074 void ChildFrameGone();
[email protected]b0030b72013-11-15 20:35:5375
76 // cc::DelegatedFrameProviderClient implementation.
dcheng6d18e402014-10-21 12:32:5277 void UnusedResourcesAreAvailable() override;
[email protected]6d3a46e2013-11-25 23:08:5378 void SetContentsOpaque(bool);
[email protected]b0030b72013-11-15 20:35:5379
[email protected]0d25cb62013-01-21 15:42:2180 protected:
81 // Friend RefCounted so that the dtor can be non-public.
[email protected]bffc8302014-01-23 20:52:1682 friend class base::RefCounted<ChildFrameCompositingHelper>;
83
[email protected]0f21e8582013-01-11 11:06:5684 private:
[email protected]94224ba62014-02-04 00:25:2485 ChildFrameCompositingHelper(
86 const base::WeakPtr<BrowserPlugin>& browser_plugin,
87 blink::WebFrame* frame,
[email protected]e3244ed2014-06-20 20:04:2788 RenderFrameProxy* render_frame_proxy,
[email protected]94224ba62014-02-04 00:25:2489 int host_routing_id);
[email protected]bffc8302014-01-23 20:52:1690
[email protected]bffc8302014-01-23 20:52:1691 virtual ~ChildFrameCompositingHelper();
[email protected]94224ba62014-02-04 00:25:2492
93 BrowserPluginManager* GetBrowserPluginManager();
94 blink::WebPluginContainer* GetContainer();
95 int GetInstanceID();
96
[email protected]bffc8302014-01-23 20:52:1697 void SendCompositorFrameSwappedACKToBrowser(
98 FrameHostMsg_CompositorFrameSwappedACK_Params& params);
[email protected]bffc8302014-01-23 20:52:1699 void SendReclaimCompositorResourcesToBrowser(
100 FrameHostMsg_ReclaimCompositorResources_Params& params);
[email protected]6d3a46e2013-11-25 23:08:53101 void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size,
102 float device_scale_factor,
103 cc::Layer* layer);
[email protected]b0030b72013-11-15 20:35:53104 void SendReturnedDelegatedResources();
[email protected]73405fb2013-12-11 04:59:37105 void CopyFromCompositingSurfaceHasResult(
106 int request_id,
107 gfx::Size dest_size,
108 scoped_ptr<cc::CopyOutputResult> result);
[email protected]b0030b72013-11-15 20:35:53109
[email protected]0f21e8582013-01-11 11:06:56110 int host_routing_id_;
[email protected]f5b4b0f2013-04-02 18:16:28111 int last_route_id_;
[email protected]53b4cc12013-07-18 23:02:30112 uint32 last_output_surface_id_;
[email protected]f5b4b0f2013-04-02 18:16:28113 int last_host_id_;
[email protected]0d25cb62013-01-21 15:42:21114 bool ack_pending_;
[email protected]6d3a46e2013-11-25 23:08:53115 bool opaque_;
[email protected]0f21e8582013-01-11 11:06:56116
[email protected]c2bfe4e2013-01-16 01:10:20117 gfx::Size buffer_size_;
[email protected]c2bfe4e2013-01-16 01:10:20118
[email protected]bdca9be22014-02-18 00:37:49119 // The lifetime of this weak pointer should be greater than the lifetime of
120 // other member objects, as they may access this pointer during their
121 // destruction.
122 base::WeakPtr<BrowserPlugin> browser_plugin_;
[email protected]e3244ed2014-06-20 20:04:27123 RenderFrameProxy* render_frame_proxy_;
[email protected]bdca9be22014-02-18 00:37:49124
[email protected]09f67382013-10-09 21:03:45125 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_;
126 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_;
127
[email protected]396fbb72013-01-23 02:33:43128 scoped_refptr<cc::SolidColorLayer> background_layer_;
[email protected]f5b4b0f2013-04-02 18:16:28129 scoped_refptr<cc::DelegatedRendererLayer> delegated_layer_;
[email protected]180ef242013-11-07 06:50:46130 scoped_ptr<blink::WebLayer> web_layer_;
[email protected]bffc8302014-01-23 20:52:16131 blink::WebFrame* frame_;
[email protected]0d25cb62013-01-21 15:42:21132
[email protected]bffc8302014-01-23 20:52:16133 DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper);
[email protected]0f21e8582013-01-11 11:06:56134};
135
136} // namespace content
137
[email protected]bffc8302014-01-23 20:52:16138#endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_