1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_
6 #define CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/shared_memory.h"
14 #include "cc/layers/delegated_frame_resource_collection.h"
15 #include "content/common/content_export.h"
16 #include "ui/gfx/geometry/size.h"
23 class CompositorFrame
;
25 class SolidColorLayer
;
26 class DelegatedFrameProvider
;
27 class DelegatedFrameResourceCollection
;
28 class DelegatedRendererLayer
;
33 class WebPluginContainer
;
42 struct FrameHostMsg_CompositorFrameSwappedACK_Params
;
43 struct FrameHostMsg_BuffersSwappedACK_Params
;
44 struct FrameHostMsg_ReclaimCompositorResources_Params
;
49 class BrowserPluginManager
;
50 class RenderFrameProxy
;
52 class CONTENT_EXPORT ChildFrameCompositingHelper
53 : public base::RefCounted
<ChildFrameCompositingHelper
>,
54 public cc::DelegatedFrameResourceCollectionClient
{
56 static ChildFrameCompositingHelper
* CreateForBrowserPlugin(
57 const base::WeakPtr
<BrowserPlugin
>& browser_plugin
);
58 static ChildFrameCompositingHelper
* CreateForRenderFrameProxy(
59 RenderFrameProxy
* render_frame_proxy
);
61 void DidCommitCompositorFrame();
62 void EnableCompositing(bool);
63 void OnContainerDestroy();
64 void OnCompositorFrameSwapped(scoped_ptr
<cc::CompositorFrame
> frame
,
66 uint32 output_surface_id
,
68 base::SharedMemoryHandle handle
);
69 void UpdateVisibility(bool);
70 void ChildFrameGone();
72 // cc::DelegatedFrameProviderClient implementation.
73 void UnusedResourcesAreAvailable() override
;
74 void SetContentsOpaque(bool);
77 // Friend RefCounted so that the dtor can be non-public.
78 friend class base::RefCounted
<ChildFrameCompositingHelper
>;
81 ChildFrameCompositingHelper(
82 const base::WeakPtr
<BrowserPlugin
>& browser_plugin
,
83 blink::WebFrame
* frame
,
84 RenderFrameProxy
* render_frame_proxy
,
87 virtual ~ChildFrameCompositingHelper();
89 BrowserPluginManager
* GetBrowserPluginManager();
90 blink::WebPluginContainer
* GetContainer();
93 void SendCompositorFrameSwappedACKToBrowser(
94 FrameHostMsg_CompositorFrameSwappedACK_Params
& params
);
95 void SendReclaimCompositorResourcesToBrowser(
96 FrameHostMsg_ReclaimCompositorResources_Params
& params
);
97 void CheckSizeAndAdjustLayerProperties(const gfx::Size
& new_size
,
98 float device_scale_factor
,
100 void SendReturnedDelegatedResources();
102 int host_routing_id_
;
104 uint32 last_output_surface_id_
;
109 gfx::Size buffer_size_
;
111 // The lifetime of this weak pointer should be greater than the lifetime of
112 // other member objects, as they may access this pointer during their
114 base::WeakPtr
<BrowserPlugin
> browser_plugin_
;
115 RenderFrameProxy
* render_frame_proxy_
;
117 scoped_refptr
<cc::DelegatedFrameResourceCollection
> resource_collection_
;
118 scoped_refptr
<cc::DelegatedFrameProvider
> frame_provider_
;
120 scoped_refptr
<cc::SolidColorLayer
> background_layer_
;
121 scoped_refptr
<cc::DelegatedRendererLayer
> delegated_layer_
;
122 scoped_ptr
<blink::WebLayer
> web_layer_
;
123 blink::WebFrame
* frame_
;
125 DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper
);
128 } // namespace content
130 #endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_