| 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" |
| 11 #include "cc/layers/texture_layer.h" | 11 #include "cc/layers/texture_layer.h" |
| 12 #include "cc/output/context_provider.h" | 12 #include "cc/output/context_provider.h" |
| 13 #include "cc/output/copy_output_request.h" | 13 #include "cc/output/copy_output_request.h" |
| 14 #include "cc/output/copy_output_result.h" | 14 #include "cc/output/copy_output_result.h" |
| 15 #include "cc/resources/single_release_callback.h" | 15 #include "cc/resources/single_release_callback.h" |
| 16 #include "content/common/browser_plugin/browser_plugin_messages.h" | 16 #include "content/common/browser_plugin/browser_plugin_messages.h" |
| 17 #include "content/common/frame_messages.h" |
| 17 #include "content/common/gpu/client/context_provider_command_buffer.h" | 18 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 18 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 19 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
| 19 #include "content/renderer/render_thread_impl.h" | 20 #include "content/renderer/render_thread_impl.h" |
| 20 #include "skia/ext/image_operations.h" | 21 #include "skia/ext/image_operations.h" |
| 21 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 22 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
| 22 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 23 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 23 #include "third_party/khronos/GLES2/gl2.h" | 24 #include "third_party/khronos/GLES2/gl2.h" |
| 24 #include "ui/gfx/size_conversions.h" | 25 #include "ui/gfx/size_conversions.h" |
| 25 #include "ui/gfx/skia_util.h" | 26 #include "ui/gfx/skia_util.h" |
| 26 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" | 27 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 &BrowserPluginCompositingHelper::CopyFromCompositingSurfaceHasResult, | 67 &BrowserPluginCompositingHelper::CopyFromCompositingSurfaceHasResult, |
| 67 this, | 68 this, |
| 68 request_id, | 69 request_id, |
| 69 dest_size)); | 70 dest_size)); |
| 70 request->set_area(source_rect); | 71 request->set_area(source_rect); |
| 71 background_layer_->RequestCopyOfOutput(request.Pass()); | 72 background_layer_->RequestCopyOfOutput(request.Pass()); |
| 72 } | 73 } |
| 73 | 74 |
| 74 void BrowserPluginCompositingHelper::DidCommitCompositorFrame() { | 75 void BrowserPluginCompositingHelper::DidCommitCompositorFrame() { |
| 75 if (software_ack_pending_) { | 76 if (software_ack_pending_) { |
| 76 cc::CompositorFrameAck ack; | 77 FrameHostMsg_CompositorFrameSwappedACK_Params params; |
| 78 params.producing_host_id = last_host_id_; |
| 79 params.producing_route_id = last_route_id_; |
| 80 params.output_surface_id = last_output_surface_id_; |
| 77 if (!unacked_software_frames_.empty()) { | 81 if (!unacked_software_frames_.empty()) { |
| 78 ack.last_software_frame_id = unacked_software_frames_.back(); | 82 params.ack.last_software_frame_id = unacked_software_frames_.back(); |
| 79 unacked_software_frames_.pop_back(); | 83 unacked_software_frames_.pop_back(); |
| 80 } | 84 } |
| 81 | 85 |
| 82 browser_plugin_manager_->Send( | 86 browser_plugin_manager_->Send( |
| 83 new BrowserPluginHostMsg_CompositorFrameACK( | 87 new BrowserPluginHostMsg_CompositorFrameSwappedACK( |
| 84 host_routing_id_, | 88 host_routing_id_, |
| 85 instance_id_, | 89 instance_id_, |
| 86 last_route_id_, | 90 params)); |
| 87 last_output_surface_id_, | |
| 88 last_host_id_, | |
| 89 ack)); | |
| 90 | 91 |
| 91 software_ack_pending_ = false; | 92 software_ack_pending_ = false; |
| 92 } | 93 } |
| 93 if (!resource_collection_.get() || !ack_pending_) | 94 if (!resource_collection_.get() || !ack_pending_) |
| 94 return; | 95 return; |
| 95 | 96 |
| 96 cc::CompositorFrameAck ack; | 97 FrameHostMsg_CompositorFrameSwappedACK_Params params; |
| 97 resource_collection_->TakeUnusedResourcesForChildCompositor(&ack.resources); | 98 params.producing_host_id = last_host_id_; |
| 99 params.producing_route_id = last_route_id_; |
| 100 params.output_surface_id = last_output_surface_id_; |
| 101 resource_collection_->TakeUnusedResourcesForChildCompositor( |
| 102 ¶ms.ack.resources); |
| 98 | 103 |
| 99 browser_plugin_manager_->Send( | 104 browser_plugin_manager_->Send( |
| 100 new BrowserPluginHostMsg_CompositorFrameACK( | 105 new BrowserPluginHostMsg_CompositorFrameSwappedACK( |
| 101 host_routing_id_, | 106 host_routing_id_, |
| 102 instance_id_, | 107 instance_id_, |
| 103 last_route_id_, | 108 params)); |
| 104 last_output_surface_id_, | |
| 105 last_host_id_, | |
| 106 ack)); | |
| 107 | 109 |
| 108 ack_pending_ = false; | 110 ack_pending_ = false; |
| 109 } | 111 } |
| 110 | 112 |
| 111 void BrowserPluginCompositingHelper::EnableCompositing(bool enable) { | 113 void BrowserPluginCompositingHelper::EnableCompositing(bool enable) { |
| 112 if (enable && !background_layer_.get()) { | 114 if (enable && !background_layer_.get()) { |
| 113 background_layer_ = cc::SolidColorLayer::Create(); | 115 background_layer_ = cc::SolidColorLayer::Create(); |
| 114 background_layer_->SetMasksToBounds(true); | 116 background_layer_->SetMasksToBounds(true); |
| 115 background_layer_->SetBackgroundColor( | 117 background_layer_->SetBackgroundColor( |
| 116 SkColorSetARGBInline(255, 255, 255, 255)); | 118 SkColorSetARGBInline(255, 255, 255, 255)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 // buffer arriving, no ACK is needed. | 168 // buffer arriving, no ACK is needed. |
| 167 if (!ack_pending_) { | 169 if (!ack_pending_) { |
| 168 last_mailbox_valid_ = false; | 170 last_mailbox_valid_ = false; |
| 169 return; | 171 return; |
| 170 } | 172 } |
| 171 ack_pending_ = false; | 173 ack_pending_ = false; |
| 172 switch (mailbox.type) { | 174 switch (mailbox.type) { |
| 173 case TEXTURE_IMAGE_TRANSPORT: { | 175 case TEXTURE_IMAGE_TRANSPORT: { |
| 174 std::string mailbox_name(reinterpret_cast<const char*>(mailbox.name.name), | 176 std::string mailbox_name(reinterpret_cast<const char*>(mailbox.name.name), |
| 175 sizeof(mailbox.name.name)); | 177 sizeof(mailbox.name.name)); |
| 178 FrameHostMsg_BuffersSwappedACK_Params params; |
| 179 params.gpu_host_id = mailbox.host_id; |
| 180 params.gpu_route_id = mailbox.route_id; |
| 181 params.mailbox_name = mailbox_name; |
| 182 params.sync_point = sync_point; |
| 176 browser_plugin_manager_->Send( | 183 browser_plugin_manager_->Send( |
| 177 new BrowserPluginHostMsg_BuffersSwappedACK( | 184 new BrowserPluginHostMsg_BuffersSwappedACK( |
| 178 host_routing_id_, | 185 host_routing_id_, |
| 179 instance_id_, | 186 instance_id_, |
| 180 mailbox.route_id, | 187 params)); |
| 181 mailbox.host_id, | |
| 182 mailbox_name, | |
| 183 sync_point)); | |
| 184 break; | 188 break; |
| 185 } | 189 } |
| 186 case GL_COMPOSITOR_FRAME: { | 190 case GL_COMPOSITOR_FRAME: { |
| 187 cc::CompositorFrameAck ack; | 191 FrameHostMsg_CompositorFrameSwappedACK_Params params; |
| 188 ack.gl_frame_data.reset(new cc::GLFrameData()); | 192 params.producing_host_id = mailbox.host_id; |
| 189 ack.gl_frame_data->mailbox = mailbox.name; | 193 params.producing_route_id = mailbox.route_id; |
| 190 ack.gl_frame_data->size = mailbox.size; | 194 params.output_surface_id = mailbox.output_surface_id; |
| 191 ack.gl_frame_data->sync_point = sync_point; | 195 params.ack.gl_frame_data.reset(new cc::GLFrameData()); |
| 196 params.ack.gl_frame_data->mailbox = mailbox.name; |
| 197 params.ack.gl_frame_data->size = mailbox.size; |
| 198 params.ack.gl_frame_data->sync_point = sync_point; |
| 192 | 199 |
| 193 browser_plugin_manager_->Send( | 200 browser_plugin_manager_->Send( |
| 194 new BrowserPluginHostMsg_CompositorFrameACK( | 201 new BrowserPluginHostMsg_CompositorFrameSwappedACK( |
| 195 host_routing_id_, | 202 host_routing_id_, |
| 196 instance_id_, | 203 instance_id_, |
| 197 mailbox.route_id, | 204 params)); |
| 198 mailbox.output_surface_id, | |
| 199 mailbox.host_id, | |
| 200 ack)); | |
| 201 break; | 205 break; |
| 202 } | 206 } |
| 203 case SOFTWARE_COMPOSITOR_FRAME: | 207 case SOFTWARE_COMPOSITOR_FRAME: |
| 204 break; | 208 break; |
| 205 } | 209 } |
| 206 } | 210 } |
| 207 | 211 |
| 208 void BrowserPluginCompositingHelper::OnContainerDestroy() { | 212 void BrowserPluginCompositingHelper::OnContainerDestroy() { |
| 209 if (container_) | 213 if (container_) |
| 210 container_->setWebLayer(NULL); | 214 container_->setWebLayer(NULL); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 dest_size.width(), | 488 dest_size.width(), |
| 485 dest_size.height()); | 489 dest_size.height()); |
| 486 } | 490 } |
| 487 browser_plugin_manager_->Send( | 491 browser_plugin_manager_->Send( |
| 488 new BrowserPluginHostMsg_CopyFromCompositingSurfaceAck( | 492 new BrowserPluginHostMsg_CopyFromCompositingSurfaceAck( |
| 489 host_routing_id_, instance_id_, request_id, | 493 host_routing_id_, instance_id_, request_id, |
| 490 resized_bitmap)); | 494 resized_bitmap)); |
| 491 } | 495 } |
| 492 | 496 |
| 493 } // namespace content | 497 } // namespace content |
| OLD | NEW |