blob: f543932968052243ee07003e0744751bc6b1c1fb [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]b0030b72013-11-15 20:35:5383
84 // cc::DelegatedFrameProviderClient implementation.
85 virtual void UnusedResourcesAreAvailable() OVERRIDE;
[email protected]6d3a46e2013-11-25 23:08:5386 void SetContentsOpaque(bool);
[email protected]b0030b72013-11-15 20:35:5387
[email protected]0d25cb62013-01-21 15:42:2188 protected:
89 // Friend RefCounted so that the dtor can be non-public.
[email protected]bffc8302014-01-23 20:52:1690 friend class base::RefCounted<ChildFrameCompositingHelper>;
91
[email protected]0f21e8582013-01-11 11:06:5692 private:
[email protected]bffc8302014-01-23 20:52:1693 ChildFrameCompositingHelper(blink::WebPluginContainer* container,
94 blink::WebFrame* frame,
95 BrowserPluginManager* manager,
96 RenderFrameImpl* render_frame,
97 int instance_id,
98 int host_routing_id);
99
[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();
118 void SendCompositorFrameSwappedACKToBrowser(
119 FrameHostMsg_CompositorFrameSwappedACK_Params& params);
120 void SendBuffersSwappedACKToBrowser(
121 FrameHostMsg_BuffersSwappedACK_Params& params);
122 void SendReclaimCompositorResourcesToBrowser(
123 FrameHostMsg_ReclaimCompositorResources_Params& params);
[email protected]6d3a46e2013-11-25 23:08:53124 void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size,
125 float device_scale_factor,
126 cc::Layer* layer);
[email protected]9f39c202013-06-18 16:06:42127 void OnBuffersSwappedPrivate(const SwapBuffersInfo& mailbox,
[email protected]c049b2e2013-06-11 04:39:30128 unsigned sync_point,
129 float device_scale_factor);
[email protected]9f39c202013-06-18 16:06:42130 void MailboxReleased(SwapBuffersInfo mailbox,
[email protected]7ba3ca72013-04-11 06:37:25131 unsigned sync_point,
132 bool lost_resource);
[email protected]b0030b72013-11-15 20:35:53133 void SendReturnedDelegatedResources();
[email protected]73405fb2013-12-11 04:59:37134 void CopyFromCompositingSurfaceHasResult(
135 int request_id,
136 gfx::Size dest_size,
137 scoped_ptr<cc::CopyOutputResult> result);
[email protected]b0030b72013-11-15 20:35:53138
[email protected]cc8ed212013-02-07 22:31:03139 int instance_id_;
[email protected]0f21e8582013-01-11 11:06:56140 int host_routing_id_;
[email protected]f5b4b0f2013-04-02 18:16:28141 int last_route_id_;
[email protected]53b4cc12013-07-18 23:02:30142 uint32 last_output_surface_id_;
[email protected]f5b4b0f2013-04-02 18:16:28143 int last_host_id_;
[email protected]0f21e8582013-01-11 11:06:56144 bool last_mailbox_valid_;
[email protected]0d25cb62013-01-21 15:42:21145 bool ack_pending_;
[email protected]9afdaef2013-09-26 07:24:37146 bool software_ack_pending_;
[email protected]6d3a46e2013-11-25 23:08:53147 bool opaque_;
[email protected]9afdaef2013-09-26 07:24:37148 std::vector<unsigned> unacked_software_frames_;
[email protected]0f21e8582013-01-11 11:06:56149
[email protected]c2bfe4e2013-01-16 01:10:20150 gfx::Size buffer_size_;
[email protected]c2bfe4e2013-01-16 01:10:20151
[email protected]09f67382013-10-09 21:03:45152 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_;
153 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_;
154
[email protected]396fbb72013-01-23 02:33:43155 scoped_refptr<cc::SolidColorLayer> background_layer_;
[email protected]0f21e8582013-01-11 11:06:56156 scoped_refptr<cc::TextureLayer> texture_layer_;
[email protected]f5b4b0f2013-04-02 18:16:28157 scoped_refptr<cc::DelegatedRendererLayer> delegated_layer_;
[email protected]180ef242013-11-07 06:50:46158 scoped_ptr<blink::WebLayer> web_layer_;
159 blink::WebPluginContainer* container_;
[email protected]bffc8302014-01-23 20:52:16160 blink::WebFrame* frame_;
[email protected]0d25cb62013-01-21 15:42:21161
162 scoped_refptr<BrowserPluginManager> browser_plugin_manager_;
[email protected]bffc8302014-01-23 20:52:16163 RenderFrameImpl* render_frame_;
164
165 DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper);
[email protected]0f21e8582013-01-11 11:06:56166};
167
168} // namespace content
169
[email protected]bffc8302014-01-23 20:52:16170#endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_