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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 gfx::Size device_scale_adjusted_size = gfx::ToFlooredSize( | 113 gfx::Size device_scale_adjusted_size = gfx::ToFlooredSize( |
114 gfx::ScaleSize(buffer_size_, 1.0f / device_scale_factor)); | 114 gfx::ScaleSize(buffer_size_, 1.0f / device_scale_factor)); |
115 layer->SetBounds(device_scale_adjusted_size); | 115 layer->SetBounds(device_scale_adjusted_size); |
116 } | 116 } |
117 | 117 |
118 // Manually manage background layer for transparent webview. | 118 // Manually manage background layer for transparent webview. |
119 if (!opaque_) | 119 if (!opaque_) |
120 background_layer_->SetIsDrawable(false); | 120 background_layer_->SetIsDrawable(false); |
121 } | 121 } |
122 | 122 |
123 void BrowserPluginCompositingHelper::MailboxReleased( | 123 void BrowserPluginCompositingHelper::MailboxReleased(SwapBuffersInfo mailbox, |
124 SwapBuffersInfo mailbox, | 124 uint32 sync_point, |
125 unsigned sync_point, | 125 bool lost_resource) { |
126 bool lost_resource) { | |
127 if (mailbox.type == SOFTWARE_COMPOSITOR_FRAME) { | 126 if (mailbox.type == SOFTWARE_COMPOSITOR_FRAME) { |
128 delete mailbox.shared_memory; | 127 delete mailbox.shared_memory; |
129 mailbox.shared_memory = NULL; | 128 mailbox.shared_memory = NULL; |
130 } else if (lost_resource) { | 129 } else if (lost_resource) { |
131 // Reset mailbox's name if the resource was lost. | 130 // Reset mailbox's name if the resource was lost. |
132 mailbox.name.SetZero(); | 131 mailbox.name.SetZero(); |
133 } | 132 } |
134 | 133 |
135 // This means the GPU process crashed or guest crashed. | 134 // This means the GPU process crashed or guest crashed. |
136 if (last_host_id_ != mailbox.host_id || | 135 if (last_host_id_ != mailbox.host_id || |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 resource_collection_ = NULL; | 198 resource_collection_ = NULL; |
200 frame_provider_ = NULL; | 199 frame_provider_ = NULL; |
201 texture_layer_ = NULL; | 200 texture_layer_ = NULL; |
202 delegated_layer_ = NULL; | 201 delegated_layer_ = NULL; |
203 background_layer_ = NULL; | 202 background_layer_ = NULL; |
204 web_layer_.reset(); | 203 web_layer_.reset(); |
205 } | 204 } |
206 | 205 |
207 void BrowserPluginCompositingHelper::OnBuffersSwappedPrivate( | 206 void BrowserPluginCompositingHelper::OnBuffersSwappedPrivate( |
208 const SwapBuffersInfo& mailbox, | 207 const SwapBuffersInfo& mailbox, |
209 unsigned sync_point, | 208 uint32 sync_point, |
210 float device_scale_factor) { | 209 float device_scale_factor) { |
211 DCHECK(!delegated_layer_.get()); | 210 DCHECK(!delegated_layer_.get()); |
212 // If these mismatch, we are either just starting up, GPU process crashed or | 211 // If these mismatch, we are either just starting up, GPU process crashed or |
213 // guest renderer crashed. | 212 // guest renderer crashed. |
214 // In this case, we are communicating with a new image transport | 213 // In this case, we are communicating with a new image transport |
215 // surface and must ACK with the new ID's and an empty mailbox. | 214 // surface and must ACK with the new ID's and an empty mailbox. |
216 if (last_route_id_ != mailbox.route_id || | 215 if (last_route_id_ != mailbox.route_id || |
217 last_output_surface_id_ != mailbox.output_surface_id || | 216 last_output_surface_id_ != mailbox.output_surface_id || |
218 last_host_id_ != mailbox.host_id) | 217 last_host_id_ != mailbox.host_id) |
219 last_mailbox_valid_ = false; | 218 last_mailbox_valid_ = false; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 return; | 261 return; |
263 } | 262 } |
264 | 263 |
265 cc::TextureMailbox texture_mailbox; | 264 cc::TextureMailbox texture_mailbox; |
266 scoped_ptr<cc::SingleReleaseCallback> release_callback; | 265 scoped_ptr<cc::SingleReleaseCallback> release_callback; |
267 if (current_mailbox_valid) { | 266 if (current_mailbox_valid) { |
268 release_callback = cc::SingleReleaseCallback::Create( | 267 release_callback = cc::SingleReleaseCallback::Create( |
269 base::Bind(&BrowserPluginCompositingHelper::MailboxReleased, | 268 base::Bind(&BrowserPluginCompositingHelper::MailboxReleased, |
270 scoped_refptr<BrowserPluginCompositingHelper>(this), | 269 scoped_refptr<BrowserPluginCompositingHelper>(this), |
271 mailbox)).Pass(); | 270 mailbox)).Pass(); |
272 if (is_software_frame) | 271 if (is_software_frame) { |
273 texture_mailbox = cc::TextureMailbox(mailbox.shared_memory, mailbox.size); | 272 texture_mailbox = cc::TextureMailbox(mailbox.shared_memory, mailbox.size); |
274 else | 273 } else { |
275 texture_mailbox = cc::TextureMailbox(mailbox.name, sync_point); | 274 texture_mailbox = |
| 275 cc::TextureMailbox(mailbox.name, GL_TEXTURE_2D, sync_point); |
| 276 } |
276 } | 277 } |
277 | 278 |
278 texture_layer_->SetFlipped(!is_software_frame); | 279 texture_layer_->SetFlipped(!is_software_frame); |
279 texture_layer_->SetTextureMailbox(texture_mailbox, release_callback.Pass()); | 280 texture_layer_->SetTextureMailbox(texture_mailbox, release_callback.Pass()); |
280 texture_layer_->SetNeedsDisplay(); | 281 texture_layer_->SetNeedsDisplay(); |
281 last_mailbox_valid_ = current_mailbox_valid; | 282 last_mailbox_valid_ = current_mailbox_valid; |
282 } | 283 } |
283 | 284 |
284 void BrowserPluginCompositingHelper::OnBuffersSwapped( | 285 void BrowserPluginCompositingHelper::OnBuffersSwapped( |
285 const gfx::Size& size, | 286 const gfx::Size& size, |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 void BrowserPluginCompositingHelper::SetContentsOpaque(bool opaque) { | 445 void BrowserPluginCompositingHelper::SetContentsOpaque(bool opaque) { |
445 opaque_ = opaque; | 446 opaque_ = opaque; |
446 | 447 |
447 if (texture_layer_.get()) | 448 if (texture_layer_.get()) |
448 texture_layer_->SetContentsOpaque(opaque_); | 449 texture_layer_->SetContentsOpaque(opaque_); |
449 if (delegated_layer_.get()) | 450 if (delegated_layer_.get()) |
450 delegated_layer_->SetContentsOpaque(opaque_); | 451 delegated_layer_->SetContentsOpaque(opaque_); |
451 } | 452 } |
452 | 453 |
453 } // namespace content | 454 } // namespace content |
OLD | NEW |