blob: c33083e3036abfaa3c43d47d9dab781e8e98d381 [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"
[email protected]c049b2e2013-06-11 04:39:3016#include "gpu/command_buffer/common/mailbox.h"
[email protected]0f21e8582013-01-11 11:06:5617#include "ui/gfx/size.h"
18
[email protected]9f39c202013-06-18 16:06:4219namespace base {
20class SharedMemory;
21}
22
[email protected]0f21e8582013-01-11 11:06:5623namespace cc {
[email protected]f5b4b0f2013-04-02 18:16:2824class CompositorFrame;
[email protected]73405fb2013-12-11 04:59:3725class CopyOutputResult;
[email protected]f5b4b0f2013-04-02 18:16:2826class Layer;
[email protected]396fbb72013-01-23 02:33:4327class SolidColorLayer;
[email protected]0f21e8582013-01-11 11:06:5628class TextureLayer;
[email protected]09f67382013-10-09 21:03:4529class DelegatedFrameProvider;
30class DelegatedFrameResourceCollection;
[email protected]f5b4b0f2013-04-02 18:16:2831class DelegatedRendererLayer;
[email protected]0f21e8582013-01-11 11:06:5632}
33
[email protected]180ef242013-11-07 06:50:4634namespace blink {
[email protected]bffc8302014-01-23 20:52:1635class WebFrame;
[email protected]0f21e8582013-01-11 11:06:5636class WebPluginContainer;
37class WebLayer;
38}
39
[email protected]73405fb2013-12-11 04:59:3740namespace gfx {
41class Rect;
42class Size;
43}
44
[email protected]bffc8302014-01-23 20:52:1645struct FrameHostMsg_CompositorFrameSwappedACK_Params;
46struct FrameHostMsg_BuffersSwappedACK_Params;
47struct 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]bffc8302014-01-23 20:52:1653class RenderFrameImpl;
[email protected]0d25cb62013-01-21 15:42:2154
[email protected]bffc8302014-01-23 20:52:1655class CONTENT_EXPORT ChildFrameCompositingHelper
56 : public base::RefCounted<ChildFrameCompositingHelper>,
57 public cc::DelegatedFrameResourceCollectionClient {
[email protected]0f21e8582013-01-11 11:06:5658 public:
[email protected]bffc8302014-01-23 20:52:1659 static ChildFrameCompositingHelper* CreateCompositingHelperForBrowserPlugin(
[email protected]94224ba62014-02-04 00:25:2460 const base::WeakPtr<BrowserPlugin>& browser_plugin);
[email protected]bffc8302014-01-23 20:52:1661 static ChildFrameCompositingHelper* CreateCompositingHelperForRenderFrame(
62 blink::WebFrame* frame,
63 RenderFrameImpl* render_frame,
64 int host_routing_id);
65
[email protected]73405fb2013-12-11 04:59:3766 void CopyFromCompositingSurface(int request_id,
67 gfx::Rect source_rect,
68 gfx::Size dest_size);
[email protected]f5b4b0f2013-04-02 18:16:2869 void DidCommitCompositorFrame();
[email protected]0f21e8582013-01-11 11:06:5670 void EnableCompositing(bool);
[email protected]0d25cb62013-01-21 15:42:2171 void OnContainerDestroy();
[email protected]0f21e8582013-01-11 11:06:5672 void OnBuffersSwapped(const gfx::Size& size,
[email protected]7c6c09e2014-02-15 00:16:1773 const gpu::Mailbox& mailbox,
[email protected]0f21e8582013-01-11 11:06:5674 int gpu_route_id,
[email protected]19fa81a02013-03-04 18:23:3275 int gpu_host_id,
76 float device_scale_factor);
[email protected]f5b4b0f2013-04-02 18:16:2877 void OnCompositorFrameSwapped(scoped_ptr<cc::CompositorFrame> frame,
78 int route_id,
[email protected]53b4cc12013-07-18 23:02:3079 uint32 output_surface_id,
[email protected]f1970082014-04-09 04:29:5680 int host_id,
81 base::SharedMemoryHandle handle);
[email protected]69b79122013-02-14 19:16:4582 void UpdateVisibility(bool);
[email protected]f49722f2014-01-30 17:54:5083 void ChildFrameGone();
[email protected]b0030b72013-11-15 20:35:5384
85 // cc::DelegatedFrameProviderClient implementation.
86 virtual void UnusedResourcesAreAvailable() OVERRIDE;
[email protected]6d3a46e2013-11-25 23:08:5387 void SetContentsOpaque(bool);
[email protected]b0030b72013-11-15 20:35:5388
[email protected]0d25cb62013-01-21 15:42:2189 protected:
90 // Friend RefCounted so that the dtor can be non-public.
[email protected]bffc8302014-01-23 20:52:1691 friend class base::RefCounted<ChildFrameCompositingHelper>;
92
[email protected]0f21e8582013-01-11 11:06:5693 private:
[email protected]94224ba62014-02-04 00:25:2494 ChildFrameCompositingHelper(
95 const base::WeakPtr<BrowserPlugin>& browser_plugin,
96 blink::WebFrame* frame,
97 RenderFrameImpl* render_frame,
98 int host_routing_id);
[email protected]bffc8302014-01-23 20:52:1699
[email protected]9f39c202013-06-18 16:06:42100 enum SwapBuffersType {
[email protected]c049b2e2013-06-11 04:39:30101 TEXTURE_IMAGE_TRANSPORT,
[email protected]9f39c202013-06-18 16:06:42102 GL_COMPOSITOR_FRAME,
103 SOFTWARE_COMPOSITOR_FRAME,
[email protected]c049b2e2013-06-11 04:39:30104 };
[email protected]9f39c202013-06-18 16:06:42105 struct SwapBuffersInfo {
106 SwapBuffersInfo();
107
[email protected]c049b2e2013-06-11 04:39:30108 gpu::Mailbox name;
[email protected]9f39c202013-06-18 16:06:42109 SwapBuffersType type;
[email protected]c049b2e2013-06-11 04:39:30110 gfx::Size size;
111 int route_id;
[email protected]53b4cc12013-07-18 23:02:30112 uint32 output_surface_id;
[email protected]c049b2e2013-06-11 04:39:30113 int host_id;
[email protected]9f39c202013-06-18 16:06:42114 unsigned software_frame_id;
115 base::SharedMemory* shared_memory;
[email protected]c049b2e2013-06-11 04:39:30116 };
[email protected]bffc8302014-01-23 20:52:16117 virtual ~ChildFrameCompositingHelper();
[email protected]94224ba62014-02-04 00:25:24118
119 BrowserPluginManager* GetBrowserPluginManager();
120 blink::WebPluginContainer* GetContainer();
121 int GetInstanceID();
122
[email protected]bffc8302014-01-23 20:52:16123 void SendCompositorFrameSwappedACKToBrowser(
124 FrameHostMsg_CompositorFrameSwappedACK_Params& params);
125 void SendBuffersSwappedACKToBrowser(
126 FrameHostMsg_BuffersSwappedACK_Params& params);
127 void SendReclaimCompositorResourcesToBrowser(
128 FrameHostMsg_ReclaimCompositorResources_Params& params);
[email protected]6d3a46e2013-11-25 23:08:53129 void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size,
130 float device_scale_factor,
131 cc::Layer* layer);
[email protected]9f39c202013-06-18 16:06:42132 void OnBuffersSwappedPrivate(const SwapBuffersInfo& mailbox,
[email protected]c049b2e2013-06-11 04:39:30133 unsigned sync_point,
134 float device_scale_factor);
[email protected]9f39c202013-06-18 16:06:42135 void MailboxReleased(SwapBuffersInfo mailbox,
[email protected]7ba3ca72013-04-11 06:37:25136 unsigned sync_point,
137 bool lost_resource);
[email protected]b0030b72013-11-15 20:35:53138 void SendReturnedDelegatedResources();
[email protected]73405fb2013-12-11 04:59:37139 void CopyFromCompositingSurfaceHasResult(
140 int request_id,
141 gfx::Size dest_size,
142 scoped_ptr<cc::CopyOutputResult> result);
[email protected]b0030b72013-11-15 20:35:53143
[email protected]0f21e8582013-01-11 11:06:56144 int host_routing_id_;
[email protected]f5b4b0f2013-04-02 18:16:28145 int last_route_id_;
[email protected]53b4cc12013-07-18 23:02:30146 uint32 last_output_surface_id_;
[email protected]f5b4b0f2013-04-02 18:16:28147 int last_host_id_;
[email protected]0f21e8582013-01-11 11:06:56148 bool last_mailbox_valid_;
[email protected]0d25cb62013-01-21 15:42:21149 bool ack_pending_;
[email protected]9afdaef2013-09-26 07:24:37150 bool software_ack_pending_;
[email protected]6d3a46e2013-11-25 23:08:53151 bool opaque_;
[email protected]9afdaef2013-09-26 07:24:37152 std::vector<unsigned> unacked_software_frames_;
[email protected]0f21e8582013-01-11 11:06:56153
[email protected]c2bfe4e2013-01-16 01:10:20154 gfx::Size buffer_size_;
[email protected]c2bfe4e2013-01-16 01:10:20155
[email protected]bdca9be22014-02-18 00:37:49156 // The lifetime of this weak pointer should be greater than the lifetime of
157 // other member objects, as they may access this pointer during their
158 // destruction.
159 base::WeakPtr<BrowserPlugin> browser_plugin_;
160 RenderFrameImpl* render_frame_;
161
[email protected]09f67382013-10-09 21:03:45162 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_;
163 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_;
164
[email protected]396fbb72013-01-23 02:33:43165 scoped_refptr<cc::SolidColorLayer> background_layer_;
[email protected]0f21e8582013-01-11 11:06:56166 scoped_refptr<cc::TextureLayer> texture_layer_;
[email protected]f5b4b0f2013-04-02 18:16:28167 scoped_refptr<cc::DelegatedRendererLayer> delegated_layer_;
[email protected]180ef242013-11-07 06:50:46168 scoped_ptr<blink::WebLayer> web_layer_;
[email protected]bffc8302014-01-23 20:52:16169 blink::WebFrame* frame_;
[email protected]0d25cb62013-01-21 15:42:21170
[email protected]bffc8302014-01-23 20:52:16171 DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper);
[email protected]0f21e8582013-01-11 11:06:56172};
173
174} // namespace content
175
[email protected]bffc8302014-01-23 20:52:16176#endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_