| 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_renderer_layer.h" | 7 #include "cc/layers/delegated_renderer_layer.h" |
| 8 #include "cc/layers/solid_color_layer.h" | 8 #include "cc/layers/solid_color_layer.h" |
| 9 #include "cc/layers/texture_layer.h" | 9 #include "cc/layers/texture_layer.h" |
| 10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
| 11 #include "cc/resources/scoped_release_callback.h" |
| 11 #include "content/common/browser_plugin/browser_plugin_messages.h" | 12 #include "content/common/browser_plugin/browser_plugin_messages.h" |
| 12 #include "content/common/gpu/client/context_provider_command_buffer.h" | 13 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 13 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 14 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
| 14 #include "content/renderer/render_thread_impl.h" | 15 #include "content/renderer/render_thread_impl.h" |
| 15 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 16 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
| 16 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 17 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 17 #include "third_party/khronos/GLES2/gl2.h" | 18 #include "third_party/khronos/GLES2/gl2.h" |
| 18 #include "ui/gfx/size_conversions.h" | 19 #include "ui/gfx/size_conversions.h" |
| 19 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" | 20 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" |
| 20 | 21 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 mailbox.shared_memory != NULL : !mailbox.name.IsZero(); | 232 mailbox.shared_memory != NULL : !mailbox.name.IsZero(); |
| 232 if (!is_software_frame && !last_mailbox_valid_) { | 233 if (!is_software_frame && !last_mailbox_valid_) { |
| 233 SwapBuffersInfo empty_info = mailbox; | 234 SwapBuffersInfo empty_info = mailbox; |
| 234 empty_info.name.SetZero(); | 235 empty_info.name.SetZero(); |
| 235 MailboxReleased(empty_info, 0, false); | 236 MailboxReleased(empty_info, 0, false); |
| 236 if (!current_mailbox_valid) | 237 if (!current_mailbox_valid) |
| 237 return; | 238 return; |
| 238 } | 239 } |
| 239 | 240 |
| 240 cc::TextureMailbox texture_mailbox; | 241 cc::TextureMailbox texture_mailbox; |
| 242 scoped_ptr<cc::ScopedReleaseCallback> release_callback; |
| 241 if (current_mailbox_valid) { | 243 if (current_mailbox_valid) { |
| 242 cc::TextureMailbox::ReleaseCallback callback = | 244 release_callback = cc::ScopedReleaseCallback::Create( |
| 243 base::Bind(&BrowserPluginCompositingHelper::MailboxReleased, | 245 base::Bind(&BrowserPluginCompositingHelper::MailboxReleased, |
| 244 scoped_refptr<BrowserPluginCompositingHelper>(this), | 246 scoped_refptr<BrowserPluginCompositingHelper>(this), |
| 245 mailbox); | 247 mailbox)).Pass(); |
| 246 if (is_software_frame) { | 248 if (is_software_frame) |
| 247 texture_mailbox = cc::TextureMailbox(mailbox.shared_memory, | 249 texture_mailbox = cc::TextureMailbox(mailbox.shared_memory, mailbox.size); |
| 248 mailbox.size, callback); | 250 else |
| 249 } else { | 251 texture_mailbox = cc::TextureMailbox(mailbox.name, sync_point); |
| 250 texture_mailbox = cc::TextureMailbox(mailbox.name, callback, sync_point); | |
| 251 } | |
| 252 } | 252 } |
| 253 | 253 |
| 254 texture_layer_->SetFlipped(!is_software_frame); | 254 texture_layer_->SetFlipped(!is_software_frame); |
| 255 texture_layer_->SetTextureMailbox(texture_mailbox); | 255 texture_layer_->SetTextureMailbox(texture_mailbox, release_callback.Pass()); |
| 256 texture_layer_->SetNeedsDisplay(); | 256 texture_layer_->SetNeedsDisplay(); |
| 257 last_mailbox_valid_ = current_mailbox_valid; | 257 last_mailbox_valid_ = current_mailbox_valid; |
| 258 } | 258 } |
| 259 | 259 |
| 260 void BrowserPluginCompositingHelper::OnBuffersSwapped( | 260 void BrowserPluginCompositingHelper::OnBuffersSwapped( |
| 261 const gfx::Size& size, | 261 const gfx::Size& size, |
| 262 const std::string& mailbox_name, | 262 const std::string& mailbox_name, |
| 263 int gpu_route_id, | 263 int gpu_route_id, |
| 264 int gpu_host_id, | 264 int gpu_host_id, |
| 265 float device_scale_factor) { | 265 float device_scale_factor) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 347 } |
| 348 | 348 |
| 349 void BrowserPluginCompositingHelper::UpdateVisibility(bool visible) { | 349 void BrowserPluginCompositingHelper::UpdateVisibility(bool visible) { |
| 350 if (texture_layer_.get()) | 350 if (texture_layer_.get()) |
| 351 texture_layer_->SetIsDrawable(visible); | 351 texture_layer_->SetIsDrawable(visible); |
| 352 if (delegated_layer_.get()) | 352 if (delegated_layer_.get()) |
| 353 delegated_layer_->SetIsDrawable(visible); | 353 delegated_layer_->SetIsDrawable(visible); |
| 354 } | 354 } |
| 355 | 355 |
| 356 } // namespace content | 356 } // namespace content |
| OLD | NEW |