Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/child_frame_compositing_helper.h" | 5 #include "content/renderer/child_frame_compositing_helper.h" |
| 6 | 6 |
| 7 #include "cc/blink/web_layer_impl.h" | 7 #include "cc/blink/web_layer_impl.h" |
| 8 #include "cc/layers/delegated_frame_provider.h" | 8 #include "cc/layers/delegated_frame_provider.h" |
| 9 #include "cc/layers/delegated_frame_resource_collection.h" | 9 #include "cc/layers/delegated_frame_resource_collection.h" |
| 10 #include "cc/layers/delegated_renderer_layer.h" | 10 #include "cc/layers/delegated_renderer_layer.h" |
| 11 #include "cc/layers/solid_color_layer.h" | 11 #include "cc/layers/solid_color_layer.h" |
| 12 #include "cc/layers/texture_layer.h" | 12 #include "cc/layers/texture_layer.h" |
| 13 #include "cc/output/context_provider.h" | 13 #include "cc/output/context_provider.h" |
| 14 #include "cc/output/copy_output_request.h" | 14 #include "cc/output/copy_output_request.h" |
| 15 #include "cc/output/copy_output_result.h" | 15 #include "cc/output/copy_output_result.h" |
| 16 #include "cc/resources/single_release_callback.h" | 16 #include "cc/resources/single_release_callback.h" |
| 17 #include "content/common/browser_plugin/browser_plugin_messages.h" | 17 #include "content/common/browser_plugin/browser_plugin_messages.h" |
| 18 #include "content/common/frame_messages.h" | 18 #include "content/common/frame_messages.h" |
| 19 #include "content/common/gpu/client/context_provider_command_buffer.h" | 19 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 20 #include "content/renderer/browser_plugin/browser_plugin.h" | 20 #include "content/renderer/browser_plugin/browser_plugin.h" |
| 21 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 21 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
| 22 #include "content/renderer/render_frame_impl.h" | 22 #include "content/renderer/render_frame_impl.h" |
| 23 #include "content/renderer/render_frame_proxy.h" | 23 #include "content/renderer/render_frame_proxy.h" |
| 24 #include "content/renderer/render_thread_impl.h" | 24 #include "content/renderer/render_thread_impl.h" |
| 25 #include "skia/ext/image_operations.h" | 25 #include "skia/ext/image_operations.h" |
| 26 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | |
| 27 #include "third_party/WebKit/public/web/WebFrame.h" | 26 #include "third_party/WebKit/public/web/WebFrame.h" |
| 28 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 27 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 29 #include "third_party/khronos/GLES2/gl2.h" | 28 #include "third_party/khronos/GLES2/gl2.h" |
| 30 #include "ui/gfx/size_conversions.h" | 29 #include "ui/gfx/size_conversions.h" |
| 31 #include "ui/gfx/skia_util.h" | 30 #include "ui/gfx/skia_util.h" |
| 32 | 31 |
| 33 namespace content { | 32 namespace content { |
| 34 | 33 |
| 35 ChildFrameCompositingHelper::SwapBuffersInfo::SwapBuffersInfo() | |
| 36 : route_id(0), | |
| 37 output_surface_id(0), | |
| 38 host_id(0), | |
| 39 software_frame_id(0), | |
| 40 shared_memory(NULL) {} | |
| 41 | |
| 42 ChildFrameCompositingHelper* | 34 ChildFrameCompositingHelper* |
| 43 ChildFrameCompositingHelper::CreateForBrowserPlugin( | 35 ChildFrameCompositingHelper::CreateForBrowserPlugin( |
| 44 const base::WeakPtr<BrowserPlugin>& browser_plugin) { | 36 const base::WeakPtr<BrowserPlugin>& browser_plugin) { |
| 45 return new ChildFrameCompositingHelper( | 37 return new ChildFrameCompositingHelper( |
| 46 browser_plugin, NULL, NULL, browser_plugin->render_view_routing_id()); | 38 browser_plugin, NULL, NULL, browser_plugin->render_view_routing_id()); |
| 47 } | 39 } |
| 48 | 40 |
| 49 ChildFrameCompositingHelper* | 41 ChildFrameCompositingHelper* |
| 50 ChildFrameCompositingHelper::CreateForRenderFrameProxy( | 42 ChildFrameCompositingHelper::CreateForRenderFrameProxy( |
| 51 RenderFrameProxy* render_frame_proxy) { | 43 RenderFrameProxy* render_frame_proxy) { |
| 52 return new ChildFrameCompositingHelper(base::WeakPtr<BrowserPlugin>(), | 44 return new ChildFrameCompositingHelper(base::WeakPtr<BrowserPlugin>(), |
| 53 render_frame_proxy->web_frame(), | 45 render_frame_proxy->web_frame(), |
| 54 render_frame_proxy, | 46 render_frame_proxy, |
| 55 render_frame_proxy->routing_id()); | 47 render_frame_proxy->routing_id()); |
| 56 } | 48 } |
| 57 | 49 |
| 58 ChildFrameCompositingHelper::ChildFrameCompositingHelper( | 50 ChildFrameCompositingHelper::ChildFrameCompositingHelper( |
| 59 const base::WeakPtr<BrowserPlugin>& browser_plugin, | 51 const base::WeakPtr<BrowserPlugin>& browser_plugin, |
| 60 blink::WebFrame* frame, | 52 blink::WebFrame* frame, |
| 61 RenderFrameProxy* render_frame_proxy, | 53 RenderFrameProxy* render_frame_proxy, |
| 62 int host_routing_id) | 54 int host_routing_id) |
| 63 : host_routing_id_(host_routing_id), | 55 : host_routing_id_(host_routing_id), |
| 64 last_route_id_(0), | 56 last_route_id_(0), |
| 65 last_output_surface_id_(0), | 57 last_output_surface_id_(0), |
| 66 last_host_id_(0), | 58 last_host_id_(0), |
| 67 last_mailbox_valid_(false), | |
| 68 ack_pending_(true), | 59 ack_pending_(true), |
| 69 software_ack_pending_(false), | |
| 70 opaque_(true), | 60 opaque_(true), |
| 71 browser_plugin_(browser_plugin), | 61 browser_plugin_(browser_plugin), |
| 72 render_frame_proxy_(render_frame_proxy), | 62 render_frame_proxy_(render_frame_proxy), |
| 73 frame_(frame) {} | 63 frame_(frame) {} |
| 74 | 64 |
| 75 ChildFrameCompositingHelper::~ChildFrameCompositingHelper() {} | 65 ChildFrameCompositingHelper::~ChildFrameCompositingHelper() {} |
| 76 | 66 |
| 77 BrowserPluginManager* ChildFrameCompositingHelper::GetBrowserPluginManager() { | 67 BrowserPluginManager* ChildFrameCompositingHelper::GetBrowserPluginManager() { |
| 78 if (!browser_plugin_) | 68 if (!browser_plugin_) |
| 79 return NULL; | 69 return NULL; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 102 if (GetBrowserPluginManager()) { | 92 if (GetBrowserPluginManager()) { |
| 103 GetBrowserPluginManager()->Send( | 93 GetBrowserPluginManager()->Send( |
| 104 new BrowserPluginHostMsg_CompositorFrameSwappedACK( | 94 new BrowserPluginHostMsg_CompositorFrameSwappedACK( |
| 105 host_routing_id_, GetInstanceID(), params)); | 95 host_routing_id_, GetInstanceID(), params)); |
| 106 } else if (render_frame_proxy_) { | 96 } else if (render_frame_proxy_) { |
| 107 render_frame_proxy_->Send( | 97 render_frame_proxy_->Send( |
| 108 new FrameHostMsg_CompositorFrameSwappedACK(host_routing_id_, params)); | 98 new FrameHostMsg_CompositorFrameSwappedACK(host_routing_id_, params)); |
| 109 } | 99 } |
| 110 } | 100 } |
| 111 | 101 |
| 112 void ChildFrameCompositingHelper::SendBuffersSwappedACKToBrowser( | |
| 113 FrameHostMsg_BuffersSwappedACK_Params& params) { | |
| 114 // This function will be removed when BrowserPluginManager is removed and | |
| 115 // BrowserPlugin is modified to use a RenderFrame. | |
| 116 if (GetBrowserPluginManager()) { | |
| 117 GetBrowserPluginManager()->Send(new BrowserPluginHostMsg_BuffersSwappedACK( | |
| 118 host_routing_id_, params)); | |
| 119 } else if (render_frame_proxy_) { | |
| 120 render_frame_proxy_->Send( | |
| 121 new FrameHostMsg_BuffersSwappedACK(host_routing_id_, params)); | |
| 122 } | |
| 123 } | |
| 124 | |
| 125 void ChildFrameCompositingHelper::SendReclaimCompositorResourcesToBrowser( | 102 void ChildFrameCompositingHelper::SendReclaimCompositorResourcesToBrowser( |
| 126 FrameHostMsg_ReclaimCompositorResources_Params& params) { | 103 FrameHostMsg_ReclaimCompositorResources_Params& params) { |
| 127 // This function will be removed when BrowserPluginManager is removed and | 104 // This function will be removed when BrowserPluginManager is removed and |
| 128 // BrowserPlugin is modified to use a RenderFrame. | 105 // BrowserPlugin is modified to use a RenderFrame. |
| 129 if (GetBrowserPluginManager()) { | 106 if (GetBrowserPluginManager()) { |
| 130 GetBrowserPluginManager()->Send( | 107 GetBrowserPluginManager()->Send( |
| 131 new BrowserPluginHostMsg_ReclaimCompositorResources( | 108 new BrowserPluginHostMsg_ReclaimCompositorResources( |
| 132 host_routing_id_, GetInstanceID(), params)); | 109 host_routing_id_, GetInstanceID(), params)); |
| 133 } else if (render_frame_proxy_) { | 110 } else if (render_frame_proxy_) { |
| 134 render_frame_proxy_->Send( | 111 render_frame_proxy_->Send( |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 145 cc::CopyOutputRequest::CreateBitmapRequest(base::Bind( | 122 cc::CopyOutputRequest::CreateBitmapRequest(base::Bind( |
| 146 &ChildFrameCompositingHelper::CopyFromCompositingSurfaceHasResult, | 123 &ChildFrameCompositingHelper::CopyFromCompositingSurfaceHasResult, |
| 147 this, | 124 this, |
| 148 request_id, | 125 request_id, |
| 149 dest_size)); | 126 dest_size)); |
| 150 request->set_area(source_rect); | 127 request->set_area(source_rect); |
| 151 background_layer_->RequestCopyOfOutput(request.Pass()); | 128 background_layer_->RequestCopyOfOutput(request.Pass()); |
| 152 } | 129 } |
| 153 | 130 |
| 154 void ChildFrameCompositingHelper::DidCommitCompositorFrame() { | 131 void ChildFrameCompositingHelper::DidCommitCompositorFrame() { |
| 155 if (software_ack_pending_) { | |
| 156 FrameHostMsg_CompositorFrameSwappedACK_Params params; | |
| 157 params.producing_host_id = last_host_id_; | |
| 158 params.producing_route_id = last_route_id_; | |
| 159 params.output_surface_id = last_output_surface_id_; | |
| 160 if (!unacked_software_frames_.empty()) { | |
| 161 params.ack.last_software_frame_id = unacked_software_frames_.back(); | |
| 162 unacked_software_frames_.pop_back(); | |
| 163 } | |
| 164 | |
| 165 SendCompositorFrameSwappedACKToBrowser(params); | |
| 166 | |
| 167 software_ack_pending_ = false; | |
| 168 } | |
| 169 if (!resource_collection_.get() || !ack_pending_) | 132 if (!resource_collection_.get() || !ack_pending_) |
| 170 return; | 133 return; |
| 171 | 134 |
| 172 FrameHostMsg_CompositorFrameSwappedACK_Params params; | 135 FrameHostMsg_CompositorFrameSwappedACK_Params params; |
| 173 params.producing_host_id = last_host_id_; | 136 params.producing_host_id = last_host_id_; |
| 174 params.producing_route_id = last_route_id_; | 137 params.producing_route_id = last_route_id_; |
| 175 params.output_surface_id = last_output_surface_id_; | 138 params.output_surface_id = last_output_surface_id_; |
| 176 resource_collection_->TakeUnusedResourcesForChildCompositor( | 139 resource_collection_->TakeUnusedResourcesForChildCompositor( |
| 177 ¶ms.ack.resources); | 140 ¶ms.ack.resources); |
| 178 | 141 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 209 gfx::Size device_scale_adjusted_size = gfx::ToFlooredSize( | 172 gfx::Size device_scale_adjusted_size = gfx::ToFlooredSize( |
| 210 gfx::ScaleSize(buffer_size_, 1.0f / device_scale_factor)); | 173 gfx::ScaleSize(buffer_size_, 1.0f / device_scale_factor)); |
| 211 layer->SetBounds(device_scale_adjusted_size); | 174 layer->SetBounds(device_scale_adjusted_size); |
| 212 } | 175 } |
| 213 | 176 |
| 214 // Manually manage background layer for transparent webview. | 177 // Manually manage background layer for transparent webview. |
| 215 if (!opaque_) | 178 if (!opaque_) |
| 216 background_layer_->SetIsDrawable(false); | 179 background_layer_->SetIsDrawable(false); |
| 217 } | 180 } |
| 218 | 181 |
| 219 void ChildFrameCompositingHelper::MailboxReleased(SwapBuffersInfo mailbox, | |
| 220 uint32 sync_point, | |
| 221 bool lost_resource) { | |
| 222 if (mailbox.type == SOFTWARE_COMPOSITOR_FRAME) { | |
| 223 delete mailbox.shared_memory; | |
| 224 mailbox.shared_memory = NULL; | |
| 225 } else if (lost_resource) { | |
| 226 // Reset mailbox's name if the resource was lost. | |
| 227 mailbox.name.SetZero(); | |
| 228 } | |
| 229 | |
| 230 // This means the GPU process crashed or guest crashed. | |
| 231 if (last_host_id_ != mailbox.host_id || | |
| 232 last_output_surface_id_ != mailbox.output_surface_id || | |
| 233 last_route_id_ != mailbox.route_id) | |
| 234 return; | |
| 235 | |
| 236 if (mailbox.type == SOFTWARE_COMPOSITOR_FRAME) | |
| 237 unacked_software_frames_.push_back(mailbox.software_frame_id); | |
| 238 | |
| 239 // We need to send an ACK to for every buffer sent to us. | |
| 240 // However, if a buffer is freed up from | |
| 241 // the compositor in cases like switching back to SW mode without a new | |
| 242 // buffer arriving, no ACK is needed. | |
| 243 if (!ack_pending_) { | |
| 244 last_mailbox_valid_ = false; | |
| 245 return; | |
| 246 } | |
| 247 ack_pending_ = false; | |
| 248 switch (mailbox.type) { | |
| 249 case TEXTURE_IMAGE_TRANSPORT: { | |
| 250 FrameHostMsg_BuffersSwappedACK_Params params; | |
| 251 params.gpu_host_id = mailbox.host_id; | |
| 252 params.gpu_route_id = mailbox.route_id; | |
| 253 params.mailbox = mailbox.name; | |
| 254 params.sync_point = sync_point; | |
| 255 SendBuffersSwappedACKToBrowser(params); | |
| 256 break; | |
| 257 } | |
| 258 case GL_COMPOSITOR_FRAME: { | |
| 259 FrameHostMsg_CompositorFrameSwappedACK_Params params; | |
| 260 params.producing_host_id = mailbox.host_id; | |
| 261 params.producing_route_id = mailbox.route_id; | |
| 262 params.output_surface_id = mailbox.output_surface_id; | |
| 263 params.ack.gl_frame_data.reset(new cc::GLFrameData()); | |
| 264 params.ack.gl_frame_data->mailbox = mailbox.name; | |
| 265 params.ack.gl_frame_data->size = mailbox.size; | |
| 266 params.ack.gl_frame_data->sync_point = sync_point; | |
| 267 SendCompositorFrameSwappedACKToBrowser(params); | |
| 268 break; | |
| 269 } | |
| 270 case SOFTWARE_COMPOSITOR_FRAME: | |
| 271 break; | |
| 272 } | |
| 273 } | |
| 274 | |
| 275 void ChildFrameCompositingHelper::OnContainerDestroy() { | 182 void ChildFrameCompositingHelper::OnContainerDestroy() { |
| 276 if (GetContainer()) | 183 if (GetContainer()) |
| 277 GetContainer()->setWebLayer(NULL); | 184 GetContainer()->setWebLayer(NULL); |
| 278 | 185 |
| 279 if (resource_collection_.get()) | 186 if (resource_collection_.get()) |
| 280 resource_collection_->SetClient(NULL); | 187 resource_collection_->SetClient(NULL); |
| 281 | 188 |
| 282 ack_pending_ = false; | 189 ack_pending_ = false; |
| 283 software_ack_pending_ = false; | |
| 284 resource_collection_ = NULL; | 190 resource_collection_ = NULL; |
| 285 frame_provider_ = NULL; | 191 frame_provider_ = NULL; |
| 286 texture_layer_ = NULL; | 192 texture_layer_ = NULL; |
| 287 delegated_layer_ = NULL; | 193 delegated_layer_ = NULL; |
| 288 background_layer_ = NULL; | 194 background_layer_ = NULL; |
| 289 web_layer_.reset(); | 195 web_layer_.reset(); |
| 290 } | 196 } |
| 291 | 197 |
| 292 void ChildFrameCompositingHelper::ChildFrameGone() { | 198 void ChildFrameCompositingHelper::ChildFrameGone() { |
| 293 background_layer_->SetBackgroundColor(SkColorSetARGBInline(255, 0, 128, 0)); | 199 background_layer_->SetBackgroundColor(SkColorSetARGBInline(255, 0, 128, 0)); |
| 294 background_layer_->RemoveAllChildren(); | 200 background_layer_->RemoveAllChildren(); |
| 295 background_layer_->SetIsDrawable(true); | 201 background_layer_->SetIsDrawable(true); |
| 296 background_layer_->SetContentsOpaque(true); | 202 background_layer_->SetContentsOpaque(true); |
| 297 } | 203 } |
| 298 | 204 |
| 299 void ChildFrameCompositingHelper::OnBuffersSwappedPrivate( | |
| 300 const SwapBuffersInfo& mailbox, | |
| 301 uint32 sync_point, | |
| 302 float device_scale_factor) { | |
| 303 DCHECK(!delegated_layer_.get()); | |
| 304 // If these mismatch, we are either just starting up, GPU process crashed or | |
| 305 // guest renderer crashed. | |
| 306 // In this case, we are communicating with a new image transport | |
| 307 // surface and must ACK with the new ID's and an empty mailbox. | |
| 308 if (last_route_id_ != mailbox.route_id || | |
| 309 last_output_surface_id_ != mailbox.output_surface_id || | |
| 310 last_host_id_ != mailbox.host_id) | |
| 311 last_mailbox_valid_ = false; | |
| 312 | |
| 313 last_route_id_ = mailbox.route_id; | |
| 314 last_output_surface_id_ = mailbox.output_surface_id; | |
| 315 last_host_id_ = mailbox.host_id; | |
| 316 | |
| 317 ack_pending_ = true; | |
| 318 // Browser plugin getting destroyed, do a fast ACK. | |
| 319 if (!background_layer_.get()) { | |
| 320 MailboxReleased(mailbox, sync_point, false); | |
| 321 return; | |
| 322 } | |
| 323 | |
| 324 if (!texture_layer_.get()) { | |
| 325 texture_layer_ = cc::TextureLayer::CreateForMailbox(NULL); | |
| 326 texture_layer_->SetIsDrawable(true); | |
| 327 SetContentsOpaque(opaque_); | |
| 328 | |
| 329 background_layer_->AddChild(texture_layer_); | |
| 330 } | |
| 331 | |
| 332 // The size of browser plugin container is not always equal to the size | |
| 333 // of the buffer that arrives here. This could be for a number of reasons, | |
| 334 // including autosize and a resize in progress. | |
| 335 // During resize, the container size changes first and then some time | |
| 336 // later, a new buffer with updated size will arrive. During this process, | |
| 337 // we need to make sure that things are still displayed pixel perfect. | |
| 338 // We accomplish this by modifying bounds of the texture layer only | |
| 339 // when a new buffer arrives. | |
| 340 // Visually, this will either display a smaller part of the buffer | |
| 341 // or introduce a gutter around it. | |
| 342 CheckSizeAndAdjustLayerProperties( | |
| 343 mailbox.size, device_scale_factor, texture_layer_.get()); | |
| 344 | |
| 345 bool is_software_frame = mailbox.type == SOFTWARE_COMPOSITOR_FRAME; | |
| 346 bool current_mailbox_valid = is_software_frame ? mailbox.shared_memory != NULL | |
| 347 : !mailbox.name.IsZero(); | |
| 348 if (!is_software_frame && !last_mailbox_valid_) { | |
| 349 SwapBuffersInfo empty_info = mailbox; | |
| 350 empty_info.name.SetZero(); | |
| 351 MailboxReleased(empty_info, 0, false); | |
| 352 if (!current_mailbox_valid) | |
| 353 return; | |
| 354 } | |
| 355 | |
| 356 cc::TextureMailbox texture_mailbox; | |
| 357 scoped_ptr<cc::SingleReleaseCallback> release_callback; | |
| 358 if (current_mailbox_valid) { | |
| 359 release_callback = | |
| 360 cc::SingleReleaseCallback::Create( | |
| 361 base::Bind(&ChildFrameCompositingHelper::MailboxReleased, | |
| 362 scoped_refptr<ChildFrameCompositingHelper>(this), | |
| 363 mailbox)).Pass(); | |
| 364 if (is_software_frame) { | |
| 365 texture_mailbox = cc::TextureMailbox(mailbox.shared_memory, mailbox.size); | |
| 366 } else { | |
| 367 texture_mailbox = | |
| 368 cc::TextureMailbox(mailbox.name, GL_TEXTURE_2D, sync_point); | |
| 369 } | |
| 370 } | |
| 371 | |
| 372 texture_layer_->SetFlipped(!is_software_frame); | |
| 373 texture_layer_->SetTextureMailbox(texture_mailbox, release_callback.Pass()); | |
| 374 texture_layer_->SetNeedsDisplay(); | |
| 375 last_mailbox_valid_ = current_mailbox_valid; | |
| 376 } | |
| 377 | |
| 378 void ChildFrameCompositingHelper::OnBuffersSwapped( | |
| 379 const gfx::Size& size, | |
| 380 const gpu::Mailbox& mailbox, | |
| 381 int gpu_route_id, | |
| 382 int gpu_host_id, | |
| 383 float device_scale_factor) { | |
| 384 SwapBuffersInfo swap_info; | |
| 385 swap_info.name = mailbox; | |
| 386 swap_info.type = TEXTURE_IMAGE_TRANSPORT; | |
| 387 swap_info.size = size; | |
| 388 swap_info.route_id = gpu_route_id; | |
| 389 swap_info.output_surface_id = 0; | |
| 390 swap_info.host_id = gpu_host_id; | |
| 391 OnBuffersSwappedPrivate(swap_info, 0, device_scale_factor); | |
| 392 } | |
| 393 | |
| 394 void ChildFrameCompositingHelper::OnCompositorFrameSwapped( | 205 void ChildFrameCompositingHelper::OnCompositorFrameSwapped( |
| 395 scoped_ptr<cc::CompositorFrame> frame, | 206 scoped_ptr<cc::CompositorFrame> frame, |
| 396 int route_id, | 207 int route_id, |
| 397 uint32 output_surface_id, | 208 uint32 output_surface_id, |
| 398 int host_id, | 209 int host_id, |
| 399 base::SharedMemoryHandle handle) { | 210 base::SharedMemoryHandle handle) { |
| 400 | |
| 401 if (frame->gl_frame_data) { | |
| 402 SwapBuffersInfo swap_info; | |
| 403 swap_info.name = frame->gl_frame_data->mailbox; | |
| 404 swap_info.type = GL_COMPOSITOR_FRAME; | |
| 405 swap_info.size = frame->gl_frame_data->size; | |
| 406 swap_info.route_id = route_id; | |
| 407 swap_info.output_surface_id = output_surface_id; | |
| 408 swap_info.host_id = host_id; | |
| 409 OnBuffersSwappedPrivate(swap_info, | |
| 410 frame->gl_frame_data->sync_point, | |
| 411 frame->metadata.device_scale_factor); | |
| 412 return; | |
| 413 } | |
| 414 | |
| 415 if (frame->software_frame_data) { | |
| 416 cc::SoftwareFrameData* frame_data = frame->software_frame_data.get(); | |
| 417 | |
| 418 SwapBuffersInfo swap_info; | |
| 419 swap_info.type = SOFTWARE_COMPOSITOR_FRAME; | |
| 420 swap_info.size = frame_data->size; | |
| 421 swap_info.route_id = route_id; | |
| 422 swap_info.output_surface_id = output_surface_id; | |
| 423 swap_info.host_id = host_id; | |
| 424 swap_info.software_frame_id = frame_data->id; | |
| 425 | |
| 426 scoped_ptr<base::SharedMemory> shared_memory( | |
| 427 new base::SharedMemory(handle, true)); | |
| 428 const size_t size_in_bytes = 4 * frame_data->size.GetArea(); | |
| 429 if (!shared_memory->Map(size_in_bytes)) { | |
| 430 LOG(ERROR) << "Failed to map shared memory of size " << size_in_bytes; | |
| 431 // Send ACK right away. | |
| 432 software_ack_pending_ = true; | |
| 433 MailboxReleased(swap_info, 0, false); | |
| 434 DidCommitCompositorFrame(); | |
| 435 return; | |
| 436 } | |
| 437 | |
| 438 swap_info.shared_memory = shared_memory.release(); | |
| 439 OnBuffersSwappedPrivate(swap_info, 0, frame->metadata.device_scale_factor); | |
| 440 software_ack_pending_ = true; | |
| 441 last_route_id_ = route_id; | |
| 442 last_output_surface_id_ = output_surface_id; | |
| 443 last_host_id_ = host_id; | |
| 444 return; | |
| 445 } | |
| 446 | |
| 447 DCHECK(!texture_layer_.get()); | 211 DCHECK(!texture_layer_.get()); |
|
danakj
2014/09/19 19:06:29
can you remove texture_layer_?
Fady Samuel
2014/09/19 20:04:13
Done.
| |
| 448 | 212 |
| 449 cc::DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); | 213 cc::DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); |
| 450 // Do nothing if we are getting destroyed or have no frame data. | 214 // Do nothing if we are getting destroyed or have no frame data. |
| 451 if (!frame_data || !background_layer_.get()) | 215 if (!frame_data || !background_layer_.get()) |
| 452 return; | 216 return; |
| 453 | 217 |
| 454 DCHECK(!frame_data->render_pass_list.empty()); | 218 DCHECK(!frame_data->render_pass_list.empty()); |
| 455 cc::RenderPass* root_pass = frame_data->render_pass_list.back(); | 219 cc::RenderPass* root_pass = frame_data->render_pass_list.back(); |
| 456 gfx::Size frame_size = root_pass->output_rect.size(); | 220 gfx::Size frame_size = root_pass->output_rect.size(); |
| 457 | 221 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 559 dest_size.height()); | 323 dest_size.height()); |
| 560 } | 324 } |
| 561 if (GetBrowserPluginManager()) { | 325 if (GetBrowserPluginManager()) { |
| 562 GetBrowserPluginManager()->Send( | 326 GetBrowserPluginManager()->Send( |
| 563 new BrowserPluginHostMsg_CopyFromCompositingSurfaceAck( | 327 new BrowserPluginHostMsg_CopyFromCompositingSurfaceAck( |
| 564 host_routing_id_, GetInstanceID(), request_id, resized_bitmap)); | 328 host_routing_id_, GetInstanceID(), request_id, resized_bitmap)); |
| 565 } | 329 } |
| 566 } | 330 } |
| 567 | 331 |
| 568 } // namespace content | 332 } // namespace content |
| OLD | NEW |