Fix a couple bugs in the settings_page_header wrt breadcrumbs.
[chromium-blink-merge.git] / content / renderer / child_frame_compositing_helper.h
blobdd822c0cf324cb743ced44b1e0982d30de7b4f56
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;
56 class CONTENT_EXPORT ChildFrameCompositingHelper
57 : public base::RefCounted<ChildFrameCompositingHelper>,
58 public cc::DelegatedFrameResourceCollectionClient {
59 public:
60 static ChildFrameCompositingHelper* CreateForBrowserPlugin(
61 const base::WeakPtr<BrowserPlugin>& browser_plugin);
62 static ChildFrameCompositingHelper* CreateForRenderFrameProxy(
63 RenderFrameProxy* render_frame_proxy);
65 void DidCommitCompositorFrame();
66 void EnableCompositing(bool);
67 void OnContainerDestroy();
68 void OnCompositorFrameSwapped(scoped_ptr<cc::CompositorFrame> frame,
69 int route_id,
70 uint32 output_surface_id,
71 int host_id,
72 base::SharedMemoryHandle handle);
73 void OnSetSurface(const cc::SurfaceId& surface_id,
74 const gfx::Size& frame_size,
75 float scale_factor,
76 const cc::SurfaceSequence& sequence);
77 void UpdateVisibility(bool);
78 void ChildFrameGone();
80 // cc::DelegatedFrameProviderClient implementation.
81 void UnusedResourcesAreAvailable() override;
82 void SetContentsOpaque(bool);
84 protected:
85 // Friend RefCounted so that the dtor can be non-public.
86 friend class base::RefCounted<ChildFrameCompositingHelper>;
88 private:
89 ChildFrameCompositingHelper(
90 const base::WeakPtr<BrowserPlugin>& browser_plugin,
91 blink::WebFrame* frame,
92 RenderFrameProxy* render_frame_proxy,
93 int host_routing_id);
95 virtual ~ChildFrameCompositingHelper();
97 BrowserPluginManager* GetBrowserPluginManager();
98 blink::WebPluginContainer* GetContainer();
99 int GetInstanceID();
101 void SendCompositorFrameSwappedACKToBrowser(
102 FrameHostMsg_CompositorFrameSwappedACK_Params& params);
103 void SendReclaimCompositorResourcesToBrowser(
104 FrameHostMsg_ReclaimCompositorResources_Params& params);
105 void CheckSizeAndAdjustLayerProperties(const gfx::Size& new_size,
106 float device_scale_factor,
107 cc::Layer* layer);
108 void SendReturnedDelegatedResources();
109 static void SatisfyCallback(base::WeakPtr<ChildFrameCompositingHelper> helper,
110 cc::SurfaceSequence sequence);
111 static void RequireCallback(base::WeakPtr<ChildFrameCompositingHelper> helper,
112 cc::SurfaceId id,
113 cc::SurfaceSequence sequence);
115 base::WeakPtr<ChildFrameCompositingHelper> GetWeakPtr() {
116 return weak_factory_.GetWeakPtr();
119 int host_routing_id_;
120 int last_route_id_;
121 uint32 last_output_surface_id_;
122 int last_host_id_;
123 bool ack_pending_;
124 bool opaque_;
126 gfx::Size buffer_size_;
128 // The lifetime of this weak pointer should be greater than the lifetime of
129 // other member objects, as they may access this pointer during their
130 // destruction.
131 base::WeakPtr<BrowserPlugin> browser_plugin_;
132 RenderFrameProxy* render_frame_proxy_;
134 scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_;
135 scoped_refptr<cc::DelegatedFrameProvider> frame_provider_;
137 // For cc::Surface support.
138 scoped_refptr<cc::SurfaceLayer> surface_layer_;
140 scoped_refptr<cc::SolidColorLayer> background_layer_;
141 scoped_refptr<cc::DelegatedRendererLayer> delegated_layer_;
142 scoped_ptr<blink::WebLayer> web_layer_;
143 blink::WebFrame* frame_;
145 base::WeakPtrFactory<ChildFrameCompositingHelper> weak_factory_;
147 DISALLOW_COPY_AND_ASSIGN(ChildFrameCompositingHelper);
150 } // namespace content
152 #endif // CONTENT_RENDERER_CHILD_FRAME_COMPOSITING_HELPER_H_