blob: 686d9a2eb894889d93ffd2a8874ea9e83798765d [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]94224ba62014-02-04 00:25:2450class BrowserPlugin;
[email protected]0d25cb62013-01-21 15:42:2151class BrowserPluginManager;
[email protected]bffc8302014-01-23 20:52:1652class RenderFrameImpl;
[email protected]0d25cb62013-01-21 15:42:2153
[email protected]bffc8302014-01-23 20:52:1654class CONTENT_EXPORT ChildFrameCompositingHelper
55 : public base::RefCounted<ChildFrameCompositingHelper>,
56 public cc::DelegatedFrameResourceCollectionClient {
[email protected]0f21e8582013-01-11 11:06:5657 public:
[email protected]bffc8302014-01-23 20:52:1658 static ChildFrameCompositingHelper* CreateCompositingHelperForBrowserPlugin(
[email protected]94224ba62014-02-04 00:25:2459 const base::WeakPtr<BrowserPlugin>& browser_plugin);
[email protected]bffc8302014-01-23 20:52:1660 static ChildFrameCompositingHelper* CreateCompositingHelperForRenderFrame(
61 blink::WebFrame* frame,
62 RenderFrameImpl* render_frame,
63 int host_routing_id);
64
[email protected]73405fb2013-12-11 04:59:3765 void CopyFromCompositingSurface(int request_id,
66 gfx::Rect source_rect,
67 gfx::Size dest_size);
[email protected]f5b4b0f2013-04-02 18:16:2868 void DidCommitCompositorFrame();
[email protected]0f21e8582013-01-11 11:06:5669 void EnableCompositing(bool);
[email protected]0d25cb62013-01-21 15:42:2170 void OnContainerDestroy();
[email protected]0f21e8582013-01-11 11:06:5671 void OnBuffersSwapped(const gfx::Size& size,
[email protected]06666c02013-03-07 19:32:3072 const std::string& mailbox_name,
[email protected]0f21e8582013-01-11 11:06:5673 int gpu_route_id,
[email protected]19fa81a02013-03-04 18:23:3274 int gpu_host_id,
75 float device_scale_factor);
[email protected]f5b4b0f2013-04-02 18:16:2876 void OnCompositorFrameSwapped(scoped_ptr<cc::CompositorFrame> frame,
77 int route_id,
[email protected]53b4cc12013-07-18 23:02:3078 uint32 output_surface_id,
[email protected]f5b4b0f2013-04-02 18:16:2879 int host_id);
[email protected]69b79122013-02-14 19:16:4580 void UpdateVisibility(bool);
[email protected]f49722f2014-01-30 17:54:5081 void ChildFrameGone();
[email protected]b0030b72013-11-15 20:35:5382
83 // cc::DelegatedFrameProviderClient implementation.
84 virtual void UnusedResourcesAreAvailable() OVERRIDE;
[email protected]6d3a46e2013-11-25 23:08:5385 void SetContentsOpaque(bool);
[email protected]b0030b72013-11-15 20:35:5386
[email protected]0d25cb62013-01-21 15:42:2187 protected:
88 // Friend RefCounted so that the dtor can be non-public.
[email protected]bffc8302014-01-23 20:52:1689 friend class base::RefCounted<ChildFrameCompositingHelper>;
90
[email protected]0f21e8582013-01-11 11:06:5691 private:
[email protected]94224ba62014-02-04 00:25:2492 ChildFrameCompositingHelper(
93 const base::WeakPtr<BrowserPlugin>& browser_plugin,
94 blink::WebFrame* frame,
95 RenderFrameImpl* render_frame,
96 int host_routing_id);
[email protected]bffc8302014-01-23 20:52:1697
[email protected]9f39c202013-06-18 16:06:4298 enum SwapBuffersType {
[email protected]c049b2e2013-06-11 04:39:3099 TEXTURE_IMAGE_TRANSPORT,
[email protected]9f39c202013-06-18 16:06:42100 GL_COMPOSITOR_FRAME,
101 SOFTWARE_COMPOSITOR_FRAME,
[email protected]c049b2e2013-06-11 04:39:30102 };
[email protected]9f39c202013-06-18 16:06:42103 struct SwapBuffersInfo {
104 SwapBuffersInfo();
105
[email protected]c049b2e2013-06-11 04:39:30106 gpu::Mailbox name;
[email protected]9f39c202013-06-18 16:06:42107 SwapBuffersType type;
[email protected]c049b2e2013-06-11 04:39:30108 gfx::Size size;
109 int route_id;
[email protected]53b4cc12013-07-18 23:02:30110 uint32 output_surface_id;
[email protected]c049b2e2013-06-11 04:39:30111 int host_id;
[email protected]9f39c202013-06-18 16:06:42112 unsigned software_frame_id;
113 base::SharedMemory* shared_memory;
[email protected]c049b2e2013-06-11 04:39:30114 };
[email protected]bffc8302014-01-23 20:52:16115 virtual ~ChildFrameCompositingHelper();
[email protected]94224ba62014-02-04 00:25:24116
117 BrowserPluginManager* GetBrowserPluginManager();
118 blink::WebPluginContainer* GetContainer();
119 int GetInstanceID();
120
[email protected]bffc8302014-01-23 20:52:16121 void SendCompositorFrameSwappedACKToBrowser(
122 FrameHostMsg_CompositorFrameSwappedACK_Params& params);
123 void SendBuffersSwappedACKToBrowser(
124 FrameHostMsg_BuffersSwappedACK_Params& params);
125 void SendReclaimCompositorResourcesToBrowser(
126 FrameHostMsg_ReclaimCompositorResources_Params& params);
[email protected]6d3a46e2013-11-25 23:08:53127 void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size,
128 float device_scale_factor,
129 cc::Layer* layer);
[email protected]9f39c202013-06-18 16:06:42130 void OnBuffersSwappedPrivate(const SwapBuffersInfo& mailbox,
[email protected]c049b2e2013-06-11 04:39:30131 unsigned sync_point,
132 float device_scale_factor);
[email protected]9f39c202013-06-18 16:06:42133 void MailboxReleased(SwapBuffersInfo mailbox,
[email protected]7ba3ca72013-04-11 06:37:25134 unsigned sync_point,
135 bool lost_resource);
[email protected]b0030b72013-11-15 20:35:53136 void SendReturnedDelegatedResources();
[email protected]73405fb2013-12-11 04:59:37137 void CopyFromCompositingSurfaceHasResult(
138 int request_id,
139 gfx::Size dest_size,
140 scoped_ptr<cc::CopyOutputResult> result);
[email protected]b0030b72013-11-15 20:35:53141
[email protected]0f21e8582013-01-11 11:06:56142 int host_routing_id_;
[email protected]f5b4b0f2013-04-02 18:16:28143 int last_route_id_;
[email protected]53b4cc12013-07-18 23:02:30144 uint32 last_output_surface_id_;
[email protected]f5b4b0f2013-04-02 18:16:28145 int last_host_id_;
[email protected]0f21e8582013-01-11 11:06:56146 bool last_mailbox_valid_;
[email protected]0d25cb62013-01-21 15:42:21147 bool ack_pending_;
[email protected]9afdaef2013-09-26 07:24:37148 bool software_ack_pending_;
[email protected]6d3a46e2013-11-25 23:08:53149 bool opaque_;
[email protected]9afdaef2013-09-26 07:24:37150 std::vector<unsigned> unacked_software_frames_;
[email protected]0f21e8582013-01-11 11:06:56151
[email protected]c2bfe4e2013-01-16 01:10:20152 gfx::Size buffer_size_;
[email protected]c2bfe4e2013-01-16 01:10:20153
[email protected]09f67382013-10-09 21:03:45154 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_;
155 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_;
156
[email protected]396fbb72013-01-23 02:33:43157 scoped_refptr<cc::SolidColorLayer> background_layer_;
[email protected]0f21e8582013-01-11 11:06:56158 scoped_refptr<cc::TextureLayer> texture_layer_;
[email protected]f5b4b0f2013-04-02 18:16:28159 scoped_refptr<cc::DelegatedRendererLayer> delegated_layer_;
[email protected]180ef242013-11-07 06:50:46160 scoped_ptr<blink::WebLayer> web_layer_;
[email protected]bffc8302014-01-23 20:52:16161 blink::WebFrame* frame_;
[email protected]0d25cb62013-01-21 15:42:21162
[email protected]94224ba62014-02-04 00:25:24163 base::WeakPtr<BrowserPlugin> browser_plugin_;
[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_