OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/browser_plugin/browser_plugin_compositing_helper.h" | 5 #include "content/renderer/browser_plugin/browser_plugin_compositing_helper.h" |
6 | 6 |
7 #include "cc/layers/delegated_frame_provider.h" | 7 #include "cc/layers/delegated_frame_provider.h" |
8 #include "cc/layers/delegated_frame_resource_collection.h" | 8 #include "cc/layers/delegated_frame_resource_collection.h" |
9 #include "cc/layers/delegated_renderer_layer.h" | 9 #include "cc/layers/delegated_renderer_layer.h" |
10 #include "cc/layers/solid_color_layer.h" | 10 #include "cc/layers/solid_color_layer.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 gfx::Size device_scale_adjusted_size = gfx::ToFlooredSize( | 132 gfx::Size device_scale_adjusted_size = gfx::ToFlooredSize( |
133 gfx::ScaleSize(buffer_size_, 1.0f / device_scale_factor)); | 133 gfx::ScaleSize(buffer_size_, 1.0f / device_scale_factor)); |
134 layer->SetBounds(device_scale_adjusted_size); | 134 layer->SetBounds(device_scale_adjusted_size); |
135 } | 135 } |
136 | 136 |
137 // Manually manage background layer for transparent webview. | 137 // Manually manage background layer for transparent webview. |
138 if (!opaque_) | 138 if (!opaque_) |
139 background_layer_->SetIsDrawable(false); | 139 background_layer_->SetIsDrawable(false); |
140 } | 140 } |
141 | 141 |
142 void BrowserPluginCompositingHelper::MailboxReleased( | 142 void BrowserPluginCompositingHelper::MailboxReleased(SwapBuffersInfo mailbox, |
143 SwapBuffersInfo mailbox, | 143 uint32 sync_point, |
144 unsigned sync_point, | 144 bool lost_resource) { |
145 bool lost_resource) { | |
146 if (mailbox.type == SOFTWARE_COMPOSITOR_FRAME) { | 145 if (mailbox.type == SOFTWARE_COMPOSITOR_FRAME) { |
147 delete mailbox.shared_memory; | 146 delete mailbox.shared_memory; |
148 mailbox.shared_memory = NULL; | 147 mailbox.shared_memory = NULL; |
149 } else if (lost_resource) { | 148 } else if (lost_resource) { |
150 // Reset mailbox's name if the resource was lost. | 149 // Reset mailbox's name if the resource was lost. |
151 mailbox.name.SetZero(); | 150 mailbox.name.SetZero(); |
152 } | 151 } |
153 | 152 |
154 // This means the GPU process crashed or guest crashed. | 153 // This means the GPU process crashed or guest crashed. |
155 if (last_host_id_ != mailbox.host_id || | 154 if (last_host_id_ != mailbox.host_id || |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 resource_collection_ = NULL; | 217 resource_collection_ = NULL; |
219 frame_provider_ = NULL; | 218 frame_provider_ = NULL; |
220 texture_layer_ = NULL; | 219 texture_layer_ = NULL; |
221 delegated_layer_ = NULL; | 220 delegated_layer_ = NULL; |
222 background_layer_ = NULL; | 221 background_layer_ = NULL; |
223 web_layer_.reset(); | 222 web_layer_.reset(); |
224 } | 223 } |
225 | 224 |
226 void BrowserPluginCompositingHelper::OnBuffersSwappedPrivate( | 225 void BrowserPluginCompositingHelper::OnBuffersSwappedPrivate( |
227 const SwapBuffersInfo& mailbox, | 226 const SwapBuffersInfo& mailbox, |
228 unsigned sync_point, | 227 uint32 sync_point, |
229 float device_scale_factor) { | 228 float device_scale_factor) { |
230 DCHECK(!delegated_layer_.get()); | 229 DCHECK(!delegated_layer_.get()); |
231 // If these mismatch, we are either just starting up, GPU process crashed or | 230 // If these mismatch, we are either just starting up, GPU process crashed or |
232 // guest renderer crashed. | 231 // guest renderer crashed. |
233 // In this case, we are communicating with a new image transport | 232 // In this case, we are communicating with a new image transport |
234 // surface and must ACK with the new ID's and an empty mailbox. | 233 // surface and must ACK with the new ID's and an empty mailbox. |
235 if (last_route_id_ != mailbox.route_id || | 234 if (last_route_id_ != mailbox.route_id || |
236 last_output_surface_id_ != mailbox.output_surface_id || | 235 last_output_surface_id_ != mailbox.output_surface_id || |
237 last_host_id_ != mailbox.host_id) | 236 last_host_id_ != mailbox.host_id) |
238 last_mailbox_valid_ = false; | 237 last_mailbox_valid_ = false; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 return; | 280 return; |
282 } | 281 } |
283 | 282 |
284 cc::TextureMailbox texture_mailbox; | 283 cc::TextureMailbox texture_mailbox; |
285 scoped_ptr<cc::SingleReleaseCallback> release_callback; | 284 scoped_ptr<cc::SingleReleaseCallback> release_callback; |
286 if (current_mailbox_valid) { | 285 if (current_mailbox_valid) { |
287 release_callback = cc::SingleReleaseCallback::Create( | 286 release_callback = cc::SingleReleaseCallback::Create( |
288 base::Bind(&BrowserPluginCompositingHelper::MailboxReleased, | 287 base::Bind(&BrowserPluginCompositingHelper::MailboxReleased, |
289 scoped_refptr<BrowserPluginCompositingHelper>(this), | 288 scoped_refptr<BrowserPluginCompositingHelper>(this), |
290 mailbox)).Pass(); | 289 mailbox)).Pass(); |
291 if (is_software_frame) | 290 if (is_software_frame) { |
292 texture_mailbox = cc::TextureMailbox(mailbox.shared_memory, mailbox.size); | 291 texture_mailbox = cc::TextureMailbox(mailbox.shared_memory, mailbox.size); |
293 else | 292 } else { |
294 texture_mailbox = cc::TextureMailbox(mailbox.name, sync_point); | 293 texture_mailbox = |
| 294 cc::TextureMailbox(mailbox.name, GL_TEXTURE_2D, sync_point); |
| 295 } |
295 } | 296 } |
296 | 297 |
297 texture_layer_->SetFlipped(!is_software_frame); | 298 texture_layer_->SetFlipped(!is_software_frame); |
298 texture_layer_->SetTextureMailbox(texture_mailbox, release_callback.Pass()); | 299 texture_layer_->SetTextureMailbox(texture_mailbox, release_callback.Pass()); |
299 texture_layer_->SetNeedsDisplay(); | 300 texture_layer_->SetNeedsDisplay(); |
300 last_mailbox_valid_ = current_mailbox_valid; | 301 last_mailbox_valid_ = current_mailbox_valid; |
301 } | 302 } |
302 | 303 |
303 void BrowserPluginCompositingHelper::OnBuffersSwapped( | 304 void BrowserPluginCompositingHelper::OnBuffersSwapped( |
304 const gfx::Size& size, | 305 const gfx::Size& size, |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 dest_size.width(), | 485 dest_size.width(), |
485 dest_size.height()); | 486 dest_size.height()); |
486 } | 487 } |
487 browser_plugin_manager_->Send( | 488 browser_plugin_manager_->Send( |
488 new BrowserPluginHostMsg_CopyFromCompositingSurfaceAck( | 489 new BrowserPluginHostMsg_CopyFromCompositingSurfaceAck( |
489 host_routing_id_, instance_id_, request_id, | 490 host_routing_id_, instance_id_, request_id, |
490 resized_bitmap)); | 491 resized_bitmap)); |
491 } | 492 } |
492 | 493 |
493 } // namespace content | 494 } // namespace content |
OLD | NEW |