Update V8 to version 4.6.61.
[chromium-blink-merge.git] / content / renderer / child_frame_compositing_helper.h
blobffd34be30930df6d0cce1c8d6a8d5a784c63aed7
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_
8 #include <string>
9 #include <vector>
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"
18 namespace base {
19 class SharedMemory;
22 namespace cc {
23 struct SurfaceId;
24 struct SurfaceSequence;
26 class CompositorFrame;
27 class Layer;
28 class SolidColorLayer;
29 class SurfaceLayer;
30 class DelegatedFrameProvider;
31 class DelegatedFrameResourceCollection;
32 class DelegatedRendererLayer;
35 namespace blink {
36 class WebFrame;
37 class WebPluginContainer;
38 class WebLayer;
41 namespace gfx {
42 class Rect;
43 class Size;
46 struct FrameHostMsg_CompositorFrameSwappedACK_Params;
47 struct FrameHostMsg_BuffersSwappedACK_Params;
48 struct FrameHostMsg_ReclaimCompositorResources_Params;
50 namespace content {
52 class BrowserPlugin;
53 class BrowserPluginManager;
54 class RenderFrameProxy;
55 class ThreadSafeSender;
57 class CONTENT_EXPORT ChildFrameCompositingHelper
58 : public base::RefCounted<ChildFrameCompositingHelper>,
59 public cc::DelegatedFrameResourceCollectionClient {
60 public:
61 static ChildFrameCompositingHelper* CreateForBrowserPlugin(
62 const base::WeakPtr<BrowserPlugin>& browser_plugin);
63 static ChildFrameCompositingHelper* CreateForRenderFrameProxy(
64 RenderFrameProxy* render_frame_proxy);
66 void DidCommitCompositorFrame();
67 void EnableCompositing(bool);
68 void OnContainerDestroy();
69 void OnCompositorFrameSwapped(scoped_ptr<cc::CompositorFrame> frame,
70 int route_id,
71 uint32 output_surface_id,
72 int host_id,
73 base::SharedMemoryHandle handle);
74 void OnSetSurface(const cc::SurfaceId& surface_id,
75 const gfx::Size& frame_size,
76 float scale_factor,
77 const cc::SurfaceSequence& sequence);
78 void UpdateVisibility(bool);
79 void ChildFrameGone();
81 // cc::DelegatedFrameProviderClient implementation.
82 void UnusedResourcesAreAvailable() override;
83 void SetContentsOpaque(bool);
85 protected:
86 // Friend RefCounted so that the dtor can be non-public.
87 friend class base::RefCounted<ChildFrameCompositingHelper>;
89 private:
90 ChildFrameCompositingHelper(
91 const base::WeakPtr<BrowserPlugin>& browser_plugin,
92 blink::WebFrame* frame,
93 RenderFrameProxy* render_frame_proxy,
94 int host_routing_id);
96 virtual ~ChildFrameCompositingHelper();
98 BrowserPluginManager* GetBrowserPluginManager();
99 blink::WebPluginContainer* GetContainer();
100 int GetInstanceID();
102 void SendCompositorFrameSwappedACKToBrowser(
103 FrameHostMsg_CompositorFrameSwappedACK_Params& params);
104 void SendReclaimCompositorResourcesToBrowser(
105 FrameHostMsg_ReclaimCompositorResources_Params& params);
106 void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size,
107 float device_scale_factor,
108 cc::Layer* layer);
109 void SendReturnedDelegatedResources();
110 static void SatisfyCallback(scoped_refptr<ThreadSafeSender> sender,
111 int host_routing_id,
112 cc::SurfaceSequence sequence);
113 static void SatisfyCallbackBrowserPlugin(
114 scoped_refptr<ThreadSafeSender> sender,
115 int host_routing_id,
116 int browser_plugin_instance_id,
117 cc::SurfaceSequence sequence);
118 static void RequireCallback(scoped_refptr<ThreadSafeSender> sender,
119 int host_routing_id,
120 cc::SurfaceId id,
121 cc::SurfaceSequence sequence);
122 static void RequireCallbackBrowserPlugin(
123 scoped_refptr<ThreadSafeSender> sender,
124 int host_routing_id,
125 int browser_plugin_instance_id,
126 cc::SurfaceId id,
127 cc::SurfaceSequence sequence);
129 int host_routing_id_;
130 int last_route_id_;
131 uint32 last_output_surface_id_;
132 int last_host_id_;
133 bool ack_pending_;
134 bool opaque_;
136 gfx::Size buffer_size_;
138 // The lifetime of this weak pointer should be greater than the lifetime of
139 // other member objects, as they may access this pointer during their
140 // destruction.
141 base::WeakPtr<BrowserPlugin> browser_plugin_;
142 RenderFrameProxy* render_frame_proxy_;
144 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_;
145 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_;
147 // For cc::Surface support.
148 scoped_refptr<cc::SurfaceLayer> surface_layer_;
150 scoped_refptr<cc::SolidColorLayer> background_layer_;
151 scoped_refptr<cc::DelegatedRendererLayer> delegated_layer_;
152 scoped_ptr<blink::WebLayer> web_layer_;
153 blink::WebFrame* frame_;
155 DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper);
158 } // namespace content
160 #endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_