[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 5 | #include "content/renderer/child_frame_compositing_helper.h" |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 6 | |
[email protected] | 3856462 | 2014-08-19 02:47:18 | [diff] [blame] | 7 | #include "cc/blink/web_layer_impl.h" |
[email protected] | 09f6738 | 2013-10-09 21:03:45 | [diff] [blame] | 8 | #include "cc/layers/delegated_frame_provider.h" |
| 9 | #include "cc/layers/delegated_frame_resource_collection.h" |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 10 | #include "cc/layers/delegated_renderer_layer.h" |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 11 | #include "cc/layers/solid_color_layer.h" |
[email protected] | 7f0d825f | 2013-03-18 07:24:30 | [diff] [blame] | 12 | #include "cc/output/context_provider.h" |
[email protected] | 73405fb | 2013-12-11 04:59:37 | [diff] [blame] | 13 | #include "cc/output/copy_output_request.h" |
| 14 | #include "cc/output/copy_output_result.h" |
[email protected] | 9260757f | 2013-09-17 01:24:16 | [diff] [blame] | 15 | #include "cc/resources/single_release_callback.h" |
[email protected] | 703dd66 | 2013-03-05 07:37:42 | [diff] [blame] | 16 | #include "content/common/browser_plugin/browser_plugin_messages.h" |
[email protected] | 95d3182 | 2014-01-03 22:21:55 | [diff] [blame] | 17 | #include "content/common/frame_messages.h" |
[email protected] | a45c46e | 2013-03-07 01:04:46 | [diff] [blame] | 18 | #include "content/common/gpu/client/context_provider_command_buffer.h" |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 19 | #include "content/renderer/browser_plugin/browser_plugin.h" |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 20 | #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 21 | #include "content/renderer/render_frame_impl.h" |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 22 | #include "content/renderer/render_frame_proxy.h" |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 23 | #include "content/renderer/render_thread_impl.h" |
[email protected] | 73405fb | 2013-12-11 04:59:37 | [diff] [blame] | 24 | #include "skia/ext/image_operations.h" |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 25 | #include "third_party/WebKit/public/web/WebFrame.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 26 | #include "third_party/WebKit/public/web/WebPluginContainer.h" |
[email protected] | 7f0d825f | 2013-03-18 07:24:30 | [diff] [blame] | 27 | #include "third_party/khronos/GLES2/gl2.h" |
tfarina | ebe974f0 | 2015-01-03 04:25:32 | [diff] [blame] | 28 | #include "ui/gfx/geometry/size_conversions.h" |
[email protected] | 73405fb | 2013-12-11 04:59:37 | [diff] [blame] | 29 | #include "ui/gfx/skia_util.h" |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 30 | |
| 31 | namespace content { |
| 32 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 33 | ChildFrameCompositingHelper* |
[email protected] | c092f5c | 2014-07-18 01:34:33 | [diff] [blame] | 34 | ChildFrameCompositingHelper::CreateForBrowserPlugin( |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 35 | const base::WeakPtr<BrowserPlugin>& browser_plugin) { |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 36 | return new ChildFrameCompositingHelper( |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 37 | browser_plugin, NULL, NULL, browser_plugin->render_view_routing_id()); |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | ChildFrameCompositingHelper* |
[email protected] | c092f5c | 2014-07-18 01:34:33 | [diff] [blame] | 41 | ChildFrameCompositingHelper::CreateForRenderFrameProxy( |
| 42 | RenderFrameProxy* render_frame_proxy) { |
| 43 | return new ChildFrameCompositingHelper(base::WeakPtr<BrowserPlugin>(), |
| 44 | render_frame_proxy->web_frame(), |
| 45 | render_frame_proxy, |
| 46 | render_frame_proxy->routing_id()); |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | ChildFrameCompositingHelper::ChildFrameCompositingHelper( |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 50 | const base::WeakPtr<BrowserPlugin>& browser_plugin, |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 51 | blink::WebFrame* frame, |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 52 | RenderFrameProxy* render_frame_proxy, |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 53 | int host_routing_id) |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 54 | : host_routing_id_(host_routing_id), |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 55 | last_route_id_(0), |
[email protected] | 53b4cc1 | 2013-07-18 23:02:30 | [diff] [blame] | 56 | last_output_surface_id_(0), |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 57 | last_host_id_(0), |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 58 | ack_pending_(true), |
[email protected] | 6d3a46e | 2013-11-25 23:08:53 | [diff] [blame] | 59 | opaque_(true), |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 60 | browser_plugin_(browser_plugin), |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 61 | render_frame_proxy_(render_frame_proxy), |
[email protected] | bdca9be2 | 2014-02-18 00:37:49 | [diff] [blame] | 62 | frame_(frame) {} |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 63 | |
lfg | a7d368e | 2015-02-03 23:01:37 | [diff] [blame^] | 64 | ChildFrameCompositingHelper::~ChildFrameCompositingHelper() { |
| 65 | if (resource_collection_.get()) |
| 66 | resource_collection_->SetClient(NULL); |
| 67 | } |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 68 | |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 69 | BrowserPluginManager* ChildFrameCompositingHelper::GetBrowserPluginManager() { |
| 70 | if (!browser_plugin_) |
| 71 | return NULL; |
| 72 | |
fsamuel | 6c1dfeb | 2014-12-18 19:21:33 | [diff] [blame] | 73 | return BrowserPluginManager::Get(); |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | blink::WebPluginContainer* ChildFrameCompositingHelper::GetContainer() { |
| 77 | if (!browser_plugin_) |
| 78 | return NULL; |
| 79 | |
| 80 | return browser_plugin_->container(); |
| 81 | } |
| 82 | |
| 83 | int ChildFrameCompositingHelper::GetInstanceID() { |
| 84 | if (!browser_plugin_) |
| 85 | return 0; |
| 86 | |
[email protected] | 2101c4c | 2014-08-22 00:16:16 | [diff] [blame] | 87 | return browser_plugin_->browser_plugin_instance_id(); |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 88 | } |
| 89 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 90 | void ChildFrameCompositingHelper::SendCompositorFrameSwappedACKToBrowser( |
| 91 | FrameHostMsg_CompositorFrameSwappedACK_Params& params) { |
| 92 | // This function will be removed when BrowserPluginManager is removed and |
| 93 | // BrowserPlugin is modified to use a RenderFrame. |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 94 | if (GetBrowserPluginManager()) { |
| 95 | GetBrowserPluginManager()->Send( |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 96 | new BrowserPluginHostMsg_CompositorFrameSwappedACK( |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 97 | host_routing_id_, GetInstanceID(), params)); |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 98 | } else if (render_frame_proxy_) { |
| 99 | render_frame_proxy_->Send( |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 100 | new FrameHostMsg_CompositorFrameSwappedACK(host_routing_id_, params)); |
| 101 | } |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 102 | } |
| 103 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 104 | void ChildFrameCompositingHelper::SendReclaimCompositorResourcesToBrowser( |
| 105 | FrameHostMsg_ReclaimCompositorResources_Params& params) { |
| 106 | // This function will be removed when BrowserPluginManager is removed and |
| 107 | // BrowserPlugin is modified to use a RenderFrame. |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 108 | if (GetBrowserPluginManager()) { |
| 109 | GetBrowserPluginManager()->Send( |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 110 | new BrowserPluginHostMsg_ReclaimCompositorResources( |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 111 | host_routing_id_, GetInstanceID(), params)); |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 112 | } else if (render_frame_proxy_) { |
| 113 | render_frame_proxy_->Send( |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 114 | new FrameHostMsg_ReclaimCompositorResources(host_routing_id_, params)); |
| 115 | } |
| 116 | } |
| 117 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 118 | void ChildFrameCompositingHelper::DidCommitCompositorFrame() { |
[email protected] | 09f6738 | 2013-10-09 21:03:45 | [diff] [blame] | 119 | if (!resource_collection_.get() || !ack_pending_) |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 120 | return; |
[email protected] | 396fbb7 | 2013-01-23 02:33:43 | [diff] [blame] | 121 | |
[email protected] | 95d3182 | 2014-01-03 22:21:55 | [diff] [blame] | 122 | FrameHostMsg_CompositorFrameSwappedACK_Params params; |
| 123 | params.producing_host_id = last_host_id_; |
| 124 | params.producing_route_id = last_route_id_; |
| 125 | params.output_surface_id = last_output_surface_id_; |
| 126 | resource_collection_->TakeUnusedResourcesForChildCompositor( |
| 127 | ¶ms.ack.resources); |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 128 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 129 | SendCompositorFrameSwappedACKToBrowser(params); |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 130 | |
| 131 | ack_pending_ = false; |
| 132 | } |
| 133 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 134 | void ChildFrameCompositingHelper::EnableCompositing(bool enable) { |
[email protected] | fc72bb1 | 2013-06-02 21:13:46 | [diff] [blame] | 135 | if (enable && !background_layer_.get()) { |
[email protected] | 67be9b1d | 2013-03-08 02:27:45 | [diff] [blame] | 136 | background_layer_ = cc::SolidColorLayer::Create(); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 137 | background_layer_->SetMasksToBounds(true); |
| 138 | background_layer_->SetBackgroundColor( |
[email protected] | 396fbb7 | 2013-01-23 02:33:43 | [diff] [blame] | 139 | SkColorSetARGBInline(255, 255, 255, 255)); |
[email protected] | 3856462 | 2014-08-19 02:47:18 | [diff] [blame] | 140 | web_layer_.reset(new cc_blink::WebLayerImpl(background_layer_)); |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 141 | } |
| 142 | |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 143 | if (GetContainer()) { |
| 144 | GetContainer()->setWebLayer(enable ? web_layer_.get() : NULL); |
| 145 | } else if (frame_) { |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 146 | frame_->setRemoteWebLayer(enable ? web_layer_.get() : NULL); |
| 147 | } |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 148 | } |
| 149 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 150 | void ChildFrameCompositingHelper::CheckSizeAndAdjustLayerProperties( |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 151 | const gfx::Size& new_size, |
| 152 | float device_scale_factor, |
| 153 | cc::Layer* layer) { |
| 154 | if (buffer_size_ != new_size) { |
| 155 | buffer_size_ = new_size; |
| 156 | // The container size is in DIP, so is the layer size. |
| 157 | // Buffer size is in physical pixels, so we need to adjust |
| 158 | // it by the device scale factor. |
| 159 | gfx::Size device_scale_adjusted_size = gfx::ToFlooredSize( |
| 160 | gfx::ScaleSize(buffer_size_, 1.0f / device_scale_factor)); |
| 161 | layer->SetBounds(device_scale_adjusted_size); |
| 162 | } |
[email protected] | 6d3a46e | 2013-11-25 23:08:53 | [diff] [blame] | 163 | |
| 164 | // Manually manage background layer for transparent webview. |
| 165 | if (!opaque_) |
| 166 | background_layer_->SetIsDrawable(false); |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 167 | } |
| 168 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 169 | void ChildFrameCompositingHelper::OnContainerDestroy() { |
fsamuel | 0147b10 | 2014-11-10 17:05:01 | [diff] [blame] | 170 | // If we have a pending ACK, then ACK now so we don't lose frames in the |
| 171 | // future. |
| 172 | DidCommitCompositorFrame(); |
| 173 | |
[email protected] | 94224ba6 | 2014-02-04 00:25:24 | [diff] [blame] | 174 | if (GetContainer()) |
| 175 | GetContainer()->setWebLayer(NULL); |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 176 | |
dcheng | 58867a9 | 2014-08-26 02:50:22 | [diff] [blame] | 177 | if (resource_collection_.get()) |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 178 | resource_collection_->SetClient(NULL); |
| 179 | |
[email protected] | 7873fe4e | 2013-11-14 18:35:22 | [diff] [blame] | 180 | ack_pending_ = false; |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 181 | resource_collection_ = NULL; |
| 182 | frame_provider_ = NULL; |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 183 | delegated_layer_ = NULL; |
[email protected] | 396fbb7 | 2013-01-23 02:33:43 | [diff] [blame] | 184 | background_layer_ = NULL; |
[email protected] | 0d25cb6 | 2013-01-21 15:42:21 | [diff] [blame] | 185 | web_layer_.reset(); |
| 186 | } |
| 187 | |
[email protected] | f49722f | 2014-01-30 17:54:50 | [diff] [blame] | 188 | void ChildFrameCompositingHelper::ChildFrameGone() { |
| 189 | background_layer_->SetBackgroundColor(SkColorSetARGBInline(255, 0, 128, 0)); |
| 190 | background_layer_->RemoveAllChildren(); |
| 191 | background_layer_->SetIsDrawable(true); |
| 192 | background_layer_->SetContentsOpaque(true); |
| 193 | } |
| 194 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 195 | void ChildFrameCompositingHelper::OnCompositorFrameSwapped( |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 196 | scoped_ptr<cc::CompositorFrame> frame, |
| 197 | int route_id, |
[email protected] | 53b4cc1 | 2013-07-18 23:02:30 | [diff] [blame] | 198 | uint32 output_surface_id, |
[email protected] | f197008 | 2014-04-09 04:29:56 | [diff] [blame] | 199 | int host_id, |
| 200 | base::SharedMemoryHandle handle) { |
[email protected] | 09f6738 | 2013-10-09 21:03:45 | [diff] [blame] | 201 | cc::DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 202 | // Do nothing if we are getting destroyed or have no frame data. |
dcheng | 58867a9 | 2014-08-26 02:50:22 | [diff] [blame] | 203 | if (!frame_data || !background_layer_.get()) |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 204 | return; |
| 205 | |
[email protected] | 09f6738 | 2013-10-09 21:03:45 | [diff] [blame] | 206 | DCHECK(!frame_data->render_pass_list.empty()); |
| 207 | cc::RenderPass* root_pass = frame_data->render_pass_list.back(); |
| 208 | gfx::Size frame_size = root_pass->output_rect.size(); |
| 209 | |
[email protected] | 317f17d | 2013-11-09 05:03:48 | [diff] [blame] | 210 | if (last_route_id_ != route_id || |
| 211 | last_output_surface_id_ != output_surface_id || |
| 212 | last_host_id_ != host_id) { |
| 213 | // Resource ids are scoped by the output surface. |
| 214 | // If the originating output surface doesn't match the last one, it |
| 215 | // indicates the guest's output surface may have been recreated, in which |
| 216 | // case we should recreate the DelegatedRendererLayer, to avoid matching |
| 217 | // resources from the old one with resources from the new one which would |
| 218 | // have the same id. |
| 219 | frame_provider_ = NULL; |
| 220 | |
| 221 | // Drop the cc::DelegatedFrameResourceCollection so that we will not return |
| 222 | // any resources from the old output surface with the new output surface id. |
dcheng | 58867a9 | 2014-08-26 02:50:22 | [diff] [blame] | 223 | if (resource_collection_.get()) { |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 224 | resource_collection_->SetClient(NULL); |
| 225 | |
| 226 | if (resource_collection_->LoseAllResources()) |
| 227 | SendReturnedDelegatedResources(); |
[email protected] | 317f17d | 2013-11-09 05:03:48 | [diff] [blame] | 228 | resource_collection_ = NULL; |
| 229 | } |
| 230 | last_output_surface_id_ = output_surface_id; |
| 231 | last_route_id_ = route_id; |
| 232 | last_host_id_ = host_id; |
| 233 | } |
dcheng | 58867a9 | 2014-08-26 02:50:22 | [diff] [blame] | 234 | if (!resource_collection_.get()) { |
[email protected] | 09f6738 | 2013-10-09 21:03:45 | [diff] [blame] | 235 | resource_collection_ = new cc::DelegatedFrameResourceCollection; |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 236 | resource_collection_->SetClient(this); |
[email protected] | 09f6738 | 2013-10-09 21:03:45 | [diff] [blame] | 237 | } |
| 238 | if (!frame_provider_.get() || frame_provider_->frame_size() != frame_size) { |
| 239 | frame_provider_ = new cc::DelegatedFrameProvider( |
| 240 | resource_collection_.get(), frame->delegated_frame_data.Pass()); |
| 241 | if (delegated_layer_.get()) |
| 242 | delegated_layer_->RemoveFromParent(); |
| 243 | delegated_layer_ = |
[email protected] | b59c161 | 2013-12-04 00:56:49 | [diff] [blame] | 244 | cc::DelegatedRendererLayer::Create(frame_provider_.get()); |
[email protected] | 09f6738 | 2013-10-09 21:03:45 | [diff] [blame] | 245 | delegated_layer_->SetIsDrawable(true); |
fsamuel | e9741a3 | 2014-09-09 05:34:07 | [diff] [blame] | 246 | buffer_size_ = gfx::Size(); |
[email protected] | 6d3a46e | 2013-11-25 23:08:53 | [diff] [blame] | 247 | SetContentsOpaque(opaque_); |
[email protected] | 09f6738 | 2013-10-09 21:03:45 | [diff] [blame] | 248 | background_layer_->AddChild(delegated_layer_); |
| 249 | } else { |
| 250 | frame_provider_->SetFrameData(frame->delegated_frame_data.Pass()); |
| 251 | } |
| 252 | |
[email protected] | 6d3a46e | 2013-11-25 23:08:53 | [diff] [blame] | 253 | CheckSizeAndAdjustLayerProperties( |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 254 | frame_data->render_pass_list.back()->output_rect.size(), |
| 255 | frame->metadata.device_scale_factor, |
| 256 | delegated_layer_.get()); |
| 257 | |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 258 | ack_pending_ = true; |
| 259 | } |
| 260 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 261 | void ChildFrameCompositingHelper::UpdateVisibility(bool visible) { |
[email protected] | fc72bb1 | 2013-06-02 21:13:46 | [diff] [blame] | 262 | if (delegated_layer_.get()) |
[email protected] | f5b4b0f | 2013-04-02 18:16:28 | [diff] [blame] | 263 | delegated_layer_->SetIsDrawable(visible); |
[email protected] | 69b7912 | 2013-02-14 19:16:45 | [diff] [blame] | 264 | } |
| 265 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 266 | void ChildFrameCompositingHelper::UnusedResourcesAreAvailable() { |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 267 | if (ack_pending_) |
| 268 | return; |
| 269 | |
| 270 | SendReturnedDelegatedResources(); |
| 271 | } |
| 272 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 273 | void ChildFrameCompositingHelper::SendReturnedDelegatedResources() { |
| 274 | FrameHostMsg_ReclaimCompositorResources_Params params; |
dcheng | 58867a9 | 2014-08-26 02:50:22 | [diff] [blame] | 275 | if (resource_collection_.get()) |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 276 | resource_collection_->TakeUnusedResourcesForChildCompositor( |
| 277 | ¶ms.ack.resources); |
| 278 | DCHECK(!params.ack.resources.empty()); |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 279 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 280 | params.route_id = last_route_id_; |
| 281 | params.output_surface_id = last_output_surface_id_; |
| 282 | params.renderer_host_id = last_host_id_; |
| 283 | SendReclaimCompositorResourcesToBrowser(params); |
[email protected] | b0030b7 | 2013-11-15 20:35:53 | [diff] [blame] | 284 | } |
| 285 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 286 | void ChildFrameCompositingHelper::SetContentsOpaque(bool opaque) { |
[email protected] | 6d3a46e | 2013-11-25 23:08:53 | [diff] [blame] | 287 | opaque_ = opaque; |
[email protected] | 6d3a46e | 2013-11-25 23:08:53 | [diff] [blame] | 288 | if (delegated_layer_.get()) |
| 289 | delegated_layer_->SetContentsOpaque(opaque_); |
| 290 | } |
| 291 | |
[email protected] | 0f21e858 | 2013-01-11 11:06:56 | [diff] [blame] | 292 | } // namespace content |