blob: 4ca8a8759922b1e56dd7d94cb740b77d1e160e8d [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]b0030b72013-11-15 20:35:5313#include "cc/layers/delegated_frame_resource_collection.h"
[email protected]0f21e8582013-01-11 11:06:5614#include "content/common/content_export.h"
[email protected]c049b2e2013-06-11 04:39:3015#include "gpu/command_buffer/common/mailbox.h"
[email protected]0f21e8582013-01-11 11:06:5616#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]0f21e8582013-01-11 11:06:5627class TextureLayer;
[email protected]09f67382013-10-09 21:03:4528class DelegatedFrameProvider;
29class DelegatedFrameResourceCollection;
[email protected]f5b4b0f2013-04-02 18:16:2830class DelegatedRendererLayer;
[email protected]0f21e8582013-01-11 11:06:5631}
32
[email protected]180ef242013-11-07 06:50:4633namespace blink {
[email protected]bffc8302014-01-23 20:52:1634class WebFrame;
[email protected]0f21e8582013-01-11 11:06:5635class WebPluginContainer;
36class WebLayer;
37}
38
[email protected]73405fb2013-12-11 04:59:3739namespace gfx {
40class Rect;
41class Size;
42}
43
[email protected]bffc8302014-01-23 20:52:1644struct FrameHostMsg_CompositorFrameSwappedACK_Params;
45struct FrameHostMsg_BuffersSwappedACK_Params;
46struct FrameHostMsg_ReclaimCompositorResources_Params;
47
[email protected]0f21e8582013-01-11 11:06:5648namespace content {
49
[email protected]0d25cb62013-01-21 15:42:2150class BrowserPluginManager;
[email protected]bffc8302014-01-23 20:52:1651class RenderFrameImpl;
[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]bffc8302014-01-23 20:52:1657 static ChildFrameCompositingHelper* CreateCompositingHelperForBrowserPlugin(
58 blink::WebPluginContainer* container,
59 BrowserPluginManager* manager,
60 int instance_id,
61 int host_routing_id);
62 static ChildFrameCompositingHelper* CreateCompositingHelperForRenderFrame(
63 blink::WebFrame* frame,
64 RenderFrameImpl* render_frame,
65 int host_routing_id);
66
[email protected]73405fb2013-12-11 04:59:3767 void CopyFromCompositingSurface(int request_id,
68 gfx::Rect source_rect,
69 gfx::Size dest_size);
[email protected]f5b4b0f2013-04-02 18:16:2870 void DidCommitCompositorFrame();
[email protected]0f21e8582013-01-11 11:06:5671 void EnableCompositing(bool);
[email protected]0d25cb62013-01-21 15:42:2172 void OnContainerDestroy();
[email protected]0f21e8582013-01-11 11:06:5673 void OnBuffersSwapped(const gfx::Size& size,
[email protected]06666c02013-03-07 19:32:3074 const std::string& mailbox_name,
[email protected]0f21e8582013-01-11 11:06:5675 int gpu_route_id,
[email protected]19fa81a02013-03-04 18:23:3276 int gpu_host_id,
77 float device_scale_factor);
[email protected]f5b4b0f2013-04-02 18:16:2878 void OnCompositorFrameSwapped(scoped_ptr<cc::CompositorFrame> frame,
79 int route_id,
[email protected]53b4cc12013-07-18 23:02:3080 uint32 output_surface_id,
[email protected]f5b4b0f2013-04-02 18:16:2881 int host_id);
[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]bffc8302014-01-23 20:52:1694 ChildFrameCompositingHelper(blink::WebPluginContainer* container,
95 blink::WebFrame* frame,
96 BrowserPluginManager* manager,
97 RenderFrameImpl* render_frame,
98 int instance_id,
99 int host_routing_id);
100
[email protected]9f39c202013-06-18 16:06:42101 enum SwapBuffersType {
[email protected]c049b2e2013-06-11 04:39:30102 TEXTURE_IMAGE_TRANSPORT,
[email protected]9f39c202013-06-18 16:06:42103 GL_COMPOSITOR_FRAME,
104 SOFTWARE_COMPOSITOR_FRAME,
[email protected]c049b2e2013-06-11 04:39:30105 };
[email protected]9f39c202013-06-18 16:06:42106 struct SwapBuffersInfo {
107 SwapBuffersInfo();
108
[email protected]c049b2e2013-06-11 04:39:30109 gpu::Mailbox name;
[email protected]9f39c202013-06-18 16:06:42110 SwapBuffersType type;
[email protected]c049b2e2013-06-11 04:39:30111 gfx::Size size;
112 int route_id;
[email protected]53b4cc12013-07-18 23:02:30113 uint32 output_surface_id;
[email protected]c049b2e2013-06-11 04:39:30114 int host_id;
[email protected]9f39c202013-06-18 16:06:42115 unsigned software_frame_id;
116 base::SharedMemory* shared_memory;
[email protected]c049b2e2013-06-11 04:39:30117 };
[email protected]bffc8302014-01-23 20:52:16118 virtual ~ChildFrameCompositingHelper();
119 void SendCompositorFrameSwappedACKToBrowser(
120 FrameHostMsg_CompositorFrameSwappedACK_Params& params);
121 void SendBuffersSwappedACKToBrowser(
122 FrameHostMsg_BuffersSwappedACK_Params& params);
123 void SendReclaimCompositorResourcesToBrowser(
124 FrameHostMsg_ReclaimCompositorResources_Params& params);
[email protected]6d3a46e2013-11-25 23:08:53125 void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size,
126 float device_scale_factor,
127 cc::Layer* layer);
[email protected]9f39c202013-06-18 16:06:42128 void OnBuffersSwappedPrivate(const SwapBuffersInfo& mailbox,
[email protected]c049b2e2013-06-11 04:39:30129 unsigned sync_point,
130 float device_scale_factor);
[email protected]9f39c202013-06-18 16:06:42131 void MailboxReleased(SwapBuffersInfo mailbox,
[email protected]7ba3ca72013-04-11 06:37:25132 unsigned sync_point,
133 bool lost_resource);
[email protected]b0030b72013-11-15 20:35:53134 void SendReturnedDelegatedResources();
[email protected]73405fb2013-12-11 04:59:37135 void CopyFromCompositingSurfaceHasResult(
136 int request_id,
137 gfx::Size dest_size,
138 scoped_ptr<cc::CopyOutputResult> result);
[email protected]b0030b72013-11-15 20:35:53139
[email protected]cc8ed212013-02-07 22:31:03140 int instance_id_;
[email protected]0f21e8582013-01-11 11:06:56141 int host_routing_id_;
[email protected]f5b4b0f2013-04-02 18:16:28142 int last_route_id_;
[email protected]53b4cc12013-07-18 23:02:30143 uint32 last_output_surface_id_;
[email protected]f5b4b0f2013-04-02 18:16:28144 int last_host_id_;
[email protected]0f21e8582013-01-11 11:06:56145 bool last_mailbox_valid_;
[email protected]0d25cb62013-01-21 15:42:21146 bool ack_pending_;
[email protected]9afdaef2013-09-26 07:24:37147 bool software_ack_pending_;
[email protected]6d3a46e2013-11-25 23:08:53148 bool opaque_;
[email protected]9afdaef2013-09-26 07:24:37149 std::vector<unsigned> unacked_software_frames_;
[email protected]0f21e8582013-01-11 11:06:56150
[email protected]c2bfe4e2013-01-16 01:10:20151 gfx::Size buffer_size_;
[email protected]c2bfe4e2013-01-16 01:10:20152
[email protected]09f67382013-10-09 21:03:45153 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_;
154 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_;
155
[email protected]396fbb72013-01-23 02:33:43156 scoped_refptr<cc::SolidColorLayer> background_layer_;
[email protected]0f21e8582013-01-11 11:06:56157 scoped_refptr<cc::TextureLayer> texture_layer_;
[email protected]f5b4b0f2013-04-02 18:16:28158 scoped_refptr<cc::DelegatedRendererLayer> delegated_layer_;
[email protected]180ef242013-11-07 06:50:46159 scoped_ptr<blink::WebLayer> web_layer_;
160 blink::WebPluginContainer* container_;
[email protected]bffc8302014-01-23 20:52:16161 blink::WebFrame* frame_;
[email protected]0d25cb62013-01-21 15:42:21162
163 scoped_refptr<BrowserPluginManager> browser_plugin_manager_;
[email protected]bffc8302014-01-23 20:52:16164 RenderFrameImpl* render_frame_;
165
166 DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper);
[email protected]0f21e8582013-01-11 11:06:56167};
168
169} // namespace content
170
[email protected]bffc8302014-01-23 20:52:16171#endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_